fix notification

This commit is contained in:
Peter Maquiran
2024-06-28 07:44:43 +01:00
parent ac0ead4885
commit 0281db0d83
18 changed files with 243 additions and 218 deletions
+42 -38
View File
@@ -94,55 +94,59 @@
<div class="notifications-content height-100">
<ion-list *ngIf="(notificationList$ | async) as notificationList">
<div class="item cursor-pointer ion-no-padding ion-no-margin" lines="none"
<div class=" cursor-pointer ion-no-padding ion-no-margin" lines="none"
*ngFor="let item of notificationList; let i = index">
<div *ngIf="item.status==false && objectRead[item.notificationId] != true" class="item-conten1 item-conten-{{item.service}}-{{item.typeAgenda}}-{{item.role}}" (click)="notificatinsRoutes(item.index, item)">
<div *ngIf="item.status==false " class="item">
<div *ngIf="objectRead[item.notificationId] != true" class="item-conten1 item-conten-{{item.service}}-{{item.typeAgenda}}-{{item.role}}" (click)="notificatinsRoutes(item.index, item)">
<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" >
<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" >
</div>
<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>
</div>
</div>
<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 *ngIf="objectRead[item.notificationId] == true" >
<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>
<div class="d-flex mt-10 width-100">
<ion-buttons slot="start" class="buttonSize" >
<button (click)="doNotKeppNotification(item)" class="btn-delete" fill="clear" >
<ion-label style="color:#d30a0a;">Sim</ion-label>
</button>
<button (click)="keppNotification(item)" class="btn-cancel" fill="clear" color="#fff" >
<ion-label>Não</ion-label>
</button>
</ion-buttons>
</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>
</div>
</div>
<div *ngIf="objectRead[item.notificationId] == true" >
<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>
<div class="d-flex mt-10 width-100">
<ion-buttons slot="start" class="buttonSize" >
<button (click)="doNotKeppNotification(item)" class="btn-delete" fill="clear" >
<ion-label style="color:#d30a0a;">Sim</ion-label>
</button>
<button (click)="keppNotification(item)" class="btn-cancel" fill="clear" color="#fff" >
<ion-label>Não</ion-label>
</button>
</ion-buttons>
</div>
</div>
</div>
</ion-list>
+9 -13
View File
@@ -136,19 +136,15 @@ ion-list {
.notifications-content {
padding: 0px 20px;
.item {
.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;
}
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;
+15 -99
View File
@@ -1,16 +1,14 @@
import { Component, OnInit, NgZone } from '@angular/core';
import { NavigationExtras, Router } from '@angular/router';
import { AnimationController, ModalController, Platform } from '@ionic/angular';
import { AnimationController, ModalController } from '@ionic/angular';
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';
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
@@ -19,7 +17,6 @@ import { NotificationRepositoryService } from 'src/app/module/notification/data/
import { Observable } from 'rxjs';
import { NotificationTable } from 'src/app/module/notification/data/infra/db/notification.db';
import { isHttpError } from 'src/app/services/http.service';
import { map, filter } from 'rxjs/operators';
@Component({
selector: 'app-profile',
templateUrl: './profile.page.html',
@@ -58,14 +55,10 @@ export class ProfilePage implements OnInit {
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,
@@ -74,9 +67,6 @@ export class ProfilePage implements OnInit {
private notificationRepositoryService: NotificationRepositoryService
) {
this.notificationList$ = this.notificationRepositoryService.getNotificationLive().pipe(
filter(data => data.some(item => item.status === false))
)
window['e'] = () => {
console.log(
@@ -96,6 +86,12 @@ export class ProfilePage implements OnInit {
this.notificationRepositoryService.init()
this.subscribe()
}
subscribe() {
this.notificationList$ = this.notificationRepositoryService.getNotificationLive()
}
ngOnInit() {
@@ -134,89 +130,6 @@ export class ProfilePage implements OnInit {
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() */;
@@ -229,9 +142,6 @@ export class ProfilePage implements OnInit {
@XTracerAsync({name:'profile/notificationClick', bugPrint: true, module:'notification'})
async notificatinsRoutes (index, item: NotificationTable, tracing?: TracingType) {
console.log({item})
try {
if (item.service === "agenda") {
this.isloading = true
@@ -243,7 +153,13 @@ export class ProfilePage implements OnInit {
if(res.isOk()) {
this.zone.run(() => this.router.navigate(['/home/agenda', item.idObject, 'agenda']));
if(res.value.Status == 'Pending') {
this.zone.run(() => this.router.navigate(['/home/agenda/event-list/approve-event', item.idObject, 'agenda']));
} else {
this.zone.run(() => this.router.navigate(['/home/agenda', item.idObject, 'agenda']));
}
this.deleteNotification(item);
tracing.setAttribute('outcome', 'success')
} else {
@@ -268,7 +184,7 @@ export class ProfilePage implements OnInit {
this.isloading = false
} else if (item.service === "agenda" && item.object === "event-list") {
} else if (item.service === "event-list" || item.object === "event-list") {
this.isloading = true
if(item.idObject) {