|
|
@@ -1,4 +1,5 @@
|
|
|
-import {Component, ViewRef} from '@angular/core';
|
|
|
+// eslint-disable-next-line import/named
|
|
|
+import {Component, OnInit, ViewRef} from '@angular/core';
|
|
|
|
|
|
import {
|
|
|
HsLanguageService,
|
|
|
@@ -7,25 +8,57 @@ import {
|
|
|
HsPanelComponent,
|
|
|
} from 'hslayers-ng';
|
|
|
|
|
|
-import {IrrigationService} from './irrigation.service';
|
|
|
+import {IrrigationForecastService} from './irrigation-forecast.service';
|
|
|
+
|
|
|
+export type ForecastModel = {
|
|
|
+ 0: number;
|
|
|
+ 1: number;
|
|
|
+ 2: number;
|
|
|
+ 3: number;
|
|
|
+ 4: number;
|
|
|
+ 5: number;
|
|
|
+ 6: number;
|
|
|
+ 7: number;
|
|
|
+};
|
|
|
+
|
|
|
+export type ForecastFlatModel = number[];
|
|
|
|
|
|
@Component({
|
|
|
selector: 'irrigation-forecast-panel',
|
|
|
templateUrl: './irrigation-forecast-panel.component.html',
|
|
|
- styleUrls: ['../app.component.scss'],
|
|
|
+ styleUrls: ['./irrigation-forecast-panel.component.scss'],
|
|
|
})
|
|
|
-export class IrrigationForecastPanelComponent implements HsPanelComponent {
|
|
|
- data;
|
|
|
+export class IrrigationForecastPanelComponent
|
|
|
+ implements HsPanelComponent, OnInit
|
|
|
+{
|
|
|
+ forecastLoaded = false;
|
|
|
+ data: {
|
|
|
+ forecast: ForecastFlatModel;
|
|
|
+ };
|
|
|
name: 'forecast';
|
|
|
viewRef: ViewRef;
|
|
|
|
|
|
constructor(
|
|
|
- public irrigationService: IrrigationService,
|
|
|
+ public irrigationForecastService: IrrigationForecastService,
|
|
|
public hsLanguageService: HsLanguageService,
|
|
|
- public hsLayoutService: HsLayoutService
|
|
|
+ private hsLayoutService: HsLayoutService
|
|
|
) {}
|
|
|
|
|
|
+ ngOnInit(): void {
|
|
|
+ this.getForecast();
|
|
|
+ }
|
|
|
+
|
|
|
isVisible(): boolean {
|
|
|
return this.hsLayoutService.panelVisible('forecast');
|
|
|
}
|
|
|
+
|
|
|
+ getForecast() {
|
|
|
+ this.irrigationForecastService
|
|
|
+ .getForecast()
|
|
|
+ .subscribe((data: ForecastModel) => {
|
|
|
+ console.log('forecast', data);
|
|
|
+ this.data.forecast = Object.values(data);
|
|
|
+ this.forecastLoaded = true;
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|