diff --git a/src/app/modals/profile/profile.page.html b/src/app/modals/profile/profile.page.html index 95d4b97f8..2891b20f8 100644 --- a/src/app/modals/profile/profile.page.html +++ b/src/app/modals/profile/profile.page.html @@ -94,55 +94,59 @@
-
-
+
+
-
- - - - +
+ + + + +
+
+
+

{{item.dateInit | date: 'HH:mm'}}

+

{{item.dateEnd | date: 'HH:mm'}}

+ +

{{item.dateInit | date: 'd/M/yy' }}

+

{{ item.dateEnd | date: 'dd/M/yy'}}

+
+ +
+
+

{{item.title}}

+

{{item.location}}

+

{{item.body}}

+
-
-
-

{{item.dateInit | date: 'HH:mm'}}

-

{{item.dateEnd | date: 'HH:mm'}}

-

{{item.dateInit | date: 'd/M/yy' }}

-

{{ item.dateEnd | date: 'dd/M/yy'}}

+
+
+ +
+ +
+

Possivelmente esta tarefa não foi criada ou já foi executada. Deseja dar a notificação como lida?

+
+ +
+ + + +
-
-

{{item.title}}

-

{{item.location}}

-

{{item.body}}

-
-
-
- -
-
-

Possivelmente esta tarefa não foi criada ou já foi executada. Deseja dar a notificação como lida?

