import {Component, ViewRef} from '@angular/core'; import { HsLanguageService, HsLayoutService, // eslint-disable-next-line import/named HsPanelComponent, } from 'hslayers-ng'; import {CalculatorService, Index} from './calculator.service'; import {FieldService} from './field.service'; @Component({ selector: 'calculator-panel', templateUrl: './calculator.component.html', styleUrls: ['./calculator.component.scss'], }) export class CalculatorComponent implements HsPanelComponent { data: { selectedProduct: Index; selectedFieldsProperties: {[x: string]: any}[]; }; name: 'calculator'; viewRef: ViewRef; constructor( public calcService: CalculatorService, private fieldService: FieldService, public hsLanguageService: HsLanguageService, public hsLayoutService: HsLayoutService ) { this.fieldService.fieldSelects.subscribe(({features}) => { this.data.selectedFieldsProperties = []; for (const feature of features) { this.data.selectedFieldsProperties.push(feature.getProperties()); } }); } isVisible(): boolean { return this.hsLayoutService.panelVisible('calculator'); } noFieldSelected(): boolean { return this.fieldService.noFieldSelected(); } noProductSelected(): boolean { return this.data.selectedProduct === undefined; } noDates(): boolean { return this.calcService.noDates(); } noDateSelected(): boolean { return this.calcService.selectedDate === undefined; } getDates() { this.calcService.getDates({product: this.data.selectedProduct}); } getZones() { this.calcService.getZones({ product: this.data.selectedProduct, }); } updateRangeSlider(value: string) { this.calcService.dateCalendarSelects.next({date: value}); } }