From 8f95a8c757fc45aa61a52b8d9640ba4f179b0c2f Mon Sep 17 00:00:00 2001 From: CloudNiner Date: Wed, 30 Aug 2017 13:39:09 -0400 Subject: [PATCH 1/4] Refactor IndicatorQueryOpts Refactor such that IndicatorQueryOpts.params now has type IndicatorParams which can be extended with additional parameters for some indicators. Improves type checking and prevents us from having to write duplicate interface defs for indicators that need to extend the params of IndicatorQueryOpts --- src/app/charts/chart.component.ts | 5 ++--- src/app/models/indicator-params.model.ts | 8 ++++++++ src/app/models/indicator-query-opts.model.ts | 8 ++------ .../models/threshold-indicator-params.model.ts | 7 +++++++ .../threshold-indicator-query-opts.model.ts | 16 ---------------- src/app/services/indicator.service.ts | 12 ++++++------ 6 files changed, 25 insertions(+), 31 deletions(-) create mode 100644 src/app/models/indicator-params.model.ts create mode 100644 src/app/models/threshold-indicator-params.model.ts delete mode 100644 src/app/models/threshold-indicator-query-opts.model.ts diff --git a/src/app/charts/chart.component.ts b/src/app/charts/chart.component.ts index a83c99cc..1a4f65dd 100644 --- a/src/app/charts/chart.component.ts +++ b/src/app/charts/chart.component.ts @@ -18,7 +18,7 @@ import { ChartData } from '../models/chart-data.model'; import { City } from '../models/city.model'; import { ClimateModel } from '../models/climate-model.model'; import { IndicatorQueryOpts } from '../models/indicator-query-opts.model'; -import { ThresholdIndicatorQueryOpts } from '../models/threshold-indicator-query-opts.model'; +import { IndicatorParams } from '../models/indicator-params.model'; import { Scenario } from '../models/scenario.model'; import { AuthService } from '../auth/auth.service'; @@ -182,8 +182,7 @@ export class ChartComponent implements OnChanges, OnDestroy, AfterViewInit { } public onThresholdSelected($event) { - const thresholdParams = $event.data as ThresholdIndicatorQueryOpts; - this.extraParams = thresholdParams; + this.extraParams = $event.data as IndicatorParams; this.onExtraParamsChanged.emit(this.extraParams); this.updateChart(this.extraParams); } diff --git a/src/app/models/indicator-params.model.ts b/src/app/models/indicator-params.model.ts new file mode 100644 index 00000000..9e0d4f48 --- /dev/null +++ b/src/app/models/indicator-params.model.ts @@ -0,0 +1,8 @@ +import { ClimateModel } from './climate-model.model'; + +export interface IndicatorParams { + climateModels?: ClimateModel[]; + years?: string[]; + time_aggregation?: string; + unit?: string; +} diff --git a/src/app/models/indicator-query-opts.model.ts b/src/app/models/indicator-query-opts.model.ts index aa818ab9..844ae976 100644 --- a/src/app/models/indicator-query-opts.model.ts +++ b/src/app/models/indicator-query-opts.model.ts @@ -1,5 +1,6 @@ import { City } from './city.model'; import { Indicator } from './indicator.model'; +import { IndicatorParams } from './indicator-params.model'; import { ClimateModel } from './climate-model.model'; import { Scenario } from './scenario.model'; @@ -7,10 +8,5 @@ export interface IndicatorQueryOpts { indicator: Indicator; city: City; scenario: Scenario; - params: { - climateModels?: ClimateModel[]; - years?: string[]; - time_aggregation?: string; - unit?: string; - } + params: IndicatorParams; } diff --git a/src/app/models/threshold-indicator-params.model.ts b/src/app/models/threshold-indicator-params.model.ts new file mode 100644 index 00000000..c8a2469d --- /dev/null +++ b/src/app/models/threshold-indicator-params.model.ts @@ -0,0 +1,7 @@ +import { IndicatorParams } from './indicator-params.model'; + +export interface ThresholdIndicatorParams extends IndicatorParams { + threshold: Number; + threshold_units: string; + threshold_comparator: string; +} diff --git a/src/app/models/threshold-indicator-query-opts.model.ts b/src/app/models/threshold-indicator-query-opts.model.ts deleted file mode 100644 index 14caaed9..00000000 --- a/src/app/models/threshold-indicator-query-opts.model.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { ClimateModel } from './climate-model.model'; -import { IndicatorQueryOpts } from './indicator-query-opts.model'; - -export interface ThresholdIndicatorQueryOpts extends IndicatorQueryOpts { - params: { - threshold: Number; - threshold_units: string; - threshold_comparator: string; - - // from base - climateModels?: ClimateModel[]; - years?: string[]; - time_aggregation?: string; - unit?: string; - } -} diff --git a/src/app/services/indicator.service.ts b/src/app/services/indicator.service.ts index f36fe0c0..cb06ea0f 100644 --- a/src/app/services/indicator.service.ts +++ b/src/app/services/indicator.service.ts @@ -6,7 +6,7 @@ import 'rxjs/Rx'; import { Indicator } from '../models/indicator.model'; import { IndicatorQueryOpts } from '../models/indicator-query-opts.model'; -import { ThresholdIndicatorQueryOpts } from '../models/threshold-indicator-query-opts.model'; +import { ThresholdIndicatorParams } from '../models/threshold-indicator-params.model'; import { ApiHttp } from '../auth/api-http.service'; import { apiHost } from '../constants'; @@ -30,14 +30,14 @@ export class IndicatorService { // append extra parameters, if needed if (isThresholdIndicator(options.indicator.name)) { - const thresholdOpts: ThresholdIndicatorQueryOpts = options; + const thresholdParams = options.params as ThresholdIndicatorParams; // abort request if chart is in flux (these parameters are required) - if (!thresholdOpts.params.threshold) { + if (!thresholdParams.threshold) { return Observable.of({url: ''}); } - searchParams.append('threshold', thresholdOpts.params.threshold.toString()); - searchParams.append('threshold_units', thresholdOpts.params.threshold_units); - searchParams.append('threshold_comparator', thresholdOpts.params.threshold_comparator); + searchParams.append('threshold', thresholdParams.threshold.toString()); + searchParams.append('threshold_units', thresholdParams.threshold_units); + searchParams.append('threshold_comparator', thresholdParams.threshold_comparator); } if (options.params.years) { From d65bc42e3d13cad2da952cb191c47a4782b6746d Mon Sep 17 00:00:00 2001 From: CloudNiner Date: Thu, 31 Aug 2017 15:35:42 -0400 Subject: [PATCH 2/4] Refactor ExtraParams event emitters Gives these EventEmitters a more specific API contract, to always be of type IndicatorParams, which includes "subtypes" such as ThresholdIndicatorParams --- src/app/charts/chart.component.ts | 6 +++--- .../threshold.component.ts | 15 +++++++-------- src/app/lab/lab.component.ts | 3 ++- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/app/charts/chart.component.ts b/src/app/charts/chart.component.ts index 1a4f65dd..a76b5d5d 100644 --- a/src/app/charts/chart.component.ts +++ b/src/app/charts/chart.component.ts @@ -42,7 +42,7 @@ import * as _ from 'lodash'; export class ChartComponent implements OnChanges, OnDestroy, AfterViewInit { @Output() onRemoveChart = new EventEmitter(); - @Output() onExtraParamsChanged = new EventEmitter(); + @Output() onExtraParamsChanged = new EventEmitter(); @Input() chart: Chart; @Input() scenario: Scenario; @@ -181,8 +181,8 @@ export class ChartComponent implements OnChanges, OnDestroy, AfterViewInit { this.imageExportService.downloadAsPNG(this.chart.indicator.name, fileName); } - public onThresholdSelected($event) { - this.extraParams = $event.data as IndicatorParams; + public onThresholdSelected(params: IndicatorParams) { + this.extraParams = params; this.onExtraParamsChanged.emit(this.extraParams); this.updateChart(this.extraParams); } diff --git a/src/app/charts/extra-params-components/threshold.component.ts b/src/app/charts/extra-params-components/threshold.component.ts index e017081d..70e0a01e 100644 --- a/src/app/charts/extra-params-components/threshold.component.ts +++ b/src/app/charts/extra-params-components/threshold.component.ts @@ -2,6 +2,7 @@ import { AfterViewInit, Component, EventEmitter, Input, Output, OnInit } from '@ import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { Indicator } from '../../models/indicator.model'; +import { ThresholdIndicatorParams } from '../../models/threshold-indicator-params.model'; import * as _ from 'lodash'; @@ -16,7 +17,8 @@ import * as _ from 'lodash'; export class ThresholdComponent implements AfterViewInit, OnInit { @Input() indicator: Indicator; - @Input() extraParams: any; + @Input() extraParams: ThresholdIndicatorParams; + @Output() thresholdParamSelected = new EventEmitter(); thresholdForm: FormGroup; @@ -50,8 +52,6 @@ export class ThresholdComponent implements AfterViewInit, OnInit { @Input() thresholdUnits: any[] = this.thresholdTemperatureUnits; - @Output() thresholdParamSelected = new EventEmitter(); - constructor(private formBuilder: FormBuilder) {} ngOnInit() { @@ -62,11 +62,11 @@ export class ThresholdComponent implements AfterViewInit, OnInit { ngAfterViewInit() { // Since valueChanges triggers initially before parent is ready, wait until // parent is ready here and trigger it to draw chart with extra parameters. - this.thresholdParamSelected.emit({data: { + this.thresholdParamSelected.emit({ 'threshold_comparator': this.thresholdForm.controls.comparatorCtl.value, 'threshold': this.thresholdForm.controls.thresholdCtl.value, 'threshold_units': this.thresholdForm.controls.thresholdUnitCtl.value - }}); + }); } createForm() { @@ -78,12 +78,11 @@ export class ThresholdComponent implements AfterViewInit, OnInit { }); this.thresholdForm.valueChanges.debounceTime(700).subscribe(form => { - this.thresholdParamSelected.emit({data: { - 'event': event, + this.thresholdParamSelected.emit({ 'threshold_comparator': form.comparatorCtl, 'threshold': form.thresholdCtl, 'threshold_units': form.thresholdUnitCtl - }}); + }); }); } diff --git a/src/app/lab/lab.component.ts b/src/app/lab/lab.component.ts index e9ebbb0a..a6d657ff 100755 --- a/src/app/lab/lab.component.ts +++ b/src/app/lab/lab.component.ts @@ -14,6 +14,7 @@ import { ProjectService } from '../services/project.service'; import { Chart } from '../models/chart.model'; import { Indicator } from '../models/indicator.model'; +import { IndicatorParams } from '../models/indicator-params.model'; import { Project } from '../models/project.model'; @@ -81,7 +82,7 @@ export class LabComponent implements OnInit, OnDestroy { this.indicator = null; } - public saveExtraParams(params: any) { + public saveExtraParams(params: IndicatorParams) { this.project.project_data.extraParams = params; } From b0a45a1baed7aafd55d85d3ab7fabdb00fc91bb3 Mon Sep 17 00:00:00 2001 From: CloudNiner Date: Thu, 31 Aug 2017 16:00:23 -0400 Subject: [PATCH 3/4] Refactor to time_aggregation: TimeAggParam Includes a few more places where we can better typecast params to the new IndicatorParam type --- src/app/charts/chart.component.ts | 12 +++++------- src/app/models/chart-data.model.ts | 3 ++- src/app/models/indicator-params.model.ts | 4 +++- src/app/models/time-agg-param.enum.ts | 6 ++++++ src/app/services/chart.service.ts | 1 - 5 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 src/app/models/time-agg-param.enum.ts diff --git a/src/app/charts/chart.component.ts b/src/app/charts/chart.component.ts index a76b5d5d..5c6e4eb0 100644 --- a/src/app/charts/chart.component.ts +++ b/src/app/charts/chart.component.ts @@ -20,6 +20,7 @@ import { ClimateModel } from '../models/climate-model.model'; import { IndicatorQueryOpts } from '../models/indicator-query-opts.model'; import { IndicatorParams } from '../models/indicator-params.model'; import { Scenario } from '../models/scenario.model'; +import { TimeAggParam } from '../models/time-agg-param.enum'; import { AuthService } from '../auth/auth.service'; import { ChartService } from '../services/chart.service'; @@ -49,7 +50,7 @@ export class ChartComponent implements OnChanges, OnDestroy, AfterViewInit { @Input() models: ClimateModel[]; @Input() city: City; @Input() unit: string; - @Input() extraParams; + @Input() extraParams: IndicatorParams; private processedData: ChartData[]; public chartData: ChartData[]; @@ -115,18 +116,15 @@ export class ChartComponent implements OnChanges, OnDestroy, AfterViewInit { this.cancelDataRequest(); } - updateChart(extraParams: any) { + updateChart(extraParams: IndicatorParams) { this.cancelDataRequest(); this.chartData = []; this.rawChartData = []; - let params = { + let params: IndicatorParams = { climateModels: this.models, unit: this.unit || this.chart.indicator.default_units, - // TODO: #212 - // As a temporary solution, the time agg defaults to the 1st valid option. - // Really, this should a user selectable option - time_aggregation: this.chart.indicator.valid_aggregations[0] + time_aggregation: TimeAggParam.Yearly } params = _.extend(params, this.extraParams); diff --git a/src/app/models/chart-data.model.ts b/src/app/models/chart-data.model.ts index d82e6498..cfb02b45 100644 --- a/src/app/models/chart-data.model.ts +++ b/src/app/models/chart-data.model.ts @@ -3,12 +3,13 @@ import { Indicator } from './indicator.model'; import { City } from './city.model'; import { ClimateModel } from './climate-model.model'; import { Scenario } from './scenario.model'; +import { TimeAggParam } from './time-agg-param.enum'; /* tslint:disable:variable-name */ export class ChartData { indicator: Indicator; data: MultiDataPoint[]; - time_aggregation: string; + time_aggregation: TimeAggParam; time_format: string; city?: City; climate_models?: ClimateModel[]; diff --git a/src/app/models/indicator-params.model.ts b/src/app/models/indicator-params.model.ts index 9e0d4f48..85ce2b77 100644 --- a/src/app/models/indicator-params.model.ts +++ b/src/app/models/indicator-params.model.ts @@ -1,8 +1,10 @@ import { ClimateModel } from './climate-model.model'; +import { TimeAggParam } from './time-agg-param.enum'; export interface IndicatorParams { climateModels?: ClimateModel[]; years?: string[]; - time_aggregation?: string; + time_aggregation?: TimeAggParam; + agg?: string; unit?: string; } diff --git a/src/app/models/time-agg-param.enum.ts b/src/app/models/time-agg-param.enum.ts new file mode 100644 index 00000000..f219cb3c --- /dev/null +++ b/src/app/models/time-agg-param.enum.ts @@ -0,0 +1,6 @@ + +export enum TimeAggParam { + Yearly = 'yearly', + Quarterly = 'quarterly', + Monthly = 'monthly' +} diff --git a/src/app/services/chart.service.ts b/src/app/services/chart.service.ts index 2d5c96d0..63015561 100644 --- a/src/app/services/chart.service.ts +++ b/src/app/services/chart.service.ts @@ -17,7 +17,6 @@ export class ChartService { private timeOptions = { 'yearly': '%Y', - 'daily': '%Y-%m-%d', 'monthly': '%Y-%m' }; From 64ecb699ed7eeac8592789ffc7e998fcb3975cb2 Mon Sep 17 00:00:00 2001 From: CloudNiner Date: Fri, 1 Sep 2017 11:57:32 -0400 Subject: [PATCH 4/4] Refactor Indicator related model names To hopefully reduce confusion: - IndicatorQueryOpts -> IndicatorRequestOpts - IndicatorParams -> IndicatorQueryParams - No change to IndicatorParam --- src/app/charts/chart.component.ts | 16 ++++++++-------- .../threshold.component.ts | 6 +++--- src/app/lab/lab.component.ts | 4 ++-- ....model.ts => indicator-query-params.model.ts} | 2 +- ....model.ts => indicator-request-opts.model.ts} | 6 +++--- .../models/threshold-indicator-params.model.ts | 7 ------- .../threshold-indicator-query-params.model.ts | 7 +++++++ src/app/services/indicator.service.ts | 8 ++++---- 8 files changed, 28 insertions(+), 28 deletions(-) rename src/app/models/{indicator-params.model.ts => indicator-query-params.model.ts} (85%) rename src/app/models/{indicator-query-opts.model.ts => indicator-request-opts.model.ts} (63%) delete mode 100644 src/app/models/threshold-indicator-params.model.ts create mode 100644 src/app/models/threshold-indicator-query-params.model.ts diff --git a/src/app/charts/chart.component.ts b/src/app/charts/chart.component.ts index 5c6e4eb0..42f8d308 100644 --- a/src/app/charts/chart.component.ts +++ b/src/app/charts/chart.component.ts @@ -17,8 +17,8 @@ import { Chart } from '../models/chart.model'; import { ChartData } from '../models/chart-data.model'; import { City } from '../models/city.model'; import { ClimateModel } from '../models/climate-model.model'; -import { IndicatorQueryOpts } from '../models/indicator-query-opts.model'; -import { IndicatorParams } from '../models/indicator-params.model'; +import { IndicatorRequestOpts } from '../models/indicator-request-opts.model'; +import { IndicatorQueryParams } from '../models/indicator-query-params.model'; import { Scenario } from '../models/scenario.model'; import { TimeAggParam } from '../models/time-agg-param.enum'; @@ -43,14 +43,14 @@ import * as _ from 'lodash'; export class ChartComponent implements OnChanges, OnDestroy, AfterViewInit { @Output() onRemoveChart = new EventEmitter(); - @Output() onExtraParamsChanged = new EventEmitter(); + @Output() onExtraParamsChanged = new EventEmitter(); @Input() chart: Chart; @Input() scenario: Scenario; @Input() models: ClimateModel[]; @Input() city: City; @Input() unit: string; - @Input() extraParams: IndicatorParams; + @Input() extraParams: IndicatorQueryParams; private processedData: ChartData[]; public chartData: ChartData[]; @@ -116,12 +116,12 @@ export class ChartComponent implements OnChanges, OnDestroy, AfterViewInit { this.cancelDataRequest(); } - updateChart(extraParams: IndicatorParams) { + updateChart(extraParams: IndicatorQueryParams) { this.cancelDataRequest(); this.chartData = []; this.rawChartData = []; - let params: IndicatorParams = { + let params: IndicatorQueryParams = { climateModels: this.models, unit: this.unit || this.chart.indicator.default_units, time_aggregation: TimeAggParam.Yearly @@ -129,7 +129,7 @@ export class ChartComponent implements OnChanges, OnDestroy, AfterViewInit { params = _.extend(params, this.extraParams); - const queryOpts: IndicatorQueryOpts = { + const queryOpts: IndicatorRequestOpts = { indicator: this.chart.indicator, scenario: this.scenario, city: this.city, @@ -179,7 +179,7 @@ export class ChartComponent implements OnChanges, OnDestroy, AfterViewInit { this.imageExportService.downloadAsPNG(this.chart.indicator.name, fileName); } - public onThresholdSelected(params: IndicatorParams) { + public onThresholdSelected(params: IndicatorQueryParams) { this.extraParams = params; this.onExtraParamsChanged.emit(this.extraParams); this.updateChart(this.extraParams); diff --git a/src/app/charts/extra-params-components/threshold.component.ts b/src/app/charts/extra-params-components/threshold.component.ts index 70e0a01e..b262751d 100644 --- a/src/app/charts/extra-params-components/threshold.component.ts +++ b/src/app/charts/extra-params-components/threshold.component.ts @@ -2,7 +2,7 @@ import { AfterViewInit, Component, EventEmitter, Input, Output, OnInit } from '@ import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { Indicator } from '../../models/indicator.model'; -import { ThresholdIndicatorParams } from '../../models/threshold-indicator-params.model'; +import { ThresholdIndicatorQueryParams } from '../../models/threshold-indicator-query-params.model'; import * as _ from 'lodash'; @@ -17,8 +17,8 @@ import * as _ from 'lodash'; export class ThresholdComponent implements AfterViewInit, OnInit { @Input() indicator: Indicator; - @Input() extraParams: ThresholdIndicatorParams; - @Output() thresholdParamSelected = new EventEmitter(); + @Input() extraParams: ThresholdIndicatorQueryParams; + @Output() thresholdParamSelected = new EventEmitter(); thresholdForm: FormGroup; diff --git a/src/app/lab/lab.component.ts b/src/app/lab/lab.component.ts index a6d657ff..7707d09c 100755 --- a/src/app/lab/lab.component.ts +++ b/src/app/lab/lab.component.ts @@ -14,7 +14,7 @@ import { ProjectService } from '../services/project.service'; import { Chart } from '../models/chart.model'; import { Indicator } from '../models/indicator.model'; -import { IndicatorParams } from '../models/indicator-params.model'; +import { IndicatorQueryParams } from '../models/indicator-query-params.model'; import { Project } from '../models/project.model'; @@ -82,7 +82,7 @@ export class LabComponent implements OnInit, OnDestroy { this.indicator = null; } - public saveExtraParams(params: IndicatorParams) { + public saveExtraParams(params: IndicatorQueryParams) { this.project.project_data.extraParams = params; } diff --git a/src/app/models/indicator-params.model.ts b/src/app/models/indicator-query-params.model.ts similarity index 85% rename from src/app/models/indicator-params.model.ts rename to src/app/models/indicator-query-params.model.ts index 85ce2b77..e3fe1339 100644 --- a/src/app/models/indicator-params.model.ts +++ b/src/app/models/indicator-query-params.model.ts @@ -1,7 +1,7 @@ import { ClimateModel } from './climate-model.model'; import { TimeAggParam } from './time-agg-param.enum'; -export interface IndicatorParams { +export interface IndicatorQueryParams { climateModels?: ClimateModel[]; years?: string[]; time_aggregation?: TimeAggParam; diff --git a/src/app/models/indicator-query-opts.model.ts b/src/app/models/indicator-request-opts.model.ts similarity index 63% rename from src/app/models/indicator-query-opts.model.ts rename to src/app/models/indicator-request-opts.model.ts index 844ae976..a5882bbf 100644 --- a/src/app/models/indicator-query-opts.model.ts +++ b/src/app/models/indicator-request-opts.model.ts @@ -1,12 +1,12 @@ import { City } from './city.model'; import { Indicator } from './indicator.model'; -import { IndicatorParams } from './indicator-params.model'; +import { IndicatorQueryParams } from './indicator-query-params.model'; import { ClimateModel } from './climate-model.model'; import { Scenario } from './scenario.model'; -export interface IndicatorQueryOpts { +export interface IndicatorRequestOpts { indicator: Indicator; city: City; scenario: Scenario; - params: IndicatorParams; + params: IndicatorQueryParams; } diff --git a/src/app/models/threshold-indicator-params.model.ts b/src/app/models/threshold-indicator-params.model.ts deleted file mode 100644 index c8a2469d..00000000 --- a/src/app/models/threshold-indicator-params.model.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { IndicatorParams } from './indicator-params.model'; - -export interface ThresholdIndicatorParams extends IndicatorParams { - threshold: Number; - threshold_units: string; - threshold_comparator: string; -} diff --git a/src/app/models/threshold-indicator-query-params.model.ts b/src/app/models/threshold-indicator-query-params.model.ts new file mode 100644 index 00000000..e304df1e --- /dev/null +++ b/src/app/models/threshold-indicator-query-params.model.ts @@ -0,0 +1,7 @@ +import { IndicatorQueryParams } from './indicator-query-params.model'; + +export interface ThresholdIndicatorQueryParams extends IndicatorQueryParams { + threshold: Number; + threshold_units: string; + threshold_comparator: string; +} diff --git a/src/app/services/indicator.service.ts b/src/app/services/indicator.service.ts index cb06ea0f..836d75a3 100644 --- a/src/app/services/indicator.service.ts +++ b/src/app/services/indicator.service.ts @@ -5,8 +5,8 @@ import 'rxjs/add/observable/of'; import 'rxjs/Rx'; import { Indicator } from '../models/indicator.model'; -import { IndicatorQueryOpts } from '../models/indicator-query-opts.model'; -import { ThresholdIndicatorParams } from '../models/threshold-indicator-params.model'; +import { IndicatorRequestOpts } from '../models/indicator-request-opts.model'; +import { ThresholdIndicatorQueryParams } from '../models/threshold-indicator-query-params.model'; import { ApiHttp } from '../auth/api-http.service'; import { apiHost } from '../constants'; @@ -20,7 +20,7 @@ import { isThresholdIndicator } from '../charts/extra-params-components/extra-pa export class IndicatorService { constructor(private apiHttp: ApiHttp) {} - public getData(options: IndicatorQueryOpts) { + public getData(options: IndicatorRequestOpts) { const url = `${apiHost}/api/climate-data/${options.city.id}/${options.scenario.name}` + `/indicator/${options.indicator.name}/`; @@ -30,7 +30,7 @@ export class IndicatorService { // append extra parameters, if needed if (isThresholdIndicator(options.indicator.name)) { - const thresholdParams = options.params as ThresholdIndicatorParams; + const thresholdParams = options.params as ThresholdIndicatorQueryParams; // abort request if chart is in flux (these parameters are required) if (!thresholdParams.threshold) { return Observable.of({url: ''});