Merge branch 'developer' of bitbucket.org:equilibriumito/gabinete-digital into feature/audio

This commit is contained in:
tiago.kayaya
2022-03-14 14:29:49 +01:00
21 changed files with 32930 additions and 945 deletions
@@ -83,7 +83,7 @@
</div>
<div *ngIf="msg.file.type != 'application/img'">
<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">
<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>
@@ -699,29 +699,52 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
async addFileToChat(types: typeof FileType[] ) {
const roomId = this.roomId
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();
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({
file: {
"type": file.type,
"guid": '',
},
attachments: [{
"title": file.name ,
"name": file.name ,
"image_url": res,
// "text": "description",
"title_link_download": false,
}],
temporaryData: formData
})
});
this.wsChatMethodsService.getGroupRoom(roomId).send({
file: {
"type": "application/img",
"guid": ''
},
temporaryData: formData,
attachments: [{
"title": file.name ,
"image_url": imageData,
"text": "description",
"title_link_download": false,
}]
})
}
blobToBase64 = blob => {
const reader = new FileReader();
reader.readAsDataURL(blob);
return new Promise(resolve => {
reader.onloadend = () => {
resolve(reader.result);
};
});
};
bookMeeting() {
let data = {
roomId: this.roomId,
@@ -816,12 +839,19 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
//this.downloadProgess = Math.round((100 * event.loaded) / event.total);
console.log('FILE TYPE 33', msg.file.type)
} else if (event.type === HttpEventType.Response) {
this.downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
msg.file = {
guid: msg.file.guid,
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') {
this.downloadFile = event.body;
}
msg.attachments[0] = {
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(() => {
@@ -837,7 +867,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
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)
} else {
@@ -846,6 +876,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
cssClass: 'modal modal-desktop',
componentProps: {
image: msg.attachments[0].image_url,
type: msg.file.type,
username: msg.u.name,
_updatedAt: msg._updatedAt
}
@@ -12,6 +12,7 @@ import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { MatButtonModule } from '@angular/material/button';
import {MatMenuModule} from '@angular/material/menu';
import { LettersAvatarModule } from "ngx-letters-avatar";
import { PdfViewerModule } from 'ng2-pdf-viewer';
@NgModule({
imports: [
@@ -22,7 +23,8 @@ import { LettersAvatarModule } from "ngx-letters-avatar";
MessagesPageRoutingModule,
MatButtonModule,
MatMenuModule,
LettersAvatarModule
LettersAvatarModule,
PdfViewerModule
],
exports: [MessagesPage],
+16 -12
View File
@@ -38,7 +38,8 @@
</ion-refresher-content>
</ion-refresher>
<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-options d-flex justify-content-end">
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer">
@@ -63,7 +64,8 @@
</div>
<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">
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer">
</fa-icon>
@@ -72,7 +74,7 @@
</mat-menu>
</div>
<div class="title">
<ion-label>{{msg.u.name}} </ion-label>
<ion-label>{{msg.u.name}} </ion-label>
<span class="time">{{msg.duration}}</span>
</div>
<div>
@@ -88,16 +90,18 @@
</div>
<div *ngIf="msg.file.type != 'application/img'">
<div class="file">
<div (click)="viewDocument(msg)" 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">
<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
*ngIf="msg.file.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'"
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/meeting'" src="assets/icon/webtrix.svg"></ion-icon>
<ion-icon *ngIf="msg.file.type == 'application/webtrix'" src="assets/icon/webtrix.svg">
</ion-icon>
<ion-icon *ngIf="msg.file.type == 'application/meeting'" src="assets/icon/webtrix.svg">
</ion-icon>
</span>
<ion-label class="file-title">{{file.title}}</ion-label>
</div>
@@ -106,8 +110,7 @@
<ion-label *ngIf="msg.file">
<span *ngIf="file.description">{{file.description}}</span>
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"></span>
<span
*ngIf="msg.file.type != 'application/webtrix'">{{msg.displayType}}</span>
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.displayType}}</span>
</ion-label>
<!-- <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>
@@ -240,8 +243,9 @@
<div class="width-100">
<ion-item class="ion-no-padding type-message" lines="none">
<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>
<button hidden class="btn-no-color" >
class="message-input" rows="1" [(ngModel)]="wsChatMethodsService.getDmRoom(roomId).message"
(ionChange)="wsChatMethodsService.getDmRoom(roomId).sendTyping()"></ion-textarea>
<button hidden class="btn-no-color">
<ion-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon>
</button>
</ion-item>
+75 -62
View File
@@ -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') {
this.downloadFile = event.body;
}
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')
});
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!')
}
+8 -1
View File
@@ -22,13 +22,20 @@
<img *ngIf="ThemeService.currentTheme == 'gov' " src='assets/images/theme/gov/governoangola_A.png' alt='logo'>
<img *ngIf="ThemeService.currentTheme == 'tribunal' " src='assets/images/theme/tribunal/tribunal-constitucional.png' alt='logo'>
</div>
<div class="logo-description d-flex align-center justify-content-center">
<div *ngIf="ThemeService.currentTheme == 'gov'" class="logo-description d-flex align-center justify-content-center">
<div class="logo-description-content">
<p class="logo-description-text">Presidente da República</p>
<div class="add-line"></div>
<p class="logo-description-text tp-5">GABINETE DIGITAL</p>
</div>
</div>
<div *ngIf="ThemeService.currentTheme == 'default'" class="logo-description d-flex align-center justify-content-center">
<div class="logo-description-content">
<p class="logo-description-text color-white">Presidente da República</p>
<div class="add-line-white"></div>
<p class="logo-description-text tp-5 color-white">GABINETE DIGITAL</p>
</div>
</div>
</div>
<div title="Perfil" class="div-profile cursor-pointer" (click)="openProfile()">
+14
View File
@@ -49,12 +49,26 @@
margin-bottom: 2.5px !important;
padding: 0 !important;
}
.add-line-white{
width: 100%;
border-bottom: 1px solid #fff;
margin-bottom: 2.5px !important;
padding: 0 !important;
}
}
.color-white{
color: #fff !important;
}
.add-botton-border{
border-bottom: 1px solid #000;
}
.add-botton-border-white{
border-bottom: 1px solid #fff;
}
}
}