@openremote/or-attribute-card 1.8.0-snapshot.20250725070921 → 1.8.0-snapshot.20250725120000
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -31
- package/dist/umd/index.bundle.js +1519 -1519
- package/dist/umd/index.bundle.js.map +1 -1
- package/lib/index.js +865 -209
- package/package.json +6 -6
package/lib/index.js
CHANGED
|
@@ -1,209 +1,865 @@
|
|
|
1
|
-
var __decorate
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
line-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
.
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
import { css, html, LitElement, unsafeCSS } from "lit";
|
|
17
|
+
import { customElement, property, state, query } from "lit/decorators.js";
|
|
18
|
+
import i18next from "i18next";
|
|
19
|
+
import { AssetModelUtil } from "@openremote/model";
|
|
20
|
+
import { DefaultColor3, DefaultColor4, manager, Util } from "@openremote/core";
|
|
21
|
+
import { isAxiosError } from "@openremote/rest";
|
|
22
|
+
import { Chart, LineController, LineElement, PointElement, LinearScale, TimeSeriesScale, Title } from "chart.js";
|
|
23
|
+
import "chartjs-adapter-moment";
|
|
24
|
+
import { InputType } from "@openremote/or-mwc-components/or-mwc-input";
|
|
25
|
+
import { getAssetDescriptorIconTemplate } from "@openremote/or-icon";
|
|
26
|
+
import "@openremote/or-mwc-components/or-mwc-dialog";
|
|
27
|
+
import "@openremote/or-attribute-picker";
|
|
28
|
+
import moment from "moment";
|
|
29
|
+
import { OrAssetTreeSelectionEvent } from "@openremote/or-asset-tree";
|
|
30
|
+
import { OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";
|
|
31
|
+
import { OrAssetAttributePicker, OrAssetAttributePickerPickedEvent } from "@openremote/or-attribute-picker";
|
|
32
|
+
import { getContentWithMenuTemplate } from "@openremote/or-mwc-components/or-mwc-menu";
|
|
33
|
+
import { when } from "lit/directives/when.js";
|
|
34
|
+
import { debounce } from "lodash";
|
|
35
|
+
Chart.register(LineController, LineElement, PointElement, LinearScale, Title, TimeSeriesScale);
|
|
36
|
+
// language=CSS
|
|
37
|
+
const style = css `
|
|
38
|
+
|
|
39
|
+
:host {
|
|
40
|
+
--internal-or-attribute-history-graph-line-color: var(--or-attribute-history-graph-line-color, var(--or-app-color4, ${unsafeCSS(DefaultColor4)}));
|
|
41
|
+
width: 100%;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
:host([hidden]) {
|
|
45
|
+
display: none;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.panel {
|
|
49
|
+
position: relative;
|
|
50
|
+
height: 100%;
|
|
51
|
+
}
|
|
52
|
+
.panel.panel-empty {
|
|
53
|
+
display: flex;
|
|
54
|
+
}
|
|
55
|
+
.panel.panel-empty .panel-content-wrapper {
|
|
56
|
+
align-items: center;
|
|
57
|
+
width: 100%;
|
|
58
|
+
}
|
|
59
|
+
.panel.panel-empty .panel-content {
|
|
60
|
+
align-items: center;
|
|
61
|
+
justify-content: center;
|
|
62
|
+
flex-direction: column;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.panel-content-wrapper {
|
|
66
|
+
height: 100%;
|
|
67
|
+
display: flex;
|
|
68
|
+
flex-direction: column;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.panel-title {
|
|
72
|
+
display: flex;
|
|
73
|
+
align-items: center;
|
|
74
|
+
/*margin: -15px -15px 0 0;*/ /* compensate for the click-space of the plusminus button */
|
|
75
|
+
font-weight: bolder;
|
|
76
|
+
line-height: 1em;
|
|
77
|
+
color: var(--internal-or-asset-viewer-title-text-color);
|
|
78
|
+
flex: 0 0 auto;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.panel-title-text {
|
|
82
|
+
flex: 1;
|
|
83
|
+
text-transform: uppercase;
|
|
84
|
+
white-space: nowrap;
|
|
85
|
+
text-overflow: ellipsis;
|
|
86
|
+
overflow: hidden;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.panel-content {
|
|
90
|
+
display: flex;
|
|
91
|
+
flex-direction: column;
|
|
92
|
+
width: 100%;
|
|
93
|
+
flex: 1;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.mainvalue-wrapper {
|
|
97
|
+
width: 100%;
|
|
98
|
+
display: flex;
|
|
99
|
+
flex: 0 0 60px;
|
|
100
|
+
align-items: center;
|
|
101
|
+
justify-content: center;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.graph-wrapper {
|
|
105
|
+
width: 100%;
|
|
106
|
+
display: flex;
|
|
107
|
+
flex: 1;
|
|
108
|
+
align-items: center;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.main-number {
|
|
112
|
+
color: var(--internal-or-asset-viewer-title-text-color);
|
|
113
|
+
font-size: 42px;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.main-number-icon {
|
|
117
|
+
font-size: 24px;
|
|
118
|
+
margin-right: 10px;
|
|
119
|
+
display: flex;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.main-number-unit {
|
|
123
|
+
font-size: 42px;
|
|
124
|
+
color: var(--internal-or-asset-viewer-title-text-color);
|
|
125
|
+
font-weight: 200;
|
|
126
|
+
margin-left: 5px;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.main-number.xs, .main-number-unit.xs {
|
|
130
|
+
font-size: 18px;
|
|
131
|
+
}
|
|
132
|
+
.main-number.s, .main-number-unit.s {
|
|
133
|
+
font-size: 24px;
|
|
134
|
+
}
|
|
135
|
+
.main-number.m, .main-number-unit.m {
|
|
136
|
+
font-size: 30px;
|
|
137
|
+
}
|
|
138
|
+
.main-number.l, .main-number-unit.l {
|
|
139
|
+
font-size: 36px;
|
|
140
|
+
}
|
|
141
|
+
.main-number.xl, .main-number-unit.xl {
|
|
142
|
+
font-size: 42px;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.chart-wrapper {
|
|
146
|
+
flex: 1 1 auto;
|
|
147
|
+
width: 65%;
|
|
148
|
+
height: 75%;
|
|
149
|
+
}
|
|
150
|
+
.controls-wrapper {
|
|
151
|
+
flex: 0 0 80px;
|
|
152
|
+
height: 100%;
|
|
153
|
+
display: flex;
|
|
154
|
+
flex-direction: column;
|
|
155
|
+
align-items: end;
|
|
156
|
+
place-content: space-between;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.delta-wrapper {
|
|
160
|
+
/*flex: 0 0 50px;*/
|
|
161
|
+
text-align: right;
|
|
162
|
+
|
|
163
|
+
/*position: absolute;*/
|
|
164
|
+
/*right: var(--internal-or-asset-viewer-panel-padding);*/
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.date-range-wrapper {
|
|
168
|
+
flex: 1;
|
|
169
|
+
display: flex;
|
|
170
|
+
justify-content: space-between;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.period-selector {
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.delta {
|
|
178
|
+
color: var(--or-app-color3, ${unsafeCSS(DefaultColor3)});
|
|
179
|
+
font-weight: bold;
|
|
180
|
+
}
|
|
181
|
+
`;
|
|
182
|
+
let OrAttributeCard = class OrAttributeCard extends LitElement {
|
|
183
|
+
static get styles() {
|
|
184
|
+
return [
|
|
185
|
+
style
|
|
186
|
+
];
|
|
187
|
+
}
|
|
188
|
+
constructor() {
|
|
189
|
+
super();
|
|
190
|
+
this.assets = [];
|
|
191
|
+
this.assetAttributes = [];
|
|
192
|
+
this.data = undefined;
|
|
193
|
+
this.mainValueDecimals = 2;
|
|
194
|
+
this.mainValueSize = "m";
|
|
195
|
+
this.delta = undefined;
|
|
196
|
+
this.deltaPlus = "";
|
|
197
|
+
this.deltaFormat = "absolute";
|
|
198
|
+
this.showControls = true;
|
|
199
|
+
this.hideAttributePicker = false;
|
|
200
|
+
this.showTitle = true;
|
|
201
|
+
this._loading = false;
|
|
202
|
+
this.period = "day";
|
|
203
|
+
}
|
|
204
|
+
connectedCallback() {
|
|
205
|
+
super.connectedCallback();
|
|
206
|
+
this._style = window.getComputedStyle(this);
|
|
207
|
+
}
|
|
208
|
+
disconnectedCallback() {
|
|
209
|
+
super.disconnectedCallback();
|
|
210
|
+
this._cleanup();
|
|
211
|
+
}
|
|
212
|
+
firstUpdated() {
|
|
213
|
+
this.loadSettings();
|
|
214
|
+
}
|
|
215
|
+
updated(changedProperties) {
|
|
216
|
+
if (changedProperties.has("realm") && changedProperties.get("realm") != undefined) {
|
|
217
|
+
this.assets = [];
|
|
218
|
+
this.loadSettings();
|
|
219
|
+
}
|
|
220
|
+
const reloadData = changedProperties.has("period") || changedProperties.has("compareTimestamp")
|
|
221
|
+
|| changedProperties.has("timestamp") || changedProperties.has("assetAttributes") || changedProperties.has("realm");
|
|
222
|
+
if (reloadData) {
|
|
223
|
+
this.data = undefined;
|
|
224
|
+
if (this._chart) {
|
|
225
|
+
this._chart.destroy();
|
|
226
|
+
this._chart = undefined;
|
|
227
|
+
}
|
|
228
|
+
this.loadData();
|
|
229
|
+
}
|
|
230
|
+
if (!this.data || this.data.length === 0) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (!this._chart) {
|
|
234
|
+
this._chart = new Chart(this._chartElem.getContext("2d"), {
|
|
235
|
+
type: "line",
|
|
236
|
+
data: {
|
|
237
|
+
datasets: [
|
|
238
|
+
{
|
|
239
|
+
data: this.data.filter(value => value.y != null),
|
|
240
|
+
tension: 0.1,
|
|
241
|
+
spanGaps: true,
|
|
242
|
+
backgroundColor: "transparent",
|
|
243
|
+
borderColor: this._style.getPropertyValue("--internal-or-attribute-history-graph-line-color"),
|
|
244
|
+
pointBorderColor: "transparent",
|
|
245
|
+
}
|
|
246
|
+
]
|
|
247
|
+
},
|
|
248
|
+
options: {
|
|
249
|
+
responsive: true,
|
|
250
|
+
maintainAspectRatio: false,
|
|
251
|
+
plugins: {
|
|
252
|
+
legend: {
|
|
253
|
+
display: false
|
|
254
|
+
},
|
|
255
|
+
tooltip: {
|
|
256
|
+
displayColors: false,
|
|
257
|
+
callbacks: {
|
|
258
|
+
title: (context) => {
|
|
259
|
+
return "";
|
|
260
|
+
},
|
|
261
|
+
// label: (context) => {
|
|
262
|
+
// return context.parsed.y; // Removes the colon before the label
|
|
263
|
+
// },
|
|
264
|
+
footer: () => {
|
|
265
|
+
return ""; // Hack the broken vertical alignment of body with footerFontSize: 0
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
scales: {
|
|
271
|
+
y: {
|
|
272
|
+
display: false
|
|
273
|
+
},
|
|
274
|
+
x: {
|
|
275
|
+
type: "time",
|
|
276
|
+
min: this._startOfPeriod,
|
|
277
|
+
max: this._endOfPeriod,
|
|
278
|
+
display: false,
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
if (changedProperties.has("data")) {
|
|
286
|
+
this._chart.data.datasets[0].data = this.data.filter(value => value.y != null);
|
|
287
|
+
this._chart.update();
|
|
288
|
+
this.delta = this.getFormattedDelta(this.getFirstKnownMeasurement(this.data), this.getLastKnownMeasurement(this.data));
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (changedProperties.has("mainValue") || changedProperties.has("mainValueDecimals")) {
|
|
292
|
+
this.formattedMainValue = this.getFormattedValue(this.mainValue);
|
|
293
|
+
}
|
|
294
|
+
if (changedProperties.has("delta")) {
|
|
295
|
+
this.deltaPlus = this.delta && this.delta.val > 0 ? "+" : "";
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
shouldHideAttributePicker() {
|
|
299
|
+
return (this.hideAttributePicker && this.hideAttributePicker.toString() == "true");
|
|
300
|
+
}
|
|
301
|
+
shouldShowControls() {
|
|
302
|
+
return (this.showControls && this.showControls.toString() == "true");
|
|
303
|
+
}
|
|
304
|
+
shouldShowTitle() {
|
|
305
|
+
return (this.showTitle && this.showTitle.toString() == "true");
|
|
306
|
+
}
|
|
307
|
+
render() {
|
|
308
|
+
if (!this._error && (!this.assets || !this.assetAttributes || this.assetAttributes.length === 0)) {
|
|
309
|
+
return html `
|
|
310
|
+
<div class="panel panel-empty">
|
|
311
|
+
<div class="panel-content-wrapper">
|
|
312
|
+
<div class="panel-content">
|
|
313
|
+
${!this.shouldHideAttributePicker() ? html `
|
|
314
|
+
<or-mwc-input class="button" .type="${InputType.BUTTON}" label="selectAttribute" icon="plus" @or-mwc-input-changed="${() => this._openDialog("editAttribute")}"></or-mwc-input>
|
|
315
|
+
` : html `
|
|
316
|
+
<span style="text-align: center;">${i18next.t('noAttributeConnected')}</span>
|
|
317
|
+
`}
|
|
318
|
+
</div>
|
|
319
|
+
</div>
|
|
320
|
+
</div>
|
|
321
|
+
`;
|
|
322
|
+
}
|
|
323
|
+
this.updateComplete.then(() => {
|
|
324
|
+
this.resizeObserver = new ResizeObserver(debounce((entries) => {
|
|
325
|
+
const elemSize = entries[0].devicePixelContentBoxSize[0].inlineSize;
|
|
326
|
+
this.setLabelSizeByWidth(elemSize);
|
|
327
|
+
}, 200));
|
|
328
|
+
this.resizeObserver.observe(this.shadowRoot.querySelector(".graph-wrapper"));
|
|
329
|
+
});
|
|
330
|
+
return html `
|
|
331
|
+
<div class="panel" id="attribute-card">
|
|
332
|
+
<div class="panel-content-wrapper">
|
|
333
|
+
<div class="panel-title">
|
|
334
|
+
${this.shouldShowTitle() ? html `<span class="panel-title-text">${this.assets[0].name + " - " + i18next.t(this.assetAttributes[0][1].name)}</span>` : undefined}
|
|
335
|
+
${this.shouldShowTitle() ? getContentWithMenuTemplate(html `
|
|
336
|
+
<or-mwc-input icon="dots-vertical" type="button"></or-mwc-input>
|
|
337
|
+
`, [
|
|
338
|
+
{
|
|
339
|
+
text: i18next.t("editAttribute"),
|
|
340
|
+
value: "editAttribute"
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
text: i18next.t("editDelta"),
|
|
344
|
+
value: "editDelta"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
text: i18next.t("editCurrentValue"),
|
|
348
|
+
value: "editCurrentValue"
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
text: i18next.t("delete"),
|
|
352
|
+
value: "delete"
|
|
353
|
+
}
|
|
354
|
+
], undefined, (option) => this.handleMenuSelect(option)) : undefined}
|
|
355
|
+
</div>
|
|
356
|
+
<div class="panel-content">
|
|
357
|
+
<div class="mainvalue-wrapper">
|
|
358
|
+
${when(!this._loading, () => html `
|
|
359
|
+
<span class="main-number-icon">${this.assets && this.assets.length === 1 ? getAssetDescriptorIconTemplate(AssetModelUtil.getAssetDescriptor(this.assets[0].type)) : ""}</span>
|
|
360
|
+
<span class="main-number ${this.mainValueSize}">${this.formattedMainValue ? this.formattedMainValue.value : ""}</span>
|
|
361
|
+
<span class="main-number-unit ${this.mainValueSize}">${this.formattedMainValue ? this.formattedMainValue.unit : ""}</span>
|
|
362
|
+
`)}
|
|
363
|
+
</div>
|
|
364
|
+
<div class="graph-wrapper">
|
|
365
|
+
|
|
366
|
+
${when(this._error, () => html `
|
|
367
|
+
<div style="flex: 0 0 80px;"></div>
|
|
368
|
+
<or-translate .value="${this._error}" style="flex: 1; text-align: center;"></or-translate>
|
|
369
|
+
`, () => html `
|
|
370
|
+
<div class="chart-wrapper">
|
|
371
|
+
${when(this._loading, () => html `
|
|
372
|
+
<or-loading-indicator></or-loading-indicator>
|
|
373
|
+
`, () => html `
|
|
374
|
+
<canvas id="chart"></canvas>
|
|
375
|
+
`)}
|
|
376
|
+
</div>
|
|
377
|
+
`)}
|
|
378
|
+
|
|
379
|
+
<div class="controls-wrapper">
|
|
380
|
+
<div class="delta-wrapper">
|
|
381
|
+
<span class="delta">${this.delta ? this.deltaPlus + (this.delta.val !== undefined && this.delta.val !== null ? this.delta.val : "") + (this.delta.unit || "") : ""}</span>
|
|
382
|
+
</div>
|
|
383
|
+
${this.shouldShowControls() ? html `
|
|
384
|
+
<div class="period-selector-wrapper">
|
|
385
|
+
${getContentWithMenuTemplate(html `<or-mwc-input class="period-selector" .type="${InputType.BUTTON}" label="${this.period ? this.period : '-'}"></or-mwc-input>`, [{ value: "hour", text: "hour" }, { value: "day", text: "day" }, { value: "week", text: "week" }, { value: "month", text: "month" }, { value: "year", text: "year" }].map((option) => {
|
|
386
|
+
option.text = i18next.t(option.value);
|
|
387
|
+
return option;
|
|
388
|
+
}), this.period, (value) => this._setPeriodOption(value), undefined, // closedCallback
|
|
389
|
+
false, // multiSelect
|
|
390
|
+
true, // translateValues
|
|
391
|
+
false, // midHeight
|
|
392
|
+
false, // fullWidth
|
|
393
|
+
"kpi-menu-id", // Menu Id
|
|
394
|
+
true // fixToHost
|
|
395
|
+
)}
|
|
396
|
+
</div>
|
|
397
|
+
` : html `
|
|
398
|
+
<or-mwc-input class="period-selector" .type="${InputType.BUTTON}" disabled .label="${i18next.t(this.period ? this.period : "-")}"></or-mwc-input>
|
|
399
|
+
`}
|
|
400
|
+
</div>
|
|
401
|
+
</div>
|
|
402
|
+
</div>
|
|
403
|
+
</div>
|
|
404
|
+
</div>
|
|
405
|
+
`;
|
|
406
|
+
}
|
|
407
|
+
_openDialog(dialogContent) {
|
|
408
|
+
let dialog;
|
|
409
|
+
switch (dialogContent) {
|
|
410
|
+
case "editDelta":
|
|
411
|
+
case "editCurrentValue":
|
|
412
|
+
dialog = new OrMwcDialog()
|
|
413
|
+
.setHeading(i18next.t(dialogContent))
|
|
414
|
+
.setDismissAction(null)
|
|
415
|
+
.setContent(dialogContent === "editDelta"
|
|
416
|
+
? html `
|
|
417
|
+
<or-mwc-input id="delta-mode-picker" value="${this.deltaFormat}" @or-mwc-input-changed="${(evt) => { this.deltaFormat = evt.detail.value; this.saveSettings(); }}" .type="${InputType.LIST}" .options="${[
|
|
418
|
+
["percentage", "Percentage"],
|
|
419
|
+
["absolute", "Absolute"]
|
|
420
|
+
]}"></or-mwc-input>
|
|
421
|
+
`
|
|
422
|
+
: html `
|
|
423
|
+
<or-mwc-input id="current-value-decimals" .label="${i18next.t("decimals")}" value="${this.mainValueDecimals}" .type="${InputType.TEXT}"></or-mwc-input>
|
|
424
|
+
`)
|
|
425
|
+
.setActions([
|
|
426
|
+
{
|
|
427
|
+
actionName: "cancel",
|
|
428
|
+
content: html `<or-mwc-input class="button" .type="${InputType.BUTTON}" label="cancel"></or-mwc-input>`,
|
|
429
|
+
action: () => {
|
|
430
|
+
// Nothing to do here
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
actionName: "yes",
|
|
435
|
+
default: true,
|
|
436
|
+
content: html `<or-mwc-input class="button" .type="${InputType.BUTTON}" label="ok" data-mdc-dialog-action="yes"></or-mwc-input>`,
|
|
437
|
+
action: () => {
|
|
438
|
+
if (dialogContent === "editDelta") {
|
|
439
|
+
this.delta = this.data ? this.getFormattedDelta(this.getFirstKnownMeasurement(this.data), this.getLastKnownMeasurement(this.data)) : undefined;
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
if (dialog && dialog.shadowRoot && dialog.shadowRoot.getElementById("current-value-decimals")) {
|
|
443
|
+
const elm = dialog.shadowRoot.getElementById("current-value-decimals");
|
|
444
|
+
const input = parseInt(elm.value, 10);
|
|
445
|
+
if (input < 0) {
|
|
446
|
+
this.mainValueDecimals = 0;
|
|
447
|
+
}
|
|
448
|
+
else if (input > 10) {
|
|
449
|
+
this.mainValueDecimals = 10;
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
this.mainValueDecimals = input;
|
|
453
|
+
}
|
|
454
|
+
this.formattedMainValue = this.getFormattedValue(this.mainValue);
|
|
455
|
+
this.saveSettings();
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
]);
|
|
461
|
+
dialog.addEventListener(OrAssetTreeSelectionEvent.NAME, (ev) => __awaiter(this, void 0, void 0, function* () {
|
|
462
|
+
const selectedNode = ev.detail && ev.detail.newNodes.length > 0 ? ev.detail.newNodes[0] : undefined;
|
|
463
|
+
if (!selectedNode) {
|
|
464
|
+
this.asset = undefined;
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
// fully load the asset
|
|
468
|
+
const assetEvent = yield manager.events.sendEventWithReply({
|
|
469
|
+
eventType: "read-asset",
|
|
470
|
+
assetId: selectedNode.asset.id
|
|
471
|
+
});
|
|
472
|
+
this.asset = assetEvent.asset;
|
|
473
|
+
}
|
|
474
|
+
}));
|
|
475
|
+
break;
|
|
476
|
+
default:
|
|
477
|
+
dialog = new OrAssetAttributePicker()
|
|
478
|
+
.setHeading(i18next.t("selectAttribute"));
|
|
479
|
+
dialog.addEventListener(OrAssetAttributePickerPickedEvent.NAME, (ev) => __awaiter(this, void 0, void 0, function* () {
|
|
480
|
+
// handle selected attrs
|
|
481
|
+
const attrRef = ev.detail[0];
|
|
482
|
+
try {
|
|
483
|
+
const response = yield manager.rest.api.AssetResource.get(attrRef.id);
|
|
484
|
+
this.asset = response.data;
|
|
485
|
+
this._setAttribute(attrRef.name);
|
|
486
|
+
}
|
|
487
|
+
catch (e) {
|
|
488
|
+
console.error("Failed to get assets requested in settings", e);
|
|
489
|
+
}
|
|
490
|
+
}));
|
|
491
|
+
break;
|
|
492
|
+
}
|
|
493
|
+
if (dialog) {
|
|
494
|
+
showDialog(dialog);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
_setAttribute(attributeName) {
|
|
498
|
+
if (this.asset && attributeName) {
|
|
499
|
+
const attr = this.asset.attributes ? this.asset.attributes[attributeName] : undefined;
|
|
500
|
+
this.assets = [this.asset];
|
|
501
|
+
this.assetAttributes = attr ? [[0, attr]] : [];
|
|
502
|
+
this.saveSettings();
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
_cleanup() {
|
|
506
|
+
if (this._chart) {
|
|
507
|
+
this._chart.destroy();
|
|
508
|
+
this._chart = undefined;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
loadSettings() {
|
|
512
|
+
return __awaiter(this, arguments, void 0, function* (reset = false) {
|
|
513
|
+
this.assetAttributes = [];
|
|
514
|
+
if (!this.period || reset) {
|
|
515
|
+
this.period = "day";
|
|
516
|
+
}
|
|
517
|
+
if (!this.deltaFormat || reset) {
|
|
518
|
+
this.deltaFormat = "absolute";
|
|
519
|
+
}
|
|
520
|
+
if (!this.mainValueDecimals || reset) {
|
|
521
|
+
this.mainValueDecimals = 0;
|
|
522
|
+
}
|
|
523
|
+
if (!this.realm) {
|
|
524
|
+
this.realm = manager.getRealm();
|
|
525
|
+
}
|
|
526
|
+
let allConfigs = (yield manager.console.retrieveData("OrChartConfig")) || [];
|
|
527
|
+
if (!Array.isArray(allConfigs)) {
|
|
528
|
+
allConfigs = [allConfigs];
|
|
529
|
+
}
|
|
530
|
+
if (allConfigs.length === 0 || !this.panelName) {
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
const viewSelector = window.location.hash;
|
|
534
|
+
let config = allConfigs.find(e => e.realm === this.realm);
|
|
535
|
+
const view = config && config.views && config.views[viewSelector] ? config.views[viewSelector][this.panelName] : undefined;
|
|
536
|
+
if (!view) {
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
if (!view.attributeRefs) {
|
|
540
|
+
// Old/invalid config format remove it
|
|
541
|
+
delete config.views[viewSelector][this.panelName];
|
|
542
|
+
const cleanData = [...allConfigs.filter(e => e.realm !== this.realm), config];
|
|
543
|
+
manager.console.storeData("OrChartConfig", cleanData);
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
const assetIds = view.attributeRefs.map((attrRef) => attrRef.id);
|
|
547
|
+
if (assetIds.length === 0) {
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
this._loading = true;
|
|
551
|
+
if (!assetIds.every(id => !!this.assets.find(asset => asset.id === id))) {
|
|
552
|
+
const query = {
|
|
553
|
+
ids: assetIds
|
|
554
|
+
};
|
|
555
|
+
try {
|
|
556
|
+
const response = yield manager.rest.api.AssetResource.queryAssets(query);
|
|
557
|
+
const assets = response.data || [];
|
|
558
|
+
view.attributeRefs = view.attributeRefs.filter((attrRef) => !!assets.find((asset) => asset.id === attrRef.id && asset.attributes && asset.attributes.hasOwnProperty(attrRef.name)));
|
|
559
|
+
allConfigs = [...allConfigs.filter(e => e.realm !== this.realm), config];
|
|
560
|
+
manager.console.storeData("OrChartConfig", allConfigs);
|
|
561
|
+
this.assets = assets.filter((asset) => view.attributeRefs.find((attrRef) => attrRef.id === asset.id));
|
|
562
|
+
}
|
|
563
|
+
catch (e) {
|
|
564
|
+
console.error("Failed to get assets requested in settings", e);
|
|
565
|
+
}
|
|
566
|
+
this._loading = false;
|
|
567
|
+
if (this.assets && this.assets.length > 0) {
|
|
568
|
+
this.assetAttributes = view.attributeRefs.map((attrRef) => {
|
|
569
|
+
const assetIndex = this.assets.findIndex((asset) => asset.id === attrRef.id);
|
|
570
|
+
const asset = assetIndex >= 0 ? this.assets[assetIndex] : undefined;
|
|
571
|
+
return asset && asset.attributes ? [assetIndex, asset.attributes[attrRef.name]] : undefined;
|
|
572
|
+
}).filter((indexAndAttr) => !!indexAndAttr);
|
|
573
|
+
this.period = view.period || "day";
|
|
574
|
+
this.mainValueDecimals = view.decimals || 0;
|
|
575
|
+
this.deltaFormat = view.deltaFormat || "absolute";
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
saveSettings() {
|
|
581
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
582
|
+
if (!this.panelName) {
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
const viewSelector = window.location.hash;
|
|
586
|
+
let allConfigs = (yield manager.console.retrieveData("OrChartConfig")) || [];
|
|
587
|
+
let config = allConfigs.find(e => e.realm === this.realm);
|
|
588
|
+
if (!config) {
|
|
589
|
+
config = {
|
|
590
|
+
realm: this.realm,
|
|
591
|
+
views: {}
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
if (!config.views[viewSelector]) {
|
|
595
|
+
config.views[viewSelector] = {};
|
|
596
|
+
}
|
|
597
|
+
if (!this.assets || !this.assetAttributes || this.assets.length === 0 || this.assetAttributes.length === 0) {
|
|
598
|
+
delete config.views[viewSelector][this.panelName];
|
|
599
|
+
}
|
|
600
|
+
else {
|
|
601
|
+
config.realm = this.realm;
|
|
602
|
+
config.views[viewSelector][this.panelName] = {
|
|
603
|
+
attributeRefs: this.assetAttributes.map(([index, attr]) => {
|
|
604
|
+
const asset = this.assets[index];
|
|
605
|
+
return !!asset ? { id: asset.id, name: attr.name } : undefined;
|
|
606
|
+
}).filter((attrRef) => !!attrRef),
|
|
607
|
+
period: this.period,
|
|
608
|
+
deltaFormat: this.deltaFormat,
|
|
609
|
+
decimals: this.mainValueDecimals
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
allConfigs = [...allConfigs.filter(e => e.realm !== this.realm), config];
|
|
613
|
+
manager.console.storeData("OrChartConfig", allConfigs);
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
loadData() {
|
|
617
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
618
|
+
var _a;
|
|
619
|
+
if (this.data || !this.assetAttributes || !this.assets || this.assets.length === 0 || this.assetAttributes.length === 0 || !this.period) {
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
// If a new requests comes in, we override it with this one using AbortController.
|
|
623
|
+
if (this._dataAbortController) {
|
|
624
|
+
this._dataAbortController.abort("Data request overridden");
|
|
625
|
+
delete this._dataAbortController;
|
|
626
|
+
}
|
|
627
|
+
this._loading = true;
|
|
628
|
+
let interval = "HOUR" /* DatapointInterval.HOUR */;
|
|
629
|
+
let stepSize = 1;
|
|
630
|
+
switch (this.period) {
|
|
631
|
+
case "hour":
|
|
632
|
+
interval = "MINUTE" /* DatapointInterval.MINUTE */;
|
|
633
|
+
stepSize = 5;
|
|
634
|
+
break;
|
|
635
|
+
case "day":
|
|
636
|
+
interval = "HOUR" /* DatapointInterval.HOUR */;
|
|
637
|
+
stepSize = 1;
|
|
638
|
+
break;
|
|
639
|
+
case "week":
|
|
640
|
+
interval = "HOUR" /* DatapointInterval.HOUR */;
|
|
641
|
+
stepSize = 6;
|
|
642
|
+
break;
|
|
643
|
+
case "month":
|
|
644
|
+
interval = "DAY" /* DatapointInterval.DAY */;
|
|
645
|
+
stepSize = 1;
|
|
646
|
+
break;
|
|
647
|
+
case "year":
|
|
648
|
+
interval = "MONTH" /* DatapointInterval.MONTH */;
|
|
649
|
+
stepSize = 1;
|
|
650
|
+
break;
|
|
651
|
+
}
|
|
652
|
+
const lowerCaseInterval = interval.toLowerCase();
|
|
653
|
+
this._startOfPeriod = moment().subtract(1, this.period).toDate().getTime();
|
|
654
|
+
this._endOfPeriod = moment().toDate().getTime();
|
|
655
|
+
const assetId = this.assets[0].id;
|
|
656
|
+
const attributeName = this.assetAttributes[0][1].name;
|
|
657
|
+
this._dataAbortController = new AbortController();
|
|
658
|
+
try {
|
|
659
|
+
const response = yield manager.rest.api.AssetDatapointResource.getDatapoints(assetId, attributeName, { type: "lttb", fromTimestamp: this._startOfPeriod, toTimestamp: this._endOfPeriod, amountOfPoints: 20 }, { signal: this._dataAbortController.signal });
|
|
660
|
+
this._loading = false;
|
|
661
|
+
if (response.status === 200) {
|
|
662
|
+
this.data = response.data;
|
|
663
|
+
this.delta = this.getFormattedDelta(this.getFirstKnownMeasurement(this.data), this.getLastKnownMeasurement(this.data));
|
|
664
|
+
this.deltaPlus = this.delta && this.delta.val > 0 ? "+" : "";
|
|
665
|
+
this._error = undefined;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
catch (ex) {
|
|
669
|
+
console.error(ex);
|
|
670
|
+
if ((ex === null || ex === void 0 ? void 0 : ex.message) === "canceled") {
|
|
671
|
+
return; // If request has been canceled (using AbortController); return, and prevent _loading is set to false.
|
|
672
|
+
}
|
|
673
|
+
this._loading = false;
|
|
674
|
+
if (isAxiosError(ex)) {
|
|
675
|
+
if (ex.message.includes("timeout")) {
|
|
676
|
+
this._error = "noAttributeDataTimeout";
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
else if (((_a = ex.response) === null || _a === void 0 ? void 0 : _a.status) === 413) {
|
|
680
|
+
this._error = "datapointRequestTooLarge";
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
this._error = "couldNotRetrieveAttribute";
|
|
685
|
+
}
|
|
686
|
+
finally {
|
|
687
|
+
// Finally, request the current value through WS request/response
|
|
688
|
+
this.mainValue = undefined;
|
|
689
|
+
this.formattedMainValue = undefined;
|
|
690
|
+
const currentValue = yield manager.events.sendEventWithReply({
|
|
691
|
+
eventType: "read-asset-attribute",
|
|
692
|
+
ref: {
|
|
693
|
+
id: assetId,
|
|
694
|
+
name: attributeName
|
|
695
|
+
}
|
|
696
|
+
});
|
|
697
|
+
this.mainValue = currentValue.value;
|
|
698
|
+
this.formattedMainValue = this.getFormattedValue(this.mainValue);
|
|
699
|
+
}
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
getTotalValue(data) {
|
|
703
|
+
return data.reduce((acc, val) => {
|
|
704
|
+
return val.y ? acc + Math.round(val.y) : acc;
|
|
705
|
+
}, 0);
|
|
706
|
+
}
|
|
707
|
+
getHighestValue(data) {
|
|
708
|
+
return Math.max.apply(Math, data.map((e) => e.y || false));
|
|
709
|
+
}
|
|
710
|
+
getFormattedValue(value) {
|
|
711
|
+
if (value === undefined || !this.assets || !this.assetAttributes || this.assets.length === 0 || this.assetAttributes.length === 0) {
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
const attr = this.assetAttributes[0][1];
|
|
715
|
+
const roundedVal = +(value === null || value === void 0 ? void 0 : value.toFixed(this.mainValueDecimals)); // + operator prevents str return
|
|
716
|
+
const attributeDescriptor = AssetModelUtil.getAttributeDescriptor(attr.name, this.assets[0].type);
|
|
717
|
+
const units = Util.resolveUnits(Util.getAttributeUnits(attr, attributeDescriptor, this.assets[0].type));
|
|
718
|
+
this.setLabelSizeByLength(roundedVal.toString());
|
|
719
|
+
if (!units) {
|
|
720
|
+
return { value: roundedVal, unit: "" };
|
|
721
|
+
}
|
|
722
|
+
return {
|
|
723
|
+
value: roundedVal,
|
|
724
|
+
unit: units
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
getFirstKnownMeasurement(data) {
|
|
728
|
+
for (let i = 0; i <= data.length; i++) {
|
|
729
|
+
if (data[i] && data[i].y !== undefined)
|
|
730
|
+
return data[i].y;
|
|
731
|
+
}
|
|
732
|
+
return 0;
|
|
733
|
+
}
|
|
734
|
+
getLastKnownMeasurement(data) {
|
|
735
|
+
for (let i = data.length - 1; i >= 0; i--) {
|
|
736
|
+
if (data[i] && data[i].y !== undefined)
|
|
737
|
+
return data[i].y;
|
|
738
|
+
}
|
|
739
|
+
return 0;
|
|
740
|
+
}
|
|
741
|
+
getFormattedDelta(firstVal, lastVal) {
|
|
742
|
+
if (this.deltaFormat === "percentage") {
|
|
743
|
+
if (firstVal && lastVal) {
|
|
744
|
+
if (lastVal === 0 && firstVal === 0) {
|
|
745
|
+
return { val: 0, unit: "%" };
|
|
746
|
+
}
|
|
747
|
+
else if (lastVal === 0 && firstVal !== 0) {
|
|
748
|
+
return { val: 100, unit: "%" };
|
|
749
|
+
}
|
|
750
|
+
else {
|
|
751
|
+
const math = Math.round((lastVal - firstVal) / firstVal * 100);
|
|
752
|
+
return { val: math, unit: "%" };
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
else {
|
|
756
|
+
return { val: 0, unit: "%" };
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
return { val: Math.round(lastVal - firstVal), unit: "" };
|
|
760
|
+
}
|
|
761
|
+
handleMenuSelect(value) {
|
|
762
|
+
if (value === "delete") {
|
|
763
|
+
this.assets = [];
|
|
764
|
+
this.assetAttributes = [];
|
|
765
|
+
this.saveSettings();
|
|
766
|
+
}
|
|
767
|
+
else {
|
|
768
|
+
this._openDialog(value);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
setLabelSizeByLength(value) {
|
|
772
|
+
if (value.length >= 20) {
|
|
773
|
+
this.mainValueSize = "xs";
|
|
774
|
+
}
|
|
775
|
+
if (value.length < 20) {
|
|
776
|
+
this.mainValueSize = "s";
|
|
777
|
+
}
|
|
778
|
+
if (value.length < 15) {
|
|
779
|
+
this.mainValueSize = "m";
|
|
780
|
+
}
|
|
781
|
+
if (value.length < 10) {
|
|
782
|
+
this.mainValueSize = "l";
|
|
783
|
+
}
|
|
784
|
+
if (value.length < 5) {
|
|
785
|
+
this.mainValueSize = "xl";
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
setLabelSizeByWidth(inlineSize) {
|
|
789
|
+
if (inlineSize < 60) {
|
|
790
|
+
this.mainValueSize = "s";
|
|
791
|
+
}
|
|
792
|
+
else if (inlineSize < 100) {
|
|
793
|
+
this.mainValueSize = "m";
|
|
794
|
+
}
|
|
795
|
+
else if (inlineSize < 200) {
|
|
796
|
+
this.mainValueSize = "l";
|
|
797
|
+
}
|
|
798
|
+
else {
|
|
799
|
+
this.mainValueSize = "xl";
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
_setPeriodOption(value) {
|
|
803
|
+
this.period = value;
|
|
804
|
+
this.saveSettings();
|
|
805
|
+
}
|
|
806
|
+
};
|
|
807
|
+
__decorate([
|
|
808
|
+
property()
|
|
809
|
+
], OrAttributeCard.prototype, "panelName", void 0);
|
|
810
|
+
__decorate([
|
|
811
|
+
property({ type: Object })
|
|
812
|
+
], OrAttributeCard.prototype, "assets", void 0);
|
|
813
|
+
__decorate([
|
|
814
|
+
property({ type: Object })
|
|
815
|
+
], OrAttributeCard.prototype, "assetAttributes", void 0);
|
|
816
|
+
__decorate([
|
|
817
|
+
property()
|
|
818
|
+
], OrAttributeCard.prototype, "data", void 0);
|
|
819
|
+
__decorate([
|
|
820
|
+
property({ type: String })
|
|
821
|
+
], OrAttributeCard.prototype, "realm", void 0);
|
|
822
|
+
__decorate([
|
|
823
|
+
property()
|
|
824
|
+
], OrAttributeCard.prototype, "mainValue", void 0);
|
|
825
|
+
__decorate([
|
|
826
|
+
property()
|
|
827
|
+
], OrAttributeCard.prototype, "mainValueDecimals", void 0);
|
|
828
|
+
__decorate([
|
|
829
|
+
property()
|
|
830
|
+
], OrAttributeCard.prototype, "mainValueSize", void 0);
|
|
831
|
+
__decorate([
|
|
832
|
+
property()
|
|
833
|
+
], OrAttributeCard.prototype, "delta", void 0);
|
|
834
|
+
__decorate([
|
|
835
|
+
property()
|
|
836
|
+
], OrAttributeCard.prototype, "deltaPlus", void 0);
|
|
837
|
+
__decorate([
|
|
838
|
+
property()
|
|
839
|
+
], OrAttributeCard.prototype, "deltaFormat", void 0);
|
|
840
|
+
__decorate([
|
|
841
|
+
property()
|
|
842
|
+
], OrAttributeCard.prototype, "showControls", void 0);
|
|
843
|
+
__decorate([
|
|
844
|
+
property()
|
|
845
|
+
], OrAttributeCard.prototype, "hideAttributePicker", void 0);
|
|
846
|
+
__decorate([
|
|
847
|
+
property()
|
|
848
|
+
], OrAttributeCard.prototype, "showTitle", void 0);
|
|
849
|
+
__decorate([
|
|
850
|
+
property()
|
|
851
|
+
], OrAttributeCard.prototype, "_loading", void 0);
|
|
852
|
+
__decorate([
|
|
853
|
+
property()
|
|
854
|
+
], OrAttributeCard.prototype, "period", void 0);
|
|
855
|
+
__decorate([
|
|
856
|
+
state()
|
|
857
|
+
], OrAttributeCard.prototype, "_error", void 0);
|
|
858
|
+
__decorate([
|
|
859
|
+
query("#chart")
|
|
860
|
+
], OrAttributeCard.prototype, "_chartElem", void 0);
|
|
861
|
+
OrAttributeCard = __decorate([
|
|
862
|
+
customElement("or-attribute-card")
|
|
863
|
+
], OrAttributeCard);
|
|
864
|
+
export { OrAttributeCard };
|
|
865
|
+
//# sourceMappingURL=index.js.map
|