From b4d515317469425f5a5fd7fb99c80fa9c2975099 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Mon, 16 Dec 2024 12:45:23 -0700 Subject: [PATCH] add interface --- .../config-example/config-example.component.ts | 14 +++++++++++--- .../components/content/content.component.html | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/projects/nshmp-apps/src/app/internal/aws/submit-haz-jobs/components/config-example/config-example.component.ts b/projects/nshmp-apps/src/app/internal/aws/submit-haz-jobs/components/config-example/config-example.component.ts index 6379492ba..09d9b2b8a 100644 --- a/projects/nshmp-apps/src/app/internal/aws/submit-haz-jobs/components/config-example/config-example.component.ts +++ b/projects/nshmp-apps/src/app/internal/aws/submit-haz-jobs/components/config-example/config-example.component.ts @@ -3,6 +3,11 @@ import * as YAML from 'yaml'; import {AppService} from '../../services/app.service'; +export enum ExampleType { + JSON = 'JSON', + YAML = 'YAML', +} + /** * YAML or JSON example of HTTP POST to run hazard on AWS. */ @@ -14,7 +19,7 @@ import {AppService} from '../../services/app.service'; }) export class ConfigExampleComponent implements OnInit { /** The example type */ - readonly type = input('YAML' || 'JSON'); + readonly type = input<ExampleType>(); /** JSON example */ exampleJson = `\n${JSON.stringify(this.service.exampleConfig(), null, 2)}`; @@ -33,8 +38,11 @@ export class ConfigExampleComponent implements OnInit { constructor(private service: AppService) {} ngOnInit(): void { - this.example = this.type() === 'YAML' ? this.exampleYml : this.exampleJson; + this.example = + this.type() === ExampleType.YAML ? this.exampleYml : this.exampleJson; this.exampleArray = - this.type() === 'YAML' ? this.exampleYmlArray : this.exampleJsonArray; + this.type() === ExampleType.YAML + ? this.exampleYmlArray + : this.exampleJsonArray; } } diff --git a/projects/nshmp-apps/src/app/internal/aws/submit-haz-jobs/components/content/content.component.html b/projects/nshmp-apps/src/app/internal/aws/submit-haz-jobs/components/content/content.component.html index 29ed91b7f..9f1fca03a 100644 --- a/projects/nshmp-apps/src/app/internal/aws/submit-haz-jobs/components/content/content.component.html +++ b/projects/nshmp-apps/src/app/internal/aws/submit-haz-jobs/components/content/content.component.html @@ -23,10 +23,10 @@ </mat-tab> <mat-tab #jsonTab label="JSON Example"> - <app-config-example type="JSON" /> + <app-config-example [type]="Type.JSON" /> </mat-tab> <mat-tab #yamlTab label="YAML Example"> - <app-config-example type="YAML" /> + <app-config-example [type]="Type.YAML" /> </mat-tab> </mat-tab-group> -- GitLab