diff --git a/ui/.eslintignore b/ui/.eslintignore index e55ff402d3..df54ff075c 100644 --- a/ui/.eslintignore +++ b/ui/.eslintignore @@ -31,5 +31,3 @@ src/app/editor src/app/files src/app/info src/app/login -src/app/notifications -src/app/NS \ No newline at end of file diff --git a/ui/.prettierignore b/ui/.prettierignore index 134205dda5..4b0f32f39f 100644 --- a/ui/.prettierignore +++ b/ui/.prettierignore @@ -31,5 +31,3 @@ src/app/editor src/app/files src/app/info src/app/login -src/app/notifications -src/app/NS \ No newline at end of file diff --git a/ui/src/app/NS/XS.service.spec.ts b/ui/src/app/NS/XS.service.spec.ts index aab2c38783..6db8f577a6 100644 --- a/ui/src/app/NS/XS.service.spec.ts +++ b/ui/src/app/NS/XS.service.spec.ts @@ -19,16 +19,16 @@ import { XsService } from './xs.service'; describe('XSService', () => { - const service: XsService = new XsService(); + const service: XsService = new XsService(); - it('should get string XS String', () => { - expect(service.XS_STRING).toBe('xs:string'); - }); + it('should get string XS String', () => { + expect(service.XS_STRING).toBe('xs:string'); + }); - it('should check for numbers', () => { - expect(service.isNumber(service.XS_DOUBLE)).toBeTrue(); - expect(service.isNumber(service.XS_INTEGER)).toBeTrue(); - expect(service.isNumber(service.XS_NUMBER)).toBeTrue(); - expect(service.isNumber(service.XS_STRING)).toBeFalse(); - }); + it('should check for numbers', () => { + expect(service.isNumber(service.XS_DOUBLE)).toBeTrue(); + expect(service.isNumber(service.XS_INTEGER)).toBeTrue(); + expect(service.isNumber(service.XS_NUMBER)).toBeTrue(); + expect(service.isNumber(service.XS_STRING)).toBeFalse(); + }); }); diff --git a/ui/src/app/NS/xs.service.ts b/ui/src/app/NS/xs.service.ts index 77986e0d63..a8eea881e3 100644 --- a/ui/src/app/NS/xs.service.ts +++ b/ui/src/app/NS/xs.service.ts @@ -20,19 +20,19 @@ import { Injectable } from '@angular/core'; @Injectable() export class XsService { + XS_STRING = 'xs:string'; + XS_INTEGER = 'http://www.w3.org/2001/XMLSchema#integer'; + XS_DOUBLE = 'http://www.w3.org/2001/XMLSchema#double'; + XS_BOOLEAN = 'http://www.w3.org/2001/XMLSchema#boolean'; + XS_NUMBER = 'http://www.w3.org/2001/XMLSchema#number'; + XS_STRING1 = 'http://www.w3.org/2001/XMLSchema#string'; + SO_URL = 'https://schema.org/URL'; - XS_STRING = 'xs:string'; - XS_INTEGER = 'http://www.w3.org/2001/XMLSchema#integer'; - XS_DOUBLE = 'http://www.w3.org/2001/XMLSchema#double'; - XS_BOOLEAN = 'http://www.w3.org/2001/XMLSchema#boolean'; - XS_NUMBER = 'http://www.w3.org/2001/XMLSchema#number'; - XS_STRING1 = 'http://www.w3.org/2001/XMLSchema#string'; - SO_URL = 'https://schema.org/URL'; - - isNumber(datatype: string): boolean { - return datatype === this.XS_DOUBLE || - datatype === this.XS_INTEGER || - datatype === this.XS_NUMBER; - } - + isNumber(datatype: string): boolean { + return ( + datatype === this.XS_DOUBLE || + datatype === this.XS_INTEGER || + datatype === this.XS_NUMBER + ); + } } diff --git a/ui/src/app/notifications/components/notification-item.component.html b/ui/src/app/notifications/components/notification-item.component.html index 1f8786d943..6b7cbc151a 100644 --- a/ui/src/app/notifications/components/notification-item.component.html +++ b/ui/src/app/notifications/components/notification-item.component.html @@ -18,11 +18,12 @@
- {{notification.createdAt | date: 'yyyy-MM-dd HH:mm:ss'}} + {{ + notification.createdAt | date : 'yyyy-MM-dd HH:mm:ss' + }}
-
diff --git a/ui/src/app/notifications/components/notification-item.component.scss b/ui/src/app/notifications/components/notification-item.component.scss index bbb3b9270d..b74594c201 100644 --- a/ui/src/app/notifications/components/notification-item.component.scss +++ b/ui/src/app/notifications/components/notification-item.component.scss @@ -52,4 +52,4 @@ .notification-item { margin-top: 30px; -} \ No newline at end of file +} diff --git a/ui/src/app/notifications/components/notification-item.component.ts b/ui/src/app/notifications/components/notification-item.component.ts index b363383bf2..5cf6d949a1 100644 --- a/ui/src/app/notifications/components/notification-item.component.ts +++ b/ui/src/app/notifications/components/notification-item.component.ts @@ -20,20 +20,19 @@ import { NotificationItem } from '../model/notifications.model'; import { DomSanitizer } from '@angular/platform-browser'; @Component({ - selector: 'notification-item', + selector: 'sp-notification-item', templateUrl: './notification-item.component.html', - styleUrls: ['./notification-item.component.scss'] + styleUrls: ['./notification-item.component.scss'], }) export class NotificationItemComponent implements OnInit { - @Input() notification: NotificationItem; sanitizedMessage; - constructor(private domSanitizer: DomSanitizer) { - - } + constructor(private domSanitizer: DomSanitizer) {} ngOnInit(): void { - this.sanitizedMessage = this.domSanitizer.bypassSecurityTrustHtml(this.notification.message); + this.sanitizedMessage = this.domSanitizer.bypassSecurityTrustHtml( + this.notification.message, + ); } } diff --git a/ui/src/app/notifications/notifications.component.html b/ui/src/app/notifications/notifications.component.html index e91ac59452..cafa23a3ea 100644 --- a/ui/src/app/notifications/notifications.component.html +++ b/ui/src/app/notifications/notifications.component.html @@ -17,7 +17,7 @@ -->
-
+
@@ -25,51 +25,108 @@
-
- -
+
-
+

