From 4ec0f7afc0a5cb66c7b205332337e9b3f1db8ed0 Mon Sep 17 00:00:00 2001
From: Brandon Clayton <bclayton@usgs.gov>
Date: Tue, 26 Nov 2024 16:16:25 -0700
Subject: [PATCH] add internal dashboard

---
 .../src/app/internal/dashboard/.compodoc.yml  |  1 +
 .../app/internal/dashboard/app.component.html | 21 ++++++
 .../app/internal/dashboard/app.component.scss |  1 +
 .../internal/dashboard/app.component.spec.ts  | 33 ++++++++++
 .../app/internal/dashboard/app.component.ts   | 65 +++++++++++++++++++
 5 files changed, 121 insertions(+)
 create mode 100644 projects/nshmp-apps/src/app/internal/dashboard/.compodoc.yml
 create mode 100644 projects/nshmp-apps/src/app/internal/dashboard/app.component.html
 create mode 100644 projects/nshmp-apps/src/app/internal/dashboard/app.component.scss
 create mode 100644 projects/nshmp-apps/src/app/internal/dashboard/app.component.spec.ts
 create mode 100644 projects/nshmp-apps/src/app/internal/dashboard/app.component.ts

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 000000000..fa7db2da1
--- /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 000000000..ba0728ed0
--- /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 000000000..9725bdd50
--- /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 000000000..892acc0c6
--- /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 000000000..51c680304
--- /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();
+  }
+}
-- 
GitLab