import {Component, OnInit, ViewRef} from '@angular/core'; import {HsDialogContainerService} from 'hslayers-ng'; import {HsLayoutService} from 'hslayers-ng'; import {HsPanelComponent} from 'hslayers-ng'; //import {AdjusterEventService} from './adjuster-event.service'; import {AdjusterLoaderComponent} from './adjuster-loader.component'; import {AdjusterService} from './adjuster.service'; @Component({ selector: 'pra-adjuster', templateUrl: './adjuster.directive.html', styleUrls: ['./adjuster.component.scss'], }) export class AdjusterComponent implements HsPanelComponent, OnInit { data: any; //descriptionVisible: boolean; errorMsg: string; //method: string; viewRef: ViewRef; constructor( public adjusterService: AdjusterService, public hsDialogContainerService: HsDialogContainerService, public hsLayoutService: HsLayoutService ) { //this.descriptionVisible = false; //this.method = this.adjusterService.method; /*this.adjusterEventService.clustersLoaded.subscribe(({success, err}) => { if (!success) { this.errorMsg = err.message; } });*/ } ngOnInit(): void { this.hsDialogContainerService.create(AdjusterLoaderComponent, {}); } isVisible(): boolean { return this.hsLayoutService.panelVisible('adjuster'); } noDataSelected(): boolean { if (this.adjusterService.factors.length === 0) { return true; } let datasetsEffectivelyTurnedOn = []; for (const factor of this.adjusterService.factors) { if (factor.weight === 0) { continue; } datasetsEffectivelyTurnedOn = [ ...datasetsEffectivelyTurnedOn, ...factor.datasets.filter((ds) => ds.included), ]; } return datasetsEffectivelyTurnedOn.length === 0; } noOperationSelected(): boolean { return ( !this.adjusterService.allowIndex && !this.adjusterService.allowClusters ); } /*selectMethod(): void { this.adjusterService.method = this.method; this.adjusterEventService.methodChanged.next(this.method); }*/ }