mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
Merge branch 'developer' of bitbucket.org:equilibriumito/gabinete-digital into developer
This commit is contained in:
@@ -88,7 +88,7 @@
|
||||
</div>
|
||||
<div *ngIf="msg.file.type != 'application/img'">
|
||||
<div class="file">
|
||||
<div (click)="docIndex(i); viewDocument(msg, file.title_link)" class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file">
|
||||
<div (click)="docIndex(i); openPreview(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>
|
||||
<fa-icon *ngIf="msg.file.type == 'application/word'" icon="file-word" class="word-icon"></fa-icon>
|
||||
|
||||
@@ -40,9 +40,10 @@ import { SearchPage } from 'src/app/pages/search/search.page';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
|
||||
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
|
||||
import {Plugins} from '@capacitor/core';
|
||||
import { Plugins } from '@capacitor/core';
|
||||
import { fromByteArray } from 'base64-js';
|
||||
|
||||
const { Filesystem } = Plugins;
|
||||
const { Filesystem } = Plugins;
|
||||
|
||||
|
||||
const IMAGE_DIR = 'stored-images';
|
||||
@@ -93,6 +94,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
myAudio: any;
|
||||
downloadfile: any;
|
||||
downloadFile: any;
|
||||
downloadProgess: number;
|
||||
|
||||
constructor(
|
||||
public popoverController: PopoverController,
|
||||
@@ -133,7 +135,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.wsChatMethodsService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
|
||||
this.wsChatMethodsService.openRoom(this.roomId)
|
||||
|
||||
setTimeout(()=>{
|
||||
setTimeout(() => {
|
||||
this.scrollToBottomClicked()
|
||||
}, 150)
|
||||
|
||||
@@ -374,7 +376,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
});
|
||||
};
|
||||
|
||||
console.log('WRITE',writeSecretFile);
|
||||
console.log('WRITE', writeSecretFile);
|
||||
|
||||
const readSecretFile = async () => {
|
||||
const contents = await Filesystem.readFile({
|
||||
@@ -386,7 +388,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
console.log('secrets:', contents);
|
||||
};
|
||||
|
||||
console.log('READ',readSecretFile);
|
||||
console.log('READ', readSecretFile);
|
||||
|
||||
} catch (e) {
|
||||
console.error("Unable to write file", e);
|
||||
@@ -557,7 +559,7 @@ export class MessagesPage implements OnInit, 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);
|
||||
@@ -572,8 +574,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
"guid": ''
|
||||
},
|
||||
attachments: [{
|
||||
"image_url": capturedImage,
|
||||
"title": capturedImageTitle ,
|
||||
"title": capturedImageTitle,
|
||||
"text": "description",
|
||||
"title_link_download": false,
|
||||
}],
|
||||
@@ -605,14 +606,14 @@ export class MessagesPage implements OnInit, 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,
|
||||
@@ -635,7 +636,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
async addFileToChatMobile(types: typeof FileType[] ) {
|
||||
async addFileToChatMobile(types: typeof FileType[]) {
|
||||
const roomId = this.roomId
|
||||
|
||||
const file = await Camera.getPhoto({
|
||||
@@ -648,7 +649,7 @@ export class MessagesPage implements OnInit, 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();
|
||||
@@ -661,8 +662,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
},
|
||||
temporaryData: formData,
|
||||
attachments: [{
|
||||
"title": file.path ,
|
||||
"image_url": 'data:image/jpeg;base64,' +file.base64String,
|
||||
"title": file.path,
|
||||
"text": "description",
|
||||
"title_link_download": false,
|
||||
}]
|
||||
@@ -672,7 +672,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
|
||||
|
||||
async addFileToChat(types: typeof FileType[] ) {
|
||||
async addFileToChat(types: typeof FileType[]) {
|
||||
|
||||
const roomId = this.roomId
|
||||
|
||||
@@ -681,11 +681,14 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
/* const imageData = await this.fileToBase64Service.convert(file).then((filee) => {
|
||||
console.log('Add file', filee)
|
||||
}) */
|
||||
const blob = new Blob([file],{type: file.type})
|
||||
console.log('Add file', blob)
|
||||
const response = await fetch(file);
|
||||
const blob = await response.blob();
|
||||
const blob2 = new Blob([blob])
|
||||
console.log('Add file base64', file)
|
||||
console.log('Add file blob', blob)
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", blob);
|
||||
formData.append("blobFile", blob2);
|
||||
|
||||
this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||
file: {
|
||||
@@ -693,10 +696,9 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
"guid": '',
|
||||
},
|
||||
attachments: [{
|
||||
"title": file.name ,
|
||||
"name": file.name ,
|
||||
"title": file.name,
|
||||
"name": file.name,
|
||||
// "text": "description",
|
||||
"image_url": file, // rocketchat
|
||||
"title_link_download": false,
|
||||
}],
|
||||
temporaryData: formData
|
||||
@@ -707,7 +709,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
async openChatOptions(ev?: any) {
|
||||
const roomId = this.roomId
|
||||
console.log('MOBILE CHAT OPTION',this.members);
|
||||
console.log('MOBILE CHAT OPTION', this.members);
|
||||
|
||||
const popover = await this.popoverController.create({
|
||||
component: ChatOptionsPopoverPage,
|
||||
@@ -721,7 +723,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
translucent: true
|
||||
});
|
||||
await popover.present();
|
||||
popover.onDidDismiss().then( async (res) => {
|
||||
popover.onDidDismiss().then(async (res) => {
|
||||
console.log(res['data']);
|
||||
if (res['data'] == 'meeting') {
|
||||
this.bookMeeting();
|
||||
@@ -819,39 +821,58 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
}
|
||||
|
||||
testeDownload(msg: MessageService) {
|
||||
this.downloadFile = "";
|
||||
this.AttachmentsService.downloadFileAndStore(msg.file.guid);
|
||||
}
|
||||
|
||||
|
||||
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(this.downloadProgess)
|
||||
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
|
||||
}
|
||||
this.sqlservice.updateChatMsg(msg._id, this.downloadFile);
|
||||
} else {
|
||||
//console.log('TRY THIS LIBRARY ',fromByteArray(event.body));
|
||||
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
|
||||
}
|
||||
this.sqlservice.updateChatMsg(msg._id, this.downloadFile);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
async openPreview(msg) {
|
||||
testDownlod(msg: MessageService) {
|
||||
this.AttachmentsService.downloadFileAndStore(msg.file.guid)
|
||||
}
|
||||
|
||||
if (msg.attachments[0].image_url === null || msg.attachments[0].image_url === '' ) {
|
||||
this.downloadFileMsg(msg)
|
||||
async openPreview(msg) {
|
||||
console.log(msg);
|
||||
|
||||
if (!msg.attachments[0].image_url || msg.attachments[0].image_url === null || msg.attachments[0].image_url === '') {
|
||||
this.downloadFile(msg)
|
||||
//this.testDownlod(msg)
|
||||
|
||||
} else {
|
||||
const modal = await this.modalController.create({
|
||||
@@ -859,6 +880,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
cssClass: 'modal modal-desktop',
|
||||
componentProps: {
|
||||
image: msg.attachments[0].image_url,
|
||||
type: msg.file.type,
|
||||
username: msg.u.name,
|
||||
_updatedAt: msg._updatedAt
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user