File

components/connected-applications/connected-applications.component.ts

Metadata

Index

Properties
Methods

Methods

Private modelParameters$
modelParameters$()
Returns : Observable<ConnectedApplicationParameter[]>
Private rtgmParameters$
rtgmParameters$()
Returns : Observable<ConnectedApplicationParameter[]>

Properties

connectedApplications
Type : ConnectedApplication[]
Default value : [ { application: apps().hazard.dynamic, description: 'Open the dynamic hazard application using the current NSHM', parameters$: this.modelParameters$(), }, { application: apps().hazard.disagg, description: 'Open the disaggregation application using the current NSHM', parameters$: this.modelParameters$(), }, { application: apps().designMaps.rtgm, description: 'Open the RTGM application using the current NSHM', parameters$: this.rtgmParameters$(), }, { application: apps().source.modelMaps, description: 'Open the model maps application using the current NSHM', parameters$: this.modelParameters$(), }, { application: apps().source.rateAndProbability, description: 'Open the rates and probabilities application using the current NSHM', parameters$: this.modelParameters$(), }, ]
Private formGroup
Default value : this.service.formGroup
Private service
Default value : inject(AppService)
import {ChangeDetectionStrategy, Component, inject} from '@angular/core';
import {toObservable} from '@angular/core/rxjs-interop';
import {
  ConnectedApplication,
  ConnectedApplicationParameter,
  NshmpConnectedApplicationsComponent,
  nshmpUtils,
} from '@ghsc/nshmp-lib-ng/nshmp';
import {ControlType} from 'projects/nshmp-apps/src/app/designmaps/rtgm/models/control-type.model';
import {apps} from 'projects/nshmp-apps/src/shared/utils/applications.utils';
import {combineLatest, map, Observable} from 'rxjs';

import {AppService} from '../../services/app.service';

@Component({
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [NshmpConnectedApplicationsComponent],
  selector: 'app-connected-applications',
  styleUrl: './connected-applications.component.scss',
  templateUrl: './connected-applications.component.html',
})
export class ConnectedApplicationsComponent {
  private service = inject(AppService);

  private formGroup = this.service.formGroup;

  connectedApplications: ConnectedApplication[] = [
    {
      application: apps().hazard.dynamic,
      description: 'Open the dynamic hazard application using the current NSHM',
      parameters$: this.modelParameters$(),
    },
    {
      application: apps().hazard.disagg,
      description: 'Open the disaggregation application using the current NSHM',
      parameters$: this.modelParameters$(),
    },
    {
      application: apps().designMaps.rtgm,
      description: 'Open the RTGM application using the current NSHM',
      parameters$: this.rtgmParameters$(),
    },
    {
      application: apps().source.modelMaps,
      description: 'Open the model maps application using the current NSHM',
      parameters$: this.modelParameters$(),
    },
    {
      application: apps().source.rateAndProbability,
      description: 'Open the rates and probabilities application using the current NSHM',
      parameters$: this.modelParameters$(),
    },
  ];

  private modelParameters$(): Observable<ConnectedApplicationParameter[]> {
    return combineLatest([
      this.formGroup.valueChanges,
      toObservable(this.service.availableModels),
    ]).pipe(
      map(([values, availableModels]) => {
        const parameters: ConnectedApplicationParameter[] = [
          {
            gridColumn: 12,
            key: 'model',
            value: values.model,
            valueDisplay: nshmpUtils.parameterToDisplay(values.model ?? '', availableModels),
          },
        ];

        return parameters;
      }),
    );
  }

  private rtgmParameters$(): Observable<ConnectedApplicationParameter[]> {
    return combineLatest([
      this.formGroup.valueChanges,
      toObservable(this.service.availableModels),
    ]).pipe(
      map(([values, availableModels]) => {
        const parameters: ConnectedApplicationParameter[] = [
          {
            key: 'model',
            value: values.model,
            valueDisplay: nshmpUtils.parameterToDisplay(values.model ?? '', availableModels),
          },
          {key: 'controlType', value: ControlType.DYNAMIC_HAZARD},
        ];

        return parameters;
      }),
    );
  }
}
<nshmp-connected-applications [applications]="connectedApplications" />
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""