From 11587cc944ab205b6f03aa1e1af4d43fcd92c509 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Thu, 27 Jun 2024 16:53:45 +0100 Subject: [PATCH] ITOTEAM-523 notification status --- src/app/modals/profile/profile.page.html | 39 +++-- src/app/modals/profile/profile.page.scss | 21 +-- src/app/modals/profile/profile.page.ts | 141 ++++++++++-------- .../async/changes/notificationListChange.ts | 37 +++++ ...firebase-push-notification.service.spec.ts | 16 ++ .../firebase-push-notification.service.ts | 80 ++++++++++ .../local-notification.service.spec.ts | 16 ++ .../datasource/local-notification.service.ts | 86 +++++++++++ .../remote-notification.service.spec.ts | 16 ++ .../datasource/remote-notification.service.ts | 29 ++++ .../data/dto/NotificationInputDTO.ts | 9 ++ .../data/dto/NotificationOutputDTO.ts | 31 ++++ .../data/infra/db/notification.db.ts | 25 ++++ .../notification-repository.service.spec.ts | 16 ++ .../data/notification-repository.service.ts | 83 +++++++++++ .../domain/mapper/notificationListMapper.ts | 21 +++ src/app/pages/agenda/agenda.page.html | 43 ++++-- src/app/pages/agenda/agenda.page.ts | 18 +++ src/app/services/agenda/list-box.service.ts | 36 ++++- src/app/services/http.service.ts | 10 ++ .../notification/notifications.service.ts | 3 + src/app/services/notifications.service.ts | 9 +- version/git-version.ts | 12 +- 23 files changed, 686 insertions(+), 111 deletions(-) create mode 100644 src/app/module/notification/data/async/changes/notificationListChange.ts create mode 100644 src/app/module/notification/data/datasource/firebase-push-notification.service.spec.ts create mode 100644 src/app/module/notification/data/datasource/firebase-push-notification.service.ts create mode 100644 src/app/module/notification/data/datasource/local-notification.service.spec.ts create mode 100644 src/app/module/notification/data/datasource/local-notification.service.ts create mode 100644 src/app/module/notification/data/datasource/remote-notification.service.spec.ts create mode 100644 src/app/module/notification/data/datasource/remote-notification.service.ts create mode 100644 src/app/module/notification/data/dto/NotificationInputDTO.ts create mode 100644 src/app/module/notification/data/dto/NotificationOutputDTO.ts create mode 100644 src/app/module/notification/data/infra/db/notification.db.ts create mode 100644 src/app/module/notification/data/notification-repository.service.spec.ts create mode 100644 src/app/module/notification/data/notification-repository.service.ts create mode 100644 src/app/module/notification/domain/mapper/notificationListMapper.ts diff --git a/src/app/modals/profile/profile.page.html b/src/app/modals/profile/profile.page.html index ea9778bcf..81b0206d2 100644 --- a/src/app/modals/profile/profile.page.html +++ b/src/app/modals/profile/profile.page.html @@ -40,7 +40,7 @@
- +
{{SessionStore.user.FullName}}
{{eventService.getCalendarOwnNameByCalendarId(event.event.CalendarId)}}
diff --git a/src/app/pages/agenda/agenda.page.ts b/src/app/pages/agenda/agenda.page.ts index 79fe7e5aa..aa870b0ec 100644 --- a/src/app/pages/agenda/agenda.page.ts +++ b/src/app/pages/agenda/agenda.page.ts @@ -1254,6 +1254,24 @@ export class AgendaPage implements OnInit { } + + diffHours(date1Str: string, date2Str: string) { + + // Convert string dates to Date objects + const date1: any = new Date(date1Str); + const date2: any = new Date(date2Str); + + date1.setHours(0, 0, 0, 0); // Set hours, minutes, seconds, and milliseconds to 0 + + // Calculate the difference in milliseconds + const timeDifferenceMs = date2 - date1; + + // Convert difference to hours + const hoursDifference = timeDifferenceMs / (1000 * 60 * 60); + + return hoursDifference + } + shoeEventDay(events: any[]) { if (this.segment == 'Combinado') { diff --git a/src/app/services/agenda/list-box.service.ts b/src/app/services/agenda/list-box.service.ts index 16791d8f1..d88e1f0f1 100644 --- a/src/app/services/agenda/list-box.service.ts +++ b/src/app/services/agenda/list-box.service.ts @@ -135,7 +135,7 @@ export class ListBoxService { if (diffDays >= 1) { - const StartEvent = this.transForm(event, {startMany: true, endMany: false, middle: false}) + const StartEvent = this.transForm(event, {startMany: true, endMany: false, middle: false, hasMany: true}) if(this.CanPush(event, selectedDate) && (new Date(event.start)).getTime() >= cloneSelectedDate.getTime()) { days[day].push(StartEvent); this.push(StartEvent, year) @@ -164,14 +164,14 @@ export class ListBoxService { startDate.getMonth() != endDate.getMonth() || startDate.getDate() != endDate.getDate())) { // last push - const EndEvent = this.transForm(cloneEvent, {startMany: false, endMany: true, middle: false}) + const EndEvent = this.transForm(cloneEvent, {startMany: false, endMany: true, middle: false, hasMany: true}) if(this.CanPush(cloneEvent, selectedDate) && cloneEvent.start.getTime() >= cloneSelectedDate.getTime()) { days[otherDays].push(EndEvent) ; this.push(EndEvent, year) } } else { - const EndEvent = this.transForm(cloneEvent, {startMany: false,endMany: true, middle: true}) + const EndEvent = this.transForm(cloneEvent, {startMany: false,endMany: false, middle: true, hasMany: true}) if(this.CanPush(cloneEvent, selectedDate) && cloneEvent.start.getTime() >= cloneSelectedDate.getTime()) { days[otherDays].push(EndEvent) ; this.push(EndEvent, year) } else { @@ -191,11 +191,11 @@ export class ListBoxService { } } else { - if(this.CanPush(event, selectedDate)) { days[day].push(event) ; this.push(event, year) } } } else { + event['sameDay'] = true if(this.CanPush(event, selectedDate) && diffDays != 2) { days[day].push(event) ; this.push(event, year) } } @@ -306,9 +306,10 @@ export class ListBoxService { return events; } - transForm(event: CustomCalendarEvent, {startMany, endMany, middle}) { + transForm(event: CustomCalendarEvent, {startMany, endMany, middle, hasMany = false}) { let daysLeft = this.daysToEndWithJS(event.start, event.end); + let eventTotalDuration = this.daysToEndWithJS(event.event.StartDate, event.event.EndDate); return Object.assign({}, { start: event.start, @@ -325,6 +326,9 @@ export class ListBoxService { CalendarId: event.event.CalendarId, daysLeft }, + eventTotalDuration, + hasMany, + duration: this.duration(event.start, event.event.EndDate), daysLeft, Subject: event.event.Subject, startMany: startMany, @@ -341,6 +345,8 @@ export class ListBoxService { const startDate: any = new Date(startDateStr); const endDate: any = new Date(endDateStr); + startDate.setHours(0, 0, 0, 0); // Set hours, minutes, seconds, and milliseconds to 0 + endDate.setHours(0, 0, 0, 0); // Set hours, minutes, seconds, and milliseconds to 0 // Calculate the difference in milliseconds between the two dates const differenceMs = Math.abs(endDate - startDate); @@ -355,6 +361,26 @@ export class ListBoxService { } + + duration(date1Str, date2Str) { + + // Convert string dates to Date objects + const date1: any = new Date(date1Str); + const date2: any = new Date(date2Str); + + // Calculate the difference in milliseconds + const timeDifferenceMs = date2 - date1; + + // Convert difference to days, hours, and minutes + const totalMinutes = Math.floor(timeDifferenceMs / (1000 * 60)); + const days = Math.floor(totalMinutes / (60 * 24)); + const hours = Math.floor((totalMinutes % (60 * 24)) / 60); + const minutes = totalMinutes % 60; + + return `${days}d` + } + + transformObjectKeyOrder(originalObject, keyOrder) { const transformedObject = {}; diff --git a/src/app/services/http.service.ts b/src/app/services/http.service.ts index 0ae0b7175..50634d4fb 100644 --- a/src/app/services/http.service.ts +++ b/src/app/services/http.service.ts @@ -62,6 +62,16 @@ export class HttpService { return err(e as HttpErrorResponse) } } + + + async patch(url: string, body ={}): Promise> { + try { + const result = await this.http.patch(url, body).toPromise(); + return ok(result as T); + } catch (e) { + return err(e as HttpErrorResponse); + } + } } diff --git a/src/app/services/notification/notifications.service.ts b/src/app/services/notification/notifications.service.ts index cad672b6c..97e86d1fe 100644 --- a/src/app/services/notification/notifications.service.ts +++ b/src/app/services/notification/notifications.service.ts @@ -6,6 +6,8 @@ import { environment } from 'src/environments/environment'; import { NotificationsEndsPointsService } from './notifications-ends-points.service' import { AngularFireMessaging } from '@angular/fire/messaging'; import { NavigationExtras, Router } from '@angular/router'; +import { NotificationRepositoryService } from 'src/app/module/notification/data/notification-repository.service' + @Injectable({ providedIn: 'root' }) @@ -20,6 +22,7 @@ export class NotificationsService { private afMessaging: AngularFireMessaging, private router: Router, private zone: NgZone, + private NotificationRepositoryService: NotificationRepositoryService ) { } diff --git a/src/app/services/notifications.service.ts b/src/app/services/notifications.service.ts index 65e828e8d..2d93f52b1 100644 --- a/src/app/services/notifications.service.ts +++ b/src/app/services/notifications.service.ts @@ -20,7 +20,7 @@ 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'; - +import { NotificationRepositoryService } from 'src/app/module/notification/data/notification-repository.service' const notificationDataSchema = z.object({ Service: z.string(), IdObject: z.string().optional(), @@ -69,10 +69,11 @@ export class NotificationsService { private zone: NgZone, private eventtrigger: EventTrigger, private afMessaging: AngularFireMessaging, - public NotificationHolderService: NotificationHolderService) { + public NotificationHolderService: NotificationHolderService, + private NotificationRepositoryService: NotificationRepositoryService) { - this.onReciveForeground(); - this.onReciveBackground(); + // this.onReciveForeground(); + // this.onReciveBackground(); } diff --git a/version/git-version.ts b/version/git-version.ts index 651741ac3..ad37c544b 100644 --- a/version/git-version.ts +++ b/version/git-version.ts @@ -1,11 +1,11 @@ export let versionData = { - "shortSHA": "02891dbb9", - "SHA": "02891dbb9a9d1123f7cd0ca2414fd6014599aec1", + "shortSHA": "78c13d1bf", + "SHA": "78c13d1bfb0b5e24a79a101990ba73e50e831107", "branch": "feature/agenda-api-peter", "lastCommitAuthor": "'Peter Maquiran'", - "lastCommitTime": "'Wed Jun 26 10:11:02 2024 +0100'", - "lastCommitMessage": "ITOTEAM-530 Inform the user how many days are left until the end of the wind for each selected day", - "lastCommitNumber": "5843", - "changeStatus": "On branch feature/agenda-api-peter\nYour branch is ahead of 'origin/feature/agenda-api-peter' by 6 commits.\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/models/entiry/agenda/eventList.ts\n\tmodified: src/app/models/search-document.ts\n\tmodified: src/app/pages/search/search.page.html\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/EventListMapper.ts\n\tnew file: src/app/services/Repositorys/Agenda/mapper/EventSearchMapper.ts\n\tmodified: src/app/services/Repositorys/Agenda/mapper/eventToApproveListMapper.ts\n\tmodified: src/app/services/Repositorys/Agenda/model/eventListDTOOutput.ts\n\tnew file: src/app/services/Repositorys/Agenda/model/eventSearchOutputDTO.ts\n\tmodified: src/app/services/http.service.ts\n\tmodified: version/git-version.ts", + "lastCommitTime": "'Wed Jun 26 13:45:25 2024 +0100'", + "lastCommitMessage": "ITOTEAM-609 search event>", + "lastCommitNumber": "5844", + "changeStatus": "On branch feature/agenda-api-peter\nYour branch is ahead of 'origin/feature/agenda-api-peter' by 7 commits.\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\tnew file: src/app/module/notification/data/async/changes/notificationListChange.ts\n\tnew file: src/app/module/notification/data/datasource/firebase-push-notification.service.spec.ts\n\tnew file: src/app/module/notification/data/datasource/firebase-push-notification.service.ts\n\tnew file: src/app/module/notification/data/datasource/local-notification.service.spec.ts\n\tnew file: src/app/module/notification/data/datasource/local-notification.service.ts\n\tnew file: src/app/module/notification/data/datasource/remote-notification.service.spec.ts\n\tnew file: src/app/module/notification/data/datasource/remote-notification.service.ts\n\tnew file: src/app/module/notification/data/dto/NotificationInputDTO.ts\n\tnew file: src/app/module/notification/data/dto/NotificationOutputDTO.ts\n\tnew file: src/app/module/notification/data/infra/db/notification.db.ts\n\tnew file: src/app/module/notification/data/notification-repository.service.spec.ts\n\tnew file: src/app/module/notification/data/notification-repository.service.ts\n\tnew file: src/app/module/notification/domain/mapper/notificationListMapper.ts\n\tmodified: src/app/pages/agenda/agenda.page.html\n\tmodified: src/app/pages/agenda/agenda.page.ts\n\tmodified: src/app/services/agenda/list-box.service.ts\n\tmodified: src/app/services/http.service.ts\n\tmodified: src/app/services/notification/notifications.service.ts\n\tmodified: src/app/services/notifications.service.ts", "changeAuthor": "peter.maquiran" } \ No newline at end of file