File

components/path-parameters/path-parameters.component.ts

Description

Control panel form fields for GMM path parameters.

Implements

OnInit OnDestroy

Metadata

Index

Properties
Methods

Constructor

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

Methods

ngOnDestroy
ngOnDestroy()
Returns : void
ngOnInit
ngOnInit()
Returns : void

Properties

controls
Default value : this.service.formGroup.controls

Form controls state

Private distanceSubscription
Default value : new Subscription()
form
Default value : this.service.formGroup

Control panel form field state

parameters
Default value : computed(() => this.service.usage()?.response.parameters)

Usage parameters

import {Component, computed, OnDestroy, OnInit} from '@angular/core';
import {ReactiveFormsModule} from '@angular/forms';
import {MatError, MatFormField, MatLabel} from '@angular/material/form-field';
import {MatInput} from '@angular/material/input';
import {Subscription} from 'rxjs';

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

/**
 * Control panel form fields for GMM path parameters.
 */
@Component({
  imports: [MatLabel, MatFormField, MatInput, MatError, ReactiveFormsModule],
  selector: 'app-path-parameters',
  styleUrl: './path-parameters.component.scss',
  templateUrl: './path-parameters.component.html',
})
export class PathParametersComponent implements OnInit, OnDestroy {
  /** Form controls state */
  controls = this.service.formGroup.controls;

  /** Control panel form field state */
  form = this.service.formGroup;

  /** Usage parameters */
  parameters = computed(() => this.service.usage()?.response.parameters);

  private distanceSubscription = new Subscription();

  constructor(private service: AppService) {}

  ngOnInit(): void {
    this.distanceSubscription = this.controls.distance.valueChanges.subscribe(
      () => this.service.resetState(),
    );
  }

  ngOnDestroy(): void {
    this.distanceSubscription.unsubscribe();
  }
}
<!-- Path Parameters -->
<div class="settings-subsection control-panel">
  <mat-label class="settings-subsection--label">Path Parameters</mat-label>
  <!-- Event parameters: Distance input -->
  <div class="settings-subsection--section distance-input">
    <mat-form-field class="grid-col-12">
      <mat-label>Distance (km)</mat-label>
      <input
        matInput
        [max]="parameters()?.distance?.max"
        [min]="parameters()?.distance?.min"
        [formControl]="controls.distance"
        step="1"
        type="number"
      />
      <mat-error>
        [
        {{ parameters()?.distance?.min }},
        {{ parameters()?.distance?.max }}
        ]
      </mat-error>
    </mat-form-field>
  </div>
</div>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""