mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
ITOTEAM-523 notification status
This commit is contained in:
@@ -15,6 +15,10 @@ import { NotificationHolderService } from 'src/app/store/notification-holder.ser
|
||||
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
import { NotificationRepositoryService } from 'src/app/module/notification/data/notification-repository.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { NotificationTable } from 'src/app/module/notification/data/infra/db/notification.db';
|
||||
import { isHttpError } from 'src/app/services/http.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-profile',
|
||||
@@ -45,6 +49,9 @@ export class ProfilePage implements OnInit {
|
||||
|
||||
|
||||
SessionStore = SessionStore;
|
||||
|
||||
notificationList$: Observable<NotificationTable[]>
|
||||
|
||||
constructor(
|
||||
private modalController: ModalController,
|
||||
private animationController: AnimationController,
|
||||
@@ -62,43 +69,43 @@ export class ProfilePage implements OnInit {
|
||||
private authservice: AuthService,
|
||||
private agendaDataRepository: AgendaDataRepositoryService,
|
||||
private toastService: ToastService,
|
||||
private notificationRepositoryService: NotificationRepositoryService
|
||||
) {
|
||||
|
||||
this.notificationList$ = this.notificationRepositoryService.getNotificationLive()
|
||||
|
||||
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)
|
||||
|
||||
|
||||
this.notificationRepositoryService.init()
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
// this.getNotificationData();
|
||||
this.getProfilpicture();
|
||||
}
|
||||
|
||||
|
||||
toDateString(e) {
|
||||
return new Date(e).toDateString()
|
||||
}
|
||||
|
||||
isValidDate(dateString) {
|
||||
const date = new Date(dateString);
|
||||
return !isNaN(date.getTime());
|
||||
}
|
||||
|
||||
getProfilpicture() {
|
||||
@@ -216,29 +223,39 @@ export class ProfilePage implements OnInit {
|
||||
}
|
||||
|
||||
@XTracerAsync({name:'profile/notificationClick', bugPrint: true, module:'notification'})
|
||||
async notificatinsRoutes (index, Service, Object, IdObject, FolderId, i, tracing?: TracingType) {
|
||||
async notificatinsRoutes (index, item: NotificationTable, tracing?: TracingType) {
|
||||
|
||||
console.log(index, i)
|
||||
|
||||
console.log({item})
|
||||
this.notificationRepositoryService.notificationStatus(item)
|
||||
|
||||
try {
|
||||
if (Service === "agenda") {
|
||||
if (item.service === "agenda") {
|
||||
this.isloading = true
|
||||
if (Service === "agenda") {
|
||||
if (item.service === "agenda") {
|
||||
|
||||
let res = await this.agendaDataRepository.getEventById(IdObject, tracing)
|
||||
let res = await this.agendaDataRepository.getEventById(item.idObject, tracing)
|
||||
|
||||
if(IdObject) {
|
||||
if(item.idObject) {
|
||||
|
||||
if(res.isOk()) {
|
||||
|
||||
this.zone.run(() => this.router.navigate(['/home/agenda', IdObject, 'agenda']));
|
||||
this.zone.run(() => this.router.navigate(['/home/agenda', item.idObject, 'agenda']));
|
||||
this.deleteNotification(index);
|
||||
tracing.setAttribute('outcome', 'success')
|
||||
} else {
|
||||
tracing.setAttribute('outcome', 'success')
|
||||
tracing.setAttribute('data.exist', 'false')
|
||||
this.NotificationHolderService.notificationList[i].read = true;
|
||||
console.log('error', res.error)
|
||||
this.NotificationHolderService.notificationList[index].read = true;
|
||||
|
||||
if (isHttpError(res.error)) {
|
||||
|
||||
if(res.error.status == 404) {
|
||||
this.toastService._badRequest('Este evento já não existe')
|
||||
this.notificationRepositoryService.localNotificationStatus(item)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tracing.setAttribute('data.IdObject', 'false')
|
||||
@@ -247,23 +264,23 @@ export class ProfilePage implements OnInit {
|
||||
|
||||
this.isloading = false
|
||||
|
||||
} else if (Service === "agenda" && Object === "event-list") {
|
||||
} else if (item.service === "agenda" && item.object === "event-list") {
|
||||
this.isloading = true
|
||||
|
||||
if(IdObject) {
|
||||
if(item.idObject) {
|
||||
|
||||
let res = await this.agendaDataRepository.getEventById(IdObject, tracing)
|
||||
let res = await this.agendaDataRepository.getEventById(item.idObject, tracing)
|
||||
if(res.isOk()) {
|
||||
console.log('evento exist')
|
||||
tracing.setAttribute('outcome', 'success')
|
||||
this.zone.run(() => this.router.navigate(['/home/agenda/event-list/approve-event', IdObject, 'agenda']));
|
||||
this.zone.run(() => this.router.navigate(['/home/agenda/event-list/approve-event', item.idObject, 'agenda']));
|
||||
this.deleteNotification(index);
|
||||
this.isloading = false
|
||||
} else {
|
||||
tracing.setAttribute('outcome', 'success')
|
||||
console.log('evento não existe')
|
||||
tracing.setAttribute('data.exist', 'false')
|
||||
this.NotificationHolderService.notificationList[i].read = true;
|
||||
// this.NotificationHolderService.notificationList[index].read = true;
|
||||
this.isloading = false
|
||||
}
|
||||
} else {
|
||||
@@ -276,65 +293,65 @@ export class ProfilePage implements OnInit {
|
||||
} else {
|
||||
tracing.setAttribute('notification.route', 'false')
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
tracing.setAttribute('parameters', JSON.stringify({Service, Object, IdObject, FolderId}))
|
||||
tracing.setAttribute('parameters', JSON.stringify({Service:item.service, Object:item.object, IdObject:item.idObject, FolderId:item.folderId}))
|
||||
}
|
||||
|
||||
} else if (Service === "gabinete-digital") {
|
||||
} else if (item.service === "gabinete-digital") {
|
||||
this.isloading = true
|
||||
this.processesService.GetTask(IdObject).subscribe((task) => {
|
||||
this.processesService.GetTask(item.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") {
|
||||
if (item.service === "gabinete-digital" && item.object === "expedientes") {
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expediente', item.idObject, 'gabinete-digital']));
|
||||
} else if (item.service === "gabinete-digital" && item.object === "despachos") {
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos', item.idObject, 'gabinete-digital'], { replaceUrl: true }));
|
||||
} else if (item.service === "gabinete-digital" && item.object === "parecer") {
|
||||
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', IdObject, 'gabinete-digital']));
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', item.idObject, 'gabinete-digital']));
|
||||
}
|
||||
else if (Service === "gabinete-digital" && Object === "deferimento") {
|
||||
else if (item.service === "gabinete-digital" && item.object === "deferimento") {
|
||||
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', IdObject, 'gabinete-digital']));
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', item.idObject, 'gabinete-digital']));
|
||||
}
|
||||
else if (Service === "gabinete-digital" && Object === "despachos-pr") {
|
||||
else if (item.service === "gabinete-digital" && item.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']));
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos-pr', item.idObject, 'gabinete-digital']));
|
||||
}else if (item.service === "gabinete-digital" && item.object === "diplomas") {
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', item.idObject, 'gabinete-digital']));
|
||||
}
|
||||
else if (Service === "gabinete-digital" && Object === "diplomas-assinar") {
|
||||
else if (item.service === "gabinete-digital" && item.object === "diplomas-assinar") {
|
||||
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas-assinar', IdObject, 'gabinete-digital']));
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas-assinar', item.idObject, 'gabinete-digital']));
|
||||
}
|
||||
else if (Service === "gabinete-digital" && Object === "diploma-revisao") {
|
||||
else if (item.service === "gabinete-digital" && item.object === "diploma-revisao") {
|
||||
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', IdObject, 'gabinete-digital']));
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', item.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 (item.service === "gabinete-digital" && item.object === "expedientes-pr") {
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', item.idObject, 'gabinete-digital']));
|
||||
}
|
||||
|
||||
this.deleteNotification(index);
|
||||
this.isloading = false
|
||||
|
||||
}, (error) => {
|
||||
this.NotificationHolderService.notificationList[i].read = true;
|
||||
// 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]));
|
||||
} else if (item.service === "accoes") {
|
||||
if (item.service === "accoes" && item.idObject === "accao") {
|
||||
this.zone.run(() => this.router.navigate(['/home/publications', item.idObject]));
|
||||
this.deleteNotification(index);
|
||||
}
|
||||
else if (Service === "accoes" && Object === "publicacao") {
|
||||
this.zone.run(() => this.router.navigate(['/home/publications/view-publications', FolderId, IdObject]));
|
||||
else if (item.service === "accoes" && item.idObject === "publicacao") {
|
||||
this.zone.run(() => this.router.navigate(['/home/publications/view-publications', item.folderId, item.idObject]));
|
||||
this.deleteNotification(index);
|
||||
}
|
||||
|
||||
} else if (Service === "chat") {
|
||||
} else if (item.service === "chat") {
|
||||
|
||||
let navigationExtras: NavigationExtras = { queryParams: { "roomId": IdObject, } };
|
||||
let navigationExtras: NavigationExtras = { queryParams: { "roomId": item.idObject, } };
|
||||
|
||||
this.zone.run(() => this.router.navigate(['/home/chat']));
|
||||
|
||||
@@ -346,18 +363,18 @@ export class ProfilePage implements OnInit {
|
||||
this.deleteNotification(index);
|
||||
} else {
|
||||
|
||||
console.log({Service, Object, IdObject, FolderId})
|
||||
console.log({service:item.service, Object, IdObject:item.idObject, FolderId:item.folderId})
|
||||
|
||||
tracing.setAttribute('notification.route', 'false')
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
tracing.setAttribute('parameters', JSON.stringify({Service, Object, IdObject, FolderId}))
|
||||
tracing.setAttribute('parameters', JSON.stringify({Service:item.service, Object, IdObject:item.idObject, FolderId:item.folderId}))
|
||||
}
|
||||
|
||||
} catch(error) {
|
||||
console.log({Service, Object, IdObject, FolderId})
|
||||
console.log({service:item.service, Object, IdObject:item.idObject, FolderId: item.folderId})
|
||||
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
tracing.setAttribute('parameters', JSON.stringify({Service, Object, IdObject, FolderId}))
|
||||
tracing.setAttribute('parameters', JSON.stringify({service:item.service, Object, IdObject:item.idObject, FolderId:item.folderId}))
|
||||
tracing.setAttribute('error', JSON.stringify(error))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user