This commit is contained in:
Peter Maquiran
2022-02-07 17:55:00 +01:00
parent 2caaad7f2b
commit e03fb2b413
14 changed files with 333 additions and 379 deletions
+10 -82
View File
@@ -450,13 +450,18 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
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);
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(roomId).send({
this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": "application/img",
"guid": '',
"image_url": capturedImage
},
temporary: formData,
attachments: [{
"title": capturedImageTitle ,
"text": "description",
@@ -464,40 +469,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}]
})
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()
updateMessage({
file: {
type: "application/img",
guid: guid.path,
image_url: capturedImage
}
})
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', capturedImage);
await this.storage.set(guid.path, capturedImage).then(() => {
console.log('add picture to chat IMAGE SAVED')
message.getFileFromDb()
});
}
});
}
async addImage() {
@@ -526,7 +497,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
if(data.selected) {
const loader = this.toastService.loading();
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(roomId).send({
this.wsChatMethodsService.getDmRoom(roomId).send({
file:{
"name": res.data.selected.Assunto,
"type": "application/webtrix",
@@ -537,31 +508,12 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
attachments: [{
"title": res.data.selected.Assunto,
"description": res.data.selected.DocTypeDesc,
// "title_link": url_no_options,
"title_link_download": true,
//"thumb_url": "assets/images/webtrix-logo.png",
// "message_link": url_no_options,
"type": "webtrix"
}],
temporary: res
})
let url = await this.processesService.GetDocumentUrl(res.data.selected.Id, res.data.selected.ApplicationType).toPromise();
let url_no_options: string = url.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1");
console.log(url_no_options);
updateMessage({
attachments: [{
"title": res.data.selected.Assunto,
"description": res.data.selected.DocTypeDesc,
"title_link": url_no_options,
"title_link_download": true,
//"thumb_url": "assets/images/webtrix-logo.png",
"message_link": url_no_options,
"type": "webtrix",
"text": res.data.selected.DocTypeDesc,
"thumb_url": "https://static.ichimura.ed.jp/uploads/2017/10/pdf-icon.png",
}]
}],
temporary: res
})
loader.remove();
@@ -581,7 +533,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
const formData = new FormData();
formData.append("blobFile", file);
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(roomId).send({
this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": "application/img",
"guid": '',
@@ -594,30 +546,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}]
})
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
updateMessage({
file: {
type: "application/img",
guid: guid.path,
image_url: imageData
}
})
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')
message.getFileFromDb()
});
}
});
}