Loading notifications...

-
-

No notifications available. Create a new pipeline using the Notification Sink to create your first notification!

+
+

+ No notifications available. Create a new pipeline using the + Notification Sink to create your first notification! +

-
+
- -
{{elementIconText.getElementIconText(existingNotification.pipelineName)}} + +
+ {{ + elementIconText.getElementIconText( + existingNotification.pipelineName + ) + }}
-

{{existingNotification.pipelineName}}

-

{{existingNotification.notificationTitle}}

+

{{ existingNotification.pipelineName }}

+

{{ existingNotification.notificationTitle }}

-
+
-
-
{{currentlySelectedNotification.pipelineName}}
-
{{currentlySelectedNotification.notificationTitle}}
-
+
+
+ {{ currentlySelectedNotification.pipelineName }} +
+
+ {{ currentlySelectedNotification.notificationTitle }} +
+
-
- +
+
-
diff --git a/ui/src/app/notifications/notifications.component.scss b/ui/src/app/notifications/notifications.component.scss index 079936714e..4e2ec2c606 100644 --- a/ui/src/app/notifications/notifications.component.scss +++ b/ui/src/app/notifications/notifications.component.scss @@ -32,7 +32,7 @@ } .mr-20 { - margin-right:20px; + margin-right: 20px; } .notifications-overview { @@ -60,11 +60,11 @@ } .header-divider { - display:flex; + display: flex; align-self: center; margin: 10px 20px; width: 100%; - border-top: 2px solid $sp-color-accent + border-top: 2px solid $sp-color-accent; } .notification-header-pipeline-name { @@ -83,17 +83,17 @@ } .list-item:hover { - background: #E0E0E0; + background: #e0e0e0; cursor: pointer; } .selected-notification { - background: #E0E0E0; + background: #e0e0e0; cursor: pointer; } .list-item { - border-bottom: 1px solid #BDBDBD; + border-bottom: 1px solid #bdbdbd; } .notification-pane { @@ -111,7 +111,7 @@ .scrolling-auto { overflow: auto; - width:100%; + width: 100%; } .new-notification-info { @@ -120,4 +120,3 @@ height: 10px; border-radius: 50%; } - diff --git a/ui/src/app/notifications/notifications.component.ts b/ui/src/app/notifications/notifications.component.ts index 4d31082e13..515885c953 100644 --- a/ui/src/app/notifications/notifications.component.ts +++ b/ui/src/app/notifications/notifications.component.ts @@ -16,211 +16,294 @@ * */ -import { Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core'; -import { ExistingNotification, NotificationItem } from './model/notifications.model'; +import { + Component, + ElementRef, + OnDestroy, + OnInit, + ViewChild, +} from '@angular/core'; +import { + ExistingNotification, + NotificationItem, +} from './model/notifications.model'; import { ElementIconText } from '../services/get-element-icon-text.service'; import { NotificationsService } from './service/notifications.service'; import { Subscription, timer } from 'rxjs'; import { NotificationUtils } from './utils/notifications.utils'; import { NotificationCountService } from '../services/notification-count-service'; -import { FreeTextStaticProperty, Pipeline, PipelineService } from '@streampipes/platform-services'; +import { + FreeTextStaticProperty, + Pipeline, + PipelineService, +} from '@streampipes/platform-services'; import { AuthService } from '../services/auth.service'; import { filter, switchMap } from 'rxjs/operators'; import { SpBreadcrumbService } from '@streampipes/shared-ui'; @Component({ - selector: 'notifications', - templateUrl: './notifications.component.html', - styleUrls: ['./notifications.component.scss'] + selector: 'sp-notifications', + templateUrl: './notifications.component.html', + styleUrls: ['./notifications.component.scss'], }) export class NotificationsComponent implements OnInit, OnDestroy { + static readonly NOTIFICATIONS_APP_ID = + 'org.apache.streampipes.sinks.internal.jvm.notification'; + static readonly NOTIFICATION_TITLE_KEY = 'title'; - static readonly NOTIFICATIONS_APP_ID = 'org.apache.streampipes.sinks.internal.jvm.notification'; - static readonly NOTIFICATION_TITLE_KEY = 'title'; - - @ViewChild('notificationPane') private notificationContainer: ElementRef; - - allNotifications: Map = new Map(); - unreadNotifications: any; - existingNotifications: ExistingNotification[] = []; - currentlySelectedNotification: ExistingNotification; - currentlySelectedNotificationId: string; - - pipelinesWithNotificationsPresent = false; - notificationsLoading = false; - - currentOffset = 0; - liveOffset = 0; - previousScrollHeight: number; - - subscription: Subscription; - notificationTopic: string; - - newNotificationInfo: boolean[] = []; - - newEventArriving = false; - lastFetchTime = new Date().getTime(); - - constructor(private authService: AuthService, - private pipelineService: PipelineService, - public elementIconText: ElementIconText, - private notificationService: NotificationsService, - private notificationCountService: NotificationCountService, - private breadcrumbService: SpBreadcrumbService) { - this.unreadNotifications = []; - } - - ngOnInit() { - this.breadcrumbService.updateBreadcrumb([{label: 'Notifications'}]); - this.getPipelinesWithNotifications(); - this.subscription = timer(0, 5000).pipe( - filter(() => (this.currentlySelectedNotification !== undefined && this.allNotifications.size > 0)), - switchMap(() => this.notificationService.getNotificationsFromTime( - this.lastFetchTime))) - .subscribe((notifications) => { - let scrollToBottom = false; - if (notifications.length > 0) { - if ((this.notificationContainer.nativeElement.scrollHeight - this.notificationContainer.nativeElement.scrollTop) <= - (this.notificationContainer.nativeElement.clientHeight + 10) && - (this.notificationContainer.nativeElement.scrollHeight - this.notificationContainer.nativeElement.scrollTop) >= - (this.notificationContainer.nativeElement.clientHeight - 10)) { - scrollToBottom = true; - } - this.newEventArriving = true; - notifications.forEach(notification => { - const notificationId = NotificationUtils.makeNotificationId(notification.correspondingPipelineId, notification.title); - const existingNots = this.allNotifications.get(notificationId); - existingNots.push(notification); - this.allNotifications.set(notificationId, existingNots); - if (this.currentlySelectedNotificationId === notificationId) { - this.liveOffset++; - notification.read = true; - setTimeout(() => { - this.notificationService.updateNotification(notification).subscribe(); - }, 500); - } else { - this.newNotificationInfo[notificationId] = true; - } - }); + @ViewChild('notificationPane') private notificationContainer: ElementRef; + + allNotifications: Map = new Map(); + unreadNotifications: any; + existingNotifications: ExistingNotification[] = []; + currentlySelectedNotification: ExistingNotification; + currentlySelectedNotificationId: string; + + pipelinesWithNotificationsPresent = false; + notificationsLoading = false; + + currentOffset = 0; + liveOffset = 0; + previousScrollHeight: number; + + subscription: Subscription; + notificationTopic: string; + + newNotificationInfo: boolean[] = []; + + newEventArriving = false; + lastFetchTime = new Date().getTime(); + + constructor( + private authService: AuthService, + private pipelineService: PipelineService, + public elementIconText: ElementIconText, + private notificationService: NotificationsService, + private notificationCountService: NotificationCountService, + private breadcrumbService: SpBreadcrumbService, + ) { + this.unreadNotifications = []; + } - if (scrollToBottom) { - setTimeout(() => { - this.scrollToBottom(); + ngOnInit() { + this.breadcrumbService.updateBreadcrumb([{ label: 'Notifications' }]); + this.getPipelinesWithNotifications(); + this.subscription = timer(0, 5000) + .pipe( + filter( + () => + this.currentlySelectedNotification !== undefined && + this.allNotifications.size > 0, + ), + switchMap(() => + this.notificationService.getNotificationsFromTime( + this.lastFetchTime, + ), + ), + ) + .subscribe(notifications => { + let scrollToBottom = false; + if (notifications.length > 0) { + if ( + this.notificationContainer.nativeElement.scrollHeight - + this.notificationContainer.nativeElement + .scrollTop <= + this.notificationContainer.nativeElement + .clientHeight + + 10 && + this.notificationContainer.nativeElement.scrollHeight - + this.notificationContainer.nativeElement + .scrollTop >= + this.notificationContainer.nativeElement + .clientHeight - + 10 + ) { + scrollToBottom = true; + } + this.newEventArriving = true; + notifications.forEach(notification => { + const notificationId = + NotificationUtils.makeNotificationId( + notification.correspondingPipelineId, + notification.title, + ); + const existingNots = + this.allNotifications.get(notificationId); + existingNots.push(notification); + this.allNotifications.set(notificationId, existingNots); + if ( + this.currentlySelectedNotificationId === + notificationId + ) { + this.liveOffset++; + notification.read = true; + setTimeout(() => { + this.notificationService + .updateNotification(notification) + .subscribe(); + }, 500); + } else { + this.newNotificationInfo[notificationId] = true; + } + }); + + if (scrollToBottom) { + setTimeout(() => { + this.scrollToBottom(); + }); + } + } + this.lastFetchTime = new Date().getTime(); + this.newEventArriving = false; }); - } - } - this.lastFetchTime = new Date().getTime(); - this.newEventArriving = false; - }); - } - - scrollToBottom() { - setTimeout(() => { - this.notificationContainer.nativeElement.scrollTop = this.notificationContainer.nativeElement.scrollHeight + 100; - }, 200); - } - - getPipelinesWithNotifications() { - this.notificationsLoading = true; - this.pipelineService.getOwnPipelines().subscribe(pipelines => { - this.existingNotifications = this.getAllExistingNotifications(pipelines); - this.notificationsLoading = false; - if (this.existingNotifications.length > 0) { - this.pipelinesWithNotificationsPresent = true; - this.selectNotification(this.existingNotifications[0]); - this.existingNotifications.forEach(notification => { - this.getNotifications(notification, this.currentOffset, 10, true); + } + + scrollToBottom() { + setTimeout(() => { + this.notificationContainer.nativeElement.scrollTop = + this.notificationContainer.nativeElement.scrollHeight + 100; + }, 200); + } + + getPipelinesWithNotifications() { + this.notificationsLoading = true; + this.pipelineService.getOwnPipelines().subscribe(pipelines => { + this.existingNotifications = + this.getAllExistingNotifications(pipelines); + this.notificationsLoading = false; + if (this.existingNotifications.length > 0) { + this.pipelinesWithNotificationsPresent = true; + this.selectNotification(this.existingNotifications[0]); + this.existingNotifications.forEach(notification => { + this.getNotifications( + notification, + this.currentOffset, + 10, + true, + ); + }); + } }); - } - }); - } - - getAllExistingNotifications(pipelines: Pipeline[]): ExistingNotification[] { - const existingNotifications = []; - pipelines.forEach(pipeline => { - const notificationActions = pipeline.actions.filter(sink => sink.appId === NotificationsComponent.NOTIFICATIONS_APP_ID); - notificationActions.forEach(notificationAction => { - const notificationName = notificationAction - .staticProperties - .filter(sp => sp.internalName === NotificationsComponent.NOTIFICATION_TITLE_KEY) - .map(sp => (sp as FreeTextStaticProperty).value)[0]; - const pipelineName = pipeline.name; - existingNotifications.push({ - notificationTitle: notificationName, - pipelineName, - pipelineId: pipeline._id, - notificationId: NotificationUtils.makeNotificationId(pipeline._id, notificationName) + } + + getAllExistingNotifications(pipelines: Pipeline[]): ExistingNotification[] { + const existingNotifications = []; + pipelines.forEach(pipeline => { + const notificationActions = pipeline.actions.filter( + sink => + sink.appId === NotificationsComponent.NOTIFICATIONS_APP_ID, + ); + notificationActions.forEach(notificationAction => { + const notificationName = notificationAction.staticProperties + .filter( + sp => + sp.internalName === + NotificationsComponent.NOTIFICATION_TITLE_KEY, + ) + .map(sp => (sp as FreeTextStaticProperty).value)[0]; + const pipelineName = pipeline.name; + existingNotifications.push({ + notificationTitle: notificationName, + pipelineName, + pipelineId: pipeline._id, + notificationId: NotificationUtils.makeNotificationId( + pipeline._id, + notificationName, + ), + }); + }); }); - }); - }); - return existingNotifications; - } - - getNotifications(notification: ExistingNotification, - offset: number, - count: number, - scrollToBottom: boolean) { - this.notificationService.getNotifications(notification, offset, count).subscribe(notifications => { - notifications.sort((a, b) => { - return (a.createdAtTimestamp - b.createdAtTimestamp); - }); - const notificationId = NotificationUtils.makeNotificationId(notification.pipelineId, notification.notificationTitle); - if (!this.allNotifications.has(notificationId)) { - this.allNotifications.set(notificationId, []); - } - this.allNotifications.get(notificationId).unshift(...notifications); - if (scrollToBottom) { - setTimeout(() => { - this.scrollToBottom(); - }, 500); - } else { - setTimeout(() => { - this.notificationContainer.nativeElement.scrollTop = - this.notificationContainer.nativeElement.scrollHeight - this.previousScrollHeight; + return existingNotifications; + } + + getNotifications( + notification: ExistingNotification, + offset: number, + count: number, + scrollToBottom: boolean, + ) { + this.notificationService + .getNotifications(notification, offset, count) + .subscribe(notifications => { + notifications.sort((a, b) => { + return a.createdAtTimestamp - b.createdAtTimestamp; + }); + const notificationId = NotificationUtils.makeNotificationId( + notification.pipelineId, + notification.notificationTitle, + ); + if (!this.allNotifications.has(notificationId)) { + this.allNotifications.set(notificationId, []); + } + this.allNotifications + .get(notificationId) + .unshift(...notifications); + if (scrollToBottom) { + setTimeout(() => { + this.scrollToBottom(); + }, 500); + } else { + setTimeout(() => { + this.notificationContainer.nativeElement.scrollTop = + this.notificationContainer.nativeElement + .scrollHeight - this.previousScrollHeight; + }); + } + this.updateUnreadNotifications(notifications); + }); + } + + updateUnreadNotifications(notifications: NotificationItem[]) { + notifications.forEach(n => { + if (!n.read) { + n.read = true; + this.notificationCountService.decreaseNotificationCount(); + this.notificationService.updateNotification(n).subscribe(); + } }); - } - this.updateUnreadNotifications(notifications); - }); - } - - updateUnreadNotifications(notifications: NotificationItem[]) { - notifications.forEach(n => { - if (!n.read) { - n.read = true; - this.notificationCountService.decreaseNotificationCount(); - this.notificationService.updateNotification(n).subscribe(); - } - }); - } - - selectNotification(notification: ExistingNotification) { - this.currentOffset = 0; - this.liveOffset = 0; - this.currentlySelectedNotification = notification; - this.currentlySelectedNotificationId = NotificationUtils.makeNotificationIdFromNotification(notification); - if (this.allNotifications.has(this.currentlySelectedNotificationId)) { - this.updateUnreadNotifications(this.allNotifications.get(this.currentlySelectedNotificationId)); } - this.newNotificationInfo[this.currentlySelectedNotificationId] = false; - this.notificationCountService.lockIncreaseUpdateForId(this.currentlySelectedNotificationId); - if (this.notificationContainer) { - this.scrollToBottom(); + + selectNotification(notification: ExistingNotification) { + this.currentOffset = 0; + this.liveOffset = 0; + this.currentlySelectedNotification = notification; + this.currentlySelectedNotificationId = + NotificationUtils.makeNotificationIdFromNotification(notification); + if (this.allNotifications.has(this.currentlySelectedNotificationId)) { + this.updateUnreadNotifications( + this.allNotifications.get(this.currentlySelectedNotificationId), + ); + } + this.newNotificationInfo[this.currentlySelectedNotificationId] = false; + this.notificationCountService.lockIncreaseUpdateForId( + this.currentlySelectedNotificationId, + ); + if (this.notificationContainer) { + this.scrollToBottom(); + } } - } - - onScroll() { - if (this.notificationContainer.nativeElement.scrollTop === 0) { - this.currentOffset += 10; - this.previousScrollHeight = this.notificationContainer.nativeElement.scrollHeight; - const currentNotifications = this.allNotifications.get(this.currentlySelectedNotificationId); - this.getNotifications(this.currentlySelectedNotification, currentNotifications.length + this.liveOffset, 10, false); + + onScroll() { + if (this.notificationContainer.nativeElement.scrollTop === 0) { + this.currentOffset += 10; + this.previousScrollHeight = + this.notificationContainer.nativeElement.scrollHeight; + const currentNotifications = this.allNotifications.get( + this.currentlySelectedNotificationId, + ); + this.getNotifications( + this.currentlySelectedNotification, + currentNotifications.length + this.liveOffset, + 10, + false, + ); + } } - } - ngOnDestroy(): void { - if (this.subscription) { - this.subscription.unsubscribe(); + ngOnDestroy(): void { + if (this.subscription) { + this.subscription.unsubscribe(); + } + this.notificationCountService.unlockIncreaseUpdate(); } - this.notificationCountService.unlockIncreaseUpdate(); - } } diff --git a/ui/src/app/notifications/notifications.module.ts b/ui/src/app/notifications/notifications.module.ts index 1882aac787..83cc795474 100644 --- a/ui/src/app/notifications/notifications.module.ts +++ b/ui/src/app/notifications/notifications.module.ts @@ -38,23 +38,12 @@ import { PlatformServicesModule } from '@streampipes/platform-services'; FlexLayoutModule, CustomMaterialModule, FormsModule, - PlatformServicesModule + PlatformServicesModule, ], - declarations: [ - NotificationsComponent, - NotificationItemComponent - ], - providers: [ - NotificationsService - ], - exports: [ - NotificationsComponent - ] + declarations: [NotificationsComponent, NotificationItemComponent], + providers: [NotificationsService], + exports: [NotificationsComponent], }) export class NotificationModule { - - constructor() { - } - + constructor() {} } - diff --git a/ui/src/app/notifications/service/notifications.service.ts b/ui/src/app/notifications/service/notifications.service.ts index f359b472de..8433f4584b 100644 --- a/ui/src/app/notifications/service/notifications.service.ts +++ b/ui/src/app/notifications/service/notifications.service.ts @@ -19,7 +19,7 @@ import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { ExistingNotification, - NotificationItem + NotificationItem, } from '../model/notifications.model'; import { Injectable } from '@angular/core'; import { NotificationUtils } from '../utils/notifications.utils'; @@ -28,41 +28,61 @@ import { PlatformServicesCommons } from '@streampipes/platform-services'; @Injectable() export class NotificationsService { + constructor( + private http: HttpClient, + private platformServicesCommons: PlatformServicesCommons, + ) {} - constructor(private http: HttpClient, - private platformServicesCommons: PlatformServicesCommons) { - } - - getNotificationsFromTime(startTime: number): Observable { + getNotificationsFromTime( + startTime: number, + ): Observable { return this.http - .get(this.notificationUrl - + '/time' - + '?' - + 'startTime=' + startTime) - .pipe(map(data => { - return data as NotificationItem[]; - })); + .get( + this.notificationUrl + '/time' + '?' + 'startTime=' + startTime, + ) + .pipe( + map(data => { + return data as NotificationItem[]; + }), + ); } - getNotifications(existingNotification: ExistingNotification, offset: number, limit: number): Observable { + getNotifications( + existingNotification: ExistingNotification, + offset: number, + limit: number, + ): Observable { return this.http - .get(this.notificationUrl - + '/offset' - + '?' - + 'notificationType=' + NotificationUtils.makeNotificationIdFromNotification(existingNotification) - + '&' - + 'offset=' + offset - + '&' - + 'count=' + limit) - .pipe(map(data => { - return data as NotificationItem[]; - })); + .get( + this.notificationUrl + + '/offset' + + '?' + + 'notificationType=' + + NotificationUtils.makeNotificationIdFromNotification( + existingNotification, + ) + + '&' + + 'offset=' + + offset + + '&' + + 'count=' + + limit, + ) + .pipe( + map(data => { + return data as NotificationItem[]; + }), + ); } updateNotification(notificationItem: NotificationItem): Observable { - return this.http.put(this.notificationUrl + '/' + notificationItem._id, notificationItem, { - headers: { ignoreLoadingBar: '' } - }); + return this.http.put( + this.notificationUrl + '/' + notificationItem._id, + notificationItem, + { + headers: { ignoreLoadingBar: '' }, + }, + ); } private get notificationUrl() { diff --git a/ui/src/app/notifications/utils/notifications.utils.ts b/ui/src/app/notifications/utils/notifications.utils.ts index 8fb001357c..da7cda8399 100644 --- a/ui/src/app/notifications/utils/notifications.utils.ts +++ b/ui/src/app/notifications/utils/notifications.utils.ts @@ -18,9 +18,13 @@ import { ExistingNotification } from '../model/notifications.model'; export class NotificationUtils { - - static makeNotificationIdFromNotification(existingNotification: ExistingNotification): string { - return this.makeNotificationId(existingNotification.pipelineId, existingNotification.notificationTitle); + static makeNotificationIdFromNotification( + existingNotification: ExistingNotification, + ): string { + return this.makeNotificationId( + existingNotification.pipelineId, + existingNotification.notificationTitle, + ); } static makeNotificationId(pipelineId: string, notificationTitle: string) {