From 6a906f29897fad67be46493089c644b1c72669fc Mon Sep 17 00:00:00 2001 From: rmroot Date: Mon, 4 Nov 2024 10:56:14 -0600 Subject: [PATCH 1/2] add disable notification for toast notification for data --- .../toast-notifications.component.css | 3 ++ .../toast-notifications.component.html | 3 ++ .../toast-notifications.component.ts | 8 +++- .../toast-notifications.service.ts | 40 ++++++++++++++----- .../local-storage-data.service.ts | 7 ++++ 5 files changed, 48 insertions(+), 13 deletions(-) diff --git a/src/app/core-components/toast-notifications/toast-notifications.component.css b/src/app/core-components/toast-notifications/toast-notifications.component.css index e69de29b..0da306a5 100644 --- a/src/app/core-components/toast-notifications/toast-notifications.component.css +++ b/src/app/core-components/toast-notifications/toast-notifications.component.css @@ -0,0 +1,3 @@ +.toast-footer{ + text-align: right; +} \ No newline at end of file diff --git a/src/app/core-components/toast-notifications/toast-notifications.component.html b/src/app/core-components/toast-notifications/toast-notifications.component.html index cc26def5..78fc82a5 100644 --- a/src/app/core-components/toast-notifications/toast-notifications.component.html +++ b/src/app/core-components/toast-notifications/toast-notifications.component.html @@ -9,6 +9,9 @@
+ \ No newline at end of file diff --git a/src/app/core-components/toast-notifications/toast-notifications.component.ts b/src/app/core-components/toast-notifications/toast-notifications.component.ts index 72e9b5ec..3e64303c 100644 --- a/src/app/core-components/toast-notifications/toast-notifications.component.ts +++ b/src/app/core-components/toast-notifications/toast-notifications.component.ts @@ -47,11 +47,15 @@ export class ToastNotificationsComponent { } } - - closeToast() { this.toast.hide(); + this.toastNotificationService.disableNotification.next(false); this.toastNotificationService.toastNotification.next(undefined); } + disableNotification() { + this.toast.hide(); + this.toastNotificationService.disableNotification.next(true); + this.toastNotificationService.toastNotification.next(undefined); + } } diff --git a/src/app/core-components/toast-notifications/toast-notifications.service.ts b/src/app/core-components/toast-notifications/toast-notifications.service.ts index 8b785d0c..9b44e2fe 100644 --- a/src/app/core-components/toast-notifications/toast-notifications.service.ts +++ b/src/app/core-components/toast-notifications/toast-notifications.service.ts @@ -1,5 +1,6 @@ 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' @@ -7,26 +8,42 @@ import { BehaviorSubject } from 'rxjs'; export class ToastNotificationsService { toastNotification: BehaviorSubject; - - constructor() { + disableNotification: BehaviorSubject; + disableNotificaitonSub: Subscription; + constructor(private localStorageDataService: LocalStorageDataService) { this.toastNotification = new BehaviorSubject(undefined); + this.disableNotification = new BehaviorSubject(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.

- 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.

+ 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; + } + }); + } } } @@ -34,7 +51,8 @@ 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'; \ No newline at end of file diff --git a/src/app/shared/shared-services/local-storage-data.service.ts b/src/app/shared/shared-services/local-storage-data.service.ts index d7c58d54..8d66aff2 100644 --- a/src/app/shared/shared-services/local-storage-data.service.ts +++ b/src/app/shared/shared-services/local-storage-data.service.ts @@ -14,6 +14,7 @@ export class LocalStorageDataService { processEquipmentAccordionGuid: string; assessmentAccordionGuid: string; disableAlphaDisclaimer: boolean; + disableDataDisclaimer: boolean; constructor(private localStorageService: LocalStorageService) { this.setupHelpPanelCollapsed = this.localStorageService.retrieve("setupHelpPanelCollapsed"); if (this.setupHelpPanelCollapsed == undefined) { @@ -32,6 +33,7 @@ export class LocalStorageDataService { this.processEquipmentAccordionGuid = this.localStorageService.retrieve("processEquipmentAccordionGuid"); this.assessmentAccordionGuid = this.localStorageService.retrieve("assessmentAccordionGuid"); this.disableAlphaDisclaimer = this.localStorageService.retrieve("disableAlphaDisclaimer"); + this.disableDataDisclaimer = this.localStorageService.retrieve("disableDataDisclaimer"); } setSetupPanelCollapsed(val: boolean) { @@ -73,4 +75,9 @@ export class LocalStorageDataService { this.disableAlphaDisclaimer = disableAlphaDisclaimer; this.localStorageService.store('disableAlphaDisclaimer', this.disableAlphaDisclaimer); } + + setDisableDataDisclaimer(disableDataDisclaimer: boolean) { + this.disableDataDisclaimer = disableDataDisclaimer; + this.localStorageService.store('disableDataDisclaimer', this.disableDataDisclaimer); + } } From 2d6080048e9aeae29047d9b81acaa1430122afd8 Mon Sep 17 00:00:00 2001 From: rmroot Date: Mon, 4 Nov 2024 11:00:55 -0600 Subject: [PATCH 2/2] all tests passing --- .../toast-notifications.component.spec.ts | 7 ++++++- .../toast-notifications.service.spec.ts | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/app/core-components/toast-notifications/toast-notifications.component.spec.ts b/src/app/core-components/toast-notifications/toast-notifications.component.spec.ts index 66c65ae1..ac267bec 100644 --- a/src/app/core-components/toast-notifications/toast-notifications.component.spec.ts +++ b/src/app/core-components/toast-notifications/toast-notifications.component.spec.ts @@ -1,16 +1,21 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ToastNotificationsComponent } from './toast-notifications.component'; +import { LocalStorageDataService } from 'src/app/shared/shared-services/local-storage-data.service'; describe('ToastNotificationsComponent', () => { let component: ToastNotificationsComponent; let fixture: ComponentFixture; + let localStorageDataService: Partial = {} beforeEach(async () => { await TestBed.configureTestingModule({ + providers: [ + { provide: LocalStorageDataService, useValue: localStorageDataService } + ], declarations: [ToastNotificationsComponent] }) - .compileComponents(); + .compileComponents(); fixture = TestBed.createComponent(ToastNotificationsComponent); component = fixture.componentInstance; diff --git a/src/app/core-components/toast-notifications/toast-notifications.service.spec.ts b/src/app/core-components/toast-notifications/toast-notifications.service.spec.ts index 072c5e96..b9093dcb 100644 --- a/src/app/core-components/toast-notifications/toast-notifications.service.spec.ts +++ b/src/app/core-components/toast-notifications/toast-notifications.service.spec.ts @@ -1,12 +1,18 @@ import { TestBed } from '@angular/core/testing'; import { ToastNotificationsService } from './toast-notifications.service'; +import { LocalStorageDataService } from 'src/app/shared/shared-services/local-storage-data.service'; describe('ToastNotificationsService', () => { let service: ToastNotificationsService; + let localStorageDataService: Partial = {} beforeEach(() => { - TestBed.configureTestingModule({}); + TestBed.configureTestingModule({ + providers: [ + { provide: LocalStorageDataService, useValue: localStorageDataService } + ] + }); service = TestBed.inject(ToastNotificationsService); });