mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
lasta chnages
This commit is contained in:
@@ -33,7 +33,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({
|
||||
@@ -274,11 +274,11 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
//fullUrl = "http://www.africau.edu/images/default/sample.pdf";
|
||||
|
||||
this.frameUrl = fullUrl; */
|
||||
let file = new Blob([msg.attachments.image_url], {type:'application/pdf'});
|
||||
let file = new Blob([msg.attachments[0].image_url], { type: 'application/pdf' });
|
||||
let fileURL = URL.createObjectURL(file)
|
||||
window.open(fileURL,"_blank");
|
||||
window.open(fileURL);
|
||||
|
||||
// this.chatService.getDocumentDetails(fullUrl);
|
||||
// this.chatService.getDocumentDetails(fullUrl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,7 +457,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();
|
||||
@@ -470,8 +470,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,
|
||||
}]
|
||||
@@ -485,7 +485,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();
|
||||
@@ -501,7 +501,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
},
|
||||
temporaryData: formData,
|
||||
attachments: [{
|
||||
"title": capturedImageTitle ,
|
||||
"title": capturedImageTitle,
|
||||
"image_url": capturedImage,
|
||||
"text": "description",
|
||||
"title_link_download": false,
|
||||
@@ -529,14 +529,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,
|
||||
@@ -558,7 +558,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({
|
||||
@@ -571,7 +571,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();
|
||||
@@ -584,8 +584,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,
|
||||
}]
|
||||
@@ -595,7 +595,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
|
||||
|
||||
async addFileToChat(types: typeof FileType[] ) {
|
||||
async addFileToChat(types: typeof FileType[]) {
|
||||
|
||||
const roomId = this.roomId
|
||||
|
||||
@@ -604,7 +604,7 @@ 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();
|
||||
@@ -619,11 +619,11 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
"guid": '',
|
||||
},
|
||||
attachments: [{
|
||||
"title": file.name ,
|
||||
"name": file.name ,
|
||||
"title": file.name,
|
||||
"name": file.name,
|
||||
//"image_url": res,
|
||||
// "text": "description",
|
||||
"title_link_download": false,
|
||||
"image_url": res,
|
||||
}],
|
||||
temporaryData: formData
|
||||
})
|
||||
@@ -632,7 +632,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
}
|
||||
|
||||
blobToBase64 = blob => {
|
||||
blobToBase64 = blob => {
|
||||
const reader = new FileReader();
|
||||
reader.readAsDataURL(blob);
|
||||
return new Promise(resolve => {
|
||||
@@ -694,7 +694,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']);
|
||||
|
||||
|
||||
@@ -738,38 +738,50 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
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;
|
||||
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 (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), ''));
|
||||
}
|
||||
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), ''));
|
||||
} else if (msg.file.type === 'application/pdf') {
|
||||
|
||||
|
||||
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')
|
||||
});
|
||||
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')
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
_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'
|
||||
@@ -778,34 +790,35 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
}
|
||||
|
||||
async openPreview(msg) {
|
||||
console.log(msg);
|
||||
console.log(msg);
|
||||
|
||||
if (msg.file.image_url === null || msg.file.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") {
|
||||
/* 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();
|
||||
}
|
||||
|
||||
} 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) {
|
||||
testEditMessage(msg: MessageService) {
|
||||
msg.receptorReceive()
|
||||
// alert('cool!')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user