libs/selector/src/lib/dataset-by-station-selector/dataset-by-station-selector.component.ts
Properties |
|
Public selected |
Type : boolean
|
Public firstValue |
Type : FirstLastValue
|
Inherited from
HelgolandTimeseries
|
Defined in
HelgolandTimeseries:38
|
Public id |
Type : string
|
Inherited from
HelgolandTimeseries
|
Defined in
HelgolandTimeseries:33
|
Public label |
Type : string
|
Inherited from
HelgolandTimeseries
|
Defined in
HelgolandTimeseries:35
|
Public lastValue |
Type : FirstLastValue
|
Inherited from
HelgolandTimeseries
|
Defined in
HelgolandTimeseries:39
|
Public parameters |
Type : ParameterConstellation
|
Inherited from
HelgolandTimeseries
|
Defined in
HelgolandTimeseries:42
|
Public platform |
Type : HelgolandPlatform
|
Inherited from
HelgolandTimeseries
|
Defined in
HelgolandTimeseries:37
|
Public referenceValues |
Type : ReferenceValue[]
|
Inherited from
HelgolandTimeseries
|
Defined in
HelgolandTimeseries:40
|
Public renderingHints |
Type : RenderingHints
|
Inherited from
HelgolandTimeseries
|
Defined in
HelgolandTimeseries:41
|
Public uom |
Type : string
|
Inherited from
HelgolandTimeseries
|
Defined in
HelgolandTimeseries:36
|
Public url |
Type : string
|
Inherited from
HelgolandTimeseries
|
Defined in
HelgolandTimeseries:34
|
Public id |
Type : string
|
Inherited from
HelgolandDataset
|
Defined in
HelgolandDataset:22
|
Public internalId |
Type : string
|
Inherited from
HelgolandDataset
|
Defined in
HelgolandDataset:19
|
Public label |
Type : string
|
Inherited from
HelgolandDataset
|
Defined in
HelgolandDataset:24
|
Public url |
Type : string
|
Inherited from
HelgolandDataset
|
Defined in
HelgolandDataset:23
|
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);
}
}