File

components/parameter-summary/parameter-summary.component.ts

Description

Summary of parameters entered, form field values to call service.

Metadata

Index

Properties
Methods

Constructor

constructor(service: AppService)
Parameters :
Name Type Optional
service AppService No

Methods

sourceTree
sourceTree(values: ControlForm, usage: SourceLogicTreesUsage)

Returns the source tree name.

Parameters :
Name Type Optional Description
values ControlForm No

Control panel form field values

usage SourceLogicTreesUsage No

Source logic trees usage

Returns : string
sourceType
sourceType(source: MfdSource)

Returns the source type name.

Parameters :
Name Type Optional Description
source MfdSource No

The MFD source

Returns : string
tectonicSetting
tectonicSetting(source: MfdSource)

Returns the tectonic setting name.

Parameters :
Name Type Optional Description
source MfdSource No

The MFD source

Returns : string

Properties

formGroup
Default value : this.service.formGroup

Form field state

Public service
Type : AppService
toDisplay
Default value : nshmpUtils.parameterToDisplay

Function to get display from a Parameter

usage
Default value : this.service.usage

Usage response state

import {Component} from '@angular/core';
import {MatList, MatListItem} from '@angular/material/list';
import {nshmpUtils} from '@ghsc/nshmp-lib-ng/nshmp';
import {SourceLogicTreesUsage} from '@ghsc/nshmp-utils-ts/libs/nshmp-haz/www/source-logic-trees-service';
import {
  sourceTypeToCapitalCase,
  tectonicSettingsToString,
} from '@ghsc/nshmp-utils-ts/libs/nshmp-lib/model';

import {ControlForm, MfdSource} from '../../models/control-form.model';
import {AppService} from '../../services/app.service';

/**
 * Summary of parameters entered, form field values to call service.
 */
@Component({
  imports: [MatList, MatListItem],
  selector: 'app-parameter-summary',
  styleUrl: './parameter-summary.component.scss',
  templateUrl: './parameter-summary.component.html',
})
export class ParameterSummaryComponent {
  /** Function to get display from a `Parameter` */
  toDisplay = nshmpUtils.parameterToDisplay;

  /** Form field state */
  formGroup = this.service.formGroup;

  /** Usage response state */
  usage = this.service.usage;

  constructor(public service: AppService) {}

  /**
   * Returns the source tree name.
   *
   * @param values Control panel form field values
   * @param usage Source logic trees usage
   */
  sourceTree(values: ControlForm, usage: SourceLogicTreesUsage): string {
    if (values.model === null || values.source === null || usage === null) {
      return '';
    }

    const source = values.source;

    const settingsTree = usage.response.trees.find(
      tree => tree.setting === source.tectonicSettings,
    );
    const tree = settingsTree?.data?.find(
      data => data.type === source.sourceType,
    );
    const data = tree?.data.find(info => info.id === values.sourceTree);

    return data ? `${data.name} (${values.sourceTree})` : '';
  }

  /**
   * Returns the source type name.
   *
   * @param source The MFD source
   * @returns
   */
  sourceType(source: MfdSource): string {
    return source === undefined || source === null
      ? ''
      : sourceTypeToCapitalCase(source.sourceType);
  }

  /**
   * Returns the tectonic setting name.
   *
   * @param source The MFD source
   * @returns
   */
  tectonicSetting(source: MfdSource): string {
    return source === undefined || source === null
      ? ''
      : tectonicSettingsToString(source.tectonicSettings);
  }
}
<div class="grid-row parameter-summary">
  <div class="grid-col-12 tablet:grid-col-6">
    <mat-list class="parameter-list">
      <mat-list-item>
        <span class="parameter">Model</span>:
        {{ toDisplay(formGroup?.value?.model, service.availableModels()) }}
      </mat-list-item>

      <mat-list-item>
        <span class="parameter">Tectonic Setting</span>:
        {{ tectonicSetting(formGroup?.value?.source) }}
      </mat-list-item>

      <mat-list-item>
        <span class="parameter">Source Type</span>:
        {{ sourceType(formGroup?.value?.source) }}
      </mat-list-item>
    </mat-list>
  </div>

  <div class="grid-col-12 tablet:grid-col-6">
    <mat-list class="parameter-list">
      <mat-list-item>
        <span class="parameter">Source Tree</span>:
        {{ sourceTree(formGroup.getRawValue(), usage()) }}
      </mat-list-item>

      <mat-list-item>
        <span class="parameter">MFD Type</span>:
        {{ formGroup?.value?.mfdType }}
      </mat-list-item>
    </mat-list>
  </div>
</div>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""