This commit is contained in:
Peter Maquiran
2022-02-04 08:00:10 +01:00
parent 1ffeb3df5c
commit 80aaf352b6
4 changed files with 24 additions and 310 deletions
+5 -44
View File
@@ -526,7 +526,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
const lastphoto: any = await this.fileService.loadFiles();
const { capturedImage, capturedImageTitle} = await this.fileService.loadFileData(lastphoto);
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(this.roomId).send({
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": "application/img",
"guid": '',
@@ -631,7 +631,9 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
"title_link_download": true,
//"thumb_url": "assets/images/webtrix-logo.png",
"message_link": url_no_options,
"type": "webtrix"
"type": "webtrix",
"text": res.data.selected.DocTypeDesc,
"thumb_url": "https://static.ichimura.ed.jp/uploads/2017/10/pdf-icon.png",
}]
})
@@ -711,48 +713,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.bookMeeting();
}
else if (res['data'] == 'take-picture') {
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 base64 = await fetch(capturedImage);
const blob = await base64.blob();
const formData = new FormData();
formData.append("blobFile", blob);
console.log('ALL IMAGE', formData)
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
console.log(guid.path);
this.AttachmentsService.downloadFile(guid.path).subscribe(async (event) => {
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) {
var fileImage = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
console.log('add picture to chat',fileImage);
await this.storage.set(guid.path, fileImage).then(() => {
console.log('add picture to chat IMAGE SAVED')
this.wsChatMethodsService.getDmRoom(this.roomId).send({
file: {
"type": "application/img",
"guid": guid.path,
"image_url": fileImage
},
attachments: [{
"title": capturedImageTitle ,
"text": "description",
"title_link_download": false,
"image_url": capturedImage,
}]
})
});
}
});
this.takePicture()
}
else if (res['data'] == 'add-picture') {
this.addImage()