Files
doneit-web/src/app/home/home.page.ts
T

103 lines
3.2 KiB
TypeScript
Raw Normal View History

2021-06-11 17:27:31 +01:00
///<reference path="../../../plugins/cordova-plugin-mfp/typings/worklight.d.ts" />
///<reference path="../../../plugins/cordova-plugin-mfp-push/typings/mfppush.d.ts" />
import { Component, OnInit, NgZone } from '@angular/core';
2020-09-08 11:17:07 +01:00
import { EventsService } from '../services/events.service';
import { Event } from '../models/event.model';
2020-09-08 11:25:00 +01:00
import { ProcessesService } from '../services/processes.service';
2021-04-12 08:34:17 +01:00
import { NotificationsService } from '../services/notifications.service';
2021-04-12 15:39:44 +01:00
import { ModalController, AlertController, AnimationController, Platform } from '@ionic/angular';
2021-06-18 11:08:55 +01:00
import { NavigationExtras,Router } from '@angular/router';
import { ToastService } from '../services/toast.service';
2020-08-05 15:39:16 +01:00
@Component({
selector: 'app-home',
templateUrl: './home.page.html',
styleUrls: ['./home.page.scss'],
})
export class HomePage implements OnInit {
2020-09-08 11:17:07 +01:00
eventsList: Event[];
prEventList: Event[];
mdEventList: Event[];
totalEvent = 0;
totalExpediente = 0;
profile: string;
2020-08-05 15:39:16 +01:00
2021-04-08 22:54:15 +01:00
adding: "intervenient" | "CC" = "intervenient";
mobileComponent = {
showAddNewEvent: false,
showEditEvent: false,
showEventDetails: false,
showEventList: false,
transparentEventList: false,
transparentEventToApprove: false,
showEventToApprove: false,
showAttendees: false,
showAttendeeModal: false
}
eventToaprove: any = {
back: false,
serialNumber: "",
saveData: {}
}
selectedEvent: Event;
postEvent: any;
folderId: string;
2021-06-16 08:37:31 +01:00
constructor(private zone: NgZone,
private eventService: EventsService,
private processesbackend: ProcessesService,
private router: Router,
private modalController: ModalController,
public modalCtrl: AlertController,
private toastService: ToastService,
2021-04-12 08:34:17 +01:00
private animationController: AnimationController,
2021-04-12 15:39:44 +01:00
private notificatinsservice: NotificationsService,
private platform: Platform) {
2021-04-08 22:54:15 +01:00
2021-03-04 16:07:09 +01:00
router.events.subscribe((val) => {
2021-06-21 14:29:49 +01:00
document.querySelectorAll('ion-modal').forEach((e) => e.remove())
2021-03-04 16:07:09 +01:00
});
2021-04-08 22:54:15 +01:00
{
//this.folderId = this.navParams.get('folderId');
}
2021-03-04 16:07:09 +01:00
}
2020-08-05 15:39:16 +01:00
ngOnInit() {
if(!this.platform.is('desktop')) {
2021-06-25 09:35:50 +01:00
this.notificatinsservice.onReceviNotification();
}
2021-06-15 17:42:51 +01:00
this.count();
2021-04-09 00:10:07 +01:00
2021-06-15 17:42:51 +01:00
}
2021-06-18 11:08:55 +01:00
async count() {
2021-02-10 13:51:39 +01:00
let date = new Date();
date.setMonth(date.getMonth() + 1);
2021-06-16 08:37:31 +01:00
let start = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
let end = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " 23:59:59";
2021-02-10 13:51:39 +01:00
2020-11-26 09:04:22 +01:00
this.profile = "mdgpr";
if (this.profile == "mdgpr") {
2021-06-15 17:42:51 +01:00
let mdOficialEvents = await this.eventService.getAllPrOficialEvents(start, end).toPromise();
let mdPessoalEvents = await this.eventService.getAllPrPessoalEvents(start, end).toPromise();
this.eventsList = mdOficialEvents.concat(mdPessoalEvents)
this.totalEvent = this.eventsList.length;
}
else {
2021-06-15 17:42:51 +01:00
let prOficialEvents = await this.eventService.getAllPrOficialEvents(start, end).toPromise();
let prPessoalEvents = await this.eventService.getAllPrPessoalEvents(start, end).toPromise();
this.eventsList = prOficialEvents.concat(prPessoalEvents)
this.totalEvent = this.eventsList.length;
}
}
2020-08-05 15:39:16 +01:00
}