diff --git a/src/app/classes/booking/booking.ts b/src/app/classes/booking/booking.ts
index 17d2015..e8b1c1e 100644
--- a/src/app/classes/booking/booking.ts
+++ b/src/app/classes/booking/booking.ts
@@ -15,6 +15,7 @@ export class Booking{
bookingStatusEnum: BookingStatusEnum
bookingComment: string
cancellationComment: string
+ isForReview: boolean
constructor(bookingId?: number, serviceman?: Serviceman, consultationPurpose?: ConsultationPurpose,
consultation?: Consultation, bookingSlot?: BookingSlot, formInstances?: FormInstance[], bookingStatusEnum?: BookingStatusEnum,
@@ -28,5 +29,6 @@ export class Booking{
this.bookingStatusEnum = bookingStatusEnum
this.bookingComment = bookingComment
this.cancellationComment = cancellationComment
+ this.isForReview = this.isForReview
}
}
\ No newline at end of file
diff --git a/src/app/classes/notification/notification.spec.ts b/src/app/classes/notification/notification.spec.ts
new file mode 100644
index 0000000..abd8e13
--- /dev/null
+++ b/src/app/classes/notification/notification.spec.ts
@@ -0,0 +1,7 @@
+import { Notification } from './notification';
+
+describe('Notification', () => {
+ it('should create an instance', () => {
+ expect(new Notification()).toBeTruthy();
+ });
+});
diff --git a/src/app/classes/notification/notification.ts b/src/app/classes/notification/notification.ts
new file mode 100644
index 0000000..3575837
--- /dev/null
+++ b/src/app/classes/notification/notification.ts
@@ -0,0 +1,39 @@
+import { NotificationTypeEnum } from '../notificationtype-enum'
+import { Serviceman } from '../serviceman/serviceman'
+
+export class Notification {
+
+ notificationId: number
+ notificationDate: Date
+ title: string
+ message: string
+ isRead: boolean
+ isFetched: boolean
+ serviceman: Serviceman
+ dynamicId: number
+ notificationTypeEnum: NotificationTypeEnum
+
+ constructor(
+ notificationId?: number,
+ notificationDate?: Date,
+ title?: string,
+ message?: string,
+ isRead?: boolean,
+ isFetched?: boolean,
+ serviceman?: Serviceman,
+ dynamicId?: number,
+ notificationTypeEnum?: NotificationTypeEnum
+ ) {
+
+ this.notificationId = notificationId
+ this.notificationDate = notificationDate
+ this.title = title
+ this.message = message
+ this.isRead = isRead
+ this.isFetched = isFetched
+ this.serviceman = serviceman
+ this.dynamicId = dynamicId
+ this.notificationTypeEnum = notificationTypeEnum
+ }
+
+}
diff --git a/src/app/classes/notificationtype-enum.ts b/src/app/classes/notificationtype-enum.ts
new file mode 100644
index 0000000..b2a2109
--- /dev/null
+++ b/src/app/classes/notificationtype-enum.ts
@@ -0,0 +1,6 @@
+export enum NotificationTypeEnum{
+ BOOKING = ('BOOKING'),
+ CONSULTATION = ("CONSULTATION"),
+ FORM = ("FORM"),
+ GENERAL = ("GENERAL")
+}
\ No newline at end of file
diff --git a/src/app/layout/app-main/app-main.component.html b/src/app/layout/app-main/app-main.component.html
index 297fa6c..a70101b 100644
--- a/src/app/layout/app-main/app-main.component.html
+++ b/src/app/layout/app-main/app-main.component.html
@@ -1,4 +1,4 @@
-
+
+
+ {{displayNotfication.message}}
+
+
+
+
diff --git a/src/app/layout/app-topbar/app-topbar.component.ts b/src/app/layout/app-topbar/app-topbar.component.ts
index ce433e4..8c656a4 100644
--- a/src/app/layout/app-topbar/app-topbar.component.ts
+++ b/src/app/layout/app-topbar/app-topbar.component.ts
@@ -1,11 +1,18 @@
import { Component, OnInit } from '@angular/core';
-import {AppMainComponent} from '../app-main/app-main.component';
+import { AppMainComponent } from '../app-main/app-main.component';
import { Router } from '@angular/router';
import { SessionService } from 'src/app/services/session/session.service';
import { Serviceman } from 'src/app/classes/serviceman/serviceman';
-
+import { Message, ConfirmationService, LazyLoadEvent, PrimeNGConfig, MenuItem } from 'primeng/api';
import { AppComponent } from '../../app.component'
+import { NotificationService } from 'src/app/services/notification/notification.service';
+import { Notification } from 'src/app/classes/notification/notification';
+import { ToastModule } from 'primeng/toast';
+import { MessageService } from 'primeng/api';
+import { NotificationTypeEnum } from 'src/app/classes/notificationtype-enum';
+import { interval } from 'rxjs';
+
@Component({
selector: 'app-topbar',
@@ -15,14 +22,155 @@ import { AppComponent } from '../../app.component'
export class AppTopbarComponent implements OnInit {
serviceman: Serviceman
+ allNotifications: Notification[] = []
+ notiHover: Boolean
+ msgForDialog: Message[] = []
+ selectedNotification: Notification
+ unreadCounter: number
+ pollInterval: number
+ items: MenuItem[];
+ display: boolean = false;
+ displayNotfication: Notification
constructor(public app: AppMainComponent, private router: Router, private sessionService: SessionService,
- public appForTimer: AppComponent) {}
+ private notificationService: NotificationService, private messageService: MessageService, private primengConfig: PrimeNGConfig,
+ public appForTimer: AppComponent) { }
ngOnInit() {
+ this.displayNotfication = new Notification
+ this.loadHomeContent()
+ this.pollInterval = 3000
+
+ interval(this.pollInterval).subscribe(_ => {
+ this.checkForUnfetchedNotifications()
+ })
this.serviceman = this.sessionService.getCurrentServiceman()
}
+ checkForUnfetchedNotifications() {
+ this.notificationService.hasUnfetchedNotifications().subscribe(
+ response => {
+ response.hasUnfetchedNotifications === true ? this.loadHomeContent() : null
+ },
+ error => {
+ console.log(error);
+ }
+ )
+ }
+
+ showDialog(notification: Notification) {
+ this.display = true;
+ this.displayNotfication = notification
+ }
+
+ numLines(str: String) {
+ return str.split(/\r\n|\r|\n/).length
+ }
+
+ getMenuItems(notification: Notification): MenuItem[] {
+ return [{
+ label: 'Update',
+ icon: 'pi pi-refresh',
+ command: () => {
+ this.deleteNotification(notification);
+ }
+ },
+ {
+ label: 'Delete',
+ icon: 'pi pi-times',
+ command: () => {
+
+ }
+ }
+ ];
+ }
+
+ loadHomeContent() {
+
+ this.unreadCounter = 0;
+ this.notiHover = false
+ this.serviceman = this.sessionService.getCurrentServiceman()
+ this.notificationService.retrieveAllServicemanNotifications().subscribe(
+ response => {
+ this.allNotifications = response.notifications
+ this.allNotifications.forEach(n => {
+ n.notificationDate = this.convertUTCStringToSingaporeDate(n.notificationDate)
+ if (!n.isRead) {
+ this.unreadCounter = this.unreadCounter + 1;
+ }
+ })
+ this.allNotifications.sort((x, y) => (y.notificationDate.getTime() - x.notificationDate.getTime()))
+ }, error => {
+ console.error(error)
+ }
+ );
+
+ }
+
+ deleteNotification(notification) {
+ this.notificationService.deleteNotification(notification.notificationId).subscribe(
+ response => {
+ this.messageService.add({ severity: 'success', summary: 'Service Message', detail: 'Notification Deleted' });
+ }, error => {
+ console.error(error)
+ }
+ )
+ }
+
+ redirecting(notification: Notification) {
+ this.notificationService.readNotification(notification.notificationId).subscribe(
+ response => {
+ this.ngOnInit()
+ }, error => {
+ console.error(error)
+ }
+ )
+ let url = ""
+ if (notification.notificationTypeEnum === NotificationTypeEnum.BOOKING) {
+ url = url + "/booking-management-screen"
+ if (notification.dynamicId !== undefined) {
+ url = url + "/" + notification.dynamicId
+ }
+ }
+ if (notification.notificationTypeEnum === NotificationTypeEnum.CONSULTATION) {
+ url = url + "/consultation-screen"
+ if (notification.dynamicId !== undefined) {
+ url = url + "/" + notification.dynamicId
+ }
+ }
+ if (notification.notificationTypeEnum === NotificationTypeEnum.FORM) {
+ url = url + "/general-eforms-screen"
+ if (notification.dynamicId !== undefined) {
+ url = url + "/" + notification.dynamicId
+ }
+ }
+ this.router.navigate([url])
+ }
+
+ readAllNotifications() {
+ this.notificationService.readAllNotifications().subscribe(
+ response => {
+ this.ngOnInit()
+ },
+ error => {
+ console.log(error);
+ }
+ )
+ }
+
+ deleteAllNotifications() {
+ this.notificationService.deleteAllNotifications().subscribe(
+ response => {
+ console.log(`deleted all`);
+ this.ngOnInit();
+ },
+ error => {
+ console.log(error);
+
+ }
+ )
+ }
+
logout() {
this.sessionService.setIsLogin(false)
this.sessionService.setCurrentServiceman(null)
@@ -30,4 +178,18 @@ export class AppTopbarComponent implements OnInit {
this.appForTimer.stopTimer()
}
+ convertUTCStringToSingaporeDate(dateCreated) {
+ if (dateCreated != null) {
+ let stringUtcTime = dateCreated.toLocaleString().substring(0, 19)
+ return new Date(Date.UTC(
+ parseInt(stringUtcTime.substring(0, 4)),
+ parseInt("" + (+stringUtcTime.substring(5, 7) - 1)),
+ parseInt(stringUtcTime.substring(8, 10)),
+ parseInt(stringUtcTime.substring(11, 13)),
+ parseInt(stringUtcTime.substring(14, 16)),
+ parseInt(stringUtcTime.substring(17, 19))
+ ));
+ }
+ }
+
}
diff --git a/src/app/screens/booking-management-screen/booking-management-screen.component.html b/src/app/screens/booking-management-screen/booking-management-screen.component.html
index 8a21afe..dbaf7cf 100644
--- a/src/app/screens/booking-management-screen/booking-management-screen.component.html
+++ b/src/app/screens/booking-management-screen/booking-management-screen.component.html
@@ -23,14 +23,14 @@
You currently have no booking
-
- Booking Id
+ | Booking Id
|
@@ -38,16 +38,17 @@ You currently have no booking
- Booking SlotBooking Slot
|
- Booking Status
+ Booking Status
|
- Form Quantity
+ Forms
|
+
| |
@@ -111,16 +112,22 @@ Select Date
+
+ dataKey="slotId" [(ngModel)]="selectedSlot" name="slot">
+
+
+
+
+
There is no available slot
@@ -134,7 +141,19 @@ There is no available slot
Booking Comments
-
+
+ Consultation type
+
+
+