File

libs/selector/src/lib/dataset-by-station-selector/dataset-by-station-selector.component.ts

Extends

HelgolandTimeseries

Index

Properties

Properties

Public selected
Type : boolean
Public firstValue
Type : FirstLastValue
Inherited from HelgolandTimeseries
Public id
Type : string
Inherited from HelgolandTimeseries
Public label
Type : string
Inherited from HelgolandTimeseries
Public lastValue
Type : FirstLastValue
Inherited from HelgolandTimeseries
Public parameters
Type : ParameterConstellation
Inherited from HelgolandTimeseries
Public platform
Type : HelgolandPlatform
Inherited from HelgolandTimeseries
Public referenceValues
Type : ReferenceValue[]
Inherited from HelgolandTimeseries
Public renderingHints
Type : RenderingHints
Inherited from HelgolandTimeseries
Public uom
Type : string
Inherited from HelgolandTimeseries
Public url
Type : string
Inherited from HelgolandTimeseries
Public id
Type : string
Inherited from HelgolandDataset
Public internalId
Type : string
Inherited from HelgolandDataset
Public label
Type : string
Inherited from HelgolandDataset
Public url
Type : string
Inherited from HelgolandDataset
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import {
    DatasetType,
    HelgolandDataset,
    HelgolandPlatform,
    HelgolandServicesConnector,
    HelgolandTimeseries,
} from '@helgoland/core';
import { TranslateService } from '@ngx-translate/core';

export class SelectableDataset extends HelgolandTimeseries {
    public selected: boolean;
}

@Component({
    selector: 'n52-dataset-by-station-selector',
    templateUrl: './dataset-by-station-selector.component.html',
    styleUrls: ['./dataset-by-station-selector.component.scss']
})
export class DatasetByStationSelectorComponent implements OnInit {

    @Input()
    public station: HelgolandPlatform;

    @Input()
    public url: string;

    @Input()
    public defaultSelected = false;

    @Input()
    public phenomenonId: string;

    @Output()
    public onSelectionChanged: EventEmitter<HelgolandDataset[]> = new EventEmitter<HelgolandDataset[]>();

    public timeseriesList: SelectableDataset[] = [];

    public counter: number;

    constructor(
        protected servicesConnector: HelgolandServicesConnector,
        public translateSrvc: TranslateService
    ) { }

    public ngOnInit() {
        if (this.station) {
            this.servicesConnector.getPlatform(this.station.id, this.url)
                .subscribe((station) => {
                    this.station = station;
                    this.counter = 0;
                    this.station.datasetIds.forEach(id => {
                        this.counter++;
                        this.servicesConnector.getDataset({ id: id, url: this.url }, { type: DatasetType.Timeseries })
                            .subscribe((result) => {
                                this.prepareResult(result as SelectableDataset, this.defaultSelected);
                                this.counter--;
                            }, (error) => {
                                this.counter--;
                            });
                    });
                });
        }
    }

    public toggle(timeseries: SelectableDataset) {
        timeseries.selected = !timeseries.selected;
        this.updateSelection();
    }

    protected prepareResult(result: SelectableDataset, selection: boolean) {
        result.selected = selection;
        this.timeseriesList.push(result);
        this.updateSelection();
    }

    private updateSelection() {
        const selection = this.timeseriesList.filter((entry) => entry.selected);
        this.onSelectionChanged.emit(selection);
    }

}

result-matching ""

    No results matching ""