mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
merge
This commit is contained in:
@@ -32,7 +32,7 @@ import { SearchPage } from 'src/app/pages/search/search.page';
|
||||
import { ProcessesService } from 'src/app/services/processes.service';
|
||||
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
|
||||
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
|
||||
import { DocumentViewer, DocumentViewerOptions} from '@ionic-native/document-viewer';
|
||||
import { DocumentViewer, DocumentViewerOptions } from '@ionic-native/document-viewer';
|
||||
|
||||
const IMAGE_DIR = 'stored-images';
|
||||
@Component({
|
||||
@@ -267,13 +267,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[0].image_url], { type: 'application/pdf' });
|
||||
let fileURL = URL.createObjectURL(file)
|
||||
window.open(fileURL);
|
||||
|
||||
this.chatService.getDocumentDetails(fullUrl);
|
||||
// this.chatService.getDocumentDetails(fullUrl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,7 +454,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
//const imageData = await this.fileToBase64Service.convert(file)
|
||||
//console.log('ADDFILECHAT', imageData)
|
||||
|
||||
const response = await fetch('data:image/jpeg;base64,'+ file.base64String!);
|
||||
const response = await fetch('data:image/jpeg;base64,' + file.base64String!);
|
||||
const blob = await response.blob();
|
||||
|
||||
const formData = new FormData();
|
||||
@@ -465,6 +469,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
attachments: [{
|
||||
"title": file.path,
|
||||
// "image_url": "",
|
||||
//"image_url": 'data:image/jpeg;base64,' + file.base64String,
|
||||
"text": "description",
|
||||
"title_link_download": false,
|
||||
}]
|
||||
@@ -478,7 +483,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
const image = await this.CameraService.takePicture();
|
||||
await this.fileService.saveImage(image)
|
||||
const lastphoto: any = await this.fileService.loadFiles();
|
||||
const { capturedImage, capturedImageTitle} = await this.fileService.loadFileData(lastphoto);
|
||||
const { capturedImage, capturedImageTitle } = await this.fileService.loadFileData(lastphoto);
|
||||
const base64 = await fetch(capturedImage);
|
||||
console.log('imsge take picture', image)
|
||||
const blob = await base64.blob();
|
||||
@@ -494,8 +499,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
},
|
||||
temporaryData: formData,
|
||||
attachments: [{
|
||||
"title": capturedImageTitle ,
|
||||
"image_url": "",
|
||||
"title": capturedImageTitle,
|
||||
"image_url": capturedImage,
|
||||
"text": "description",
|
||||
"title_link_download": false,
|
||||
}]
|
||||
@@ -522,14 +527,14 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
}
|
||||
});
|
||||
await modal.present();
|
||||
modal.onDidDismiss().then(async res=>{
|
||||
modal.onDidDismiss().then(async res => {
|
||||
const data = res.data;
|
||||
const roomId = this.roomId
|
||||
|
||||
if(data.selected) {
|
||||
if (data.selected) {
|
||||
|
||||
this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||
file:{
|
||||
file: {
|
||||
"name": res.data.selected.Assunto,
|
||||
"type": "application/webtrix",
|
||||
"ApplicationId": res.data.selected.ApplicationType,
|
||||
@@ -551,7 +556,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
});
|
||||
}
|
||||
|
||||
async addFileToChatMobile(types: typeof FileType[] ) {
|
||||
async addFileToChatMobile(types: typeof FileType[]) {
|
||||
const roomId = this.roomId
|
||||
|
||||
const file = await Camera.getPhoto({
|
||||
@@ -564,7 +569,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
//const imageData = await this.fileToBase64Service.convert(file)
|
||||
//console.log('ADDFILECHAT', imageData)
|
||||
|
||||
const response = await fetch('data:image/jpeg;base64,'+ file.base64String!);
|
||||
const response = await fetch('data:image/jpeg;base64,' + file.base64String!);
|
||||
const blob = await response.blob();
|
||||
|
||||
const formData = new FormData();
|
||||
@@ -577,8 +582,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
},
|
||||
temporaryData: formData,
|
||||
attachments: [{
|
||||
"title": file.path ,
|
||||
"image_url": 'data:image/jpeg;base64,' +file.base64String,
|
||||
"title": file.path,
|
||||
//"image_url": 'data:image/jpeg;base64,' + file.base64String,
|
||||
"text": "description",
|
||||
"title_link_download": false,
|
||||
}]
|
||||
@@ -588,7 +593,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
|
||||
|
||||
async addFileToChat(types: typeof FileType[] ) {
|
||||
async addFileToChat(types: typeof FileType[]) {
|
||||
|
||||
const roomId = this.roomId
|
||||
|
||||
@@ -597,30 +602,44 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
/* const imageData = await this.fileToBase64Service.convert(file).then((filee) => {
|
||||
console.log('Add file', filee)
|
||||
}) */
|
||||
const blob = new Blob([file],{type: file.type})
|
||||
const blob = new Blob([file], { type: file.type })
|
||||
console.log('Add file', blob)
|
||||
|
||||
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,
|
||||
//"image_url": res,
|
||||
// "text": "description",
|
||||
"title_link_download": false,
|
||||
}],
|
||||
temporaryData: formData
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
blobToBase64 = blob => {
|
||||
const reader = new FileReader();
|
||||
reader.readAsDataURL(blob);
|
||||
return new Promise(resolve => {
|
||||
reader.onloadend = () => {
|
||||
resolve(reader.result);
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
bookMeeting() {
|
||||
let data = {
|
||||
@@ -673,7 +692,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
}
|
||||
});
|
||||
await modal.present();
|
||||
modal.onDidDismiss().then( async (res) => {
|
||||
modal.onDidDismiss().then(async (res) => {
|
||||
console.log(res['data']);
|
||||
|
||||
|
||||
@@ -716,35 +735,52 @@ 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") {
|
||||
this.AttachmentsService.downloadFile(msg.file.guid).subscribe(async (event) => {
|
||||
console.log('FILE TYPE 22', msg.file.guid)
|
||||
var name = msg.file.guid;
|
||||
//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;
|
||||
|
||||
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) {
|
||||
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) {
|
||||
if (msg.file.type == "application/img") {
|
||||
this.downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
||||
|
||||
msg.file = {
|
||||
guid: msg.file.guid,
|
||||
image_url: this.downloadFile,
|
||||
type: msg.file.type
|
||||
}
|
||||
|
||||
await this.storage.set(msg.file.guid, this.downloadFile).then(() => {
|
||||
console.log('IMAGE SAVED')
|
||||
});
|
||||
} else if (msg.file.type === 'application/pdf') {
|
||||
|
||||
this.downloadFile = event.body;
|
||||
}
|
||||
|
||||
});
|
||||
msg.attachments[0] = {
|
||||
image_url: this.downloadFile,
|
||||
name: msg.attachments[0].name,
|
||||
title: msg.attachments[0].title,
|
||||
title_link_download: msg.attachments[0].title_link_download,
|
||||
ts: msg.attachments[0].ts
|
||||
}
|
||||
|
||||
}
|
||||
await this.storage.set(msg.file.guid, this.downloadFile).then(() => {
|
||||
console.log('IMAGE SAVED')
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
pdfPreviwe() {
|
||||
_arrayBufferToBase64( buffer ) {
|
||||
var binary = '';
|
||||
var bytes = new Uint8Array( buffer );
|
||||
var len = bytes.byteLength;
|
||||
for (var i = 0; i < len; i++) {
|
||||
binary += String.fromCharCode( bytes[ i ] );
|
||||
}
|
||||
return window.btoa( binary );
|
||||
}
|
||||
|
||||
pdfPreview() {
|
||||
const options: DocumentViewerOptions = {
|
||||
title: 'My App'
|
||||
};
|
||||
@@ -752,26 +788,38 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
}
|
||||
|
||||
async openPreview(msg) {
|
||||
console.log(msg);
|
||||
console.log(msg);
|
||||
|
||||
if (msg.attachments[0].image_url === null || msg.attachments[0].image_url === '' ) {
|
||||
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 { */
|
||||
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
|
||||
}
|
||||
});
|
||||
modal.present();
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
testEditMessage(msg: MessageService) {
|
||||
// msg.receptorReceive()
|
||||
// alert('cool!')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user