mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fix message
This commit is contained in:
@@ -855,17 +855,19 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
|
||||
|
||||
async openViewDocumentModal(file: any) {
|
||||
async openViewDocumentModal(msg: MessageViewModal) {
|
||||
|
||||
console.log('passing', msg)
|
||||
let task = {
|
||||
serialNumber: '',
|
||||
taskStartDate: '',
|
||||
isEvent: true,
|
||||
workflowInstanceDataFields: {
|
||||
FolderID: '',
|
||||
Subject: file.Assunto,
|
||||
SourceSecFsID: file.ApplicationId,
|
||||
Subject: msg.attachments[0].description,
|
||||
SourceSecFsID: msg.attachments[0].applicationId,
|
||||
SourceType: 'DOC',
|
||||
SourceID: file.DocId,
|
||||
SourceID: msg.attachments[0].docId,
|
||||
DispatchNumber: ''
|
||||
}
|
||||
}
|
||||
@@ -874,13 +876,13 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
"Id": "",
|
||||
"ParentId": "",
|
||||
"Source": 1,
|
||||
"ApplicationId": file.ApplicationId,
|
||||
"ApplicationId": msg.attachments[0].applicationId,
|
||||
"CreateDate": "",
|
||||
"Data": null,
|
||||
"Description": "",
|
||||
"Link": null,
|
||||
"SourceId": file.DocId,
|
||||
"SourceName": file.Assunto,
|
||||
"SourceId": msg.attachments[0].docId,
|
||||
"SourceName": msg.attachments[0].description,
|
||||
"Stakeholders": "",
|
||||
}
|
||||
|
||||
@@ -889,13 +891,13 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
componentProps: {
|
||||
trustedUrl: '',
|
||||
file: {
|
||||
title: file.Assunto,
|
||||
title: msg.attachments[0].description,
|
||||
url: '',
|
||||
title_link: '',
|
||||
},
|
||||
Document: doc,
|
||||
applicationId: file.ApplicationId,
|
||||
docId: file.DocId,
|
||||
applicationId: msg.attachments[0].applicationId,
|
||||
docId: msg.attachments[0].docId,
|
||||
folderId: '',
|
||||
task: task
|
||||
},
|
||||
@@ -1092,7 +1094,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
source: MessageAttachmentSource.Webtrix,
|
||||
fileType: MessageAttachmentFileType.Doc,
|
||||
applicationId: res.data.selected.ApplicationType,
|
||||
docId: res.data.selected.Id,
|
||||
docId: parseInt(res.data.selected.Id) ,
|
||||
description: res.data.selected.Assunto
|
||||
}]
|
||||
|
||||
@@ -1387,25 +1389,33 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
return blob;
|
||||
}
|
||||
|
||||
downloadFileFromBrowser(fileName: string, data: any): void {
|
||||
downloadFileFromBrowser(fileName: string, msg: MessageViewModal): void {
|
||||
|
||||
const link = document.createElement("a")
|
||||
link.href = `data:${data.type}';base64,${data.image_url}`;
|
||||
link.download = fileName
|
||||
link.click()
|
||||
if(msg.attachments[0]?.blobURl) {
|
||||
// Create a temporary URL for the Blob
|
||||
const url = msg.attachments[0].safeFile;
|
||||
|
||||
// Create an <a> element with the download attribute
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = fileName; // Set the desired file name
|
||||
|
||||
// Programmatically click the <a> element to trigger the download
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
} else {
|
||||
const link = document.createElement("a")
|
||||
link.href = `data:${msg.attachments[0].mimeType}';base64,${msg.attachments[0].safeFile}`;
|
||||
link.download = fileName
|
||||
link.click()
|
||||
|
||||
link.remove()
|
||||
}
|
||||
|
||||
link.remove()
|
||||
}
|
||||
|
||||
viewDocument(file: any, url?: string) {
|
||||
|
||||
if (file.type == "application/webtrix") {
|
||||
this.openViewDocumentModal(file);
|
||||
}
|
||||
else {
|
||||
let fullUrl = "https://www.tabularium.pt" + url;
|
||||
this.fileService.viewDocumentByUrl(fullUrl);
|
||||
}
|
||||
viewDocument(msg: MessageViewModal) {
|
||||
this.openViewDocumentModal(msg);
|
||||
}
|
||||
|
||||
openFile(pdfString, filename, type) {
|
||||
@@ -1432,42 +1442,42 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
.catch(e => console.error(e))
|
||||
}
|
||||
|
||||
async openPreview(msg) {
|
||||
async openPreview(msg: MessageViewModal) {
|
||||
|
||||
|
||||
if (msg.file.type === "application/webtrix") {
|
||||
this.viewDocument(msg.file, msg.attachments.image_url)
|
||||
console.log(msg)
|
||||
if (msg.attachments[0].source === MessageAttachmentSource.Webtrix) {
|
||||
this.viewDocument(msg)
|
||||
} else {
|
||||
|
||||
if (!msg.attachments[0].image_url || msg.attachments[0].image_url === null || msg.attachments[0].image_url === '') {
|
||||
if (!msg.attachments[0].safeFile || msg.attachments[0].safeFile === null || msg.attachments[0].safeFile === '') {
|
||||
// this.downloadFileMsg(msg)
|
||||
|
||||
} else {
|
||||
|
||||
var str = msg.attachments[0].image_url
|
||||
str = str.substring(1, ((str.length) - 1));
|
||||
var str = msg.attachments[0].safeFile
|
||||
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
|
||||
if (msg.file.type == "application/img") {
|
||||
if (msg.attachments[0].mimeType.includes('image')) {
|
||||
const modal = await this.modalController.create({
|
||||
component: ViewMediaPage,
|
||||
cssClass: 'modal modal-desktop',
|
||||
componentProps: {
|
||||
image: msg.attachments[0].image_url,
|
||||
type: msg.file.type,
|
||||
username: msg.u.name,
|
||||
_updatedAt: msg._updatedAt
|
||||
image: msg.attachments[0].safeFile,
|
||||
type: msg.attachments[0].mimeType,
|
||||
username: msg.attachments[0].description,
|
||||
_updatedAt: msg.sentAt
|
||||
}
|
||||
});
|
||||
modal.present();
|
||||
} else {
|
||||
this.downloadFileFromBrowser(msg.attachments[0].title, msg.attachments[0],)
|
||||
this.downloadFileFromBrowser(msg.attachments[0].description, msg)
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
this.openFile(msg.attachments[0].image_url, msg.attachments[0].title, msg.file.type);
|
||||
this.openFile(msg.attachments[0].safeFile, msg.attachments[0].description, msg.attachments[0].mimeType);
|
||||
// this.downloadFileFromBrowser("file", str)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user