-
diff --git a/src/app/shared/chat/messages/messages.page.ts b/src/app/shared/chat/messages/messages.page.ts
index ee22e686d..2c768a2c7 100644
--- a/src/app/shared/chat/messages/messages.page.ts
+++ b/src/app/shared/chat/messages/messages.page.ts
@@ -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();
+ }
+
}
}
diff --git a/src/app/shared/popover/chat-options-popover/chat-options-popover.page.html b/src/app/shared/popover/chat-options-popover/chat-options-popover.page.html
index 96b7c7ae8..33bebb685 100644
--- a/src/app/shared/popover/chat-options-popover/chat-options-popover.page.html
+++ b/src/app/shared/popover/chat-options-popover/chat-options-popover.page.html
@@ -7,7 +7,7 @@