mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
save
This commit is contained in:
@@ -194,16 +194,19 @@
|
||||
<div class="container width-100 d-flex">
|
||||
<div>
|
||||
|
||||
<button class="btn-no-color" (click)="openChatOptions()">
|
||||
<button *ngIf="!lastAudioRecorded" class="btn-no-color" (click)="openChatOptions()">
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-options" src="assets/images/icons-add.svg"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-options" src="assets/images/theme/gov/icons-add.svg"></ion-icon>
|
||||
</button>
|
||||
<button *ngIf="lastAudioRecorded" class="btn-no-color" (click)="deleteRecording(lastAudioRecorded)">
|
||||
<fa-icon icon="trash" class="word-icon"></fa-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="width-70">
|
||||
<ion-item class="ion-no-padding ion-no-margin type-message" lines="none">
|
||||
<ion-item *ngIf="!lastAudioRecorded" class="ion-no-padding ion-no-margin type-message" lines="none">
|
||||
<ion-textarea autocomplete="on" autocorrect="on" spellcheck="true" *ngIf="!recording" clearOnEdit="true" placeholder="Escrever uma mensagem" auto-grow class="message-input" rows="1" [(ngModel)]="wsChatMethodsService.getDmRoom(roomId).message" (ionChange)="wsChatMethodsService.getDmRoom(roomId).sendTyping()"></ion-textarea>
|
||||
<ion-textarea autocomplete="on" spellcheck="true" *ngIf="recording" clearOnEdit="true" placeholder="Escrever uma mensagem" auto-grow class="message-input" rows="1" [(ngModel)]="durationDisplay"></ion-textarea>
|
||||
<button #recordbtn class="btn-no-color" (click)="notImplemented()">
|
||||
<button #recordbtn class="btn-no-color">
|
||||
<ion-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon>
|
||||
</button>
|
||||
</ion-item>
|
||||
@@ -213,7 +216,11 @@
|
||||
<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="!wsChatMethodsService.getDmRoom(roomId).message" class="btn-no-color">
|
||||
<button *ngIf="!wsChatMethodsService.getDmRoom(roomId).message && !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>
|
||||
<button *ngIf="!wsChatMethodsService.getDmRoom(roomId).message && 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>
|
||||
|
||||
@@ -366,6 +366,86 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.wsChatMethodsService.getDmRoom(this.roomId).send({})
|
||||
}
|
||||
|
||||
async sendAudio(fileName) {
|
||||
|
||||
const roomId = this.roomId
|
||||
|
||||
/* const file: any = await this.fileService.getFileFromDevice(audio);
|
||||
console.log('Add file', file)
|
||||
|
||||
const blob = new Blob([file],{type: file.type})
|
||||
console.log('Add file', blob)
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", blob);
|
||||
|
||||
let pdfBase64;
|
||||
this.blobToBase64(blob).then(res => {
|
||||
console.log('Base64 pdf', res);
|
||||
this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||
file: {
|
||||
"type": file.type,
|
||||
"guid": '',
|
||||
},
|
||||
attachments: [{
|
||||
"title": file.name ,
|
||||
"title_link": res,
|
||||
"title_link_download": true,
|
||||
"type": "file"
|
||||
}],
|
||||
temporaryData: formData
|
||||
})
|
||||
}); */
|
||||
|
||||
const audioFile = await Filesystem.readFile({
|
||||
path: fileName,
|
||||
directory: Directory.Data
|
||||
})
|
||||
console.log(audioFile);
|
||||
const base64sound = audioFile.data;
|
||||
|
||||
const audioRef = new Audio(`data:audio/aac;base64,${base64sound}`)
|
||||
|
||||
console.log(audioRef);
|
||||
|
||||
//Converting base64 to blob
|
||||
const base64 = await fetch(base64sound);
|
||||
const base64Response = await fetch(`data:audio/aac;base64,${base64sound}`);
|
||||
const blob = await base64Response.blob();
|
||||
|
||||
console.log(blob);
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", blob);
|
||||
|
||||
this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||
file: {
|
||||
"type": "audio/aac",
|
||||
"guid": '',
|
||||
},
|
||||
attachments: [{
|
||||
"title": fileName ,
|
||||
"title_link": audioRef,
|
||||
"title_link_download": true,
|
||||
"type": "file"
|
||||
}],
|
||||
temporaryData: formData
|
||||
})
|
||||
|
||||
alert('OK')
|
||||
|
||||
}
|
||||
|
||||
blobToBase64 = blob => {
|
||||
const reader = new FileReader();
|
||||
reader.readAsDataURL(blob);
|
||||
return new Promise(resolve => {
|
||||
reader.onloadend = () => {
|
||||
resolve(reader.result);
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
viewDocument(msg: any, url?: string) {
|
||||
console.log(msg)
|
||||
if (msg.attachments.type == "application/webtrix") {
|
||||
|
||||
@@ -751,7 +751,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
} else {
|
||||
this.downloadFile = btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
||||
}
|
||||
|
||||
|
||||
|
||||
msg.file = {
|
||||
guid: msg.file.guid,
|
||||
@@ -799,7 +799,7 @@ console.log(msg);
|
||||
});
|
||||
modal.present();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user