mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
Merge branch 'developer' of bitbucket.org:equilibriumito/gabinete-digital into feature/audio
This commit is contained in:
@@ -95,6 +95,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
myAudio: any;
|
||||
downloadfile: any;
|
||||
downloadFile: any;
|
||||
downloadProgess: number;
|
||||
|
||||
constructor(
|
||||
public popoverController: PopoverController,
|
||||
@@ -138,7 +139,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.wsChatMethodsService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
|
||||
this.wsChatMethodsService.openRoom(this.roomId)
|
||||
|
||||
setTimeout(()=>{
|
||||
setTimeout(() => {
|
||||
this.scrollToBottomClicked()
|
||||
}, 150)
|
||||
|
||||
@@ -484,7 +485,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
});
|
||||
};
|
||||
|
||||
console.log('WRITE',writeSecretFile);
|
||||
console.log('WRITE', writeSecretFile);
|
||||
|
||||
const readSecretFile = async () => {
|
||||
const contents = await Filesystem.readFile({
|
||||
@@ -496,7 +497,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
console.log('secrets:', contents);
|
||||
};
|
||||
|
||||
console.log('READ',readSecretFile);
|
||||
console.log('READ', readSecretFile);
|
||||
|
||||
} catch (e) {
|
||||
console.error("Unable to write file", e);
|
||||
@@ -674,7 +675,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
const image = await this.CameraService.takePicture();
|
||||
await this.fileService.saveImage(image)
|
||||
const lastphoto: any = await this.fileService.loadFiles();
|
||||
const { capturedImage, capturedImageTitle} = await this.fileService.loadFileData(lastphoto);
|
||||
const { capturedImage, capturedImageTitle } = await this.fileService.loadFileData(lastphoto);
|
||||
|
||||
|
||||
const base64 = await fetch(capturedImage);
|
||||
@@ -689,8 +690,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
"guid": ''
|
||||
},
|
||||
attachments: [{
|
||||
"image_url": capturedImage,
|
||||
"title": capturedImageTitle ,
|
||||
"title": capturedImageTitle,
|
||||
"text": "description",
|
||||
"title_link_download": false,
|
||||
}],
|
||||
@@ -722,14 +722,14 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
});
|
||||
await modal.present();
|
||||
modal.onDidDismiss().then(async res=>{
|
||||
modal.onDidDismiss().then(async res => {
|
||||
const data = res.data;
|
||||
const roomId = this.roomId
|
||||
|
||||
if(data.selected) {
|
||||
if (data.selected) {
|
||||
|
||||
this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||
file:{
|
||||
file: {
|
||||
"name": res.data.selected.Assunto,
|
||||
"type": "application/webtrix",
|
||||
"ApplicationId": res.data.selected.ApplicationType,
|
||||
@@ -752,7 +752,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
async addFileToChatMobile(types: typeof FileType[] ) {
|
||||
async addFileToChatMobile(types: typeof FileType[]) {
|
||||
const roomId = this.roomId
|
||||
|
||||
const file = await Camera.getPhoto({
|
||||
@@ -765,7 +765,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
//const imageData = await this.fileToBase64Service.convert(file)
|
||||
//console.log('ADDFILECHAT', imageData)
|
||||
|
||||
const response = await fetch('data:image/jpeg;base64,'+ file.base64String!);
|
||||
const response = await fetch('data:image/jpeg;base64,' + file.base64String!);
|
||||
const blob = await response.blob();
|
||||
|
||||
const formData = new FormData();
|
||||
@@ -778,8 +778,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
},
|
||||
temporaryData: formData,
|
||||
attachments: [{
|
||||
"title": file.path ,
|
||||
"image_url": 'data:image/jpeg;base64,' +file.base64String,
|
||||
"title": file.path,
|
||||
"text": "description",
|
||||
"title_link_download": false,
|
||||
}]
|
||||
@@ -789,7 +788,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
|
||||
|
||||
async addFileToChat(types: typeof FileType[] ) {
|
||||
async addFileToChat(types: typeof FileType[]) {
|
||||
|
||||
const roomId = this.roomId
|
||||
|
||||
@@ -798,11 +797,14 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
/* const imageData = await this.fileToBase64Service.convert(file).then((filee) => {
|
||||
console.log('Add file', filee)
|
||||
}) */
|
||||
const blob = new Blob([file],{type: file.type})
|
||||
console.log('Add file', blob)
|
||||
const response = await fetch(file);
|
||||
const blob = await response.blob();
|
||||
const blob2 = new Blob([blob])
|
||||
console.log('Add file base64', file)
|
||||
console.log('Add file blob', blob)
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", blob);
|
||||
formData.append("blobFile", blob2);
|
||||
|
||||
this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||
file: {
|
||||
@@ -810,10 +812,9 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
"guid": '',
|
||||
},
|
||||
attachments: [{
|
||||
"title": file.name ,
|
||||
"name": file.name ,
|
||||
"title": file.name,
|
||||
"name": file.name,
|
||||
// "text": "description",
|
||||
"image_url": file, // rocketchat
|
||||
"title_link_download": false,
|
||||
}],
|
||||
temporaryData: formData
|
||||
@@ -824,7 +825,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
async openChatOptions(ev?: any) {
|
||||
const roomId = this.roomId
|
||||
console.log('MOBILE CHAT OPTION',this.members);
|
||||
console.log('MOBILE CHAT OPTION', this.members);
|
||||
|
||||
const popover = await this.popoverController.create({
|
||||
component: ChatOptionsPopoverPage,
|
||||
@@ -838,7 +839,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
translucent: true
|
||||
});
|
||||
await popover.present();
|
||||
popover.onDidDismiss().then( async (res) => {
|
||||
popover.onDidDismiss().then(async (res) => {
|
||||
console.log(res['data']);
|
||||
if (res['data'] == 'meeting') {
|
||||
this.bookMeeting();
|
||||
@@ -936,39 +937,58 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
}
|
||||
|
||||
testeDownload(msg: MessageService) {
|
||||
this.downloadFile = "";
|
||||
this.AttachmentsService.downloadFileAndStore(msg.file.guid);
|
||||
}
|
||||
|
||||
|
||||
downloadFileMsg(msg: MessageService) {
|
||||
console.log('FILE TYPE', msg.file.type)
|
||||
this.downloadFile = "";
|
||||
if (msg.file.type == "application/img") {
|
||||
this.AttachmentsService.downloadFile(msg.file.guid).subscribe(async (event) => {
|
||||
console.log('FILE TYPE 22', msg.file.guid)
|
||||
var name = msg.file.guid;
|
||||
//if (msg.file.type == "application/img") {
|
||||
this.AttachmentsService.downloadFile(msg.file.guid).subscribe(async (event) => {
|
||||
console.log('FILE TYPE 22', msg.file.guid)
|
||||
var name = msg.file.guid;
|
||||
|
||||
if (event.type === HttpEventType.DownloadProgress) {
|
||||
//this.downloadProgess = Math.round((100 * event.loaded) / event.total);
|
||||
console.log('FILE TYPE 33', msg.file.type)
|
||||
} else if (event.type === HttpEventType.Response) {
|
||||
if (event.type === HttpEventType.DownloadProgress) {
|
||||
this.downloadProgess = Math.round((100 * event.loaded) / event.total);
|
||||
console.log(this.downloadProgess)
|
||||
console.log('FILE TYPE 33', msg.file.type)
|
||||
} else if (event.type === HttpEventType.Response) {
|
||||
if (msg.file.type == "application/img") {
|
||||
this.downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
||||
|
||||
msg.file = {
|
||||
guid: msg.file.guid,
|
||||
image_url: this.downloadFile,
|
||||
type: msg.file.type
|
||||
}
|
||||
this.sqlservice.updateChatMsg(msg._id, this.downloadFile);
|
||||
} else {
|
||||
//console.log('TRY THIS LIBRARY ',fromByteArray(event.body));
|
||||
this.downloadFile = event.body;
|
||||
}
|
||||
|
||||
});
|
||||
msg.attachments[0] = {
|
||||
image_url: this.downloadFile,
|
||||
name: msg.attachments[0].name,
|
||||
title: msg.attachments[0].title,
|
||||
title_link_download: msg.attachments[0].title_link_download,
|
||||
ts: msg.attachments[0].ts
|
||||
}
|
||||
this.sqlservice.updateChatMsg(msg._id, this.downloadFile);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
async openPreview(msg) {
|
||||
testDownlod(msg: MessageService) {
|
||||
this.AttachmentsService.downloadFileAndStore(msg.file.guid)
|
||||
}
|
||||
|
||||
if (msg.attachments[0].image_url === null || msg.attachments[0].image_url === '' ) {
|
||||
this.downloadFileMsg(msg)
|
||||
async openPreview(msg) {
|
||||
console.log(msg);
|
||||
|
||||
if (!msg.attachments[0].image_url || msg.attachments[0].image_url === null || msg.attachments[0].image_url === '') {
|
||||
this.downloadFile(msg)
|
||||
//this.testDownlod(msg)
|
||||
|
||||
} else {
|
||||
const modal = await this.modalController.create({
|
||||
@@ -976,6 +996,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
cssClass: 'modal modal-desktop',
|
||||
componentProps: {
|
||||
image: msg.attachments[0].image_url,
|
||||
type: msg.file.type,
|
||||
username: msg.u.name,
|
||||
_updatedAt: msg._updatedAt
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user