Skip to content
Snippets Groups Projects
Commit d6ba6bc5 authored by Clayton, Brandon Scott's avatar Clayton, Brandon Scott
Browse files

handle imported config

parent 576c74df
No related branches found
No related tags found
1 merge request!572AWS Updates
......@@ -11,8 +11,6 @@ import {
import {
CalcConfig,
CloudConfig,
MapConfig,
NshmpConfig,
RunNshmpHazHttpPostConfig,
RunNshmpHazResponseData,
} from '@ghsc/nshmp-utils-ts/libs/aws/run-nshmp-haz';
......@@ -37,22 +35,9 @@ import {
import {RunNshmpHazFormGroup} from '../models/form-group.model';
import {GitlabTagItem} from '../models/gitlab-tag-item.model';
import {NshmpHazClass} from '../models/nshmp-haz-class.model';
import {PostConfig} from '../models/post-config.model';
import {AppState} from '../models/state.model';
/**
* Post config.
*/
interface PostConfig {
/** Calc config */
calcConfig: CalcConfig | CalcConfig[];
/** AWS cloud config */
cloudConfig: CloudConfig;
/** NSHMP config to run nshmp-haz */
nshmpConfig: NshmpConfig;
/** Hazard map creation config */
mapConfig?: MapConfig;
}
/**
* Application service.
*/
......@@ -142,14 +127,24 @@ export class AppService implements AppServiceModel<AppState, RunNshmpHazForm> {
this.spinnerService.show('Calling nshmp-haz on AWS');
const url = `${this.baseUrl}${environment.webServices.aws.services.runHazardJobs}`;
const {cloudConfig, mapConfig, nshmpConfig} = this.formGroup.getRawValue();
const importedConfig = this.state().importedConfig;
const calls = this.state()
.calcConfig.map(calcConfig => {
const postConfig: RunNshmpHazHttpPostConfig = {
calcConfig,
cloudConfig,
mapConfig,
nshmpConfig,
cloudConfig: {
...importedConfig?.cloudConfig,
...cloudConfig,
},
mapConfig: {
...importedConfig?.mapConfig,
...mapConfig,
},
nshmpConfig: {
...importedConfig?.nshmpConfig,
...nshmpConfig,
},
};
return postConfig;
......@@ -199,6 +194,7 @@ export class AppService implements AppServiceModel<AppState, RunNshmpHazForm> {
instanceType: 'm7i.4xlarge',
},
mapConfig: {
createMap: true,
region: null,
title: 'Total Hazard Mean',
},
......@@ -234,6 +230,7 @@ export class AppService implements AppServiceModel<AppState, RunNshmpHazForm> {
instanceType: values.cloudConfig.instanceType,
},
mapConfig: {
createMap: true,
region: 'CONUS',
title: 'Total Mean Hazard',
},
......@@ -579,6 +576,10 @@ export class AppService implements AppServiceModel<AppState, RunNshmpHazForm> {
});
}
this.updateState({
importedConfig: awsConfig,
});
this.formGroup.markAsDirty();
} catch (e) {
const error = e instanceof Error ? e : new Error(e as string);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment