mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Merge branch 'feature/downloadFile' of https://bitbucket.org/equilibriumito/gabinete-digital into developer
This commit is contained in:
@@ -143,7 +143,7 @@ import { FirebaseX } from '@ionic-native/firebase-x/ngx'; */
|
||||
Media,
|
||||
StreamingMedia,
|
||||
PhotoViewer,
|
||||
NgxImageCompressService
|
||||
NgxImageCompressService,
|
||||
],
|
||||
bootstrap: [AppComponent],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' (click)="openPreview(msg)" *ngIf="msg.msg !=''">
|
||||
<div (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' (click)="openPreview(msg)" *ngIf="msg.msg !=''">
|
||||
<div class="title">
|
||||
<ion-label>{{msg.u.name}}</ion-label>
|
||||
<span class="time">{{msg.duration}}</span>
|
||||
@@ -70,7 +70,7 @@
|
||||
<ion-label>{{msg.msg}}</ion-label>
|
||||
{{last ? scrollToBottom() : ''}}
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
|
||||
<div *ngIf="msg.file">
|
||||
@@ -88,7 +88,7 @@
|
||||
</div>
|
||||
<div *ngIf="msg.file.type != 'application/img'">
|
||||
<div class="file">
|
||||
<div (click)="docIndex(i); viewDocument(msg.file, file.title_link)" class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file">
|
||||
<div (click)="docIndex(i); viewDocument(msg, file.title_link)" 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>
|
||||
@@ -120,7 +120,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
<!-- <div *ngIf="msg.file">
|
||||
<div *ngIf="msg.file">
|
||||
<div *ngIf="msg.file.type == 'application/meeting'" class="info-meeting">
|
||||
<ion-label class="info-meeting-small">{{msg.u.name}} criou esta reunião</ion-label><br />
|
||||
<button (click)="goToEvent(msg.file.id)" class="btn-no-color info-meeting-normal"><ion-label class="info-meeting-normal">{{msg.file.subject}}</ion-label></button><br />
|
||||
@@ -128,7 +128,7 @@
|
||||
<ion-label class="info-meeting-medium"><ion-icon></ion-icon><ion-icon name="location-outline"></ion-icon> {{msg.file.venue}}</ion-label><br />
|
||||
</div>
|
||||
{{last ? scrollToBottom() : ''}}
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ion-fab horizontal="end" vertical="bottom" slot="fixed">
|
||||
|
||||
@@ -19,7 +19,8 @@ import { ChatMessageStore } from 'src/app/store/chat/chat-message.service';
|
||||
import { ChatUserStorage } from 'src/app/store/chat/chat-user.service';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { ThemeService } from 'src/app/services/theme.service'
|
||||
import { Filesystem, Directory, Encoding } from '@capacitor/filesystem';
|
||||
|
||||
import { Directory, Encoding, FilesystemDirectory } from '@capacitor/filesystem';
|
||||
import { VoiceRecorder, VoiceRecorderPlugin, RecordingData, GenericResponse, CurrentRecordingStatus } from 'capacitor-voice-recorder';
|
||||
import { Haptics, ImpactStyle } from '@capacitor/haptics';
|
||||
import { PreviewCameraPage } from 'src/app/modals/preview-camera/preview-camera.page';
|
||||
@@ -39,6 +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';
|
||||
|
||||
const { Filesystem } = Plugins;
|
||||
|
||||
|
||||
const IMAGE_DIR = 'stored-images';
|
||||
|
||||
@@ -195,7 +200,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
const temp: any[] = result.files.reverse();
|
||||
this.storedFileNames = temp[0];
|
||||
console.log(this.storedFileNames);
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
@@ -352,10 +356,41 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.wsChatMethodsService.getDmRoom(this.roomId).send({})
|
||||
}
|
||||
|
||||
viewDocument(file: any, url?: string) {
|
||||
viewDocument(msg: any, url?: string) {
|
||||
console.log(msg)
|
||||
if (msg.attachments.type == "application/webtrix") {
|
||||
//this.openViewDocumentModal(file);
|
||||
}
|
||||
|
||||
if (file.type == "application/webtrix") {
|
||||
this.openViewDocumentModal(file);
|
||||
if (msg.attachments.type == "application/pdf") {
|
||||
|
||||
try {
|
||||
const writeSecretFile = async () => {
|
||||
await Filesystem.writeFile({
|
||||
path: msg.attachments.name,
|
||||
data: msg.attachments.image_url,
|
||||
directory: Directory.Documents,
|
||||
encoding: Encoding.UTF8,
|
||||
});
|
||||
};
|
||||
|
||||
console.log('WRITE',writeSecretFile);
|
||||
|
||||
const readSecretFile = async () => {
|
||||
const contents = await Filesystem.readFile({
|
||||
path: msg.attachments.name,
|
||||
directory: Directory.Documents,
|
||||
encoding: Encoding.UTF8,
|
||||
});
|
||||
|
||||
console.log('secrets:', contents);
|
||||
};
|
||||
|
||||
console.log('READ',readSecretFile);
|
||||
|
||||
} catch (e) {
|
||||
console.error("Unable to write file", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,7 +408,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
FolderID: '',
|
||||
Subject: file.Assunto,
|
||||
SourceSecFsID: file.ApplicationId,
|
||||
SourceType: 'DOC',
|
||||
SourceType: 'PDF',
|
||||
SourceID: file.DocId,
|
||||
DispatchNumber: ''
|
||||
}
|
||||
@@ -638,30 +673,36 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
|
||||
async addFileToChat(types: typeof FileType[] ) {
|
||||
|
||||
const roomId = this.roomId
|
||||
|
||||
const file: any = await this.fileService.getFileFromDevice(types);
|
||||
console.log('ADDFILECHAT', file)
|
||||
const imageData = await this.fileToBase64Service.convert(file)
|
||||
console.log('ADDFILECHAT', imageData)
|
||||
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);
|
||||
|
||||
this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||
file: {
|
||||
"type": "application/img",
|
||||
"type": file.type,
|
||||
"guid": '',
|
||||
},
|
||||
temporaryData: formData,
|
||||
attachments: [{
|
||||
"title": file.name ,
|
||||
"image_url": imageData,
|
||||
"text": "description",
|
||||
"name": file.name ,
|
||||
// "text": "description",
|
||||
"image_url": file, // rocketchat
|
||||
"title_link_download": false,
|
||||
}]
|
||||
}],
|
||||
temporaryData: formData
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
async openChatOptions(ev?: any) {
|
||||
@@ -847,6 +888,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
}
|
||||
|
||||
|
||||
// async ShareEmail(msg){
|
||||
// // Check if sharing via email is supported
|
||||
// await Share.share({
|
||||
|
||||
@@ -10,7 +10,7 @@ import { ViewPublicationsPage } from './view-publications.page';
|
||||
|
||||
import { HeaderPageModule } from 'src/app/shared/header/header.module';
|
||||
|
||||
import { Attributes, IntersectionObserverHooks, LazyLoadImageModule, LAZYLOAD_IMAGE_HOOKS } from 'ng-lazyload-image'; // <-- import it
|
||||
import { Attributes, IntersectionObserverHooks, LazyLoadImageModule, LAZYLOAD_IMAGE_HOOKS } from 'ng-lazyload-image';
|
||||
|
||||
export class LazyLoadImageHooks extends IntersectionObserverHooks {
|
||||
setup(attributes: Attributes) {
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
</div>
|
||||
<div class="div-attach">
|
||||
<ion-item>
|
||||
<ion-buttons slot="end" (click)="showAlert()">
|
||||
<ion-buttons slot="end">
|
||||
<ion-label color="secondary">Editar</ion-label>
|
||||
</ion-buttons>
|
||||
<ion-label class="attach-label">Anexos</ion-label>
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
</div>
|
||||
<div class="div-attach">
|
||||
<ion-item>
|
||||
<ion-buttons slot="end" (click)="showAlert()">
|
||||
<ion-buttons slot="end">
|
||||
<ion-label color="secondary">Editar</ion-label>
|
||||
</ion-buttons>
|
||||
<ion-label class="attach-label">Anexos</ion-label>
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
</div>
|
||||
<div class="div-attach">
|
||||
<ion-item>
|
||||
<ion-buttons slot="end" (click)="showAlert()">
|
||||
<ion-buttons slot="end">
|
||||
<ion-label color="secondary">Editar</ion-label>
|
||||
</ion-buttons>
|
||||
<ion-label class="attach-label">Anexos</ion-label>
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
</div>
|
||||
<div *ngIf="msg.file.type != 'application/img'">
|
||||
<div class="file">
|
||||
<div (click)="viewDocument(msg, file.title_link)" class="file-details add-ellipsis cursor-pointer"
|
||||
<div (click)="viewDocument(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>
|
||||
|
||||
@@ -268,13 +268,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.image_url], {type:'application/pdf'});
|
||||
let fileURL = URL.createObjectURL(file)
|
||||
window.open(fileURL,"_blank");
|
||||
|
||||
this.chatService.getDocumentDetails(fullUrl);
|
||||
// this.chatService.getDocumentDetails(fullUrl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -606,24 +610,38 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
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 ,
|
||||
// "text": "description",
|
||||
"title_link_download": false,
|
||||
"image_url": res,
|
||||
}],
|
||||
temporaryData: formData
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
blobToBase64 = blob => {
|
||||
const reader = new FileReader();
|
||||
reader.readAsDataURL(blob);
|
||||
return new Promise(resolve => {
|
||||
reader.onloadend = () => {
|
||||
resolve(reader.result);
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
bookMeeting() {
|
||||
let data = {
|
||||
@@ -719,7 +737,7 @@ 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") {
|
||||
//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;
|
||||
@@ -728,7 +746,12 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
//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), ''));
|
||||
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), ''));
|
||||
}
|
||||
|
||||
|
||||
msg.file = {
|
||||
guid: msg.file.guid,
|
||||
@@ -743,11 +766,11 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
pdfPreviwe() {
|
||||
pdfPreview() {
|
||||
const options: DocumentViewerOptions = {
|
||||
title: 'My App'
|
||||
};
|
||||
@@ -757,20 +780,26 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
async openPreview(msg) {
|
||||
console.log(msg);
|
||||
|
||||
if (msg.attachments[0].image_url === null || msg.attachments[0].image_url === '' ) {
|
||||
if (msg.file.image_url === null || msg.file.image_url === '' ) {
|
||||
this.downloadFileMsg(msg)
|
||||
|
||||
} 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();
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<button (click)="takePicture()" full class="btn-ok" shape="round" >Tirar Fotografia</button>
|
||||
<button hidden (click)="addFile()" class="btn-ok" shape="round" >Anexar Documento</button>
|
||||
<button (click)="addFile()" class="btn-ok" shape="round" >Anexar Documento</button>
|
||||
<button (click)="anexarFoto()" full class="btn-ok" shape="round" >Anexar Fotografia</button>
|
||||
<button (click)="addDocGestaoDocumental()" class="btn-ok" shape="round" >Gestão Documental</button>
|
||||
<div class="solid"></div>
|
||||
|
||||
@@ -13,7 +13,7 @@ export const environment = {
|
||||
domain: 'gabinetedigital.local', //gabinetedigital.local
|
||||
defaultuser: 'paulo.pinto@gabinetedigital.local',//paulo.pinto paulo.pinto@gabinetedigital.local
|
||||
defaultuserpwd: 'tabteste@006', //tabteste@006,
|
||||
chatOffline: true
|
||||
chatOffline: false
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -195,7 +195,7 @@ $app-theme: mat-light-theme(
|
||||
* -------------------------------------------
|
||||
*/
|
||||
|
||||
.ios body {
|
||||
/* .ios body {
|
||||
--ion-background-color: #000000;
|
||||
--ion-background-color-rgb: 0, 0, 0;
|
||||
|
||||
@@ -229,14 +229,14 @@ $app-theme: mat-light-theme(
|
||||
--ion-card-background: #1c1c1d;
|
||||
|
||||
--ion-color-expediente: #dae3f3;
|
||||
}
|
||||
} */
|
||||
|
||||
/*
|
||||
* Material Design Dark Theme
|
||||
* -------------------------------------------
|
||||
*/
|
||||
|
||||
.md body {
|
||||
/* .md body {
|
||||
--ion-background-color: #121212;
|
||||
--ion-background-color-rgb: 18, 18, 18;
|
||||
|
||||
@@ -272,9 +272,9 @@ $app-theme: mat-light-theme(
|
||||
--ion-tab-bar-background: #1f1f1f;
|
||||
|
||||
--ion-card-background: #1e1e1e;
|
||||
/* My colors */
|
||||
|
||||
--ion-color-expediente: #dae3f3;
|
||||
}
|
||||
} */
|
||||
}
|
||||
.center {
|
||||
text-align: center;
|
||||
|
||||
Reference in New Issue
Block a user