mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
merge
This commit is contained in:
@@ -88,28 +88,26 @@ export class ContactsPage implements OnInit {
|
||||
doRefresh(event){
|
||||
}
|
||||
|
||||
close(){
|
||||
this.modalController.dismiss();
|
||||
close() {
|
||||
this.modalController.dismiss({});
|
||||
}
|
||||
|
||||
clicked(){
|
||||
|
||||
}
|
||||
clicked() {}
|
||||
|
||||
createRoom(username:string){
|
||||
let body = {
|
||||
username: username,
|
||||
}
|
||||
this.chatService.createRoom(body).subscribe(res => {
|
||||
this.chatService.createRoom(body).subscribe(async(res) => {
|
||||
|
||||
this.room = res['room'];
|
||||
|
||||
|
||||
await this.WsChatMethodsService.getAllRooms();
|
||||
this.getDirectMessage(this.room._id);
|
||||
this.WsChatMethodsService.getAllRooms()
|
||||
});
|
||||
}
|
||||
getDirectMessage(roomId:any){
|
||||
|
||||
getDirectMessage(roomId:any) {
|
||||
|
||||
|
||||
this.chatService.getAllDirectMessages().subscribe(res=>{
|
||||
@@ -121,6 +119,7 @@ export class ContactsPage implements OnInit {
|
||||
this.openModal(this.dm._id);
|
||||
});
|
||||
}
|
||||
|
||||
async openModal(roomId:any){
|
||||
this.close();
|
||||
|
||||
@@ -137,26 +136,10 @@ export class ContactsPage implements OnInit {
|
||||
}
|
||||
|
||||
async openMessages(username:string){
|
||||
/* this.close(); */
|
||||
|
||||
let dm:any;
|
||||
//Create new room
|
||||
this.createRoom(username);
|
||||
//Get direct messages (dm)
|
||||
/* this.getDirectMessage(this.room._id); */
|
||||
|
||||
this.createRoom(username);
|
||||
|
||||
|
||||
/* const modal = await this.modalController.create({
|
||||
component: MessagesPage,
|
||||
cssClass: 'group-messages',
|
||||
backdropDismiss: false,
|
||||
componentProps: {
|
||||
dm: dm,
|
||||
},
|
||||
});
|
||||
await modal.present();
|
||||
modal.onDidDismiss(); */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,7 +54,6 @@
|
||||
<span class="time">{{msg.duration}}</span>
|
||||
</div>
|
||||
<div>
|
||||
<!-- <div class="message-attachments"> -->
|
||||
<div class="file">
|
||||
<ion-label *ngIf="msg.delate == false">{{msg.msg}}</ion-label>
|
||||
<ion-label *ngIf="msg.delate == true">{{msg.msg}}</ion-label>
|
||||
@@ -67,7 +66,6 @@
|
||||
<ion-icon *ngIf="msg.viewed.length >= 1" src="assets/images/check-double-solid -viewed.svg"></ion-icon>
|
||||
</ion-label>
|
||||
</div>
|
||||
<!-- </div> -->
|
||||
{{last ? scrollToBottom() : ''}}
|
||||
</div>
|
||||
</div>
|
||||
@@ -87,8 +85,12 @@
|
||||
<ion-item class="add-attachment-bg-color" shape="round" lines="none" type="button">
|
||||
<ion-icon name="image" class="file-icon"></ion-icon>
|
||||
<ion-label>{{"Imagem"}}</ion-label>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="icon-download" src="assets/icon/theme/default/icons-download.svg" slot="end"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="icon-download" src="assets/icon/theme/gov/icons-download.svg" slot="end"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' && msg.downloadLoader == false && msg.downloadAttachmentsTemp == 0 " class="icon-download" src="assets/icon/theme/default/icons-download.svg" slot="end"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && msg.downloadLoader == false && msg.downloadAttachmentsTemp == 0" class="icon-download" src="assets/icon/theme/gov/icons-download.svg" slot="end"></ion-icon>
|
||||
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' && msg.downloadLoader == true " class="icon-download" src="assets/gif/theme/default/Blocks-loader.svg" slot="end"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && msg.downloadLoader == true" class="icon-download" src="assets/gif/theme/gov/Blocks-loader.svg" slot="end"></ion-icon>
|
||||
<ion-icon *ngIf="msg.downloadAttachments == false && msg.downloadAttachmentsTemp >= 1 && msg.downloadLoader == false" src="assets/images/retry-svgrepo-com.svg" class="icon-download font-12"> </ion-icon>
|
||||
</ion-item>
|
||||
</div>
|
||||
<img *ngIf="msg.attachments[0].image_url" src="{{msg.attachments[0].image_url}}" alt="image">
|
||||
@@ -107,10 +109,11 @@
|
||||
|
||||
<div *ngIf="!msg.attachments[0].image_url">
|
||||
<ion-item class="add-attachment-bg-color" shape="round" lines="none" type="button">
|
||||
<ion-icon name="document" class="file-icon"></ion-icon>
|
||||
<ion-icon *ngIf="msg.attachments[0].type != 'webtrix'" name="document" class="file-icon"></ion-icon>
|
||||
<ion-icon *ngIf="msg.attachments[0].type == 'webtrix'" src="assets/icon/webtrix.svg" class="file-icon"></ion-icon>
|
||||
<ion-label>{{file.title}}</ion-label>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="icon-download" src="assets/icon/theme/default/icons-download.svg" slot="end"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="icon-download" src="assets/icon/theme/gov/icons-download.svg" slot="end"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' && msg.attachments[0].type != 'webtrix' " class="icon-download" src="assets/icon/theme/default/icons-download.svg" slot="end"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && msg.attachments[0].type != 'webtrix' " class="icon-download" src="assets/icon/theme/gov/icons-download.svg" slot="end"></ion-icon>
|
||||
</ion-item>
|
||||
</div>
|
||||
|
||||
@@ -135,8 +138,12 @@
|
||||
<ion-item class="add-attachment-bg-color" shape="round" lines="none" type="button">
|
||||
<ion-icon name="mic-outline" class="file-icon"></ion-icon>
|
||||
<ion-label>{{"Mensagem de voz"}}</ion-label>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="icon-download" src="assets/icon/theme/default/icons-download.svg" slot="end"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="icon-download" src="assets/icon/theme/gov/icons-download.svg" slot="end"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' && msg.downloadLoader == false && msg.downloadAttachmentsTemp == 0 " class="icon-download" src="assets/icon/theme/default/icons-download.svg" slot="end"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && msg.downloadLoader == false && msg.downloadAttachmentsTemp == 0" class="icon-download" src="assets/icon/theme/gov/icons-download.svg" slot="end"></ion-icon>
|
||||
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' && msg.downloadLoader == true " class="icon-download" src="assets/gif/theme/default/Blocks-loader.svg" slot="end"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && msg.downloadLoader == true" class="icon-download" src="assets/gif/theme/gov/Blocks-loader.svg" slot="end"></ion-icon>
|
||||
<ion-icon *ngIf="msg.downloadAttachments == false && msg.downloadAttachmentsTemp >= 1 && msg.downloadLoader == false" src="assets/images/retry-svgrepo-com.svg" class="icon-download font-12"> </ion-icon>
|
||||
</ion-item>
|
||||
</div>
|
||||
<div class="file audio-contentainer" *ngIf="msg.file.type == 'application/audio' && file.title_link">
|
||||
@@ -167,7 +174,7 @@
|
||||
</div>
|
||||
<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">
|
||||
<button (click)="goToEvent(msg.file)" class="btn-no-color info-meeting-normal">
|
||||
<ion-label class="info-meeting-normal">{{msg.file.subject}}</ion-label>
|
||||
</button><br />
|
||||
<ion-label class="info-meeting-medium">
|
||||
@@ -185,7 +192,7 @@
|
||||
<div *ngIf="msg.file && msg.delate == false">
|
||||
<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">
|
||||
<button (click)="goToEvent(msg.file)" class="btn-no-color info-meeting-normal">
|
||||
<ion-label class="info-meeting-normal">{{msg.file.subject}}</ion-label>
|
||||
</button><br />
|
||||
<ion-label class="info-meeting-medium">
|
||||
|
||||
@@ -19,7 +19,7 @@ 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 { VoiceRecorder, RecordingData, GenericResponse} from 'capacitor-voice-recorder';
|
||||
import { VoiceRecorder, RecordingData, GenericResponse } from 'capacitor-voice-recorder';
|
||||
import { Haptics, ImpactStyle } from '@capacitor/haptics';
|
||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
|
||||
@@ -38,7 +38,9 @@ import { DomSanitizer } from '@angular/platform-browser';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
|
||||
|
||||
import { File } from '@awesome-cordova-plugins/file/ngx';
|
||||
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
|
||||
import { Filesystem, Directory } from '@capacitor/filesystem';
|
||||
|
||||
const IMAGE_DIR = 'stored-images';
|
||||
|
||||
@@ -101,7 +103,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
downloadProgess: number;
|
||||
downloadLoader: boolean;
|
||||
|
||||
audioPermissionStatus: 'granted'| 'denied' | 'prompt' | null = null
|
||||
audioPermissionStatus: 'granted' | 'denied' | 'prompt' | null = null
|
||||
sessionStore = SessionStore
|
||||
|
||||
constructor(
|
||||
@@ -123,7 +125,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
private sqlservice: SqliteService,
|
||||
public wsChatMethodsService: WsChatMethodsService,
|
||||
private AttachmentsService: AttachmentsService,
|
||||
|
||||
private CameraService: CameraService,
|
||||
private processesService: ProcessesService,
|
||||
private storage: Storage,
|
||||
@@ -133,10 +134,12 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
private sanitiser: DomSanitizer,
|
||||
private alertController: AlertController,
|
||||
// private document: DocumentViewer
|
||||
private file: File,
|
||||
private fileOpener: FileOpener,
|
||||
) {
|
||||
this.loggedUser = authService.ValidatedUserChat['data'];
|
||||
this.roomId = this.navParams.get('roomId');
|
||||
|
||||
|
||||
|
||||
window.onresize = (event) => {
|
||||
if (window.innerWidth > 701) {
|
||||
@@ -144,7 +147,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.wsChatMethodsService.getDmRoom(this.roomId).loadHistory({})
|
||||
this.wsChatMethodsService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
|
||||
@@ -158,12 +160,13 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.createDirectoryImage()
|
||||
this.wsChatMethodsService.getAllRooms();
|
||||
this.chatService.refreshtoken();
|
||||
this.wsChatMethodsService.getUserOfRoom(this.roomId).then((value) => {
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
this.getChatMembers();
|
||||
}
|
||||
|
||||
@@ -213,11 +216,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
try {
|
||||
this.storage.get('recordData').then((recordData) => {
|
||||
|
||||
|
||||
if (recordData?.value?.recordDataBase64.includes('data:audio')) {
|
||||
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData?.value?.recordDataBase64);
|
||||
}
|
||||
else if(recordData?.value?.mimeType && recordData?.value?.recordDataBase64) {
|
||||
else if (recordData?.value?.mimeType && recordData?.value?.recordDataBase64) {
|
||||
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`);
|
||||
}
|
||||
});
|
||||
@@ -228,22 +231,22 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
async startRecording() {
|
||||
VoiceRecorder.requestAudioRecordingPermission();
|
||||
if(await VoiceRecorder.canDeviceVoiceRecord().then((result: GenericResponse) =>{return result.value})){
|
||||
if(await VoiceRecorder.requestAudioRecordingPermission().then((result: GenericResponse) => {return result.value})){
|
||||
if (await VoiceRecorder.canDeviceVoiceRecord().then((result: GenericResponse) => { return result.value })) {
|
||||
if (await VoiceRecorder.requestAudioRecordingPermission().then((result: GenericResponse) => { return result.value })) {
|
||||
//if(await this.hasAudioRecordingPermission()){
|
||||
if (this.recording) {
|
||||
return;
|
||||
}
|
||||
this.recording = true;
|
||||
VoiceRecorder.startRecording();
|
||||
this.calculateDuration();
|
||||
if (this.recording) {
|
||||
return;
|
||||
}
|
||||
this.recording = true;
|
||||
VoiceRecorder.startRecording();
|
||||
this.calculateDuration();
|
||||
//}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
this.toastService._badRequest('Para gravar uma mensagem de voz, permita o acesso do Gabinete Digital ao seu microfone.');
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
this.toastService._badRequest('Este dispositivo não tem capacidade para gravação de áudio!');
|
||||
}
|
||||
}
|
||||
@@ -251,13 +254,13 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
stopRecording() {
|
||||
this.deleteRecording();
|
||||
this.allowTyping = false;
|
||||
|
||||
|
||||
if (!this.recording) {
|
||||
return;
|
||||
}
|
||||
this.recording = false;
|
||||
VoiceRecorder.stopRecording().then(async (result: RecordingData) => {
|
||||
|
||||
|
||||
this.recording = false;
|
||||
if (result.value && result.value.recordDataBase64) {
|
||||
const recordData = result.value.recordDataBase64;
|
||||
@@ -266,7 +269,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
//Save file
|
||||
this.storage.set('fileName', fileName);
|
||||
this.storage.set('recordData', result).then(() => {
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -335,7 +338,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
} catch (err) { }
|
||||
}
|
||||
|
||||
async goToEvent(eventId: any) {
|
||||
async goToEvent(event: any) {
|
||||
|
||||
let classs;
|
||||
if (window.innerWidth < 701) {
|
||||
classs = 'modal modal-desktop'
|
||||
@@ -345,13 +349,14 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
const modal = await this.modalController.create({
|
||||
component: ViewEventPage,
|
||||
componentProps: {
|
||||
eventId: eventId,
|
||||
eventId: event.id,
|
||||
CalendarId: event.calendarId
|
||||
},
|
||||
cssClass: classs,
|
||||
});
|
||||
await modal.present();
|
||||
modal.onDidDismiss().then((res) => {
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -415,16 +420,16 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
if (recordData?.value?.recordDataBase64.includes('data:audio')) {
|
||||
this.audioRecorded = recordData?.value?.recordDataBase64;
|
||||
}
|
||||
else if(recordData?.value?.mimeType && recordData?.value?.recordDataBase64) {
|
||||
else if (recordData?.value?.mimeType && recordData?.value?.recordDataBase64) {
|
||||
this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//Converting base64 to blob
|
||||
const encodedData = btoa(this.audioRecorded);
|
||||
const blob = this.base64toBlob(encodedData, recordData.value.mimeType)
|
||||
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", blob);
|
||||
|
||||
@@ -447,7 +452,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
viewDocument(file: any, url?: string) {
|
||||
|
||||
|
||||
if (file.type == "application/webtrix") {
|
||||
this.openViewDocumentModal(file);
|
||||
}
|
||||
@@ -598,7 +603,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
IsRequired: "true",
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
this.popoverController.dismiss();
|
||||
if (window.innerWidth <= 1024) {
|
||||
const modal = await this.modalController.create({
|
||||
@@ -632,7 +637,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
const blob = await base64.blob();
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", blob);
|
||||
|
||||
|
||||
|
||||
this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||
file: {
|
||||
@@ -712,7 +717,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
resultType: CameraResultType.Base64,
|
||||
source: CameraSource.Photos
|
||||
});
|
||||
|
||||
|
||||
//const imageData = await this.fileToBase64Service.convert(file)
|
||||
//
|
||||
|
||||
@@ -749,17 +754,17 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
const file: any = await this.fileService.getFileFromDevice(types);
|
||||
|
||||
|
||||
|
||||
|
||||
if (file.type != "application/img" && file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/gif") {
|
||||
|
||||
const encodedData = btoa(JSON.stringify(await this.getBase64(file)));
|
||||
const blob = this.base64toBlob(encodedData, file.type)
|
||||
|
||||
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('blobFile', blob);
|
||||
|
||||
|
||||
|
||||
this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||
file: {
|
||||
@@ -775,7 +780,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
temporaryData: formData
|
||||
});
|
||||
} else {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -790,7 +795,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
resolve(reader.result)
|
||||
};
|
||||
reader.onerror = function (error) {
|
||||
|
||||
|
||||
};
|
||||
});
|
||||
|
||||
@@ -798,7 +803,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
async openChatOptions(ev?: any) {
|
||||
const roomId = this.roomId
|
||||
|
||||
|
||||
|
||||
const popover = await this.popoverController.create({
|
||||
component: ChatOptionsPopoverPage,
|
||||
@@ -813,7 +818,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
});
|
||||
await popover.present();
|
||||
popover.onDidDismiss().then(async (res) => {
|
||||
|
||||
|
||||
if (res['data'] == 'meeting') {
|
||||
this.bookMeeting();
|
||||
}
|
||||
@@ -840,11 +845,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
} else {
|
||||
this.sqlservice.getAllChatMSG(roomId).then((msg: any) => {
|
||||
|
||||
|
||||
let chatmsgArray = [];
|
||||
let array = []
|
||||
msg.forEach(element => {
|
||||
|
||||
|
||||
|
||||
let msgChat = {
|
||||
_id: element.Id,
|
||||
@@ -864,7 +869,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -946,27 +951,27 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
openFile(pdfString, filename, type) {
|
||||
// const blob = this.b64toBlob(pdfString, type)
|
||||
// let pathFile = ''
|
||||
// const fileName = filename
|
||||
// const contentFile = blob
|
||||
// if (this.platform.is('ios')) {
|
||||
// pathFile = this.file.documentsDirectory
|
||||
// } else {
|
||||
// pathFile = this.file.externalRootDirectory
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// this.file
|
||||
// .writeFile(pathFile, fileName, contentFile, { replace: true })
|
||||
// .then(success => {
|
||||
// this.fileOpener
|
||||
// .open(pathFile + fileName, type)
|
||||
// .then(() =>
|
||||
// .catch(e =>
|
||||
// })
|
||||
// .catch(e =>
|
||||
const blob = this.b64toBlob(pdfString, type)
|
||||
let pathFile = ''
|
||||
const fileName = filename
|
||||
const contentFile = blob
|
||||
if (this.platform.is('ios')) {
|
||||
pathFile = this.file.documentsDirectory
|
||||
} else {
|
||||
pathFile = this.file.externalRootDirectory
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.file
|
||||
.writeFile(pathFile, fileName, contentFile, { replace: true })
|
||||
.then(success => {
|
||||
this.fileOpener
|
||||
.open(pathFile + fileName, type)
|
||||
.then(() => console.log())
|
||||
.catch(e => console.error(e))
|
||||
})
|
||||
.catch(e => console.error(e))
|
||||
}
|
||||
|
||||
downloadFileFromBrowser(fileName: string, data: any): void {
|
||||
@@ -979,9 +984,9 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
|
||||
async openPreview(msg) {
|
||||
|
||||
|
||||
if(msg.file.type === "application/webtrix") {
|
||||
|
||||
if (msg.file.type === "application/webtrix") {
|
||||
this.viewDocument(msg.file, msg.attachments.image_url)
|
||||
} else {
|
||||
|
||||
@@ -996,6 +1001,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
|
||||
console.log(msg)
|
||||
|
||||
if (msg.file.type == "application/img") {
|
||||
const modal = await this.modalController.create({
|
||||
component: ViewMediaPage,
|
||||
@@ -1009,11 +1015,28 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
});
|
||||
modal.present();
|
||||
} else {
|
||||
|
||||
this.downloadFileFromBrowser("file", str)
|
||||
this.downloadFileFromBrowser(msg.attachments[0].name, str)
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
this.openFile(str, msg.attachments[0].name, msg.file.type);
|
||||
if (msg.file.type == "application/img") {
|
||||
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();
|
||||
} else {
|
||||
this.openFile(str, msg.attachments[0].name, msg.file.type);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1022,7 +1045,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
async audioPreview(msg) {
|
||||
|
||||
|
||||
if (!msg.attachments[0].title_link || msg.attachments[0].title_link === null || msg.attachments[0].title_link === '') {
|
||||
this.downloadFileMsg(msg)
|
||||
} else { }
|
||||
@@ -1059,6 +1082,13 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
// });
|
||||
// }
|
||||
|
||||
async createDirectoryImage() {
|
||||
await Filesystem.mkdir({
|
||||
path: IMAGE_DIR,
|
||||
directory: Directory.Data,
|
||||
recursive: true
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user