-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f57e166
commit c1fd648
Showing
9 changed files
with
101 additions
and
36 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
projects/gameboard-ui/src/app/admin/admin-page/admin-page.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
projects/gameboard-ui/src/app/support/support-page/support-page.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
<!-- Copyright 2021 Carnegie Mellon University. All Rights Reserved. --> | ||
<!-- Released under a MIT (SEI)-style license. See LICENSE.md in the project root for license information. --> | ||
|
||
<div class="mb-4"> | ||
<h1 class="support-header mb-0">Support</h1> | ||
<div class="mb-4 container"> | ||
<h1 class="support-header mb-0 pl-0">Support</h1> | ||
</div> | ||
|
||
<main class=" mb-4 pb-4"> | ||
|
||
<router-outlet></router-outlet> | ||
|
||
</main> | ||
|
||
<footer class="p-4 mt-4"></footer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 7 additions & 2 deletions
9
.../system-notifications/components/system-notifications/system-notifications.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
<div class="notificatons-container"> | ||
<alert *ngFor="let notification of (notifications$ | async)" [dismissible]="true" | ||
<alert *ngFor="let notification of notifications" [dismissible]="true" | ||
[type]="notification.notificationType | notificationTypeToAlertType" (onClose)="handleClosed(notification)"> | ||
<h2 class="fs-11 m-0 cursor-pointer" (click)="handleClicked(notification)">{{notification.title}}</h2> | ||
<div class="container" (click)="handleClicked(notification)"> | ||
<h2 class="fs-11 m-0 cursor-pointer"> | ||
{{notification.title}} | ||
</h2> | ||
<small class="d-block fs-08 cursor-pointer text-upper font-bold">[more info]</small> | ||
</div> | ||
</alert> | ||
</div> |
49 changes: 38 additions & 11 deletions
49
...pp/system-notifications/components/system-notifications/system-notifications.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,66 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { firstValueFrom, timer } from 'rxjs'; | ||
import { ModalConfirmService } from '@/services/modal-confirm.service'; | ||
import { ViewSystemNotification } from '@/system-notifications/system-notifications.models'; | ||
import { SystemNotificationsService } from '@/system-notifications/system-notifications.service'; | ||
import { Component } from '@angular/core'; | ||
import { Observable, firstValueFrom, tap } from 'rxjs'; | ||
import { UserService as LocalUserService } from "@/utility/user.service"; | ||
import { UnsubscriberService } from '@/services/unsubscriber.service'; | ||
|
||
@Component({ | ||
selector: 'app-system-notifications', | ||
templateUrl: './system-notifications.component.html', | ||
styleUrls: ['./system-notifications.component.scss'] | ||
}) | ||
export class SystemNotificationsComponent { | ||
notifications$: Observable<ViewSystemNotification[]>; | ||
export class SystemNotificationsComponent implements OnInit { | ||
protected notifications: ViewSystemNotification[] = []; | ||
private UPDATE_INTERVAL = 1000 * 60 * 60 * 30; | ||
|
||
constructor( | ||
private localUserService: LocalUserService, | ||
private modalService: ModalConfirmService, | ||
private systemNotificationsService: SystemNotificationsService) { | ||
this.notifications$ = systemNotificationsService.getVisibleNotifications().pipe( | ||
tap(notifications => { | ||
private systemNotificationsService: SystemNotificationsService, | ||
private unsub: UnsubscriberService) { } | ||
|
||
}) | ||
async ngOnInit(): Promise<void> { | ||
this.unsub.add( | ||
this.localUserService.user$.subscribe(async u => { | ||
await this.loadNotifications(); | ||
}), | ||
this.systemNotificationsService.systemNotificationsUpdated$.subscribe(async () => await this.loadNotifications()), | ||
timer(0, this.UPDATE_INTERVAL).subscribe(async u => await this.loadNotifications()) | ||
); | ||
} | ||
|
||
protected async handleClosed(notification: ViewSystemNotification) { | ||
await firstValueFrom(this.systemNotificationsService.logInteraction(notification.id, "dismissed")); | ||
await firstValueFrom(this.systemNotificationsService.logInteraction("dismissed", notification.id)); | ||
} | ||
|
||
protected async handleClicked(notification: ViewSystemNotification) { | ||
await firstValueFrom(this.systemNotificationsService.logInteraction("sawFull", notification.id)); | ||
|
||
this.modalService.openConfirm({ | ||
title: notification.title, | ||
bodyContent: notification.markdownContent, | ||
renderBodyAsMarkdown: true, | ||
hideCancel: true | ||
hideCancel: true, | ||
onConfirm: async () => { | ||
await this.loadNotifications(); | ||
await firstValueFrom(this.systemNotificationsService.logInteraction("dismissed", notification.id)); | ||
} | ||
}); | ||
} | ||
|
||
private async loadNotifications(): Promise<void> { | ||
if (!this.localUserService.user$.value) { | ||
this.notifications = []; | ||
return; | ||
} | ||
|
||
this.notifications = await firstValueFrom(this.systemNotificationsService.getVisibleNotifications()); | ||
const shownNotificationIds = this.notifications.map(n => n.id); | ||
|
||
await firstValueFrom(this.systemNotificationsService.logInteraction(notification.id, "sawFull")); | ||
if (shownNotificationIds.length) { | ||
await firstValueFrom(this.systemNotificationsService.logInteraction("sawCallout", ...shownNotificationIds)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters