diff --git a/projects/nshmp-apps/src/app/internal/dashboard/.compodoc.yml b/projects/nshmp-apps/src/app/internal/dashboard/.compodoc.yml new file mode 100644 index 0000000000000000000000000000000000000000..fa7db2da1bb1eb1292cba4b4e1cc4af449f90fb1 --- /dev/null +++ b/projects/nshmp-apps/src/app/internal/dashboard/.compodoc.yml @@ -0,0 +1 @@ +name: Development Dashboard diff --git a/projects/nshmp-apps/src/app/internal/dashboard/app.component.html b/projects/nshmp-apps/src/app/internal/dashboard/app.component.html new file mode 100644 index 0000000000000000000000000000000000000000..ba0728ed002fc40d1b8bdf8eef71bb819b3f973f --- /dev/null +++ b/projects/nshmp-apps/src/app/internal/dashboard/app.component.html @@ -0,0 +1,21 @@ +<nshmp-lib-ng-template #template [navigationList]="navigationList"> + <!-- Dashboard --> + <nshmp-lib-ng-dashboard [sections]="sections"> + <nshmp-lib-ng-dashboard-title> + USGS Earthquake + <br /> + Hazard Toolbox: + <br /> + Internal Applications + </nshmp-lib-ng-dashboard-title> + <nshmp-lib-ng-dashboard-description /> + </nshmp-lib-ng-dashboard> + + <!-- About page --> + <nshmp-lib-ng-about-page> + <nshmp-lib-ng-about-content + [showSavingSettingPanel]="false" + [showUsingApplicationPanel]="false" + /> + </nshmp-lib-ng-about-page> +</nshmp-lib-ng-template> diff --git a/projects/nshmp-apps/src/app/internal/dashboard/app.component.scss b/projects/nshmp-apps/src/app/internal/dashboard/app.component.scss new file mode 100644 index 0000000000000000000000000000000000000000..9725bdd50fd511d82056ee0edd62b199fb4fdeaa --- /dev/null +++ b/projects/nshmp-apps/src/app/internal/dashboard/app.component.scss @@ -0,0 +1 @@ +@import '../../../styles/dashboards'; diff --git a/projects/nshmp-apps/src/app/internal/dashboard/app.component.spec.ts b/projects/nshmp-apps/src/app/internal/dashboard/app.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..892acc0c639cb4d4ba6d7c40f483790efb8c7c13 --- /dev/null +++ b/projects/nshmp-apps/src/app/internal/dashboard/app.component.spec.ts @@ -0,0 +1,33 @@ +import {provideHttpClient} from '@angular/common/http'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; +import {provideNoopAnimations} from '@angular/platform-browser/animations'; +import {provideRouter} from '@angular/router'; + +import {AppComponent} from './app.component'; + +describe('DashboardComponent', () => { + let component: AppComponent; + let fixture: ComponentFixture<AppComponent>; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [AppComponent], + providers: [ + provideHttpClient(), + provideNoopAnimations(), + provideRouter([]), + ], + teardown: {destroyAfterEach: false}, + }).compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(AppComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/projects/nshmp-apps/src/app/internal/dashboard/app.component.ts b/projects/nshmp-apps/src/app/internal/dashboard/app.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..51c6803040c302d59ff4bd9265d03c334e21a947 --- /dev/null +++ b/projects/nshmp-apps/src/app/internal/dashboard/app.component.ts @@ -0,0 +1,65 @@ +import {Component, OnDestroy, OnInit} from '@angular/core'; +import { + NshmpLibNgAboutContentComponent, + NshmpLibNgAboutPageComponent, +} from '@ghsc/nshmp-lib-ng/about'; +import { + ApplicationSections, + NshmpLibNgDashboardComponent, + NshmpLibNgDashboardDescriptionComponent, + NshmpLibNgDashboardTitleComponent, + NshmpLibNgTemplateComponent, +} from '@ghsc/nshmp-lib-ng/nshmp'; +import {Subscription} from 'rxjs'; + +import * as nav from '../../../shared/utils/navigation.utils'; +import {AuthService} from '../shared/services/auth.service'; + +/** + * Development dashboard showing links to development applications. + */ +@Component({ + imports: [ + NshmpLibNgTemplateComponent, + NshmpLibNgAboutPageComponent, + NshmpLibNgAboutContentComponent, + NshmpLibNgDashboardComponent, + NshmpLibNgDashboardTitleComponent, + NshmpLibNgDashboardDescriptionComponent, + ], + selector: 'app-app', + standalone: true, + styleUrl: './app.component.scss', + templateUrl: './app.component.html', +}) +export class AppComponent implements OnInit, OnDestroy { + /** Navigation list for menu */ + navigationList = nav.devNavigation(); + + /** AWS applications */ + private awsApps = nav.devAwsApps(); + + sections: ApplicationSections[] = []; + + private sub: Subscription; + + constructor(private authService: AuthService) {} + ngOnInit(): void { + this.sub = this.authService.isAuthorized().subscribe(() => { + this.sections = [ + { + sections: [ + { + applications: this.awsApps.map(navigation => ({navigation})), + }, + ], + }, + ]; + }); + } + + ngOnDestroy(): void { + this.sections = []; + this.sub.unsubscribe(); + } +}