forked from nathan-gs/ha-map-card
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLayerConfig.js
37 lines (34 loc) · 1.06 KB
/
LayerConfig.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
export default class LayerConfig {
/** @type {string} */
url;
/** @type {object} */
options;
historyProperty;
historySource;
historyForceMidnight;
historySourceSuffix;
constructor(url, options, historyConfig, attribution = null) {
this.url = url;
this.options = {...{attribution: attribution}, ...options};
// history: propName
// history:
// property: dateTime - value to set
// source: entity.myEntity - source for data. Default to auto (inherit from parent)
// suffix:
// force_midnight:
if (historyConfig) {
// Default source
this.historySource = 'auto';
// Array type
if (historyConfig.property) {
this.historyProperty = historyConfig.property;
this.historySource = historyConfig.source ?? this.historySource;
this.historyForceMidnight = historyConfig.force_midnight ?? false;
this.historySourceSuffix = historyConfig.suffix;
} else {
// Singular
this.historyProperty = historyConfig;
}
}
}
}