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
+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) {