Commit to get icon and splash

This commit is contained in:
Eudes Inácio
2022-02-25 15:10:10 +01:00
parent ef0e724f58
commit 99275b891b
78 changed files with 1432 additions and 58 deletions
@@ -88,7 +88,7 @@
</div>
<div *ngIf="msg.file.type != 'application/img'">
<div class="file">
<div (click)="viewDocument(msg, file.title_link)" class="file-details add-ellipsis cursor-pointer"
<div (click)="viewDocument(msg)" class="file-details add-ellipsis cursor-pointer"
*ngIf="msg.file">
<span *ngIf="msg.file.type">
<fa-icon *ngIf="msg.file.type == 'application/pdf'" icon="file-pdf" class="pdf-icon"></fa-icon>
+61 -32
View File
@@ -268,13 +268,17 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
this.openViewDocumentModal(msg.file);
}
else {
let fullUrl;
console.log('PDF CLICK', msg)
/* let fullUrl;
fullUrl = "https://gabinetedigitalchat.dyndns.info" + url;
//fullUrl = "http://www.africau.edu/images/default/sample.pdf";
this.frameUrl = fullUrl;
this.frameUrl = fullUrl; */
let file = new Blob([msg.attachments.image_url], {type:'application/pdf'});
let fileURL = URL.createObjectURL(file)
window.open(fileURL,"_blank");
this.chatService.getDocumentDetails(fullUrl);
// this.chatService.getDocumentDetails(fullUrl);
}
}
@@ -606,24 +610,38 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
const formData = new FormData();
formData.append("blobFile", blob);
this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": file.type,
"guid": '',
},
attachments: [{
"title": file.name ,
"name": file.name ,
// "text": "description",
"image_url": file, // rocketchat
"title_link_download": false,
}],
temporaryData: formData
})
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 ,
"name": file.name ,
// "text": "description",
"title_link_download": false,
"image_url": res,
}],
temporaryData: formData
})
});
}
blobToBase64 = blob => {
const reader = new FileReader();
reader.readAsDataURL(blob);
return new Promise(resolve => {
reader.onloadend = () => {
resolve(reader.result);
};
});
};
bookMeeting() {
let data = {
@@ -719,7 +737,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
downloadFileMsg(msg: MessageService) {
console.log('FILE TYPE', msg.file.type)
this.downloadFile = "";
if (msg.file.type == "application/img") {
//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;
@@ -728,7 +746,12 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
//this.downloadProgess = Math.round((100 * event.loaded) / event.total);
console.log('FILE TYPE 33', msg.file.type)
} else if (event.type === HttpEventType.Response) {
this.downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
if (msg.file.type == "application/img") {
this.downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
} else {
this.downloadFile = btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
}
msg.file = {
guid: msg.file.guid,
@@ -743,11 +766,11 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
});
}
// }
}
pdfPreviwe() {
pdfPreview() {
const options: DocumentViewerOptions = {
title: 'My App'
};
@@ -757,20 +780,26 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
async openPreview(msg) {
console.log(msg);
if (msg.attachments[0].image_url === null || msg.attachments[0].image_url === '' ) {
if (msg.file.image_url === null || msg.file.image_url === '' ) {
this.downloadFileMsg(msg)
} else {
const modal = await this.modalController.create({
component: ViewMediaPage,
cssClass: 'modal modal-desktop',
componentProps: {
image: msg.attachments[0].image_url,
username: msg.u.name,
_updatedAt: msg._updatedAt
}
});
modal.present();
if(msg.file.type === "application/pdf") {
this.viewDocument(msg, msg.attachments.image_url)
} else {
const modal = await this.modalController.create({
component: ViewMediaPage,
cssClass: 'modal modal-desktop',
componentProps: {
image: msg.attachments[0].image_url,
username: msg.u.name,
_updatedAt: msg._updatedAt
}
});
modal.present();
}
}
}