File

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

Metadata

Index

Properties
Methods

Methods

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

Properties

connectedApplications
Type : ConnectedApplication[]
Default value : [ { application: apps().designMaps.rtgm, description: 'Open the RTGM application using the current control panel inputs', parameters$: this.rtgmParameters$(), }, { application: apps().ncm.geophysicalProfiles, description: 'Open the NCM geophysical profiles applications using the current location', parameters$: this.geophysicalParameters$(), }, ]
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().designMaps.rtgm,
      description: 'Open the RTGM application using the current control panel inputs',
      parameters$: this.rtgmParameters$(),
    },
    {
      application: apps().ncm.geophysicalProfiles,
      description: 'Open the NCM geophysical profiles applications using the current location',
      parameters$: this.geophysicalParameters$(),
    },
  ];

  private geophysicalParameters$(): Observable<ConnectedApplicationParameter[]> {
    return this.formGroup.valueChanges.pipe(
      map(values => {
        return [
          {
            gridColumn: 12,
            key: 'location',
            value: `${values.latitude}, ${values.longitude}`,
            valueDisplay: [
              `${this.service.checkNanDisplay(values.latitude)}°`,
              `${this.service.checkNanDisplay(values.longitude)}°`,
            ].join(),
          },
        ];
      }),
    );
  }

  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: 'latitude', units: '°', value: values.latitude},
          {key: 'returnPeriod', units: 'years', value: values.returnPeriod},
          {key: 'longitude', units: '°', value: values.longitude},
          {key: 'siteClass', value: values.siteClass},
          {key: 'controlType', value: ControlType.STATIC_HAZARD},
        ];

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

results matching ""

    No results matching ""