diff --git a/src/app/charts/extra-params-components/basetemp.component.html b/src/app/charts/extra-params-components/basetemp.component.html
index cfd1f6dd..bc1d2915 100644
--- a/src/app/charts/extra-params-components/basetemp.component.html
+++ b/src/app/charts/extra-params-components/basetemp.component.html
@@ -4,9 +4,10 @@
Show {{indicator.label | lowercase}} with base temperature
+ step="1"
+ formControlName="basetempCtl">
-
+
{{unit.label}}
diff --git a/src/app/charts/extra-params-components/basetemp.component.ts b/src/app/charts/extra-params-components/basetemp.component.ts
index 84aaff09..ba058165 100644
--- a/src/app/charts/extra-params-components/basetemp.component.ts
+++ b/src/app/charts/extra-params-components/basetemp.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 { BasetempIndicatorQueryParams } from '../../models/basetemp-indicator-query-params.model';
import * as _ from 'lodash';
@@ -16,7 +17,8 @@ import * as _ from 'lodash';
export class BasetempComponent implements AfterViewInit, OnInit {
@Input() indicator: Indicator;
- @Input() extraParams: any;
+ @Input() extraParams: BasetempIndicatorQueryParams;
+ @Output() basetempParamSelected = new EventEmitter();
basetempForm: FormGroup;
@@ -24,7 +26,11 @@ export class BasetempComponent implements AfterViewInit, OnInit {
private defaultBasetemp = 50;
private defaultBasetempUnit = 'F';
- @Output() basetempParamSelected = new EventEmitter();
+ public basetempUnits: any[] = [
+ {'key': 'K', 'label': 'Kelvin'},
+ {'key': 'F', 'label': 'Farenheit'},
+ {'key': 'C', 'label': 'Centigrade'}
+ ];
constructor(private formBuilder: FormBuilder) {}
@@ -36,10 +42,10 @@ export class BasetempComponent 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.basetempParamSelected.emit({data: {
+ this.basetempParamSelected.emit({
'basetemp': this.basetempForm.controls.basetempCtl.value,
'basetemp_units': this.basetempForm.controls.basetempUnitCtl.value
- }});
+ });
}
createForm() {
@@ -49,11 +55,10 @@ export class BasetempComponent implements AfterViewInit, OnInit {
});
this.basetempForm.valueChanges.debounceTime(700).subscribe(form => {
- this.basetempParamSelected.emit({data: {
- 'event': event,
+ this.basetempParamSelected.emit({
'basetemp': form.basetempCtl,
'basetemp_units': form.basetempUnitCtl
- }});
+ });
});
}
}
\ No newline at end of file
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 38f38772..6f418245 100644
--- a/src/app/charts/extra-params-components/extra-params.constants.ts
+++ b/src/app/charts/extra-params-components/extra-params.constants.ts
@@ -15,12 +15,7 @@ const basetempIndicatorNames = [
const extraParamsIndicatorNames = thresholdIndicatorNames;
export function isBasetempIndicator(indicatorName: string): boolean {
- for (const basetempName of basetempIndicatorNames) {
- if (indicatorName === basetempName) {
- return true;
- }
- }
- return false;
+ return basetempIndicatorNames.indexOf(indicatorName) !== -1;
}
export function isThresholdIndicator(indicatorName: string): boolean {
diff --git a/src/app/charts/line-graph.component.ts b/src/app/charts/line-graph.component.ts
index 6da5b64a..f11bf860 100644
--- a/src/app/charts/line-graph.component.ts
+++ b/src/app/charts/line-graph.component.ts
@@ -115,7 +115,7 @@ export class LineGraphComponent implements OnChanges, AfterContentInit {
/* Will setup the chart basics */
private setup(): void {
- this.margin = { top: 10, right: 40, bottom: 30, left: 50 };
+ this.margin = { top: 10, right: 50, bottom: 30, left: 60 };
this.width = $('.chart').width() - this.margin.left - this.margin.right;
this.height = $('.line-graph').height() - this.margin.top - this.margin.bottom;
this.xScale = D3.scaleTime().range([0, this.width]);
diff --git a/src/app/login/login.component.spec.ts b/src/app/login/login.component.spec.ts
index afdab36a..60cc5cf3 100644
--- a/src/app/login/login.component.spec.ts
+++ b/src/app/login/login.component.spec.ts
@@ -31,7 +31,7 @@ import {
} from '../lab';
import { ThresholdComponent,
- BasetempComponent } from '../charts/extra-params-components/threshold.component';
+ BasetempComponent } from '../charts/extra-params-components';
import { NavbarComponent } from '../navbar/navbar.component';
import { DashboardComponent } from '../dashboard/dashboard.component';
diff --git a/src/app/models/basetemp-indicator-query-opts.model.ts b/src/app/models/basetemp-indicator-query-params.model.ts
similarity index 100%
rename from src/app/models/basetemp-indicator-query-opts.model.ts
rename to src/app/models/basetemp-indicator-query-params.model.ts
diff --git a/src/app/services/indicator.service.ts b/src/app/services/indicator.service.ts
index f4ab2f7c..fec063a0 100644
--- a/src/app/services/indicator.service.ts
+++ b/src/app/services/indicator.service.ts
@@ -8,7 +8,7 @@ import { Indicator } from '../models/indicator.model';
import { IndicatorRequestOpts } from '../models/indicator-request-opts.model';
import { ThresholdIndicatorQueryParams } from '../models/threshold-indicator-query-params.model';
import { BasetempIndicatorQueryParams } from '../models/basetemp-indicator-query-params.model';
-import { IndicatorQueryParams } from '../models/indicator-query-params.model';\
+import { IndicatorQueryParams } from '../models/indicator-query-params.model';
import { ApiHttp } from '../auth/api-http.service';
import { apiHost } from '../constants';
@@ -46,13 +46,13 @@ export class IndicatorService {
// append extra parameters, if needed
if (isBasetempIndicator(options.indicator.name)) {
- const basetempOpts: BasetempIndicatorQueryOpts = options;
+ const basetempOpts = options.params as BasetempIndicatorQueryParams;
// abort request if chart is in flux (these parameters are required)
- if (!basetempOpts.params.basetemp) {
+ if (!basetempOpts.basetemp) {
return Observable.of({url: ''});
}
- searchParams.append('basetemp', basetempOpts.params.basetemp.toString());
- searchParams.append('basetemp_units', basetempOpts.params.basetemp_units);
+ searchParams.append('basetemp', basetempOpts.basetemp.toString());
+ searchParams.append('basetemp_units', basetempOpts.basetemp_units);
}
if (options.params.years) {