mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 05:16:07 +00:00
realtime
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
</ion-header>
|
||||
|
||||
<ion-content>
|
||||
|
||||
|
||||
<ion-refresher name="refresher" slot="fixed" (ionRefresh)="doRefresh($event)">
|
||||
<ion-progress-bar type="indeterminate" *ngIf="showLoader"></ion-progress-bar>
|
||||
<ion-refresher-content>
|
||||
@@ -32,8 +32,8 @@
|
||||
</ion-refresher>
|
||||
<div class="main-content">
|
||||
<ion-progress-bar class="position-absolute" type="indeterminate" *ngIf="loading"></ion-progress-bar>
|
||||
<ion-virtual-scroll [items]="ChatSystemService.users | filter:textSearch: 'name' " approxItemHeight="70px" [headerFn]="separateLetter">
|
||||
|
||||
<!-- <ion-virtual-scroll [items]="ChatSystemService.users | filter:textSearch: 'name' " approxItemHeight="70px" [headerFn]="separateLetter">
|
||||
|
||||
<div class="item-divider" *virtualHeader="let header">
|
||||
<ion-label>{{header}}</ion-label>
|
||||
</div>
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
</ion-virtual-scroll>
|
||||
</ion-virtual-scroll> -->
|
||||
|
||||
</div>
|
||||
</ion-content>
|
||||
|
||||
@@ -54,14 +54,28 @@
|
||||
|
||||
<div class="d-flex justify-content-between">
|
||||
<div>
|
||||
{{ message.message }}
|
||||
</div>
|
||||
<div>
|
||||
{{ message.message }}
|
||||
</div>
|
||||
|
||||
<div *ngFor="let attachment of message.attachments">
|
||||
<div *ngIf="attachment.fileType == 1">
|
||||
|
||||
<ion-icon src="assets/icon/webtrix.svg" class="file-icon font-25"></ion-icon>
|
||||
<ion-label>{{ attachment.fileName}}</ion-label>
|
||||
<!-- <ion-icon *ngIf="ThemeService.currentTheme == 'default' && attachment.type != 'webtrix' && !( msg.downloadLoader == true || msg.uploadingFile == true ) " class="icon-download" src="assets/icon/theme/default/icons-download.svg" slot="end"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && attachment.type != 'webtrix' && !( msg.downloadLoader == true || msg.uploadingFile == true ) " class="icon-download" src="assets/icon/theme/gov/icons-download.svg" slot="end"></ion-icon>
|
||||
<ion-icon *ngIf="( msg.downloadLoader == true || msg.uploadingFile == true )" class="icon-download" src="assets/gif/theme/{{ThemeService.currentTheme}}/Blocks-loader.svg" slot="end"></ion-icon> -->
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="message-item-options d-flex justify-content-end">
|
||||
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer"></fa-icon>
|
||||
<mat-menu #beforeMenu="matMenu" xPosition="before">
|
||||
<button (click)="messageDelete({messageId: message.id })" class="menuButton">Apagar mensagem</button>
|
||||
<button (click)="messageDelete(message)" class="menuButton">Apagar mensagem</button>
|
||||
<button (click)="editMessage(message)" class="menuButton">Editar mensagem</button>
|
||||
<button (click)="toggleEmojiPicker(message)" class="menuButton">Reagir mensagem</button>
|
||||
</mat-menu>
|
||||
@@ -128,7 +142,7 @@
|
||||
</div>
|
||||
-->
|
||||
|
||||
|
||||
</div>
|
||||
</ion-content>
|
||||
|
||||
<ion-footer>
|
||||
@@ -170,26 +184,17 @@
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button #recordbtn *ngIf="!textField && !lastAudioRecorded"
|
||||
(click)="startRecording()" class="btn-no-color">
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-send"
|
||||
src="assets/icon/theme/default/icons-chat-record-audio.svg"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-send"
|
||||
src="assets/icon/theme/gov/icons-chat-record-audio.svg"></ion-icon>
|
||||
<button #recordbtn *ngIf="textField == '' && !lastAudioRecorded" (click)="startRecording()" class="btn-no-color">
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-send" src="assets/icon/theme/default/icons-chat-record-audio.svg"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-record-audio.svg"></ion-icon>
|
||||
</button>
|
||||
<button *ngIf="textField" class="btn-no-color" (click)="sendMessage()"
|
||||
class="btn-no-color">
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-send"
|
||||
src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-send"
|
||||
src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon>
|
||||
<button *ngIf="textField != ''" class="btn-no-color" (click)="sendMessage()">
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon>
|
||||
</button>
|
||||
<button *ngIf="!textField && lastAudioRecorded"
|
||||
(click)="sendAudio(lastAudioRecorded)" class="btn-no-color">
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-send"
|
||||
src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-send"
|
||||
src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon>
|
||||
<button *ngIf="textField == '' && lastAudioRecorded" class="btn-no-color" (click)="sendAudio(lastAudioRecorded)">
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -13,14 +13,11 @@ import { ChatOptionsPopoverPage } from 'src/app/shared/popover/chat-options-popo
|
||||
import { MessagesOptionsPage } from 'src/app/shared/popover/messages-options/messages-options.page';
|
||||
import { ChatMessageStore } from 'src/app/store/chat/chat-message.service';
|
||||
import { ChatUserStorage } from 'src/app/store/chat/chat-user.service';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { ThemeService } from 'src/app/services/theme.service'
|
||||
|
||||
import { VoiceRecorder, RecordingData, GenericResponse } from 'capacitor-voice-recorder';
|
||||
import { Haptics, ImpactStyle } from '@capacitor/haptics';
|
||||
import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
|
||||
// import { ChatSystemService } from 'src/app/services/chat/chat-system.service'
|
||||
// import { MessageService } from 'src/app/services/chat/message.service';
|
||||
import { FileType } from 'src/app/models/fileType';
|
||||
import { SearchPage } from 'src/app/pages/search/search.page';
|
||||
import { Storage } from '@ionic/storage';
|
||||
@@ -52,8 +49,12 @@ import { tap } from 'rxjs/operators';
|
||||
import { MessageEntity } from 'src/app/module/chat/domain/entity/message';
|
||||
import { MemberTable } from 'src/app/module/chat/infra/database/dexie/schema/members';
|
||||
import { TypingTable } from 'src/app/module/chat/infra/database/dexie/schema/typing';
|
||||
|
||||
|
||||
import { CameraService } from 'src/app/infra/camera/camera.service'
|
||||
import { MessageAttachmentFileType, MessageAttachmentSource } from 'src/app/module/chat/data/dto/message/messageOutputDTO';
|
||||
import { compressImageBase64 } from 'src/app/utils/imageCompressore';
|
||||
import { FilePickerService } from 'src/app/infra/file-picker/file-picker.service'
|
||||
import { FilePickerMobileService } from 'src/app/infra/file-picker/mobile/file-picker-mobile.service'
|
||||
import { AttachmentsPageRoutingModule } from '../../events/attachments/attachments-routing.module';
|
||||
|
||||
const IMAGE_DIR = 'stored-images';
|
||||
|
||||
@@ -155,7 +156,10 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
private roomRepositoryService: RoomRepositoryService,
|
||||
private messageRepositoryService: MessageRepositoryService,
|
||||
private userTypingServiceRepository: UserTypingServiceRepository,
|
||||
private chatServiceService: ChatServiceService
|
||||
private chatServiceService: ChatServiceService,
|
||||
private CameraService: CameraService,
|
||||
private FilePickerService: FilePickerService,
|
||||
private FilePickerMobileService: FilePickerMobileService
|
||||
) {
|
||||
|
||||
|
||||
@@ -439,8 +443,20 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
sendMessage() {
|
||||
// this.ChatSystemService.getDmRoom(this.roomId).send({}).then(() => {
|
||||
// })
|
||||
const message = new MessageEntity();
|
||||
message.message = this.textField
|
||||
message.roomId = this.roomId
|
||||
|
||||
message.sender = {
|
||||
userPhoto: '',
|
||||
wxeMail: SessionStore.user.Email,
|
||||
wxFullName: SessionStore.user.FullName,
|
||||
wxUserId: SessionStore.user.UserId
|
||||
}
|
||||
|
||||
this.chatServiceService.sendMessage(message)
|
||||
|
||||
this.textField = ''
|
||||
}
|
||||
|
||||
/* sendMessage(msg) {
|
||||
@@ -472,30 +488,26 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
//Converting base64 to blob
|
||||
const encodedData = btoa(this.audioRecorded);
|
||||
const blob = this.fileService.base64toBlob(encodedData, recordData.value.mimeType)
|
||||
|
||||
const message = new MessageEntity();
|
||||
message.roomId = this.roomId
|
||||
|
||||
const validation = await this.FileValidatorService.validateAudioFromBlob(blob)
|
||||
message.sender = {
|
||||
userPhoto: '',
|
||||
wxeMail: SessionStore.user.Email,
|
||||
wxFullName: SessionStore.user.FullName,
|
||||
wxUserId: SessionStore.user.UserId
|
||||
}
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", blob);
|
||||
message.attachments = [{
|
||||
file: encodedData,
|
||||
fileName: "audio",
|
||||
source: MessageAttachmentSource.Device,
|
||||
fileType: MessageAttachmentFileType.Audio
|
||||
}]
|
||||
|
||||
this.chatServiceService.sendMessage(message)
|
||||
|
||||
// this.ChatSystemService.getDmRoom(roomId).send({
|
||||
// file: {
|
||||
// "type": "application/audio",
|
||||
// "msDuration": audioFile.value.msDuration,
|
||||
// "mimeType": audioFile.value.mimeType,
|
||||
// },
|
||||
// attachments: [{
|
||||
// "title": sanitize(fileName),
|
||||
// "title_link_download": true,
|
||||
// "type": "audio"
|
||||
// }],
|
||||
// temporaryData: formData,
|
||||
// attachmentsModelData: {
|
||||
// fileBase64: encodedData,
|
||||
// }
|
||||
// })
|
||||
|
||||
});
|
||||
this.deleteRecording();
|
||||
@@ -689,51 +701,47 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
|
||||
async takePicture() {
|
||||
async takePictureMobile() {
|
||||
|
||||
const roomId = this.roomId
|
||||
const picture = await this.CameraService.takePicture({
|
||||
cameraResultType: CameraResultType.DataUrl,
|
||||
quality: 90
|
||||
})
|
||||
|
||||
const file = await Camera.getPhoto({
|
||||
quality: 90,
|
||||
// allowEditing: true,
|
||||
resultType: CameraResultType.Base64,
|
||||
source: CameraSource.Camera
|
||||
});
|
||||
if(picture.isOk()) {
|
||||
const file = picture.value
|
||||
|
||||
var imageBase64 = 'data:image/jpeg;base64,' + file.base64String
|
||||
const compressedImage = await compressImageBase64(
|
||||
file.dataUrl,
|
||||
800, // maxWidth
|
||||
800, // maxHeight
|
||||
0.9 // quality
|
||||
)
|
||||
|
||||
if(compressedImage.isOk()) {
|
||||
|
||||
const compressedImage = await this.compressImageBase64(
|
||||
imageBase64,
|
||||
800, // maxWidth
|
||||
800, // maxHeight
|
||||
0.9 // quality
|
||||
).then((picture) => {
|
||||
console.log('Selected: ', picture)
|
||||
imageBase64 = picture
|
||||
});
|
||||
const message = new MessageEntity();
|
||||
message.roomId = this.roomId
|
||||
|
||||
//console.log(imageBase64)
|
||||
const blob = this.dataURItoBlob(imageBase64)
|
||||
message.sender = {
|
||||
userPhoto: '',
|
||||
wxeMail: SessionStore.user.Email,
|
||||
wxFullName: SessionStore.user.FullName,
|
||||
wxUserId: SessionStore.user.UserId
|
||||
}
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", blob);
|
||||
message.attachments = [{
|
||||
file: compressedImage.value,
|
||||
fileName: "foto",
|
||||
source: MessageAttachmentSource.Device,
|
||||
fileType: MessageAttachmentFileType.Image
|
||||
}]
|
||||
|
||||
// this.ChatSystemService.getDmRoom(roomId).send({
|
||||
// file: {
|
||||
// "type": "application/img",
|
||||
// "guid": ''
|
||||
// },
|
||||
// attachments: [{
|
||||
// "title": "file.jpg",
|
||||
// "text": "description",
|
||||
// "title_link_download": false,
|
||||
// }],
|
||||
// temporaryData: formData,
|
||||
// attachmentsModelData: {
|
||||
// fileBase64: imageBase64,
|
||||
// }
|
||||
// })
|
||||
this.chatServiceService.sendMessage(message)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -762,13 +770,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
}
|
||||
|
||||
async addImageMobile() {
|
||||
this.addFileToChatMobile(['image/apng', 'image/jpeg', 'image/png'])
|
||||
}
|
||||
|
||||
async addImage() {
|
||||
this.addFileToChat(['image/apng', 'image/jpeg', 'image/png'])
|
||||
}
|
||||
|
||||
async addFile() {
|
||||
this.addFileToChat(['.doc', '.docx', '.pdf'])
|
||||
@@ -791,85 +792,130 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
if (data.selected) {
|
||||
|
||||
// this.ChatSystemService.getDmRoom(roomId).send({
|
||||
// file: {
|
||||
// "name": res.data.selected.Assunto,
|
||||
// "type": "application/webtrix",
|
||||
// "ApplicationId": res.data.selected.ApplicationType,
|
||||
// "DocId": res.data.selected.Id,
|
||||
// "Assunto": res.data.selected.Assunto,
|
||||
// },
|
||||
// temporaryData: res,
|
||||
// attachments: [{
|
||||
// "title": res.data.selected.Assunto,
|
||||
// "description": res.data.selected.DocTypeDesc,
|
||||
// // "title_link": url_no_options,
|
||||
// "title_link_download": true,
|
||||
// "thumb_url": "https://static.ichimura.ed.jp/uploads/2017/10/pdf-icon.png",
|
||||
// // "message_link": url_no_options,
|
||||
// "text": res.data.selected.DocTypeDesc,
|
||||
// "type": "webtrix"
|
||||
// }],
|
||||
// })
|
||||
const message = new MessageEntity();
|
||||
message.message = this.textField
|
||||
message.roomId = this.roomId
|
||||
|
||||
message.sender = {
|
||||
userPhoto: '',
|
||||
wxeMail: SessionStore.user.Email,
|
||||
wxFullName: SessionStore.user.FullName,
|
||||
wxUserId: SessionStore.user.UserId
|
||||
}
|
||||
message.attachments = [{
|
||||
fileName: res.data.selected.Assunto,
|
||||
source: MessageAttachmentSource.Webtrix,
|
||||
fileType: MessageAttachmentFileType.Doc,
|
||||
applicationId: res.data.selected.ApplicationType,
|
||||
docId: res.data.selected.Id,
|
||||
}]
|
||||
|
||||
this.chatServiceService.sendMessage(message)
|
||||
this.textField = ''
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async addFileToChatMobile(types: typeof FileType[]) {
|
||||
const roomId = this.roomId
|
||||
async pickPicture() {
|
||||
|
||||
const file = await Camera.getPhoto({
|
||||
quality: 90,
|
||||
// allowEditing: true,
|
||||
resultType: CameraResultType.Base64,
|
||||
source: CameraSource.Photos
|
||||
});
|
||||
const file = await this.FilePickerService.getPicture({
|
||||
cameraResultType: CameraResultType.Base64
|
||||
})
|
||||
|
||||
//const imageData = await this.fileToBase64Service.convert(file)
|
||||
//
|
||||
if(file.isOk()) {
|
||||
|
||||
var imageBase64 = 'data:image/jpeg;base64,' + file.base64String
|
||||
var base64 = 'data:image/jpeg;base64,' + file.value.base64String
|
||||
if (file.value.format == "jpeg" || file.value.format == "png" || file.value.format == "gif") {
|
||||
|
||||
const compressedImage = await compressImageBase64(
|
||||
base64,
|
||||
800, // maxWidth
|
||||
800, // maxHeight
|
||||
0.9 // quality
|
||||
)
|
||||
|
||||
const compressedImage = await this.compressImageBase64(
|
||||
imageBase64,
|
||||
800, // maxWidth
|
||||
800, // maxHeight
|
||||
0.9 // quality
|
||||
).then((picture) => {
|
||||
console.log('Selected: ', picture)
|
||||
imageBase64 = picture
|
||||
});
|
||||
if(compressedImage.isOk()) {
|
||||
|
||||
//console.log(imageBase64)
|
||||
const message = new MessageEntity();
|
||||
message.roomId = this.roomId
|
||||
|
||||
const response = await fetch(imageBase64);
|
||||
const blob = await response.blob();
|
||||
message.sender = {
|
||||
userPhoto: '',
|
||||
wxeMail: SessionStore.user.Email,
|
||||
wxFullName: SessionStore.user.FullName,
|
||||
wxUserId: SessionStore.user.UserId
|
||||
}
|
||||
|
||||
const formData = new FormData();
|
||||
//console.log('add file', formData)
|
||||
formData.append("blobFile", blob);
|
||||
//console.log('add file', formData)
|
||||
message.attachments = [{
|
||||
file: compressedImage.value,
|
||||
fileName: "foto",
|
||||
source: MessageAttachmentSource.Device,
|
||||
fileType: MessageAttachmentFileType.Image
|
||||
}]
|
||||
|
||||
// this.ChatSystemService.getDmRoom(roomId).send({
|
||||
// file: {
|
||||
// "type": "application/img",
|
||||
// "guid": ''
|
||||
// },
|
||||
// temporaryData: formData,
|
||||
// attachments: [{
|
||||
// "title": file.path,
|
||||
// "text": "description",
|
||||
// "title_link_download": false,
|
||||
// }],
|
||||
// attachmentsModelData: {
|
||||
// fileBase64: imageBase64,
|
||||
// }
|
||||
// })
|
||||
this.chatServiceService.sendMessage(message)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// async addFileToChatMobile() {
|
||||
// const roomId = this.roomId
|
||||
|
||||
// const file = await Camera.getPhoto({
|
||||
// quality: 90,
|
||||
// // allowEditing: true,
|
||||
// resultType: CameraResultType.Base64,
|
||||
// source: CameraSource.Photos
|
||||
// });
|
||||
|
||||
// //const imageData = await this.fileToBase64Service.convert(file)
|
||||
// //
|
||||
|
||||
// var imageBase64 = 'data:image/jpeg;base64,' + file.base64String
|
||||
|
||||
|
||||
// const compressedImage = await this.compressImageBase64(
|
||||
// imageBase64,
|
||||
// 800, // maxWidth
|
||||
// 800, // maxHeight
|
||||
// 0.9 // quality
|
||||
// ).then((picture) => {
|
||||
// console.log('Selected: ', picture)
|
||||
// imageBase64 = picture
|
||||
// });
|
||||
|
||||
// //console.log(imageBase64)
|
||||
|
||||
// const response = await fetch(imageBase64);
|
||||
// const blob = await response.blob();
|
||||
|
||||
// const formData = new FormData();
|
||||
// //console.log('add file', formData)
|
||||
// formData.append("blobFile", blob);
|
||||
// //console.log('add file', formData)
|
||||
|
||||
// // this.ChatSystemService.getDmRoom(roomId).send({
|
||||
// // file: {
|
||||
// // "type": "application/img",
|
||||
// // "guid": ''
|
||||
// // },
|
||||
// // temporaryData: formData,
|
||||
// // attachments: [{
|
||||
// // "title": file.path,
|
||||
// // "text": "description",
|
||||
// // "title_link_download": false,
|
||||
// // }],
|
||||
// // attachmentsModelData: {
|
||||
// // fileBase64: imageBase64,
|
||||
// // }
|
||||
// // })
|
||||
|
||||
// }
|
||||
|
||||
getFileReader(): FileReader {
|
||||
const fileReader = new FileReader();
|
||||
const zoneOriginalInstance = (fileReader as any)["__zone_symbol__originalInstance"];
|
||||
@@ -890,7 +936,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
})
|
||||
}
|
||||
|
||||
async addFileToChat(types: typeof FileType[]) {
|
||||
async addFileToChat(types) {
|
||||
console.log('add file ')
|
||||
const roomId = this.roomId
|
||||
|
||||
@@ -906,29 +952,25 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
console.log('RESULT', resultt.files[0].data)
|
||||
|
||||
const blobb = this.fileService.base64toBlob(resultt.files[0].data, resultt.files[0].mimeType)
|
||||
const blob = new Blob([resultt.files[0].data], {type: resultt.files[0].mimeType});
|
||||
const message = new MessageEntity();
|
||||
message.roomId = this.roomId
|
||||
|
||||
const formDataa = new FormData();
|
||||
formDataa.append('blobFile', blobb);
|
||||
/* console.log('add file', fileBase64) */
|
||||
message.sender = {
|
||||
userPhoto: '',
|
||||
wxeMail: SessionStore.user.Email,
|
||||
wxFullName: SessionStore.user.FullName,
|
||||
wxUserId: SessionStore.user.UserId
|
||||
}
|
||||
|
||||
message.attachments = [{
|
||||
file: resultt.files[0].data,
|
||||
fileName: resultt.files[0].name,
|
||||
source: MessageAttachmentSource.Device,
|
||||
fileType: MessageAttachmentFileType.Doc
|
||||
}]
|
||||
|
||||
this.chatServiceService.sendMessage(message)
|
||||
|
||||
// this.ChatSystemService.getDmRoom(roomId).send({
|
||||
// file: {
|
||||
// "type": resultt.files[0].mimeType,
|
||||
// "guid": '',
|
||||
// },
|
||||
// attachments: [{
|
||||
// "title": sanitize(resultt.files[0].name),
|
||||
// "name": sanitize(resultt.files[0].name),
|
||||
// // "text": "description",
|
||||
// "title_link_download": false,
|
||||
// }],
|
||||
// temporaryData: formDataa,
|
||||
// attachmentsModelData: {
|
||||
// fileBase64: '',
|
||||
// }
|
||||
// })
|
||||
return
|
||||
|
||||
}
|
||||
@@ -937,17 +979,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
console.log(file)
|
||||
|
||||
|
||||
/* const encodedData = btoa(JSON.stringify(await this.getBase64(file).catch ((error) => {
|
||||
console.error(error);
|
||||
})));
|
||||
const blob = this.fileService.base64toBlob(encodedData, file.type)
|
||||
|
||||
const fileBase64 = await this._getBase64(file)
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('blobFile', blob);
|
||||
console.log('add file', fileBase64) */
|
||||
|
||||
const fileName = file.name
|
||||
|
||||
const validation = this.FileValidatorService.fileNameValidation(fileName)
|
||||
@@ -962,24 +993,27 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('blobFile', blob);
|
||||
/* console.log('add file', fileBase64) */
|
||||
|
||||
// this.ChatSystemService.getDmRoom(roomId).send({
|
||||
// file: {
|
||||
// "type": file.type,
|
||||
// "guid": '',
|
||||
// },
|
||||
// attachments: [{
|
||||
// "title": sanitize(fileName),
|
||||
// "name": sanitize(fileName),
|
||||
// // "text": "description",
|
||||
// "title_link_download": false,
|
||||
// }],
|
||||
// temporaryData: formData,
|
||||
// attachmentsModelData: {
|
||||
// fileBase64: encodedData,
|
||||
// }
|
||||
// });
|
||||
|
||||
const message = new MessageEntity();
|
||||
message.roomId = this.roomId
|
||||
|
||||
message.sender = {
|
||||
userPhoto: '',
|
||||
wxeMail: SessionStore.user.Email,
|
||||
wxFullName: SessionStore.user.FullName,
|
||||
wxUserId: SessionStore.user.UserId
|
||||
}
|
||||
|
||||
message.attachments = [{
|
||||
file: encodedData,
|
||||
fileName: "doc",
|
||||
source: MessageAttachmentSource.Device,
|
||||
fileType: MessageAttachmentFileType.Doc
|
||||
}]
|
||||
|
||||
this.chatServiceService.sendMessage(message)
|
||||
|
||||
} else {
|
||||
this.toastService._badRequest("Ficheiro inválido")
|
||||
}
|
||||
@@ -1022,11 +1056,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.bookMeeting();
|
||||
}
|
||||
else if (res['data'] == 'take-picture') {
|
||||
this.takePicture()
|
||||
this.takePictureMobile()
|
||||
}
|
||||
else if (res['data'] == 'add-picture') {
|
||||
console.log('add-picture')
|
||||
this.addImageMobile()
|
||||
this.pickPicture()
|
||||
}
|
||||
else if (res['data'] == 'add-document') {
|
||||
this.addFile()
|
||||
@@ -1447,6 +1481,3 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.userTypingServiceRepository.addUserTyping(this.roomId)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user