-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #306 from NREL/issue-287
Add disabled button option to toast notification
- Loading branch information
Showing
7 changed files
with
61 additions
and
15 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.toast-footer{ | ||
text-align: right; | ||
} |
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
7 changes: 6 additions & 1 deletion
7
src/app/core-components/toast-notifications/toast-notifications.component.spec.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
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
8 changes: 7 additions & 1 deletion
8
src/app/core-components/toast-notifications/toast-notifications.service.spec.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
40 changes: 29 additions & 11 deletions
40
src/app/core-components/toast-notifications/toast-notifications.service.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,40 +1,58 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { BehaviorSubject } from 'rxjs'; | ||
import { BehaviorSubject, Subscription } from 'rxjs'; | ||
import { LocalStorageDataService } from 'src/app/shared/shared-services/local-storage-data.service'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class ToastNotificationsService { | ||
|
||
toastNotification: BehaviorSubject<ToastNotification>; | ||
|
||
constructor() { | ||
disableNotification: BehaviorSubject<boolean>; | ||
disableNotificaitonSub: Subscription; | ||
constructor(private localStorageDataService: LocalStorageDataService) { | ||
this.toastNotification = new BehaviorSubject<ToastNotification>(undefined); | ||
this.disableNotification = new BehaviorSubject<boolean>(false); | ||
} | ||
|
||
showToast(title: string, body: string, toastClass: ToastClass, autoHide: boolean) { | ||
showToast(title: string, body: string, toastClass: ToastClass, autoHide: boolean, showDisable: boolean) { | ||
this.toastNotification.next({ | ||
autoHide: autoHide, | ||
title: title, | ||
body: body, | ||
toastClass: toastClass | ||
toastClass: toastClass, | ||
showDisable: showDisable | ||
}) | ||
} | ||
|
||
showWebDisclaimer() { | ||
let title: string = "JUSTIFI Web"; | ||
let body: string = `You are running JUSTIFI in a web browser. All application data is saved within this browser (The DOE does not have access to your data). | ||
It is encouraged that you download backup files of your data frequently. Backups can be uploaded to restore lost or corrupted data. Additionally, sharing backups with the development team can help in their effort to make this tool. <br> <hr> | ||
You can download data backups using the "Download Data" button in the upper right hand corner of your screen.` | ||
this.showToast(title, body, "bg-info", false); | ||
if (!this.localStorageDataService.disableDataDisclaimer) { | ||
let title: string = "JUSTIFI Web"; | ||
let body: string = `You are running JUSTIFI in a web browser. All application data is saved within this browser (The DOE does not have access to your data). | ||
It is encouraged that you download backup files of your data frequently. Backups can be uploaded to restore lost or corrupted data. Additionally, sharing backups with the development team can help in their effort to make this tool. <br> <hr> | ||
You can download data backups using the "Download Data" button in the upper right hand corner of your screen.` | ||
this.showToast(title, body, "bg-info", false, true); | ||
let initDisable: boolean = true; | ||
this.disableNotificaitonSub = this.disableNotification.subscribe(val => { | ||
if (val == true) { | ||
this.localStorageDataService.setDisableDataDisclaimer(true) | ||
}; | ||
if (!initDisable) { | ||
this.disableNotificaitonSub.unsubscribe(); | ||
} else { | ||
initDisable = false; | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
|
||
export interface ToastNotification { | ||
autoHide: boolean, | ||
title: string, | ||
body: string, | ||
toastClass: ToastClass | ||
toastClass: ToastClass, | ||
showDisable: boolean | ||
} | ||
|
||
export type ToastClass = 'bg-success' | 'bg-info' | 'bg-danger' | 'bg-primary' | 'bg-secondary' | 'bg-warning' | 'bg-light' | 'bg-dark'; |
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