diff --git a/src/app/charts/chart.component.html b/src/app/charts/chart.component.html index 3442e5af..0c581311 100644 --- a/src/app/charts/chart.component.html +++ b/src/app/charts/chart.component.html @@ -14,7 +14,7 @@

+ (basetempParamSelected)="onExtraParamsSelected($event)">
diff --git a/src/app/charts/chart.component.ts b/src/app/charts/chart.component.ts index ce27a455..4c222112 100644 --- a/src/app/charts/chart.component.ts +++ b/src/app/charts/chart.component.ts @@ -29,7 +29,7 @@ import { DataExportService } from '../services/data-export.service'; import { ImageExportService } from '../services/image-export.service'; import { isBasetempIndicator, - isPercentileIndicator + isPercentileIndicator, isThresholdIndicator } from '../charts/extra-params-components/extra-params.constants'; import * as _ from 'lodash'; diff --git a/src/app/charts/extra-params-components/basetemp.component.html b/src/app/charts/extra-params-components/basetemp.component.html index bc1d2915..5a28364e 100644 --- a/src/app/charts/extra-params-components/basetemp.component.html +++ b/src/app/charts/extra-params-components/basetemp.component.html @@ -8,10 +8,10 @@ formControlName="basetempCtl">
- \ No newline at end of file + diff --git a/src/app/charts/extra-params-components/basetemp.component.ts b/src/app/charts/extra-params-components/basetemp.component.ts index 86c457e0..affad747 100644 --- a/src/app/charts/extra-params-components/basetemp.component.ts +++ b/src/app/charts/extra-params-components/basetemp.component.ts @@ -3,6 +3,7 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { Indicator } from '../../models/indicator.model'; import { BasetempIndicatorQueryParams } from '../../models/basetemp-indicator-query-params.model'; +import { TemperatureUnits } from './extra-params.constants'; import * as _ from 'lodash'; @@ -25,12 +26,7 @@ export class BasetempComponent implements AfterViewInit, OnInit { // default form values private defaultBasetemp = 50; private defaultBasetempUnit = 'F'; - - public basetempUnits: any[] = [ - {'key': 'K', 'label': 'Kelvin'}, - {'key': 'F', 'label': 'Farenheit'}, - {'key': 'C', 'label': 'Centigrade'} - ]; + private temperatureUnits = TemperatureUnits; constructor(private formBuilder: FormBuilder) {} diff --git a/src/app/charts/extra-params-components/extra-params.constants.ts b/src/app/charts/extra-params-components/extra-params.constants.ts index f9a817cd..bab1cebf 100644 --- a/src/app/charts/extra-params-components/extra-params.constants.ts +++ b/src/app/charts/extra-params-components/extra-params.constants.ts @@ -19,6 +19,18 @@ const percentileIndicatorNames = [ const extraParamsIndicatorNames = [].concat(thresholdIndicatorNames, percentileIndicatorNames); +export const TemperatureUnits: any[] = [ + {'key': 'K', 'label': 'Kelvin'}, + {'key': 'F', 'label': 'Farenheit'}, + {'key': 'C', 'label': 'Centigrade'} + ]; + +export const PrecipitationUnits: any[] = [ + {'key': 'mm', 'label': 'millimeters'}, + {'key': 'in', 'label': 'inches'}, + {'key': 'kg/m^2', 'label': 'kg/m^2'} +]; + export function isBasetempIndicator(indicatorName: string): boolean { return basetempIndicatorNames.indexOf(indicatorName) !== -1; } @@ -33,4 +45,4 @@ export function hasExtraParams(indicatorName: string): boolean { export function isPercentileIndicator(indicatorName: string): boolean { return percentileIndicatorNames.indexOf(indicatorName) !== -1; -} +} \ No newline at end of file diff --git a/src/app/charts/extra-params-components/threshold.component.ts b/src/app/charts/extra-params-components/threshold.component.ts index ce8eef2b..fc75ca2f 100644 --- a/src/app/charts/extra-params-components/threshold.component.ts +++ b/src/app/charts/extra-params-components/threshold.component.ts @@ -3,6 +3,8 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { Indicator } from '../../models/indicator.model'; import { ThresholdIndicatorQueryParams } from '../../models/threshold-indicator-query-params.model'; +import { PrecipitationUnits, + TemperatureUnits } from './extra-params.constants'; import * as _ from 'lodash'; @@ -22,24 +24,15 @@ export class ThresholdComponent implements AfterViewInit, OnInit { thresholdForm: FormGroup; - private thresholdTemperatureUnits: any[] = [ - {'key': 'K', 'label': 'Kelvin'}, - {'key': 'F', 'label': 'Farenheit'}, - {'key': 'C', 'label': 'Centigrade'} - ]; - - private thresholdComparators: any[] = [ + private thresholdComparators: any[] = [ {'key': 'gte', 'label': 'greater than or equal to'}, {'key': 'lte', 'label': 'less than or equal to'}, {'key': 'gt', 'label': 'greater than'}, {'key': 'lt', 'label': 'less than'} ]; - private thresholdPrecipitationUnits: any[] = [ - {'key': 'mm', 'label': 'millimeters'}, - {'key': 'in', 'label': 'inches'}, - {'key': 'kg/m^2', 'label': 'kg/m^2'} - ]; + private temperatureUnits = TemperatureUnits; + private precipitationUnits = PrecipitationUnits; // default form values private defaultThreshold = 50; @@ -49,8 +42,7 @@ export class ThresholdComponent implements AfterViewInit, OnInit { private defaultComparator = 'lte'; @Input() comparators: any[] = this.thresholdComparators; - - @Input() thresholdUnits: any[] = this.thresholdTemperatureUnits; + @Input() thresholdUnits: any[] = this.temperatureUnits; constructor(private formBuilder: FormBuilder) {} @@ -90,10 +82,10 @@ export class ThresholdComponent implements AfterViewInit, OnInit { // Set component to precip or temperature if (this.indicator.variables.includes('pr')) { this.defaultUnit = this.defaultPrecipitationUnit; - this.thresholdUnits = this.thresholdPrecipitationUnits; + this.thresholdUnits = this.precipitationUnits; } else { this.defaultUnit = this.defaultTemperatureUnit; - this.thresholdUnits = this.thresholdTemperatureUnits; + this.thresholdUnits = this.temperatureUnits; } } } diff --git a/src/app/services/indicator.service.ts b/src/app/services/indicator.service.ts index 84f33bc4..b620e8e0 100644 --- a/src/app/services/indicator.service.ts +++ b/src/app/services/indicator.service.ts @@ -11,9 +11,6 @@ import { BasetempIndicatorQueryParams } from '../models/basetemp-indicator-query import { PercentileIndicatorQueryParams } from '../models/percentile-indicator-query-params.model'; import { IndicatorQueryParams } from '../models/indicator-query-params.model'; -import { ApiHttp } from '../auth/api-http.service'; -import { apiHost } from '../constants'; - import { isBasetempIndicator, isPercentileIndicator, isThresholdIndicator } from '../charts/extra-params-components/extra-params.constants';