mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
Error and conflits after pull solved
This commit is contained in:
@@ -416,19 +416,45 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
}
|
||||
else {
|
||||
console.log('PDF CLICK', msg)
|
||||
var str = msg.attachments[0].image_url;
|
||||
str = str.substring(1,((str.length)-1));
|
||||
|
||||
const encodedData = btoa(str);
|
||||
/* let fullUrl;
|
||||
fullUrl = "https://gabinetedigitalchat.dyndns.info" + url;
|
||||
//fullUrl = "http://www.africau.edu/images/default/sample.pdf";
|
||||
|
||||
this.frameUrl = fullUrl; */
|
||||
let file = new Blob([msg.attachments[0].image_url], { type: 'application/pdf' });
|
||||
let file = this.base64toBlob(encodedData, 'application/pdf')
|
||||
let fileURL = URL.createObjectURL(file)
|
||||
console.log('PDF CLICK', fileURL)
|
||||
window.open(fileURL);
|
||||
|
||||
// this.chatService.getDocumentDetails(fullUrl);
|
||||
}
|
||||
}
|
||||
|
||||
base64toBlob(base64Data, contentType) {
|
||||
contentType = contentType || '';
|
||||
var sliceSize = 1024;
|
||||
var byteCharacters = atob(base64Data);
|
||||
var bytesLength = byteCharacters.length;
|
||||
var slicesCount = Math.ceil(bytesLength / sliceSize);
|
||||
var byteArrays = new Array(slicesCount);
|
||||
|
||||
for (var sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
|
||||
var begin = sliceIndex * sliceSize;
|
||||
var end = Math.min(begin + sliceSize, bytesLength);
|
||||
|
||||
var bytes = new Array(end - begin);
|
||||
for (var offset = begin, i = 0; offset < end; ++i, ++offset) {
|
||||
bytes[i] = byteCharacters[offset].charCodeAt(0);
|
||||
}
|
||||
byteArrays[sliceIndex] = new Uint8Array(bytes);
|
||||
}
|
||||
return new Blob(byteArrays, { type: contentType });
|
||||
}
|
||||
|
||||
|
||||
async openViewDocumentModal(file: any) {
|
||||
let task = {
|
||||
@@ -944,7 +970,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
if (!msg.attachments[0].image_url || msg.attachments[0].image_url === null || msg.attachments[0].image_url === '') {
|
||||
this.downloadFileMsg(msg)
|
||||
|
||||
|
||||
} else if (msg.file.type === "application/pdf") {
|
||||
this.viewDocument(msg, msg.attachments.image_url)
|
||||
} else {
|
||||
|
||||
/* if(msg.file.type === "application/pdf") {
|
||||
|
||||
Reference in New Issue
Block a user