Files
doneit-web/src/app/pages/gabinete-digital/gabinete-digital.page.ts
T
tiago.kayaya a1ecd1e4a6 save
2021-04-08 21:03:42 +01:00

257 lines
6.3 KiB
TypeScript

import { Component, OnInit } from '@angular/core';
import { ProcessesService } from 'src/app/services/processes.service';
import { AlertService } from 'src/app/services/alert.service';
import { EventsService } from 'src/app/services/events.service';
import { ModalController } from '@ionic/angular';
import { EventListPage } from './event-list/event-list.page';
import { ExpedientePage } from './expediente/expediente.page';
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
@Component({
selector: 'app-gabinete-digital',
templateUrl: './gabinete-digital.page.html',
styleUrls: ['./gabinete-digital.page.scss'],
})
export class GabineteDigitalPage implements OnInit {
segment:string;
showLoader: boolean;
public profile:string;
count_exp_dailywork=0;
count_exp_pp : string;
count_exp_pd : string;
count_dip_apr : string;
count_dip_pv : string;
count_de_pr : string;
count_ev_pr=0;
count_ev_md=0;
desktopComponent: any = {
showEventList: false,
showExpediente : false
}
showEventsToApprove = false;
showEmptyContainer = false;
showExpedients = true;
showExpedientDetail = false;
emptyTextDescription = 'Sem opção selecionada';
serialNumber:string;
constructor(
private processesbackend:ProcessesService,
private modalController: ModalController,
private alertService: AlertService,
private activatedRoute: ActivatedRoute,
private router: Router,
) {
window.onresize = (event) => {
// if not mobile remove all component
if( window.innerWidth <= 1024){
this.modalController.dismiss();
}
this.adjastModalHeight();
};
this.adjastModalHeight();
this.activatedRoute.queryParams.subscribe(params => {
if(params["show"]){
this.openExpedientListPage();
}
else if(params["events"]){
this.openEventsToApprovePage("MDGPR");
}
});
}
adjastModalHeight(){
setTimeout(() => {
if( window.innerWidth <= 1366){
document.querySelectorAll('.gabinete-digital-mobile-modal-to-Desktop').forEach(e=>{
console.log('adjast width')
e.setAttribute('style',`height:${window.innerHeight - (74 + 57)}px`)
})
} else if( window.innerWidth >= 1366){
document.querySelectorAll('.gabinete-digital-mobile-modal-to-Desktop').forEach(e=>{
console.log('adjast width')
e.setAttribute('style',`height:${window.innerHeight - (74)}px`)
})
}
}, 200);
}
closeAllDesktopComponent(){
this.desktopComponent = {
showEventList: false,
showExpediente: false
}
}
ngOnInit() {
//Initialize profile as mdgpr
this.profile = "MDGPR";
this.router.events.forEach((event) => {
if(event instanceof NavigationEnd && event.url == this.router.url) {
this.LoadCounts();
}
});
this.LoadCounts();
/* this.eventService.getAllMdEvents.subscribe(res=>{
console.log(res);
});
console.log(this.eventService.getAllPrEvents.length);
*/
this.processesbackend.GetActionsList().subscribe(res=>{
console.log(res);
});
}
closeAllDesktopComponents(){
this.showEmptyContainer = false;
this.showEventsToApprove = false;
this.showExpedients = false;
this.showExpedients = false;
this.showExpedientDetail = false;
}
LoadCounts() {
this.showLoader = true;
this.processesbackend.GetTasksList("Expediente", true).subscribe(res =>{
this.showLoader = false;
this.count_exp_dailywork = res;
});
this.processesbackend.GetToApprovedEvents('PR','true').subscribe(res=>{
this.count_ev_pr = res;
});
this.processesbackend.GetToApprovedEvents('MDGPR','true').subscribe(res=>{
this.count_ev_md = res;
});
this.count_exp_pp = "-";
this.count_exp_pd = "-";
this.count_dip_apr = "-";
this.count_dip_pv = "-";
this.count_de_pr ='-';
}
doRefresh(event) {
this.closeAllDesktopComponents();
this.showExpedients = true;
this.LoadCounts();
setTimeout(() => {
event.target.complete();
}, 2000);
}
notImplemented(){
this.alertService.presentAlert('Funcionalidade em desenvolvimento');
}
openEventsToApprovePage(profile:any){
console.log(profile);
this.closeAllDesktopComponents();
if( window.innerWidth <= 1024){
this.openEventsToApproveList(profile);
}
else{
this.showEventsToApprove = true;
}
}
async openEventsToApproveList(profile:any){
this.closeAllDesktopComponent();
let classs;
if( window.innerWidth <= 800){
classs = 'modal'
} else {
classs = 'gabinete-digital-mobile-modal-to-Desktop'
}
//if( window.innerWidth <= 1024){
this.adjastModalHeight();
const modal = await this.modalController.create({
component: EventListPage,
componentProps:{
profile: profile,
},
cssClass: classs,
backdropDismiss: false
});
await modal.present();
modal.onDidDismiss();
//} else {
//this.desktopComponent.showEventList = true;
//}
}
openExpedientListPage(){
this.closeAllDesktopComponents();
if( window.innerWidth <= 1024){
this.openExpedientList();
}
else{
this.showExpedients = true;
}
}
openExpedientPage(data){
console.log(data);
this.closeAllDesktopComponents();
if( window.innerWidth <= 1024){
//this.openExpedientList();
}
else{
this.serialNumber = data;
this.showExpedientDetail = true;
}
}
async openExpedientList(){
this.closeAllDesktopComponent();
let classs;
if( window.innerWidth <= 1024){
classs = 'modal'
} else {
classs = 'gabinete-digital-mobile-modal-to-Desktop'
}
//if( window.innerWidth <= 1024){
this.adjastModalHeight();
const modal = await this.modalController.create({
component: ExpedientePage,
componentProps:{
profile: this.profile,
},
cssClass: classs,
backdropDismiss: false
});
await modal.present();
modal.onDidDismiss();
//} else {
console.log('show desktop modal')
//this.desktopComponent.showExpediente = true;
//}
}
}