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
+31 -5
View File
@@ -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 = {};
+10
View File
@@ -62,6 +62,16 @@ export class HttpService {
return err(e as HttpErrorResponse)
}
}
async patch<T>(url: string, body ={}): Promise<Result<T, HttpErrorResponse>> {
try {
const result = await this.http.patch<T>(url, body).toPromise();
return ok(result as T);
} catch (e) {
return err(e as HttpErrorResponse);
}
}
}
@@ -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
) { }
+5 -4
View File
@@ -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();
}