Files
doneit-web/src/app/modals/view-document/view-document.page.ts
T

195 lines
5.2 KiB
TypeScript
Raw Normal View History

import { Component, OnInit } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
2023-01-24 15:56:47 +01:00
import { NavParams } from '@ionic/angular';
2021-10-08 19:29:21 +01:00
import { ExpedientTaskModalPageNavParamsTask } from 'src/app/models/ExpedientTaskModalPage';
import { ExpedientTaskModalPage } from 'src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page';
import { ProcessesService } from 'src/app/services/processes.service';
import { EventDetailsDocumentsOptionsPage } from 'src/app/shared/popover/event-details-documents-options/event-details-documents-options.page';
import { DocumentSetUpMeetingPage } from '../document-set-up-meeting/document-set-up-meeting.page';
2023-01-24 15:56:47 +01:00
import { AlertController, ModalController } from '@ionic/angular';
2023-08-20 22:00:23 +01:00
import { SearchList } from 'src/app/models/search-document';
2023-02-27 17:41:33 +01:00
@Component({
selector: 'app-view-document',
templateUrl: './view-document.page.html',
styleUrls: ['./view-document.page.scss'],
})
export class ViewDocumentPage implements OnInit {
trustedUrl: any;
2021-10-08 19:29:21 +01:00
file: any;
applicationId: any;
docId: any
task: ExpedientTaskModalPageNavParamsTask;
Document: any
2023-02-27 17:41:33 +01:00
loader = true
2023-08-20 22:00:23 +01:00
attachment: SearchList[] = [];
constructor(
private modalController: ModalController,
private navParams: NavParams,
private sanitazer: DomSanitizer,
2021-10-08 19:29:21 +01:00
private processes: ProcessesService,
2023-01-24 15:56:47 +01:00
private alertController: AlertController,
) {
this.file = this.navParams.get('file');
2021-10-08 19:29:21 +01:00
this.applicationId = this.navParams.get('applicationId');
this.docId = this.navParams.get('docId');
this.Document = this.navParams.get('Document')
2021-10-09 11:31:58 +01:00
this.task = this.navParams.get('task')
2023-08-20 22:00:23 +01:00
this.attachment = this.navParams.get('attachment')
2021-10-08 19:29:21 +01:00
2021-10-09 15:49:00 +01:00
if(!this.file.title) {
this.file.title = 'Sem Título'
}
2021-10-11 09:28:54 +01:00
2023-08-31 12:00:52 +01:00
console.log({
file: this.file,
applicationId: this.applicationId,
docId: this.docId,
Document: this.Document,
task: this.task,
attachment: this.attachment
})
2021-10-11 09:28:54 +01:00
2021-10-08 19:29:21 +01:00
}
ngOnInit() {
2021-10-08 19:29:21 +01:00
2023-01-24 15:56:47 +01:00
this.processes.GetViewer(this.docId, this.applicationId).subscribe(async(res)=> {
2023-01-24 15:56:47 +01:00
const link: string = res.replace('//pdfjs/web/', '/pdfjs/web/')
2021-10-08 19:29:21 +01:00
this.trustedUrl = this.sanitazer.bypassSecurityTrustResourceUrl(link);
2023-01-24 15:56:47 +01:00
2023-02-27 17:41:33 +01:00
// const iframe = document.getElementById("iframe")
// const handleLoad = () => {
// this.loader = false
// };
// iframe.addEventListener('load', handleLoad, true)
2023-01-24 15:56:47 +01:00
if(res == "") {
const alert = await this.alertController.create({
cssClass: 'my-custom-class',
//header: 'Apagar evento!',
message: 'Sem imagem',
buttons: [
{
text: 'Sim',
handler: () => {
this.close();
}
}
]
});
}
2021-10-09 15:58:54 +01:00
}, ()=>{
2021-10-18 17:10:33 +01:00
this.close();
});
2021-10-08 19:29:21 +01:00
}
2021-10-08 19:29:21 +01:00
close() {
this.modalController.dismiss();
}
2021-10-08 19:29:21 +01:00
async openOptions() {
const modal = await this.modalController.create({
component: EventDetailsDocumentsOptionsPage,
cssClass: 'model aside-modal search-submodal',
componentProps: {
2023-08-31 12:00:52 +01:00
content: "", // check
Document:this.Document // check
2021-10-08 19:29:21 +01:00
}
});
await modal.present();
modal.onDidDismiss().then((res)=>{
2021-10-11 09:28:54 +01:00
if(res.data) {
if(res.data.component == 'openBookMeetingModal') {
this.openBookMeetingModal()
} else if(res.data.component == 'openExpedientActionsModal') {
this.openExpedientActionsModal(res.data.taskAction)
} else {
2023-05-26 14:23:37 +01:00
2021-10-11 09:28:54 +01:00
}
2021-10-08 19:29:21 +01:00
}
2021-10-11 09:28:54 +01:00
2023-07-14 10:19:33 +01:00
}, (error) => {
console.log(error)
2021-10-08 19:29:21 +01:00
})
}
async openBookMeetingModal() {
2024-01-17 10:25:16 +01:00
//console.log('this.Document----------', this.Document)
2021-10-08 19:29:21 +01:00
let classs;
if( window.innerWidth < 701) {
classs = 'book-meeting-modal modal modal-desktop'
} else {
classs = 'modal modal-desktop showAsideOptions'
}
2023-08-31 12:00:52 +01:00
// check passing
2021-10-08 19:29:21 +01:00
const modal = await this.modalController.create({
component: DocumentSetUpMeetingPage,
componentProps: {
2023-08-31 12:00:52 +01:00
subject: this.task.workflowInstanceDataFields.Subject, // check
document: this.Document, // document
2021-10-08 19:29:21 +01:00
},
cssClass: classs,
backdropDismiss: false
});
2023-07-15 11:01:09 +01:00
2021-10-08 19:29:21 +01:00
modal.onDidDismiss().then(res=>{
2022-01-06 14:47:22 +01:00
//this.RouteService.goBack();
2023-07-14 10:19:33 +01:00
}, (error) => {
console.log(error)
2021-10-08 19:29:21 +01:00
});
2023-07-15 11:01:09 +01:00
await modal.present();
2021-10-08 19:29:21 +01:00
}
// efetuar despacho
2021-10-11 09:28:54 +01:00
2021-10-08 19:29:21 +01:00
async openExpedientActionsModal( taskAction: any) {
let classs;
if( window.innerWidth < 701) {
classs = 'modal modal-desktop'
} else {
classs = 'modal modal-desktop showAsideOptions'
}
2023-08-31 12:00:52 +01:00
// check passing
2024-01-17 10:25:16 +01:00
//console.log('this.Document----------openExpedientActionsModal', this.Document)
2021-10-08 19:29:21 +01:00
const modal = await this.modalController.create({
component: ExpedientTaskModalPage,
componentProps: {
2023-08-31 12:00:52 +01:00
taskAction: taskAction, // check
task: this.task, // check
document: this.Document, // nope
2024-02-15 17:11:59 +01:00
aplicationId: this.Document.ApplicationId || this.Document.ApplicationID, // check
applicationId: this.applicationId,
docId: this.docId,
createProcessFromFile: true,
2021-10-08 19:29:21 +01:00
},
cssClass: classs,
});
2023-07-15 11:01:09 +01:00
modal.onDidDismiss().then(
2023-07-14 10:19:33 +01:00
async(res)=>{}
, (error) => {
console.log(error)
}
);
2021-10-08 19:29:21 +01:00
2023-07-15 11:01:09 +01:00
await modal.present();
2021-10-08 19:29:21 +01:00
}
}