ITOTEAM-523 notification status

This commit is contained in:
Peter Maquiran
2024-06-27 16:53:45 +01:00
parent 78c13d1bfb
commit 11587cc944
23 changed files with 686 additions and 111 deletions
+23 -16
View File
@@ -40,7 +40,7 @@
<div class="d-flex align-center flex-column">
<div *ngIf="profilePicture == ''">
<img
<img
class="profile-pic" src="assets/images/theme/gov/icons-profile.svg">
<!-- <img *ngIf="SessionStore.user.RoleDescription == 'Presidente da República' " class="profile-pic"
@@ -55,7 +55,7 @@
<img class="profile-pic"
src={{profilePicture}}>
</div>
<!-- <ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="profile-pic"
src="assets/images/icons-default-profile.svg"></ion-icon>
@@ -93,25 +93,32 @@
<div class="notifications-content height-100">
<ion-list>
<ion-list *ngIf="(notificationList$ | async) as notificationList">
<div class="item cursor-pointer ion-no-padding ion-no-margin" lines="none"
*ngFor="let item of NotificationHolderService.notificationList; let i = index">
*ngFor="let item of notificationList; let i = index">
<div *ngIf="item.status==false" class="item-conten1 item-conten-{{item.service}}-{{item.typeAgenda}}-{{item.role}}" (click)="notificatinsRoutes(item.index, item)">
<div *ngIf="item.read == false" class="item-conten-{{item.Service}}-{{item.TypeAgenda}}-{{item.Role}}" (click)="notificatinsRoutes(item.index,item.Service,item.Object,item.IdObject,item.FolderId,i)">
<div class="notification-item">
<img class="notification-icon" slot="end" *ngIf = "item.Service == 'agenda'" src="assets/images/icons-default-agenda.svg" >
<img class="notification-icon" slot="end" *ngIf = "item.Service == 'gabinete-digital'" src="assets/images/icons-correspondencias.svg" >
<img class="notification-icon" slot="end" *ngIf = "item.Service == 'accoes'" src="assets/images/icons-nav-accoes-active.svg" >
<img class="notification-icon" slot="end" *ngIf = "item.Service == 'chat'" src="assets/images/icons-nav-agenda-active.svg" >
<img class="notification-icon" slot="end" *ngIf = "item.service == 'agenda'" src="assets/images/icons-default-agenda.svg" >
<img class="notification-icon" slot="end" *ngIf = "item.service == 'gabinete-digital'" src="assets/images/icons-correspondencias.svg" >
<img class="notification-icon" slot="end" *ngIf = "item.service == 'accoes'" src="assets/images/icons-nav-accoes-active.svg" >
<img class="notification-icon" slot="end" *ngIf = "item.service == 'chat'" src="assets/images/icons-nav-agenda-active.svg" >
</div>
<div class="approve-event-time">
<p *ngIf = "item.Service == 'agenda'">{{item.dateInit}}</p>
<p *ngIf = "item.Service == 'agenda'">{{item.dateEnd}}</p>
<div class="approve-event-time" *ngIf = "item.service == 'agenda'">
<div *ngIf="isValidDate(item.dateInit)">
<p *ngIf="toDateString(item.dateInit) == toDateString(item.dateEnd)">{{item.dateInit | date: 'HH:mm'}} </p>
<p *ngIf="toDateString(item.dateInit) == toDateString(item.dateEnd)">{{item.dateEnd | date: 'HH:mm'}}</p>
<p *ngIf="toDateString(item.dateInit) != toDateString(item.dateEnd)">{{item.dateInit | date: 'd/M/yy' }}</p>
<p *ngIf="toDateString(item.dateInit) != toDateString(item.dateEnd)">{{ item.dateEnd | date: 'dd/M/yy'}} </p>
</div>
</div>
<div class="approve-event-detail">
<h3 id="profile-title">{{item.title}}</h3>
<p *ngIf = "item.Service == 'agenda'">{{item.Location}}</p>
<p id="profile-title" *ngIf = "item.Service != 'agenda'">{{item.body}}</p>
<p *ngIf = "item.service == 'agenda'">{{item.location}}</p>
<p id="profile-title" *ngIf = "item.service != 'agenda'">{{item.body}}</p>
</div>
</div>
@@ -119,7 +126,7 @@
<div class="notification-item">
<img class="notification-icon-error" slot="end" src="assets/images/exclamation_mark.svg" >
</div>
<div class="approve-event-detail-error">
<p id="profile-title-error">Possivelmente esta tarefa não foi criada ou já foi executada. Deseja dar a notificação como lida?</p>
</div>
@@ -143,4 +150,4 @@
</div>
</ion-content>
</ion-content>
+12 -9
View File
@@ -136,16 +136,19 @@ ion-list {
.notifications-content {
padding: 0px 20px;
.item {
border-radius: 15px;
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.07);
border: solid 1px #e9e9e9;
background-color: var(--white);
margin: 0 auto;
padding: 10px;
margin-bottom: 10px;
color: #000;
overflow: hidden;
.item-conten1{
border-radius: 15px;
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.07);
border: solid 1px #e9e9e9;
background-color: var(--white);
margin: 0 auto;
padding: 10px;
margin-bottom: 10px;
color: #000;
overflow: hidden;
}
.notification-item {
width: fit-content;
float: left;
+79 -62
View File
@@ -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))
}