-
- -
- - - - -
- -
diff --git a/src/app/modals/profile/profile.page.scss b/src/app/modals/profile/profile.page.scss index d92e2f2e5..29909cc5f 100644 --- a/src/app/modals/profile/profile.page.scss +++ b/src/app/modals/profile/profile.page.scss @@ -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; diff --git a/src/app/modals/profile/profile.page.ts b/src/app/modals/profile/profile.page.ts index cee117a73..abe076227 100644 --- a/src/app/modals/profile/profile.page.ts +++ b/src/app/modals/profile/profile.page.ts @@ -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) { diff --git a/src/app/models/search-document.ts b/src/app/models/search-document.ts index 0d7c4e76a..f913032e7 100644 --- a/src/app/models/search-document.ts +++ b/src/app/models/search-document.ts @@ -9,6 +9,7 @@ export class SearchList { docId: number; subject: string; applicationId: number + eventStatus?: number } export class SearchList_v2 { diff --git a/src/app/module/notification/data/datasource/local-notification.service.ts b/src/app/module/notification/data/datasource/local-notification.service.ts index d334a7ad1..7f1a24e6f 100644 --- a/src/app/module/notification/data/datasource/local-notification.service.ts +++ b/src/app/module/notification/data/datasource/local-notification.service.ts @@ -36,10 +36,18 @@ export class LocalNotificationService { async updateNotifications(data: NotificationTable[]) { // db.eve try { - const result = await NotificationDataSource.notification.bulkUpdate(data.map(e => ({ - key: e.notificationId, - changes: { status: e.status } - }))) + const result = await NotificationDataSource.notification.bulkDelete(data.map(e => e.notificationId)) + return ok(result) + } catch (e) { + return err(false) + } + } + + + async deleteNotifications(data: NotificationTable[]) { + // db.eve + try { + const result = await NotificationDataSource.notification.bulkDelete(data.map(e => e.notificationId)) return ok(result) } catch (e) { return err(false) @@ -58,6 +66,46 @@ export class LocalNotificationService { return result.success; }); + // Add valid notifications to the database + if (validNotifications.length > 0) { + + } else { + console.log('No valid notifications to add.'); + } + + console.log({failed}) + + return ok(failed) + } + + async clearAndAddRecords(notifications: NotificationTable[]) { + try { + await NotificationDataSource.transaction('rw', NotificationDataSource.notification, async () => { + // Clear existing records from myTable + await NotificationDataSource.notification.clear(); + + await NotificationDataSource.notification.bulkAdd(notifications); + + }); + console.log('Clear and add operations completed within transaction.'); + } catch (error) { + console.error('Error performing transaction:', error, notifications); + } + } + + + async addRemove(notifications: NotificationTable[]) { + // Validate each notification + const failed = [] + const validNotifications = notifications.filter(notification => { + const result = NotificationTableSchema.safeParse(notification); + + if(!result.success) { + failed.push(notification) + } + return result.success; + }); + // Add valid notifications to the database if (validNotifications.length > 0) { await NotificationDataSource.notification.bulkAdd(validNotifications); @@ -73,6 +121,19 @@ export class LocalNotificationService { getNotificationLive() { return from(liveQuery( () => { return NotificationDataSource.notification.orderBy('createdAt').reverse().toArray() + .then(notifications => { + return notifications.filter(notification => notification.status === false) + }) + })) + } + + getNotificationLiveCount() { + return from(liveQuery( () => { + return NotificationDataSource.notification + .toArray() + .then(notifications => { + return notifications.filter(notification => notification.status === false).length + }) })) } diff --git a/src/app/module/notification/data/infra/db/notification.db.ts b/src/app/module/notification/data/infra/db/notification.db.ts index 7678182a2..bcda6fe24 100644 --- a/src/app/module/notification/data/infra/db/notification.db.ts +++ b/src/app/module/notification/data/infra/db/notification.db.ts @@ -21,5 +21,5 @@ export const NotificationDataSource = new Dexie('NotificationDataSource') as Dex }; NotificationDataSource.version(1).stores({ - notification: 'notificationId, title, service, object, idObject, folderId, dateInit, dateEnd, location, createdAt' + notification: 'notificationId, title, service, object, idObject, folderId, dateInit, dateEnd, location, createdAt, status' }); diff --git a/src/app/module/notification/data/notification-repository.service.ts b/src/app/module/notification/data/notification-repository.service.ts index e7db1334b..c7d380a5e 100644 --- a/src/app/module/notification/data/notification-repository.service.ts +++ b/src/app/module/notification/data/notification-repository.service.ts @@ -5,7 +5,6 @@ import { FirebasePushNotificationService } from './datasource/firebase-push-noti import { LocalNotificationService } from './datasource/local-notification.service' import { SessionStore } from 'src/app/store/session.service'; import { NotificationListMapper } from '../domain/mapper/notificationListMapper'; -import { NotificationListChanges } from './async/changes/notificationListChange'; import { NotificationTable } from './infra/db/notification.db'; @Injectable({ @@ -27,32 +26,33 @@ export class NotificationRepositoryService { }) - this.init() + if(SessionStore.user.UserId) { + this.init() + } + } async init() { const result = await this.getNotification({ PageNumber: "1", - PageSize: "50", + PageSize: "100", userId: SessionStore.user.UserId.toString() }) if(result.isOk()) { - console.log('notification-list', result.value.data.result) + // console.log('notification-list', result.value.data.result) const serverListFiltered = result.value.data.result.filter( e => e.body != 'Foi editado um evento na vossa agenda' && e.body != 'Foi apagado um evento na vossa agenda') result.value.data.result = serverListFiltered if(result.value.data.result.length >= 1) { - const localList = await this.LocalNotificationService.getNotification() - const serverList = NotificationListMapper(result.value) - const { insert, update } = NotificationListChanges(localList, serverList) + // const localList = await this.LocalNotificationService.getNotification() + // const serverList = NotificationListMapper(result.value) + // const { insert, update, remove } = NotificationListChanges(localList, serverList) - console.log({insert, update}) - this.LocalNotificationService.addNotifications(insert) - this.LocalNotificationService.updateNotifications(update) - // this.LocalNotificationService.addNotifications. + this.LocalNotificationService.clearAndAddRecords(NotificationListMapper(result.value)) + } else { this.LocalNotificationService.clear() } @@ -68,6 +68,10 @@ export class NotificationRepositoryService { return this.LocalNotificationService.getNotificationLive() } + getNotificationLiveCount() { + return this.LocalNotificationService.getNotificationLiveCount() + } + async notificationStatus(item: NotificationTable) { await this.RemoteNotificationService.notificationStatus(item.notificationId) item.status = true @@ -92,4 +96,9 @@ export class NotificationRepositoryService { this.init() return } + + clearData() { + return this.LocalNotificationService.clear() + } + } diff --git a/src/app/pages/login/login.page.ts b/src/app/pages/login/login.page.ts index 66c33ff08..4213e277b 100644 --- a/src/app/pages/login/login.page.ts +++ b/src/app/pages/login/login.page.ts @@ -24,7 +24,7 @@ import { StorageService } from 'src/app/services/storage.service'; import { DeviceService } from 'src/app/services/device.service' import { Cy } from 'cypress/enum' import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service'; - +import { NotificationRepositoryService } from 'src/app/module/notification/data/notification-repository.service' @Component({ selector: 'app-login', templateUrl: './login.page.html', @@ -66,6 +66,7 @@ export class LoginPage implements OnInit { private NotificationHolderService: NotificationHolderService, private DeviceService: DeviceService, public AgendaDataRepositoryService: AgendaDataRepositoryService, + private NotificationRepositoryService: NotificationRepositoryService ) { } ngOnInit() { } @@ -161,6 +162,8 @@ export class LoginPage implements OnInit { await this.authService.loginToChatWs(); this.ChatService.setheader() + this.NotificationRepositoryService.init() + } catch(error) { console.log("faild to clear chat") } @@ -178,6 +181,8 @@ export class LoginPage implements OnInit { } else { + await this.NotificationRepositoryService.clearData() + await this.AgendaDataRepositoryService.clearSharedCalendar() this.RochetChatConnectorService.logout(); this.clearStoreService.clear(); @@ -191,6 +196,7 @@ export class LoginPage implements OnInit { this.storage.clear(); await this.authService.SetSession(attempt, this.userattempt); + this.NotificationRepositoryService.init() /* CPSession.save(data) */ this.changeProfileService.run(); diff --git a/src/app/pages/search/search.page.ts b/src/app/pages/search/search.page.ts index 505ea4a0f..4757b5b5f 100644 --- a/src/app/pages/search/search.page.ts +++ b/src/app/pages/search/search.page.ts @@ -23,6 +23,7 @@ import { SessionStore } from 'src/app/store/session.service'; import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer'; import { isHttpError } from 'src/app/services/http.service'; import { ToastService } from 'src/app/services/toast.service'; +import { EEventFilterStatus } from 'src/app/services/Repositorys/Agenda/model/enums'; const CUSTOM_DATE_FORMATS: NgxMatDateFormats = { parse: { @@ -388,7 +389,7 @@ export class SearchPage implements OnInit { } if (this.type == "Agenda") { - + this.showLoader = true if (this.searchSubject.trim() == "" && searchDocumentDate == null && searchDocumentDateEnd == null && this.searchSenderId == null && this.searchOrganicEntiryCode == null && this.searchDocTypeId == null) { @@ -397,7 +398,11 @@ export class SearchPage implements OnInit { } else { - const searchEvents = await this.agendaDataRepository.searchEvent({value: this.searchSubject.trim() }, tracing) + const searchEvents = await this.agendaDataRepository.searchEvent({ + value: this.searchSubject.trim(), + status: EEventFilterStatus.AllToCommunicate + + }, tracing) if(searchEvents.isOk()) { this.showDocuments = true; @@ -468,6 +473,8 @@ export class SearchPage implements OnInit { // // console.log(error) // }); } + + this.showLoader = false } else if (this.type == "AccoesPresidenciais & ArquivoDespachoElect" && this.eventAgenda == true) { this.showLoader = true; diff --git a/src/app/services/Repositorys/Agenda/agenda-data-repository.service.ts b/src/app/services/Repositorys/Agenda/agenda-data-repository.service.ts index 8475a61e8..89920a258 100644 --- a/src/app/services/Repositorys/Agenda/agenda-data-repository.service.ts +++ b/src/app/services/Repositorys/Agenda/agenda-data-repository.service.ts @@ -108,7 +108,7 @@ export class AgendaDataRepositoryService { } - async searchEvent(queryParameters: {value}, tracing?: TracingType) { + async searchEvent(queryParameters: {value, status}, tracing?: TracingType) { const result = await this.agendaDataService.searchEvent(queryParameters) return result.map( response => { APINODReturn(EventListDataOutputDTOSchema, response, 'get/Events', tracing) diff --git a/src/app/services/Repositorys/Agenda/agenda-data.service.ts b/src/app/services/Repositorys/Agenda/agenda-data.service.ts index ccc444f9c..0b6233d7a 100644 --- a/src/app/services/Repositorys/Agenda/agenda-data.service.ts +++ b/src/app/services/Repositorys/Agenda/agenda-data.service.ts @@ -74,7 +74,7 @@ export class AgendaDataService { return this.http.get(`${this.baseUrl}/Events`, { params }); } - searchEvent(queryParameter: {value}) { + searchEvent(queryParameter: {value, status}) { return this.httpService.get(`${this.baseUrl}/Events`, queryParameter); } diff --git a/src/app/services/Repositorys/Agenda/mapper/EventDetailsMapper.ts b/src/app/services/Repositorys/Agenda/mapper/EventDetailsMapper.ts index 5c5e1e317..e7d5cfa89 100644 --- a/src/app/services/Repositorys/Agenda/mapper/EventDetailsMapper.ts +++ b/src/app/services/Repositorys/Agenda/mapper/EventDetailsMapper.ts @@ -82,6 +82,7 @@ export class EventMapper { // "RoleDescription": null, // "RoleId": 0 })), + "Status": status, "IsMeeting": category, "IsRecurring": dto.isRecurring, "IsAllDayEvent": dto.isAllDayEvent, diff --git a/src/app/services/Repositorys/Agenda/mapper/EventToApproveDetailsMapper.ts b/src/app/services/Repositorys/Agenda/mapper/EventToApproveDetailsMapper.ts index cb58b86d3..a7c4f47b1 100644 --- a/src/app/services/Repositorys/Agenda/mapper/EventToApproveDetailsMapper.ts +++ b/src/app/services/Repositorys/Agenda/mapper/EventToApproveDetailsMapper.ts @@ -79,6 +79,13 @@ export class EventToApproveDetailsMapper { + let status; + if(dto.status == EEventStatus.Pending) { + status = 'Pending' + } else if(dto.status == EEventStatus.Revision) { + status = 'Revision' + } + return { "owner": dto.owner, "serialNumber": dto.id, @@ -119,7 +126,7 @@ export class EventToApproveDetailsMapper { // "MDName": "Eduardo Vilarinho", // "MDEmail": "evilarinho@gabinetedigital.local", // "OriginatorComments": "", - "Status": "Active", + "Status": status, "TimeZone": getTextInsideParentheses(new Date(dto.startDate)+ ''), "Agenda": category , "EventType": dto.type, diff --git a/src/app/services/notification/notifications.service.ts b/src/app/services/notification/notifications.service.ts index 97e86d1fe..0406afa44 100644 --- a/src/app/services/notification/notifications.service.ts +++ b/src/app/services/notification/notifications.service.ts @@ -176,7 +176,7 @@ export class NotificationsService { notificatinsRoutes = (notification) => { - console.log('BACK BACK',notification) + console.log('BACK BACK 32',notification) if (notification.notification.data.Service === "agenda" && notification.notification.data.IdObject.length > 10) { diff --git a/src/app/services/notifications.service.ts b/src/app/services/notifications.service.ts index 2d93f52b1..c575bd7c0 100644 --- a/src/app/services/notifications.service.ts +++ b/src/app/services/notifications.service.ts @@ -14,9 +14,7 @@ import { notificationObject } from '../models/notifications'; import { Capacitor } from '@capacitor/core'; import { AngularFireMessaging } from '@angular/fire/messaging'; import { NotificationHolderService } from 'src/app/store/notification-holder.service'; -import { ChatService } from 'src/app/services/chat.service'; import { FCM } from '@capacitor-community/fcm'; -import { ChatSystemService } from './chat/chat-system.service'; import {ChatController} from 'src/app/controller/chat' import { TracingType, XTracer, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer'; import { z } from 'zod'; @@ -73,7 +71,7 @@ export class NotificationsService { private NotificationRepositoryService: NotificationRepositoryService) { // this.onReciveForeground(); - // this.onReciveBackground(); + this.onReciveBackground(); } @@ -363,64 +361,70 @@ export class NotificationsService { } - @XTracer({name:'Notification/notificatinsRoutes', bugPrint: true, module:'notification'}) + @XTracer({name:'phone-notification/notificationRoutes', bugPrint: true, module:'notification'}) notificatinsRoutes (notification, tracing?: TracingType) { try { - console.log('BACK BACK', notification) + console.log('BACK BACK 12', notification) - if (notification.notification.data.Service === "agenda" && notification.notification.data.IdObject.length > 10) { + if (notification.notification.data.service === "agenda" ) { + const data = JSON.parse(notification.notification.data.item) + if(data.status == 1) { + this.zone.run(() => this.router.navigate(['/home/agenda/event-list/approve-event', notification.notification.data.idObject, 'agenda'])); + } else { + this.zone.run(() => this.router.navigate(['/home/agenda', notification.notification.data.idObject, 'agenda'])); + } - this.zone.run(() => this.router.navigate(['/home/agenda', notification.notification.data.IdObject, 'agenda'])); + this.zone.run(() => this.router.navigate(['/home/agenda', notification.notification.data.idObject, 'agenda'])); } - else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "expedientes") { - this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expediente', notification.notification.data.IdObject, 'gabinete-digital'])); + else if (notification.notification.data.service === "gabinete-digital" && notification.notification.data.object === "expedientes") { + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expediente', notification.notification.data.idObject, 'gabinete-digital'])); } - else if (notification.notification.data.Service === "agenda" && notification.notification.data.Object === "event-list") { + else if (notification.notification.data.service === "agenda" && notification.notification.data.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', notification.notification.data.IdObject, 'agenda'])); + this.zone.run(() => this.router.navigate(['/home/agenda/event-list/approve-event', notification.notification.data.idObject, 'agenda'])); - } else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "despachos") { + } else if (notification.notification.data.service === "gabinete-digital" && notification.notification.data.object === "despachos") { - this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos', notification.notification.data.IdObject, 'gabinete-digital'], { replaceUrl: true })); + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos', notification.notification.data.idObject, 'gabinete-digital'], { replaceUrl: true })); } - else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "parecer") { + else if (notification.notification.data.service === "gabinete-digital" && notification.notification.data.object === "parecer") { - this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', notification.notification.data.IdObject, 'gabinete-digital'])); + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', notification.notification.data.idObject, 'gabinete-digital'])); } - else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "deferimento") { + else if (notification.notification.data.service === "gabinete-digital" && notification.notification.data.object === "deferimento") { - this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', notification.notification.data.IdObject, 'gabinete-digital'])); + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', notification.notification.data.idObject, 'gabinete-digital'])); } - else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "despachos-pr") { + else if (notification.notification.data.service === "gabinete-digital" && notification.notification.data.object === "despachos-pr") { - this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos-pr', notification.notification.data.IdObject, 'gabinete-digital'])); + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos-pr', notification.notification.data.idObject, 'gabinete-digital'])); } - else if (notification.notification.data.Service === "accoes" && notification.notification.data.Object === "accao") { - this.zone.run(() => this.router.navigate(['/home/publications', notification.notification.data.IdObject])); + else if (notification.notification.data.service === "accoes" && notification.notification.data.object === "accao") { + this.zone.run(() => this.router.navigate(['/home/publications', notification.notification.data.idObject])); } - else if (notification.notification.data.Service === "accoes" && notification.notification.data.Object === "publicacao") { + else if (notification.notification.data.service === "accoes" && notification.notification.data.object === "publicacao") { this.zone.run(() => this.router.navigate(['/home/publications/view-publications', notification.notification.data.FolderId, notification.data.IdObject])); } - else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "diplomas") { - this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', notification.notification.data.IdObject, 'gabinete-digital'])); + else if (notification.notification.data.service === "gabinete-digital" && notification.notification.data.object === "diplomas") { + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', notification.notification.data.idObject, 'gabinete-digital'])); } - else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "diplomas-assinar") { + else if (notification.notification.data.service === "gabinete-digital" && notification.notification.data.object === "diplomas-assinar") { - this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas-assinar', notification.notification.data.IdObject, 'gabinete-digital'])); + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas-assinar', notification.notification.data.idObject, 'gabinete-digital'])); } - else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "diploma-revisao") { + else if (notification.notification.data.service === "gabinete-digital" && notification.notification.data.object === "diploma-revisao") { - this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', notification.notification.data.IdObject, 'gabinete-digital'])); + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', notification.notification.data.idObject, 'gabinete-digital'])); } - else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "expedientes-pr") { - this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', notification.notification.data.IdObject, 'gabinete-digital'])); - } else if (notification.notification.data.Service === "chat") { + else if (notification.notification.data.service === "gabinete-digital" && notification.notification.data.object === "expedientes-pr") { + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', notification.notification.data.idObject, 'gabinete-digital'])); + } else if (notification.notification.data.service === "chat") { - let navigationExtras: NavigationExtras = { queryParams: { "roomId": notification.notification.data.IdObject, } }; + let navigationExtras: NavigationExtras = { queryParams: { "roomId": notification.notification.data.idObject, } }; if (window.location.search.includes("roomId")) { this.zone.run(() => this.router.navigate(['/home/chat'])); diff --git a/src/app/shared/header/header.page.html b/src/app/shared/header/header.page.html index 7abfa5c56..903326fbf 100644 --- a/src/app/shared/header/header.page.html +++ b/src/app/shared/header/header.page.html @@ -75,9 +75,9 @@ -
-
- {{NotificationHolderService.notificationList.length}}
+
+
+ {{notificationCount}}
@@ -243,9 +243,10 @@
-
-
- {{NotificationHolderService.notificationList.length}}
+
+ +
+ {{notificationCount}}
diff --git a/src/app/shared/header/header.page.ts b/src/app/shared/header/header.page.ts index e378e3218..23c267f04 100644 --- a/src/app/shared/header/header.page.ts +++ b/src/app/shared/header/header.page.ts @@ -19,6 +19,8 @@ import { NotificationHolderService } from 'src/app/store/notification-holder.ser import { HeaderSettingsService } from "src/app/services/header-settings.service" import { PublicationHolderService } from 'src/app/services/publication/publication-holder.service' import { Cy } from 'cypress/enum' +import { NotificationRepositoryService } from 'src/app/module/notification/data/notification-repository.service'; +import { Observable } from 'rxjs'; @Component({ selector: 'app-header', templateUrl: './header.page.html', @@ -56,6 +58,8 @@ export class HeaderPage implements OnInit { Cy = Cy + notificationCount$: Observable + constructor( private router: Router, private modalController: ModalController, @@ -74,8 +78,16 @@ export class HeaderPage implements OnInit { private attachmentService: AttachmentsService, public NotificationHolderService: NotificationHolderService, public HeaderSettingsService: HeaderSettingsService, - public PublicationHolderService: PublicationHolderService + public PublicationHolderService: PublicationHolderService, + private notificationRepositoryService: NotificationRepositoryService ) { + + this.notificationCount$ = this.notificationRepositoryService.getNotificationLiveCount() + + this.notificationCount$.subscribe(count => { + console.log('Notification Count:', count); + }); + this.loggeduser = SessionStore.user; router.events.subscribe((val) => { this.hideSearch(); diff --git a/version/git-version.ts b/version/git-version.ts index b36d767bf..8fddbcf35 100644 --- a/version/git-version.ts +++ b/version/git-version.ts @@ -1,11 +1,11 @@ export let versionData = { - "shortSHA": "11587cc94", - "SHA": "11587cc944ab205b6f03aa1e1af4d43fcd92c509", + "shortSHA": "ac0ead488", + "SHA": "ac0ead488567a67d226beaac56ffd88f7a1d69f1", "branch": "feature/agenda-api-peter", "lastCommitAuthor": "'Peter Maquiran'", - "lastCommitTime": "'Thu Jun 27 16:53:45 2024 +0100'", - "lastCommitMessage": "ITOTEAM-523 notification status", - "lastCommitNumber": "5845", - "changeStatus": "On branch feature/agenda-api-peter\nYour branch is up to date with 'origin/feature/agenda-api-peter'.\n\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/modals/profile/profile.page.html\n\tmodified: src/app/modals/profile/profile.page.scss\n\tmodified: src/app/modals/profile/profile.page.ts\n\tmodified: src/app/module/notification/data/notification-repository.service.ts\n\tmodified: version/git-version.ts", + "lastCommitTime": "'Thu Jun 27 17:43:44 2024 +0100'", + "lastCommitMessage": "nice", + "lastCommitNumber": "5846", + "changeStatus": "On branch feature/agenda-api-peter\nYour branch is ahead of 'origin/feature/agenda-api-peter' by 1 commit.\n (use \"git push\" to publish your local commits)\n\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/modals/profile/profile.page.html\n\tmodified: src/app/modals/profile/profile.page.scss\n\tmodified: src/app/modals/profile/profile.page.ts\n\tmodified: src/app/models/search-document.ts\n\tmodified: src/app/module/notification/data/datasource/local-notification.service.ts\n\tmodified: src/app/module/notification/data/infra/db/notification.db.ts\n\tmodified: src/app/module/notification/data/notification-repository.service.ts\n\tmodified: src/app/pages/login/login.page.ts\n\tmodified: src/app/pages/search/search.page.ts\n\tmodified: src/app/services/Repositorys/Agenda/agenda-data-repository.service.ts\n\tmodified: src/app/services/Repositorys/Agenda/agenda-data.service.ts\n\tmodified: src/app/services/Repositorys/Agenda/mapper/EventDetailsMapper.ts\n\tmodified: src/app/services/Repositorys/Agenda/mapper/EventToApproveDetailsMapper.ts\n\tmodified: src/app/services/notification/notifications.service.ts\n\tmodified: src/app/services/notifications.service.ts\n\tmodified: src/app/shared/header/header.page.html\n\tmodified: src/app/shared/header/header.page.ts", "changeAuthor": "peter.maquiran" } \ No newline at end of file