mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
469 lines
16 KiB
TypeScript
469 lines
16 KiB
TypeScript
import { Component, OnInit, NgZone } from '@angular/core';
|
|
import { NavigationExtras, Router } from '@angular/router';
|
|
import { AnimationController, ModalController, Platform } from '@ionic/angular';
|
|
import { LoginUserRespose } from 'src/app/models/user.model';
|
|
import { AuthService } from 'src/app/services/auth.service';
|
|
import { EditProfilePage } from './edit-profile/edit-profile.page';
|
|
import { StorageService } from '../../services/storage.service';
|
|
import { NotificationsService } from '../../services/notifications.service';
|
|
import { SessionStore } from 'src/app/store/session.service';
|
|
import { EventTrigger } from '../../services/eventTrigger.service';
|
|
import { ThemeService } from 'src/app/services/theme.service'
|
|
import { environment } from 'src/environments/environment';
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
import { EventsService } from 'src/app/services/events.service';
|
|
import { NotificationHolderService } from 'src/app/store/notification-holder.service';
|
|
|
|
@Component({
|
|
selector: 'app-profile',
|
|
templateUrl: './profile.page.html',
|
|
styleUrls: ['./profile.page.scss'],
|
|
})
|
|
export class ProfilePage implements OnInit {
|
|
|
|
userLoginPreference = ''
|
|
DataArray: Array<Object> = [];
|
|
|
|
service: "agenda";
|
|
typeagenda: "official";
|
|
typeagenda2: "pessoal";
|
|
pr: "100000014";
|
|
md: "100000011";
|
|
date: "60:20";
|
|
location: "Gabinete";
|
|
isProfileOpen = false
|
|
hideImage = false
|
|
logoutOut = false
|
|
notificationStatus = '';
|
|
environment = environment
|
|
taskExist = true;
|
|
taskNotExist = false;
|
|
isloading = false;
|
|
profilePicture = "";
|
|
|
|
|
|
SessionStore = SessionStore;
|
|
constructor(
|
|
private modalController: ModalController,
|
|
private animationController: AnimationController,
|
|
private router: Router,
|
|
private storageservice: StorageService,
|
|
private zone: NgZone,
|
|
private platform: Platform,
|
|
private eventTriger: EventTrigger,
|
|
public ThemeService: ThemeService,
|
|
private notificationService: NotificationsService,
|
|
private processesService: ProcessesService,
|
|
private eventsService: EventsService,
|
|
private storageService: StorageService,
|
|
public NotificationHolderService: NotificationHolderService,
|
|
private authservice: AuthService
|
|
) {
|
|
|
|
window['e'] = () => {
|
|
console.log(
|
|
this.zone.run(() => this.router.navigate(['/home/chat']))
|
|
)
|
|
}
|
|
|
|
|
|
router.events.subscribe((val) => {
|
|
this.isProfileOpen = false
|
|
this.logoutOut = true
|
|
});
|
|
|
|
/* this.eventTriger.getObservable().subscribe((event) => {
|
|
if (event.notification == "recive") {
|
|
this.getNotificationData();
|
|
} else if (event.notification == "deleted") {
|
|
console.log('header', event.notification)
|
|
this.getNotificationData();
|
|
}
|
|
}); */
|
|
|
|
/* this.notificationService.notificationReceived.subscribe(() => {
|
|
this.getNotificationData();
|
|
}); */
|
|
|
|
setTimeout(() => {
|
|
this.hideImage = true
|
|
}, 2000)
|
|
}
|
|
|
|
ngOnInit() {
|
|
|
|
// this.getNotificationData();
|
|
this.getProfilpicture();
|
|
|
|
}
|
|
|
|
getProfilpicture() {
|
|
this.storageService.get(this.SessionStore.user.RoleID.toString()).then((picture) => {
|
|
if(picture) {
|
|
this.profilePicture = picture
|
|
} else {
|
|
this.profilePicture = "";
|
|
}
|
|
/* console.log(picture) */
|
|
}).catch((error ) => {
|
|
this.profilePicture = "";
|
|
})
|
|
}
|
|
|
|
|
|
close() {
|
|
this.modalController.dismiss();
|
|
}
|
|
|
|
notImplemented() { }
|
|
|
|
asyncNotification() { }
|
|
|
|
// async getNotificationData() {
|
|
|
|
// //const keyExist = await this.storageservice.keyExist("Notifications")
|
|
|
|
// //if(keyExist) {
|
|
// await this.storageservice.get("Notifications").then((value) => {
|
|
|
|
// console.log('Getnotifications 111', value)
|
|
|
|
// this.DataArray = []
|
|
// value.forEach((element, i) => {
|
|
// console.log('Getnotifications', element, i)
|
|
// let notificationObject;
|
|
// if (element.notification) {
|
|
|
|
// notificationObject = {
|
|
// index: i,
|
|
// title: element.notification.title,
|
|
// Service: element.data.Service,
|
|
// Object: element.data.Object,
|
|
// IdObject: element.data.IdObject,
|
|
// FolderId: element.data.FolderId,
|
|
// body: element.notification.body,
|
|
// dateInit: this.getFormatedTime(element.data.dateInit),
|
|
// dateEnd: this.getFormatedTime(element.data.dateEnd),
|
|
// Location: element.data.Location,
|
|
// TypeAgenda: element.data.TypeAgenda,
|
|
// Role: element.data.Role,
|
|
// Status: element.data.Status,
|
|
// read: false,
|
|
// }
|
|
|
|
// } else if (element.data) {
|
|
// notificationObject = {
|
|
// index: i,
|
|
// title: element.title,
|
|
// Service: element.data.Service,
|
|
// Object: element.data.Object,
|
|
// IdObject: element.data.IdObject,
|
|
// FolderId: element.data.FolderId,
|
|
// body: element.body,
|
|
// dateInit: this.getFormatedTime(element.data.dateInit),
|
|
// dateEnd: this.getFormatedTime(element.data.dateEnd),
|
|
// Location: element.data.Location,
|
|
// TypeAgenda: element.data.TypeAgenda,
|
|
// Role: element.data.Role,
|
|
// Status: element.data.Status,
|
|
// read: false,
|
|
// }
|
|
|
|
// } else {
|
|
// {
|
|
// notificationObject = {
|
|
// FolderId: element.FolderId,
|
|
// IdObject: element.IdObject,
|
|
// Location: element.Location,
|
|
// Object: element.Object,
|
|
// Role: element.Role,
|
|
// Service: element.Service,
|
|
// Status: element.Status,
|
|
// TypeAgenda: element.TypeAgenda,
|
|
// body: element.body,
|
|
// dateEnd: element.dateEnd,
|
|
// dateInit: element.dateInit,
|
|
// index: element.index,
|
|
// title: element.title,
|
|
// read: false,
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// this.DataArray.push(notificationObject)
|
|
// });
|
|
// this.notificationdata = this.DataArray.reverse();
|
|
// }).catch((error) => {
|
|
// console.error('storage getnotification: ', error)
|
|
// })
|
|
// // }
|
|
|
|
|
|
// }
|
|
|
|
|
|
getFormatedTime(dateString) {
|
|
var date = new Date(dateString);
|
|
var hours = date.getHours() /* > 12 ? date.getHours() - 12 : date.getHours() */;
|
|
var am_pm = date.getHours() >= 12 ? "pm" : "am";
|
|
var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
|
|
let time = hours + ":" + minutes /* + " " + am_pm */;
|
|
return time;
|
|
}
|
|
|
|
notificatinsRoutes = (index, Service, Object, IdObject, FolderId, i) => {
|
|
|
|
console.log(index, i)
|
|
|
|
if (Service === "agenda") {
|
|
this.isloading = true
|
|
if (Service === "agenda" && IdObject.length > 10) {
|
|
this.eventsService.getEvent(IdObject).subscribe((task) => {
|
|
|
|
this.zone.run(() => this.router.navigate(['/home/agenda', IdObject, 'agenda']));
|
|
this.deleteNotification(index);
|
|
this.isloading = false
|
|
|
|
}, (error) => {
|
|
this.NotificationHolderService.notificationList[i].read = true;
|
|
this.isloading = false
|
|
})
|
|
}
|
|
|
|
if (Service === "agenda" && Object === "event-list") {
|
|
this.isloading = true
|
|
this.processesService.GetTask(IdObject).subscribe((task) => {
|
|
console.log('evento exist')
|
|
this.zone.run(() => this.router.navigate(['/home/agenda/event-list/approve-event', IdObject, 'agenda']));
|
|
this.deleteNotification(index);
|
|
this.isloading = false
|
|
|
|
}, (error) => {
|
|
console.log('evento não existe')
|
|
this.NotificationHolderService.notificationList[i].read = true;
|
|
this.isloading = false
|
|
})
|
|
|
|
}
|
|
|
|
} else if (Service === "gabinete-digital") {
|
|
this.isloading = true
|
|
this.processesService.GetTask(IdObject).subscribe((task) => {
|
|
|
|
if (Service === "gabinete-digital" && Object === "expedientes") {
|
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expediente', IdObject, 'gabinete-digital']));
|
|
} else if (Service === "gabinete-digital" && Object === "despachos") {
|
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos', IdObject, 'gabinete-digital'], { replaceUrl: true }));
|
|
} else if (Service === "gabinete-digital" && Object === "parecer") {
|
|
|
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', IdObject, 'gabinete-digital']));
|
|
}
|
|
else if (Service === "gabinete-digital" && Object === "deferimento") {
|
|
|
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', IdObject, 'gabinete-digital']));
|
|
}
|
|
else if (Service === "gabinete-digital" && Object === "despachos-pr") {
|
|
|
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos-pr', IdObject, 'gabinete-digital']));
|
|
}else if (Service === "gabinete-digital" && Object === "diplomas") {
|
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', IdObject, 'gabinete-digital']));
|
|
}
|
|
else if (Service === "gabinete-digital" && Object === "diplomas-assinar") {
|
|
|
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas-assinar', IdObject, 'gabinete-digital']));
|
|
}
|
|
else if (Service === "gabinete-digital" && Object === "diploma-revisao") {
|
|
|
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', IdObject, 'gabinete-digital']));
|
|
}
|
|
else if (Service === "gabinete-digital" && Object === "expedientes-pr") {
|
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', IdObject, 'gabinete-digital']));
|
|
}
|
|
|
|
this.deleteNotification(index);
|
|
this.isloading = false
|
|
|
|
}, (error) => {
|
|
this.NotificationHolderService.notificationList[i].read = true;
|
|
this.isloading = false
|
|
})
|
|
|
|
|
|
} else if (Service === "accoes") {
|
|
if (Service === "accoes" && Object === "accao") {
|
|
this.zone.run(() => this.router.navigate(['/home/publications', IdObject]));
|
|
this.deleteNotification(index);
|
|
}
|
|
else if (Service === "accoes" && Object === "publicacao") {
|
|
this.zone.run(() => this.router.navigate(['/home/publications/view-publications', FolderId, IdObject]));
|
|
this.deleteNotification(index);
|
|
}
|
|
|
|
} else if (Service === "chat") {
|
|
|
|
let navigationExtras: NavigationExtras = { queryParams: { "roomId": IdObject, } };
|
|
|
|
this.zone.run(() => this.router.navigate(['/home/chat']));
|
|
|
|
setTimeout(() => {
|
|
this.zone.run(() => this.router.navigate(['/home/chat'], navigationExtras));
|
|
}, 200);
|
|
|
|
|
|
this.deleteNotification(index);
|
|
}
|
|
|
|
|
|
/* if (Service === "agenda" && IdObject.length > 10) {
|
|
this.zone.run(() => this.router.navigate(['/home/agenda', IdObject, 'agenda']));
|
|
}
|
|
else if (Service === "gabinete-digital" && Object === "expedientes") {
|
|
this.processesService.GetTask(IdObject).subscribe((task) => {
|
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expediente', IdObject, 'gabinete-digital']));
|
|
}, (error) => {
|
|
this.notificationdata[i].read = true;
|
|
})
|
|
}
|
|
else if (Service === "agenda" && Object === "event-list") {
|
|
//this.zone.run(() => this.router.navigate(['/home/gabinete-digital/event-list/approve-event',IdObject, 'agenda']));
|
|
this.zone.run(() => this.router.navigate(['/home/agenda/event-list/approve-event', IdObject, 'agenda']));
|
|
|
|
} else if (Service === "gabinete-digital" && Object === "despachos") {
|
|
this.processesService.GetTask(IdObject).subscribe((task) => {
|
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos', IdObject, 'gabinete-digital'], { replaceUrl: true }));
|
|
}, (error) => {
|
|
this.notificationdata[i].read = true;
|
|
})
|
|
|
|
|
|
}
|
|
else if (Service === "gabinete-digital" && Object === "parecer") {
|
|
|
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', IdObject, 'gabinete-digital']));
|
|
}
|
|
else if (Service === "gabinete-digital" && Object === "deferimento") {
|
|
|
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', IdObject, 'gabinete-digital']));
|
|
}
|
|
else if (Service === "gabinete-digital" && Object === "despachos-pr") {
|
|
|
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos-pr', IdObject, 'gabinete-digital']));
|
|
}
|
|
else if (Service === "accoes" && Object === "accao") {
|
|
this.zone.run(() => this.router.navigate(['/home/publications', IdObject]));
|
|
}
|
|
else if (Service === "accoes" && Object === "publicacao") {
|
|
this.zone.run(() => this.router.navigate(['/home/publications/view-publications', FolderId, IdObject]));
|
|
}
|
|
else if (Service === "gabinete-digital" && Object === "diplomas") {
|
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', IdObject, 'gabinete-digital']));
|
|
}
|
|
else if (Service === "gabinete-digital" && Object === "diplomas-assinar") {
|
|
|
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas-assinar', IdObject, 'gabinete-digital']));
|
|
}
|
|
else if (Service === "gabinete-digital" && Object === "expedientes-pr") {
|
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', IdObject, 'gabinete-digital']));
|
|
} else if (Service === "chat") {
|
|
let navigationExtras: NavigationExtras = { queryParams: { "roomId": IdObject, } };
|
|
this.zone.run(() => this.router.navigate(['/home/chat'], navigationExtras));
|
|
} */
|
|
|
|
// this.notificationservice.tempClearArray();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
deleteNotification(index) {
|
|
const notificationdata = this.NotificationHolderService.notificationList.find(item => item.index == index);
|
|
this.NotificationHolderService.removeNotification(notificationdata)
|
|
}
|
|
|
|
logout() {
|
|
this.authservice.logoutUser();
|
|
SessionStore.setInativity(false)
|
|
SessionStore.setUrlBeforeInactivity(this.router.url);
|
|
this.logoutOut == false
|
|
|
|
if (environment.production) {
|
|
window.location.pathname = '/auth'
|
|
this.notificationService.DeletePostToken()
|
|
} else {
|
|
const pathBeforeGoOut = window.location.pathname
|
|
this.router.navigateByUrl('/auth', { replaceUrl: true });
|
|
this.notificationService.DeletePostToken()
|
|
|
|
setTimeout(() => {
|
|
if (this.logoutOut == false || pathBeforeGoOut == window.location.pathname) {
|
|
window.location.pathname = '/auth'
|
|
this.notificationService.DeletePostToken()
|
|
} else {
|
|
|
|
}
|
|
}, 500)
|
|
}
|
|
|
|
}
|
|
|
|
async editProfile() {
|
|
|
|
const enterAnimation = (baseEl: any) => {
|
|
const backdropAnimation = this.animationController.create()
|
|
.addElement(baseEl.querySelector('ion-backdrop')!)
|
|
.fromTo('opacity', '0.01', 'var(--backdrop-opacity)');
|
|
|
|
const wrapperAnimation = this.animationController.create()
|
|
.addElement(baseEl.querySelector('.modal-wrapper')!)
|
|
.keyframes([
|
|
{ offset: 0, opacity: '1', right: '-100%' },
|
|
{ offset: 1, opacity: '1', right: '0px' }
|
|
]);
|
|
|
|
return this.animationController.create()
|
|
.addElement(baseEl)
|
|
.easing('ease-out')
|
|
.duration(500)
|
|
.addAnimation([backdropAnimation, wrapperAnimation]);
|
|
}
|
|
|
|
const leaveAnimation = (baseEl: any) => {
|
|
return enterAnimation(baseEl).direction('reverse');
|
|
}
|
|
|
|
|
|
if (this.isProfileOpen == false) {
|
|
this.isProfileOpen = true;
|
|
|
|
const modal = await this.modalController.create({
|
|
component: EditProfilePage,
|
|
cssClass: 'model profile-modal search-submodal',
|
|
componentProps: {
|
|
}
|
|
});
|
|
|
|
|
|
modal.onDidDismiss().then(() => {
|
|
this.isProfileOpen = false;
|
|
this.getProfilpicture()
|
|
}, (error) => {
|
|
console.log(error)
|
|
})
|
|
|
|
await modal.present();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
keppNotification(index) {
|
|
this.NotificationHolderService.notificationList[index].read = false;
|
|
}
|
|
|
|
doNotKeppNotification(index) {
|
|
this.deleteNotification(index);
|
|
}
|
|
|
|
}
|