lasta chnages

This commit is contained in:
Eudes Inácio
2022-03-03 08:21:22 +01:00
parent 99275b891b
commit 5c210928c0
15 changed files with 527 additions and 365 deletions
@@ -18,6 +18,6 @@
} }
}, },
"server": { "server": {
"url": "http://192.168.0.92:8100" "url": "http://192.168.1.5:8100"
} }
} }
+83 -14
View File
@@ -4999,6 +4999,11 @@
"integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==",
"dev": true "dev": true
}, },
"@types/pdfjs-dist": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/@types/pdfjs-dist/-/pdfjs-dist-0.1.2.tgz",
"integrity": "sha512-BvRLWz6RCI8FMKbgfdTCadVwimUv8920gLsnBEAkECjtqIy95jtt+G1ebNQE2b8PTnLjJICPpmBOGhgkSsiPKA=="
},
"@types/prettier": { "@types/prettier": {
"version": "2.4.1", "version": "2.4.1",
"resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.4.1.tgz", "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.4.1.tgz",
@@ -6159,8 +6164,7 @@
"big.js": { "big.js": {
"version": "5.2.2", "version": "5.2.2",
"resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
"integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ=="
"dev": true
}, },
"binary-extensions": { "binary-extensions": {
"version": "2.2.0", "version": "2.2.0",
@@ -7181,8 +7185,7 @@
"co": { "co": {
"version": "4.6.0", "version": "4.6.0",
"resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
"integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ="
"dev": true
}, },
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
@@ -9453,8 +9456,7 @@
"emojis-list": { "emojis-list": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz", "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz",
"integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==", "integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q=="
"dev": true
}, },
"enabled": { "enabled": {
"version": "2.0.0", "version": "2.0.0",
@@ -16465,18 +16467,22 @@
} }
}, },
"ng2-pdf-viewer": { "ng2-pdf-viewer": {
"version": "7.0.1", "version": "3.0.8",
"resolved": "https://registry.npmjs.org/ng2-pdf-viewer/-/ng2-pdf-viewer-7.0.1.tgz", "resolved": "https://registry.npmjs.org/ng2-pdf-viewer/-/ng2-pdf-viewer-3.0.8.tgz",
"integrity": "sha512-kjjsvHd5t1Ff7ydb3Far3d6cSyw/XJH5KXgcp/0bFzSFBAV2c5aOghxoY/yQVjgG+R6F16nVUh2UrZdngLXLSg==", "integrity": "sha512-p2qndFu1wQW4y+xXXw7yk1BhpRo5PGHKWD3PTc7pUULujx9d2vT26lhXR3p9WHitySadGqdCQpkA7W3v1dBlSg==",
"requires": { "requires": {
"pdfjs-dist": "~2.7.570", "@types/pdfjs-dist": "^0.1.1",
"tslib": "^2.0.0" "pdfjs-dist": "1.9.489"
}, },
"dependencies": { "dependencies": {
"pdfjs-dist": { "pdfjs-dist": {
"version": "2.7.570", "version": "1.9.489",
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-2.7.570.tgz", "resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-1.9.489.tgz",
"integrity": "sha512-/ZkA1FwkEOyDaq11JhMLazdwQAA0F9uwrP7h/1L9Akt9KWh1G5/tkzS+bPuUELq2s2GDFnaT+kooN/aSjT7DXQ==" "integrity": "sha1-yuWf7d0WouXRlappUnlVz+QALB0=",
"requires": {
"node-ensure": "^0.0.0",
"worker-loader": "^0.8.0"
}
} }
} }
}, },
@@ -16565,6 +16571,11 @@
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.2.1.tgz", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.2.1.tgz",
"integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==" "integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A=="
}, },
"node-ensure": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/node-ensure/-/node-ensure-0.0.0.tgz",
"integrity": "sha1-7K52QVDemYYexcgQ/V0Jaxg5Mqc="
},
"node-fetch": { "node-fetch": {
"version": "2.6.1", "version": "2.6.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
@@ -24774,6 +24785,64 @@
"resolved": "https://registry.npmjs.org/wordcloud/-/wordcloud-1.2.2.tgz", "resolved": "https://registry.npmjs.org/wordcloud/-/wordcloud-1.2.2.tgz",
"integrity": "sha512-fUnDsGrHXou+49j1OeKaC7nOeZPx+sWjIet0L/j6eAcm0nXy+a+AuUs/iDAX4PLBg1Zc6wgXWXhoXdQsXRWAEw==" "integrity": "sha512-fUnDsGrHXou+49j1OeKaC7nOeZPx+sWjIet0L/j6eAcm0nXy+a+AuUs/iDAX4PLBg1Zc6wgXWXhoXdQsXRWAEw=="
}, },
"worker-loader": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/worker-loader/-/worker-loader-0.8.1.tgz",
"integrity": "sha1-6OmVMx6jTfW/aCloJL+38K1XjUM=",
"requires": {
"loader-utils": "^1.0.2",
"schema-utils": "^0.3.0"
},
"dependencies": {
"ajv": {
"version": "5.5.2",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz",
"integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=",
"requires": {
"co": "^4.6.0",
"fast-deep-equal": "^1.0.0",
"fast-json-stable-stringify": "^2.0.0",
"json-schema-traverse": "^0.3.0"
}
},
"fast-deep-equal": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz",
"integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ="
},
"json-schema-traverse": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz",
"integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A="
},
"json5": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
"integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
"requires": {
"minimist": "^1.2.0"
}
},
"loader-utils": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.0.tgz",
"integrity": "sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==",
"requires": {
"big.js": "^5.2.2",
"emojis-list": "^3.0.0",
"json5": "^1.0.1"
}
},
"schema-utils": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-0.3.0.tgz",
"integrity": "sha1-9YdyIs4+kx7a4DnxfrNxbnE3+M8=",
"requires": {
"ajv": "^5.0.0"
}
}
}
},
"wrap-ansi": { "wrap-ansi": {
"version": "7.0.0", "version": "7.0.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
+2 -1
View File
@@ -97,6 +97,7 @@
"angular-cropperjs": "^0.1.5", "angular-cropperjs": "^0.1.5",
"angular-svg-icon": "^12.0.0", "angular-svg-icon": "^12.0.0",
"angular-tag-cloud-module": "^5.2.2", "angular-tag-cloud-module": "^5.2.2",
"base64-js": "^1.5.1",
"bootstrap": "^4.5.0", "bootstrap": "^4.5.0",
"build": "0.1.4", "build": "0.1.4",
"capacitor-voice-recorder": "^2.0.0", "capacitor-voice-recorder": "^2.0.0",
@@ -133,7 +134,7 @@
"lite-server": "^2.6.1", "lite-server": "^2.6.1",
"moment": "^2.29.1", "moment": "^2.29.1",
"ng-lazyload-image": "^9.1.2", "ng-lazyload-image": "^9.1.2",
"ng2-pdf-viewer": "^7.0.1", "ng2-pdf-viewer": "^3.0.8",
"ngx-cookie-service": "^12.0.3", "ngx-cookie-service": "^12.0.3",
"ngx-image-compress": "^11.0.3", "ngx-image-compress": "^11.0.3",
"ngx-image-cropper": "^5.0.1", "ngx-image-cropper": "^5.0.1",
@@ -8,6 +8,7 @@ import { ViewMediaPageRoutingModule } from './view-media-routing.module';
import { ViewMediaPage } from './view-media.page'; import { ViewMediaPage } from './view-media.page';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { PdfViewerModule } from 'ng2-pdf-viewer';
@NgModule({ @NgModule({
imports: [ imports: [
@@ -15,7 +16,8 @@ import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
FormsModule, FormsModule,
IonicModule, IonicModule,
FontAwesomeModule, FontAwesomeModule,
ViewMediaPageRoutingModule ViewMediaPageRoutingModule,
PdfViewerModule
], ],
declarations: [ViewMediaPage] declarations: [ViewMediaPage]
}) })
@@ -20,8 +20,14 @@
<ion-slides style="width: 100%; height: 100%;" [options]="sliderOpts"> <ion-slides style="width: 100%; height: 100%;" [options]="sliderOpts">
<ion-slide> <ion-slide>
<div class="swiper-zoom-container"> <div class="swiper-zoom-container">
<div *ngIf="type == 'application/img'">
<img src="{{image}}"> <img src="{{image}}">
</div> </div>
<div *ngIf="type == 'application/pdf'">
<pdf-viewer [src]="image" [render-text]="true" [original-size]="false" [zoom]="0.5" style="display: block;">
</pdf-viewer>
</div>
</div>
</ion-slide> </ion-slide>
</ion-slides> </ion-slides>
@@ -9,6 +9,7 @@ import { ModalController, NavParams } from '@ionic/angular';
export class ViewMediaPage implements OnInit { export class ViewMediaPage implements OnInit {
image: any; image: any;
type: any;
name: string name: string
_updatedAt: string _updatedAt: string
@@ -22,6 +23,7 @@ export class ViewMediaPage implements OnInit {
private navParams:NavParams, private navParams:NavParams,
) { ) {
this.image = this.navParams.get('image') this.image = this.navParams.get('image')
this.type = this.navParams.get('type')
this.name = this.navParams.get('username') this.name = this.navParams.get('username')
this._updatedAt = this.navParams.get('_updatedAt') this._updatedAt = this.navParams.get('_updatedAt')
} }
@@ -107,7 +107,7 @@
</div> </div>
<div *ngIf="msg.file.type != 'application/img'"> <div *ngIf="msg.file.type != 'application/img'">
<div class="file"> <div class="file">
<div (click)="viewDocument(msg.file, file.title_link)" class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file"> <div (click)="openPreview(msg)" class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file">
<span *ngIf="msg.file.type"> <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/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> <fa-icon *ngIf="msg.file.type == 'application/word'" icon="file-word" class="word-icon"></fa-icon>
@@ -455,7 +455,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
temporaryData: formData, temporaryData: formData,
attachments: [{ attachments: [{
"title": capturedImageTitle, "title": capturedImageTitle,
"image_url": capturedImage, // rocketchat //"image_url": capturedImage, // rocketchat
"text": "description", "text": "description",
"title_link_download": false, "title_link_download": false,
}] }]
@@ -515,26 +515,37 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
async addFileToChat(types: typeof FileType[] ) { async addFileToChat(types: typeof FileType[] ) {
const roomId = this.roomId
const file: any = await this.fileService.getFileFromDevice(types); const file: any = await this.fileService.getFileFromDevice(types);
const imageData = await this.fileToBase64Service.convert(file) console.log('Add file', file)
/* const imageData = await this.fileToBase64Service.convert(file).then((filee) => {
console.log('Add file', filee)
}) */
const response = await fetch(file);
const blob = await response.blob();
console.log('Add file', blob)
const formData = new FormData(); const formData = new FormData();
formData.append("blobFile", file); formData.append("blobFile", blob);
this.wsChatMethodsService.getGroupRoom(this.roomId).send({ this.wsChatMethodsService.getGroupRoom(roomId).send({
file: { file: {
"type": "application/img", "type": file.type,
"guid": '' "guid": '',
}, },
temporaryData: formData,
attachments: [{ attachments: [{
"title": file.name , "title": file.name ,
"text": "description", "name": file.name ,
"image_url": imageData, // "text": "description",
//"image_url": file.base64String, // rocketchat
"title_link_download": false, "title_link_download": false,
}] }],
temporaryData: formData
}) })
} }
async openChatOptions(ev?: any) { async openChatOptions(ev?: any) {
@@ -794,7 +805,7 @@ touchStart(card) {
downloadFileMsg(msg) { downloadFileMsg(msg) {
console.log('FILE TYPE', msg.file.type) console.log('FILE TYPE', msg.file.type)
this.downloadFile = ""; this.downloadFile = "";
if (msg.file.type == "application/img") { // if (msg.file.type == "application/img") {
this.AttachmentsService.downloadFile(msg.file.guid).subscribe(async (event) => { this.AttachmentsService.downloadFile(msg.file.guid).subscribe(async (event) => {
console.log('FILE TYPE 22', msg.file.guid) console.log('FILE TYPE 22', msg.file.guid)
var name = msg.file.guid; var name = msg.file.guid;
@@ -803,24 +814,30 @@ downloadFileMsg(msg) {
//this.downloadProgess = Math.round((100 * event.loaded) / event.total); //this.downloadProgess = Math.round((100 * event.loaded) / event.total);
console.log('FILE TYPE 33', msg.file.type) console.log('FILE TYPE 33', msg.file.type)
} else if (event.type === HttpEventType.Response) { } 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), '')); this.downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
console.log('FILE TYPE 44', this.downloadFile) } else {
msg.file = { this.downloadFile = event.body;
guid: msg.file.guid, }
msg.attachments[0] = {
image_url: this.downloadFile, image_url: this.downloadFile,
type: msg.file.type 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); this.sqlservice.updateChatMsg(msg._id, this.downloadFile);
} }
}); });
console.log('FILE TYPE 44', this.downloadFile) console.log('FILE TYPE 44', this.downloadFile)
} //}
} }
async openPreview(msg) { async openPreview(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) this.downloadFileMsg(msg)
} else { } else {
@@ -829,6 +846,7 @@ async openPreview(msg) {
cssClass: 'modal modal-desktop', cssClass: 'modal modal-desktop',
componentProps: { componentProps: {
image: msg.attachments[0].image_url, image: msg.attachments[0].image_url,
type: msg.file.type,
username: msg.u.name, username: msg.u.name,
_updatedAt: msg._updatedAt _updatedAt: msg._updatedAt
} }
@@ -88,7 +88,7 @@
</div> </div>
<div *ngIf="msg.file.type != 'application/img'"> <div *ngIf="msg.file.type != 'application/img'">
<div class="file"> <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"> <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/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> <fa-icon *ngIf="msg.file.type == 'application/word'" icon="file-word" class="word-icon"></fa-icon>
+21 -11
View File
@@ -41,6 +41,7 @@ import { Storage } from '@ionic/storage';
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service'; import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera'; 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;
@@ -573,7 +574,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
"guid": '' "guid": ''
}, },
attachments: [{ attachments: [{
"image_url": capturedImage,
"title": capturedImageTitle, "title": capturedImageTitle,
"text": "description", "text": "description",
"title_link_download": false, "title_link_download": false,
@@ -663,7 +663,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
temporaryData: formData, temporaryData: formData,
attachments: [{ attachments: [{
"title": file.path, "title": file.path,
"image_url": 'data:image/jpeg;base64,' +file.base64String,
"text": "description", "text": "description",
"title_link_download": false, "title_link_download": false,
}] }]
@@ -682,8 +681,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
/* const imageData = await this.fileToBase64Service.convert(file).then((filee) => { /* const imageData = await this.fileToBase64Service.convert(file).then((filee) => {
console.log('Add file', filee) console.log('Add file', filee)
}) */ }) */
const blob = new Blob([file],{type: file.type}) const response = await fetch(file);
console.log('Add file', blob) 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(); const formData = new FormData();
formData.append("blobFile", blob); formData.append("blobFile", blob);
@@ -697,7 +699,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
"title": file.name, "title": file.name,
"name": file.name, "name": file.name,
// "text": "description", // "text": "description",
"image_url": file, // rocketchat
"title_link_download": false, "title_link_download": false,
}], }],
temporaryData: formData temporaryData: formData
@@ -824,7 +825,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
downloadFileMsg(msg: MessageService) { downloadFileMsg(msg: MessageService) {
console.log('FILE TYPE', msg.file.type) console.log('FILE TYPE', msg.file.type)
this.downloadFile = ""; this.downloadFile = "";
if (msg.file.type == "application/img") { //if (msg.file.type == "application/img") {
this.AttachmentsService.downloadFile(msg.file.guid).subscribe(async (event) => { this.AttachmentsService.downloadFile(msg.file.guid).subscribe(async (event) => {
console.log('FILE TYPE 22', msg.file.guid) console.log('FILE TYPE 22', msg.file.guid)
var name = msg.file.guid; var name = msg.file.guid;
@@ -833,25 +834,33 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
//this.downloadProgess = Math.round((100 * event.loaded) / event.total); //this.downloadProgess = Math.round((100 * event.loaded) / event.total);
console.log('FILE TYPE 33', msg.file.type) console.log('FILE TYPE 33', msg.file.type)
} else if (event.type === HttpEventType.Response) { } 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), '')); this.downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
} else {
//console.log('TRY THIS LIBRARY ',fromByteArray(event.body));
this.downloadFile = event.body;
}
msg.file = { msg.attachments[0] = {
guid: msg.file.guid,
image_url: this.downloadFile, image_url: this.downloadFile,
type: msg.file.type 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); this.sqlservice.updateChatMsg(msg._id, this.downloadFile);
} }
}); });
} //}
} }
async openPreview(msg) { async openPreview(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) this.downloadFileMsg(msg)
} else { } else {
@@ -860,6 +869,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
cssClass: 'modal modal-desktop', cssClass: 'modal modal-desktop',
componentProps: { componentProps: {
image: msg.attachments[0].image_url, image: msg.attachments[0].image_url,
type: msg.file.type,
username: msg.u.name, username: msg.u.name,
_updatedAt: msg._updatedAt _updatedAt: msg._updatedAt
} }
@@ -83,7 +83,7 @@
</div> </div>
<div *ngIf="msg.file.type != 'application/img'"> <div *ngIf="msg.file.type != 'application/img'">
<div class="file"> <div class="file">
<div (click)="viewDocument(msg.file, file.title_link)" class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file"> <div (click)="openPreview(msg)" class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file">
<span *ngIf="msg.file.type"> <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/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> <fa-icon *ngIf="msg.file.type == 'application/word'" icon="file-word" class="word-icon"></fa-icon>
@@ -695,29 +695,52 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
async addFileToChat(types: typeof FileType[] ) { async addFileToChat(types: typeof FileType[] ) {
const roomId = this.roomId const roomId = this.roomId
const file: any = await this.fileService.getFileFromDevice(types); const file: any = await this.fileService.getFileFromDevice(types);
const imageData = await this.fileToBase64Service.convert(file) console.log('Add file', file)
/* 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 formData = new FormData(); const formData = new FormData();
formData.append("blobFile", file); formData.append("blobFile", blob);
let pdfBase64;
this.blobToBase64(blob).then(res => {
console.log('Base64 pdf', res);
this.wsChatMethodsService.getGroupRoom(roomId).send({ this.wsChatMethodsService.getGroupRoom(roomId).send({
file: { file: {
"type": "application/img", "type": file.type,
"guid": '' "guid": '',
}, },
temporaryData: formData,
attachments: [{ attachments: [{
"title": file.name , "title": file.name ,
"image_url": imageData, "name": file.name ,
"text": "description", "image_url": res,
// "text": "description",
"title_link_download": false, "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() { bookMeeting() {
let data = { let data = {
roomId: this.roomId, roomId: this.roomId,
@@ -812,12 +835,19 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
//this.downloadProgess = Math.round((100 * event.loaded) / event.total); //this.downloadProgess = Math.round((100 * event.loaded) / event.total);
console.log('FILE TYPE 33', msg.file.type) console.log('FILE TYPE 33', msg.file.type)
} else if (event.type === HttpEventType.Response) { } 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), '')); 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 = { this.downloadFile = event.body;
guid: msg.file.guid, }
msg.attachments[0] = {
image_url: this.downloadFile, image_url: this.downloadFile,
type: msg.file.type 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(() => { await this.storage.set(msg.file.guid, this.downloadFile).then(() => {
@@ -833,7 +863,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
async openPreview(msg) { async openPreview(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) this.downloadFileMsg(msg)
} else { } else {
@@ -842,6 +872,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
cssClass: 'modal modal-desktop', cssClass: 'modal modal-desktop',
componentProps: { componentProps: {
image: msg.attachments[0].image_url, image: msg.attachments[0].image_url,
type: msg.file.type,
username: msg.u.name, username: msg.u.name,
_updatedAt: msg._updatedAt _updatedAt: msg._updatedAt
} }
@@ -12,6 +12,7 @@ import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { MatButtonModule } from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button';
import {MatMenuModule} from '@angular/material/menu'; import {MatMenuModule} from '@angular/material/menu';
import { LettersAvatarModule } from "ngx-letters-avatar"; import { LettersAvatarModule } from "ngx-letters-avatar";
import { PdfViewerModule } from 'ng2-pdf-viewer';
@NgModule({ @NgModule({
imports: [ imports: [
@@ -22,7 +23,8 @@ import { LettersAvatarModule } from "ngx-letters-avatar";
MessagesPageRoutingModule, MessagesPageRoutingModule,
MatButtonModule, MatButtonModule,
MatMenuModule, MatMenuModule,
LettersAvatarModule LettersAvatarModule,
PdfViewerModule
], ],
exports: [MessagesPage], exports: [MessagesPage],
+30 -22
View File
@@ -38,7 +38,8 @@
</ion-refresher-content> </ion-refresher-content>
</ion-refresher> </ion-refresher>
<div class="messages" #scrollMe> <div class="messages" #scrollMe>
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of wsChatMethodsService.getDmRoom(roomId).messages; let last = last"> <div class="messages-list-item-wrapper container-width-100"
*ngFor="let msg of wsChatMethodsService.getDmRoom(roomId).messages; let last = last">
<div class='message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45' *ngIf="msg.msg !=''"> <div class='message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45' *ngIf="msg.msg !=''">
<div class="message-item-options d-flex justify-content-end"> <div class="message-item-options d-flex justify-content-end">
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer"> <fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer">
@@ -54,7 +55,8 @@
<div class="d-flex justify-space-between"> <div class="d-flex justify-space-between">
<ion-label class="flex-0">{{msg.msg}}</ion-label> <ion-label class="flex-0">{{msg.msg}}</ion-label>
<ion-label class="float-status-all float-status"> <ion-label class="float-status-all float-status">
<ion-icon *ngIf="!msg.offline && msg.viewed.length == 0" src="assets/images/check-double-solid.svg"></ion-icon> <ion-icon *ngIf="!msg.offline && msg.viewed.length == 0" src="assets/images/check-double-solid.svg">
</ion-icon>
<ion-icon *ngIf="msg.offline && msg.viewed.length == 0" src="assets/images/check-solid.svg"></ion-icon> <ion-icon *ngIf="msg.offline && msg.viewed.length == 0" src="assets/images/check-solid.svg"></ion-icon>
<ion-icon *ngIf="msg.viewed.length == 1" src="assets/images/check-double-solid -viewed.svg"></ion-icon> <ion-icon *ngIf="msg.viewed.length == 1" src="assets/images/check-double-solid -viewed.svg"></ion-icon>
</ion-label> </ion-label>
@@ -63,7 +65,8 @@
</div> </div>
<div *ngIf="msg.file"> <div *ngIf="msg.file">
<div class='message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45' *ngIf="msg.file.type != 'application/meeting'"> <div class='message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45'
*ngIf="msg.file.type != 'application/meeting'">
<div class="message-item-options d-flex justify-content-end"> <div class="message-item-options d-flex justify-content-end">
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer"> <fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer">
</fa-icon> </fa-icon>
@@ -81,23 +84,28 @@
<div *ngIf="msg.file.type == 'application/img'" (click)="openPreview(msg)" dfsdvsvs> <div *ngIf="msg.file.type == 'application/img'" (click)="openPreview(msg)" dfsdvsvs>
<img src={{msg.attachments[0].image_url}} alt="image"> <img src={{msg.attachments[0].image_url}} alt="image">
<ion-label class="float-status-image float-status-all"> <ion-label class="float-status-image float-status-all">
<ion-icon *ngIf="!msg.offline && msg.viewed.length == 0" src="assets/images/check-double-solid.svg"></ion-icon> <ion-icon *ngIf="!msg.offline && msg.viewed.length == 0" src="assets/images/check-double-solid.svg">
<ion-icon *ngIf="msg.offline && msg.viewed.length == 0" src="assets/images/check-solid.svg"></ion-icon> </ion-icon>
<ion-icon *ngIf="msg.viewed.length == 1" src="assets/images/check-double-solid -viewed.svg"></ion-icon> <ion-icon *ngIf="msg.offline && msg.viewed.length == 0" src="assets/images/check-solid.svg">
</ion-icon>
<ion-icon *ngIf="msg.viewed.length == 1" src="assets/images/check-double-solid -viewed.svg">
</ion-icon>
</ion-label> </ion-label>
</div> </div>
<div *ngIf="msg.file.type != 'application/img'"> <div *ngIf="msg.file.type != 'application/img'">
<div class="file"> <div class="file">
<div (click)="viewDocument(msg)" class="file-details add-ellipsis cursor-pointer" <div (click)="openPreview(msg)" class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file">
*ngIf="msg.file">
<span *ngIf="msg.file.type"> <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/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> <fa-icon *ngIf="msg.file.type == 'application/word'" icon="file-word" class="word-icon">
</fa-icon>
<fa-icon <fa-icon
*ngIf="msg.file.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'" *ngIf="msg.file.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'"
icon="file-word" class="excel-icon"></fa-icon> icon="file-word" class="excel-icon"></fa-icon>
<ion-icon *ngIf="msg.file.type == 'application/webtrix'" src="assets/icon/webtrix.svg"></ion-icon> <ion-icon *ngIf="msg.file.type == 'application/webtrix'" src="assets/icon/webtrix.svg">
<ion-icon *ngIf="msg.file.type == 'application/meeting'" src="assets/icon/webtrix.svg"></ion-icon> </ion-icon>
<ion-icon *ngIf="msg.file.type == 'application/meeting'" src="assets/icon/webtrix.svg">
</ion-icon>
</span> </span>
<ion-label class="file-title">{{file.title}}</ion-label> <ion-label class="file-title">{{file.title}}</ion-label>
</div> </div>
@@ -106,13 +114,15 @@
<ion-label *ngIf="msg.file"> <ion-label *ngIf="msg.file">
<span *ngIf="file.description">{{file.description}}</span> <span *ngIf="file.description">{{file.description}}</span>
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"></span> <span *ngIf="file.description && msg.file.type != 'application/webtrix'"></span>
<span <span *ngIf="msg.file.type != 'application/webtrix'">{{msg.displayType}}</span>
*ngIf="msg.file.type != 'application/webtrix'">{{msg.displayType}}</span>
</ion-label> </ion-label>
<ion-label class="float-status-webtrix float-status-all"> <ion-label class="float-status-webtrix float-status-all">
<ion-icon *ngIf="!msg.offline && msg.viewed.length == 0" src="assets/images/check-double-solid.svg"></ion-icon> <ion-icon *ngIf="!msg.offline && msg.viewed.length == 0"
<ion-icon *ngIf="msg.offline && msg.viewed.length == 0" src="assets/images/check-solid.svg"></ion-icon> src="assets/images/check-double-solid.svg"></ion-icon>
<ion-icon *ngIf="msg.viewed.length == 1" src="assets/images/check-double-solid -viewed.svg"></ion-icon> <ion-icon *ngIf="msg.offline && msg.viewed.length == 0" src="assets/images/check-solid.svg">
</ion-icon>
<ion-icon *ngIf="msg.viewed.length == 1" src="assets/images/check-double-solid -viewed.svg">
</ion-icon>
</ion-label> </ion-label>
</div> </div>
</div> </div>
@@ -199,11 +209,8 @@
<ion-footer> <ion-footer>
<div class="typing"> <div class="typing">
<ngx-letters-avatar *ngIf="showAvatar" <ngx-letters-avatar *ngIf="showAvatar" [avatarName]="wsChatMethodsService.getDmRoom(roomId).name" [width]="30"
[avatarName]= "wsChatMethodsService.getDmRoom(roomId).name" [circular]="true" fontFamily="Open Sans"></ngx-letters-avatar>
[width]="30"
[circular]="true"
fontFamily="Open Sans"></ngx-letters-avatar>
A escrever... A escrever...
</div> </div>
@@ -240,7 +247,8 @@
<div class="width-100"> <div class="width-100">
<ion-item class="ion-no-padding type-message" lines="none"> <ion-item class="ion-no-padding type-message" lines="none">
<ion-textarea (keyup.enter)="sendMessage()" clearOnEdit="true" placeholder="Escrever uma mensagem" <ion-textarea (keyup.enter)="sendMessage()" clearOnEdit="true" placeholder="Escrever uma mensagem"
class="message-input" rows="1" [(ngModel)]="wsChatMethodsService.getDmRoom(roomId).message" (ionChange)="wsChatMethodsService.getDmRoom(roomId).sendTyping()"></ion-textarea> class="message-input" rows="1" [(ngModel)]="wsChatMethodsService.getDmRoom(roomId).message"
(ionChange)="wsChatMethodsService.getDmRoom(roomId).sendTyping()"></ion-textarea>
<button hidden class="btn-no-color"> <button hidden class="btn-no-color">
<ion-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon> <ion-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon>
</button> </button>
+28 -15
View File
@@ -274,9 +274,9 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
//fullUrl = "http://www.africau.edu/images/default/sample.pdf"; //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 file = new Blob([msg.attachments[0].image_url], { type: 'application/pdf' });
let fileURL = URL.createObjectURL(file) let fileURL = URL.createObjectURL(file)
window.open(fileURL,"_blank"); window.open(fileURL);
// this.chatService.getDocumentDetails(fullUrl); // this.chatService.getDocumentDetails(fullUrl);
} }
@@ -471,7 +471,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
temporaryData: formData, temporaryData: formData,
attachments: [{ attachments: [{
"title": file.path, "title": file.path,
"image_url": 'data:image/jpeg;base64,' +file.base64String, //"image_url": 'data:image/jpeg;base64,' + file.base64String,
"text": "description", "text": "description",
"title_link_download": false, "title_link_download": false,
}] }]
@@ -585,7 +585,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
temporaryData: formData, temporaryData: formData,
attachments: [{ attachments: [{
"title": file.path, "title": file.path,
"image_url": 'data:image/jpeg;base64,' +file.base64String, //"image_url": 'data:image/jpeg;base64,' + file.base64String,
"text": "description", "text": "description",
"title_link_download": false, "title_link_download": false,
}] }]
@@ -621,9 +621,9 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
attachments: [{ attachments: [{
"title": file.name, "title": file.name,
"name": file.name, "name": file.name,
//"image_url": res,
// "text": "description", // "text": "description",
"title_link_download": false, "title_link_download": false,
"image_url": res,
}], }],
temporaryData: formData temporaryData: formData
}) })
@@ -748,15 +748,17 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
} else if (event.type === HttpEventType.Response) { } else if (event.type === HttpEventType.Response) {
if (msg.file.type == "application/img") { if (msg.file.type == "application/img") {
this.downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), '')); this.downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
} else { } else if (msg.file.type === 'application/pdf') {
this.downloadFile = btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
this.downloadFile = event.body;
} }
msg.attachments[0] = {
msg.file = {
guid: msg.file.guid,
image_url: this.downloadFile, image_url: this.downloadFile,
type: msg.file.type 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(() => { await this.storage.set(msg.file.guid, this.downloadFile).then(() => {
@@ -770,6 +772,16 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
} }
_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() { pdfPreview() {
const options: DocumentViewerOptions = { const options: DocumentViewerOptions = {
title: 'My App' title: 'My App'
@@ -780,25 +792,26 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
async openPreview(msg) { 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) this.downloadFileMsg(msg)
} else { } else {
if(msg.file.type === "application/pdf") { /* if(msg.file.type === "application/pdf") {
this.viewDocument(msg, msg.attachments.image_url) this.viewDocument(msg, msg.attachments.image_url)
} else { } else { */
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: ViewMediaPage, component: ViewMediaPage,
cssClass: 'modal modal-desktop', cssClass: 'modal modal-desktop',
componentProps: { componentProps: {
image: msg.attachments[0].image_url, image: msg.attachments[0].image_url,
type: msg.file.type,
username: msg.u.name, username: msg.u.name,
_updatedAt: msg._updatedAt _updatedAt: msg._updatedAt
} }
}); });
modal.present(); modal.present();
} //}
} }