add and view docments on chat solved

This commit is contained in:
Equilibrium ITO
2024-03-14 09:10:17 +01:00
parent 5b7224dbd6
commit 8cb9961bad
19 changed files with 230 additions and 25 deletions
@@ -35,6 +35,7 @@ import { RouteService } from 'src/app/services/route.service';
import { FileValidatorService } from "src/app/services/file/file-validator.service"
import { sanitize } from "sanitize-filename-ts";
import { FilePicker } from '@capawesome/capacitor-file-picker';
import { ViewDocumentSecondOptionsPage } from 'src/app/modals/view-document-second-options/view-document-second-options.page';
@Component({
selector: 'app-group-messages',
@@ -1160,7 +1161,16 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
async openFile(pdfString, filename, type) {
const blob = this.b64toBlob(pdfString, type)
const modal = await this.modalController.create({
component: ViewDocumentSecondOptionsPage,
componentProps: {
fileUrl: pdfString,
filename: filename
},
cssClass: 'modal modal-desktop'
});
await modal.present();
/* const blob = this.b64toBlob(pdfString, type)
let pathFile = ''
const fileName = filename
const contentFile = blob
@@ -1180,7 +1190,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
.open(dir.uri, type)
.then(() => console.log())
.catch(e => console.error(e))
});
}); */
}
downloadFileMsg(msg: MessageService) {
@@ -1242,7 +1252,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
});
modal.present();
} else {
this.openFile(str, msg.attachments[0].title, msg.file.type);
this.openFile(msg.attachments[0].image_url, msg.attachments[0].title, msg.file.type);
}
}
}
@@ -80,7 +80,6 @@
</div>
</div>
<div *ngIf="msg.file && msg.delate == false">
<div (press)="handlePress(msg._id)"
class='message-container incoming-{{msg.u.username!=sessionStore.user.UserName}}'
+15 -2
View File
@@ -2,6 +2,7 @@ import { AfterViewInit, Component, ElementRef, OnDestroy, OnInit, ViewChild } fr
import { Router } from '@angular/router'
import { GestureController, ModalController, NavParams, PopoverController, Platform, AlertController } from '@ionic/angular';
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
import { ViewDocumentSecondOptionsPage} from 'src/app/modals/view-document-second-options/view-document-second-options.page';
import { EventPerson } from 'src/app/models/eventperson.model';
import { ExpedientTaskModalPageNavParamsTask } from 'src/app/models/ExpedientTaskModalPage';
import { ContactsPage } from 'src/app/pages/chat/messages/contacts/contacts.page';
@@ -1115,6 +1116,18 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
async openFile(pdfString, filename, type) {
console.log('url while open ',pdfString)
const modal = await this.modalController.create({
component: ViewDocumentSecondOptionsPage,
componentProps: {
fileUrl: pdfString,
filename: filename
},
cssClass: 'modal modal-desktop'
});
await modal.present();
/*
var blob = new Blob([pdfString], { type: 'application/pdf' });
console.log('blob blob', blob)
@@ -1152,7 +1165,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
.catch(e => console.error(e))
}).catch((error) => {
console.log('error writing the file', error)
});
}); */
}
removeTextBeforeSlash(inputString, controlString) {
@@ -1227,7 +1240,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
});
modal.present();
} else {
this.openFile(str, msg.attachments[0].title, msg.file.type);
this.openFile(msg.attachments[0].image_url, msg.attachments[0].title, msg.file.type);
}
}
@@ -835,7 +835,7 @@ console.log(stringGerada);
fileObject ={};
const deleteSecretFile = async () => {
await Filesystem.deleteFile({
path: 'output.mp4',
path: `${stringGerada}.mp4`,
directory: Directory.Cache,
});
};
@@ -953,7 +953,7 @@ console.log(stringGerada);
let fileObject ={};
this.videoconvertService.convertVideo(fullPath,directory.uri,filename,'mp4').then(() => {
Filesystem.readFile({ path: `${directory.uri}output.mp4`})
Filesystem.readFile({ path: `${directory.uri}${filename}.mp4`})
.then(async (content) => {
console.log(content.data)
@@ -972,7 +972,7 @@ console.log(stringGerada);
fileObject ={};
const deleteSecretFile = async () => {
await Filesystem.deleteFile({
path: 'output.mp4',
path: `${filename}.mp4`,
directory: Directory.Cache,
});
};