@openremote/or-chart 1.6.0-snapshot.20250512145140 → 1.6.0-snapshot.20250512155842

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.
@@ -0,0 +1,623 @@
1
+ {
2
+ "schemaVersion": "1.0.0",
3
+ "readme": "",
4
+ "modules": [
5
+ {
6
+ "kind": "javascript-module",
7
+ "path": "src/index.ts",
8
+ "declarations": [
9
+ {
10
+ "kind": "class",
11
+ "description": "",
12
+ "name": "OrChartEvent",
13
+ "members": [
14
+ {
15
+ "kind": "field",
16
+ "name": "NAME",
17
+ "type": {
18
+ "text": "string"
19
+ },
20
+ "privacy": "public",
21
+ "static": true,
22
+ "readonly": true,
23
+ "default": "\"or-chart-event\""
24
+ }
25
+ ],
26
+ "superclass": {
27
+ "name": "CustomEvent",
28
+ "module": "src/index.ts"
29
+ }
30
+ },
31
+ {
32
+ "kind": "class",
33
+ "description": "",
34
+ "name": "OrChart",
35
+ "members": [
36
+ {
37
+ "kind": "field",
38
+ "name": "DEFAULT_TIMESTAMP_FORMAT",
39
+ "type": {
40
+ "text": "string"
41
+ },
42
+ "privacy": "public",
43
+ "static": true,
44
+ "default": "\"L HH:mm:ss\""
45
+ },
46
+ {
47
+ "kind": "field",
48
+ "name": "styles",
49
+ "static": true,
50
+ "readonly": true
51
+ },
52
+ {
53
+ "kind": "field",
54
+ "name": "assets",
55
+ "type": {
56
+ "text": "Asset[]"
57
+ },
58
+ "privacy": "public",
59
+ "default": "[]"
60
+ },
61
+ {
62
+ "kind": "field",
63
+ "name": "activeAsset",
64
+ "type": {
65
+ "text": "Asset | undefined"
66
+ },
67
+ "privacy": "private"
68
+ },
69
+ {
70
+ "kind": "field",
71
+ "name": "assetAttributes",
72
+ "type": {
73
+ "text": "[number, Attribute<any>][]"
74
+ },
75
+ "privacy": "public",
76
+ "default": "[]"
77
+ },
78
+ {
79
+ "kind": "field",
80
+ "name": "rightAxisAttributes",
81
+ "type": {
82
+ "text": "AttributeRef[]"
83
+ },
84
+ "privacy": "public",
85
+ "default": "[]"
86
+ },
87
+ {
88
+ "kind": "field",
89
+ "name": "dataProvider",
90
+ "type": {
91
+ "text": "(startOfPeriod: number, endOfPeriod: number, timeUnits: TimeUnit, stepSize: number) => Promise<ChartDataset<\"line\", ScatterDataPoint[]>[]> | undefined"
92
+ },
93
+ "privacy": "public"
94
+ },
95
+ {
96
+ "kind": "field",
97
+ "name": "colors",
98
+ "type": {
99
+ "text": "string[]"
100
+ },
101
+ "privacy": "public",
102
+ "default": "[\"#3869B1\", \"#DA7E30\", \"#3F9852\", \"#CC2428\", \"#6B4C9A\", \"#922427\", \"#958C3D\", \"#535055\"]"
103
+ },
104
+ {
105
+ "kind": "field",
106
+ "name": "datapointQuery",
107
+ "type": {
108
+ "text": "AssetDatapointQueryUnion"
109
+ },
110
+ "privacy": "public",
111
+ "readonly": true
112
+ },
113
+ {
114
+ "kind": "field",
115
+ "name": "config",
116
+ "type": {
117
+ "text": "OrChartConfig | undefined"
118
+ },
119
+ "privacy": "public"
120
+ },
121
+ {
122
+ "kind": "field",
123
+ "name": "chartOptions",
124
+ "type": {
125
+ "text": "any | undefined"
126
+ },
127
+ "privacy": "public"
128
+ },
129
+ {
130
+ "kind": "field",
131
+ "name": "realm",
132
+ "type": {
133
+ "text": "string | undefined"
134
+ },
135
+ "privacy": "public"
136
+ },
137
+ {
138
+ "kind": "field",
139
+ "name": "panelName",
140
+ "type": {
141
+ "text": "string | undefined"
142
+ },
143
+ "privacy": "public"
144
+ },
145
+ {
146
+ "kind": "field",
147
+ "name": "attributeControls",
148
+ "type": {
149
+ "text": "boolean"
150
+ },
151
+ "privacy": "public",
152
+ "default": "true"
153
+ },
154
+ {
155
+ "kind": "field",
156
+ "name": "timeframe",
157
+ "type": {
158
+ "text": "[Date, Date] | undefined"
159
+ },
160
+ "privacy": "public"
161
+ },
162
+ {
163
+ "kind": "field",
164
+ "name": "timestampControls",
165
+ "type": {
166
+ "text": "boolean"
167
+ },
168
+ "privacy": "public",
169
+ "default": "true"
170
+ },
171
+ {
172
+ "kind": "field",
173
+ "name": "timePresetOptions",
174
+ "type": {
175
+ "text": "Map<string, TimePresetCallback> | undefined"
176
+ },
177
+ "privacy": "public"
178
+ },
179
+ {
180
+ "kind": "field",
181
+ "name": "timePresetKey",
182
+ "type": {
183
+ "text": "string | undefined"
184
+ },
185
+ "privacy": "public"
186
+ },
187
+ {
188
+ "kind": "field",
189
+ "name": "showLegend",
190
+ "type": {
191
+ "text": "boolean"
192
+ },
193
+ "privacy": "public",
194
+ "default": "true"
195
+ },
196
+ {
197
+ "kind": "field",
198
+ "name": "denseLegend",
199
+ "type": {
200
+ "text": "boolean"
201
+ },
202
+ "privacy": "public",
203
+ "default": "false"
204
+ },
205
+ {
206
+ "kind": "field",
207
+ "name": "_loading",
208
+ "type": {
209
+ "text": "boolean"
210
+ },
211
+ "privacy": "protected",
212
+ "default": "false"
213
+ },
214
+ {
215
+ "kind": "field",
216
+ "name": "_data",
217
+ "type": {
218
+ "text": "ChartDataset<\"line\", ScatterDataPoint[]>[] | undefined"
219
+ },
220
+ "privacy": "protected",
221
+ "default": "undefined"
222
+ },
223
+ {
224
+ "kind": "field",
225
+ "name": "_tableTemplate",
226
+ "type": {
227
+ "text": "TemplateResult | undefined"
228
+ },
229
+ "privacy": "protected"
230
+ },
231
+ {
232
+ "kind": "field",
233
+ "name": "_chartElem",
234
+ "type": {
235
+ "text": "HTMLCanvasElement"
236
+ },
237
+ "privacy": "protected"
238
+ },
239
+ {
240
+ "kind": "field",
241
+ "name": "_chart",
242
+ "type": {
243
+ "text": "Chart | undefined"
244
+ },
245
+ "privacy": "protected"
246
+ },
247
+ {
248
+ "kind": "field",
249
+ "name": "_style",
250
+ "type": {
251
+ "text": "CSSStyleDeclaration"
252
+ },
253
+ "privacy": "protected"
254
+ },
255
+ {
256
+ "kind": "field",
257
+ "name": "_startOfPeriod",
258
+ "type": {
259
+ "text": "number | undefined"
260
+ },
261
+ "privacy": "protected"
262
+ },
263
+ {
264
+ "kind": "field",
265
+ "name": "_endOfPeriod",
266
+ "type": {
267
+ "text": "number | undefined"
268
+ },
269
+ "privacy": "protected"
270
+ },
271
+ {
272
+ "kind": "field",
273
+ "name": "_timeUnits",
274
+ "type": {
275
+ "text": "TimeUnit | undefined"
276
+ },
277
+ "privacy": "protected"
278
+ },
279
+ {
280
+ "kind": "field",
281
+ "name": "_stepSize",
282
+ "type": {
283
+ "text": "number | undefined"
284
+ },
285
+ "privacy": "protected"
286
+ },
287
+ {
288
+ "kind": "field",
289
+ "name": "_latestError",
290
+ "type": {
291
+ "text": "string | undefined"
292
+ },
293
+ "privacy": "protected"
294
+ },
295
+ {
296
+ "kind": "field",
297
+ "name": "_dataAbortController",
298
+ "type": {
299
+ "text": "AbortController | undefined"
300
+ },
301
+ "privacy": "protected"
302
+ },
303
+ {
304
+ "kind": "method",
305
+ "name": "firstUpdated"
306
+ },
307
+ {
308
+ "kind": "method",
309
+ "name": "updated",
310
+ "parameters": [
311
+ {
312
+ "name": "changedProperties",
313
+ "type": {
314
+ "text": "PropertyValues"
315
+ }
316
+ }
317
+ ]
318
+ },
319
+ {
320
+ "kind": "method",
321
+ "name": "applyChartResponsiveness",
322
+ "return": {
323
+ "type": {
324
+ "text": "void"
325
+ }
326
+ }
327
+ },
328
+ {
329
+ "kind": "method",
330
+ "name": "render"
331
+ },
332
+ {
333
+ "kind": "method",
334
+ "name": "_onTreeSelectionChanged",
335
+ "privacy": "protected",
336
+ "parameters": [
337
+ {
338
+ "name": "event",
339
+ "type": {
340
+ "text": "OrAssetTreeSelectionEvent"
341
+ }
342
+ }
343
+ ]
344
+ },
345
+ {
346
+ "kind": "method",
347
+ "name": "removeDatasetHighlight",
348
+ "parameters": [
349
+ {
350
+ "name": "bgColor",
351
+ "type": {
352
+ "text": "string"
353
+ }
354
+ }
355
+ ]
356
+ },
357
+ {
358
+ "kind": "method",
359
+ "name": "addDatasetHighlight",
360
+ "parameters": [
361
+ {
362
+ "name": "assetId",
363
+ "optional": true,
364
+ "type": {
365
+ "text": "string"
366
+ }
367
+ },
368
+ {
369
+ "name": "attrName",
370
+ "optional": true,
371
+ "type": {
372
+ "text": "string"
373
+ }
374
+ }
375
+ ]
376
+ },
377
+ {
378
+ "kind": "method",
379
+ "name": "loadSettings",
380
+ "parameters": [
381
+ {
382
+ "name": "reset",
383
+ "type": {
384
+ "text": "boolean"
385
+ }
386
+ }
387
+ ]
388
+ },
389
+ {
390
+ "kind": "method",
391
+ "name": "saveSettings"
392
+ },
393
+ {
394
+ "kind": "method",
395
+ "name": "_openDialog",
396
+ "privacy": "protected"
397
+ },
398
+ {
399
+ "kind": "method",
400
+ "name": "_openTimeDialog",
401
+ "privacy": "protected",
402
+ "parameters": [
403
+ {
404
+ "name": "startTimestamp",
405
+ "optional": true,
406
+ "type": {
407
+ "text": "number"
408
+ }
409
+ },
410
+ {
411
+ "name": "endTimestamp",
412
+ "optional": true,
413
+ "type": {
414
+ "text": "number"
415
+ }
416
+ }
417
+ ]
418
+ },
419
+ {
420
+ "kind": "method",
421
+ "name": "_addAttribute",
422
+ "privacy": "protected",
423
+ "parameters": [
424
+ {
425
+ "name": "selectedAttrs",
426
+ "optional": true,
427
+ "type": {
428
+ "text": "AttributeRef[]"
429
+ }
430
+ }
431
+ ]
432
+ },
433
+ {
434
+ "kind": "method",
435
+ "name": "_getSelectedAttributes",
436
+ "privacy": "protected"
437
+ },
438
+ {
439
+ "kind": "method",
440
+ "name": "onCompleted"
441
+ },
442
+ {
443
+ "kind": "method",
444
+ "name": "_cleanup",
445
+ "privacy": "protected"
446
+ },
447
+ {
448
+ "kind": "method",
449
+ "name": "_deleteAttribute",
450
+ "privacy": "protected",
451
+ "parameters": [
452
+ {
453
+ "name": "index",
454
+ "type": {
455
+ "text": "number"
456
+ }
457
+ }
458
+ ]
459
+ },
460
+ {
461
+ "kind": "method",
462
+ "name": "_getAttributeOptionsOld",
463
+ "privacy": "protected",
464
+ "return": {
465
+ "type": {
466
+ "text": "[string, string][] | undefined"
467
+ }
468
+ }
469
+ },
470
+ {
471
+ "kind": "method",
472
+ "name": "_getAttributeOptions",
473
+ "privacy": "protected",
474
+ "return": {
475
+ "type": {
476
+ "text": "[string, string][] | undefined"
477
+ }
478
+ }
479
+ },
480
+ {
481
+ "kind": "method",
482
+ "name": "_getDefaultTimestampOptions",
483
+ "privacy": "protected",
484
+ "return": {
485
+ "type": {
486
+ "text": "Map<string, TimePresetCallback>"
487
+ }
488
+ }
489
+ },
490
+ {
491
+ "kind": "method",
492
+ "name": "_getInterval",
493
+ "privacy": "protected",
494
+ "return": {
495
+ "type": {
496
+ "text": "[number, DatapointInterval]"
497
+ }
498
+ },
499
+ "parameters": [
500
+ {
501
+ "name": "diffInHours",
502
+ "type": {
503
+ "text": "number"
504
+ }
505
+ }
506
+ ]
507
+ },
508
+ {
509
+ "kind": "method",
510
+ "name": "_loadData",
511
+ "privacy": "protected"
512
+ },
513
+ {
514
+ "kind": "method",
515
+ "name": "_loadAttributeData",
516
+ "privacy": "protected",
517
+ "return": {
518
+ "type": {
519
+ "text": "Promise<ChartDataset<\"line\", ScatterDataPoint[]>>"
520
+ }
521
+ },
522
+ "parameters": [
523
+ {
524
+ "name": "asset",
525
+ "type": {
526
+ "text": "Asset"
527
+ }
528
+ },
529
+ {
530
+ "name": "attribute",
531
+ "type": {
532
+ "text": "Attribute<any>"
533
+ }
534
+ },
535
+ {
536
+ "name": "color",
537
+ "type": {
538
+ "text": "string | undefined"
539
+ }
540
+ },
541
+ {
542
+ "name": "from",
543
+ "type": {
544
+ "text": "number"
545
+ }
546
+ },
547
+ {
548
+ "name": "to",
549
+ "type": {
550
+ "text": "number"
551
+ }
552
+ },
553
+ {
554
+ "name": "predicted",
555
+ "type": {
556
+ "text": "boolean"
557
+ }
558
+ },
559
+ {
560
+ "name": "label",
561
+ "optional": true,
562
+ "type": {
563
+ "text": "string"
564
+ }
565
+ },
566
+ {
567
+ "name": "options",
568
+ "optional": true,
569
+ "type": {
570
+ "text": "any"
571
+ }
572
+ }
573
+ ]
574
+ }
575
+ ],
576
+ "events": [
577
+ {
578
+ "name": "resize",
579
+ "type": {
580
+ "text": "OrChartEvent"
581
+ }
582
+ },
583
+ {
584
+ "name": "rendered",
585
+ "type": {
586
+ "text": "OrChartEvent"
587
+ }
588
+ }
589
+ ],
590
+ "mixins": [
591
+ {
592
+ "name": "translate(i18next)",
593
+ "module": "src/index.ts"
594
+ }
595
+ ],
596
+ "superclass": {
597
+ "name": "LitElement",
598
+ "package": "lit"
599
+ },
600
+ "customElement": true
601
+ }
602
+ ],
603
+ "exports": [
604
+ {
605
+ "kind": "js",
606
+ "name": "OrChartEvent",
607
+ "declaration": {
608
+ "name": "OrChartEvent",
609
+ "module": "src/index.ts"
610
+ }
611
+ },
612
+ {
613
+ "kind": "js",
614
+ "name": "OrChart",
615
+ "declaration": {
616
+ "name": "OrChart",
617
+ "module": "src/index.ts"
618
+ }
619
+ }
620
+ ]
621
+ }
622
+ ]
623
+ }
@@ -1033,7 +1033,7 @@
1033
1033
  </div>
1034
1034
  `:void 0}
1035
1035
  </div>
1036
- `}_onTreeSelectionChanged(t){return Tp(this,void 0,void 0,(function*(){if(!Ue().events)return;const e=t.detail&&t.detail.newNodes.length>0?t.detail.newNodes[0]:void 0;if(e){const t=yield Ue().events.sendEventWithReply({eventType:"read-asset",assetId:e.asset.id});this.activeAsset=t.asset}else this.activeAsset=void 0}))}removeDatasetHighlight(t){this._chart&&this._chart.data&&this._chart.data.datasets&&(this._chart.data.datasets.map(((t,e)=>{t.borderColor&&"string"==typeof t.borderColor&&9===t.borderColor.length&&(t.borderColor=t.borderColor.slice(0,-2),t.backgroundColor=t.borderColor)})),this._chart.update())}addDatasetHighlight(t,e){t&&e&&this._chart&&this._chart.data&&this._chart.data.datasets&&(this._chart.data.datasets.map(((n,i)=>{n.assetId===t&&n.attrName===e||(n.borderColor=n.borderColor+"36",n.backgroundColor=n.borderColor)})),this._chart.update())}loadSettings(t){return Tp(this,void 0,void 0,(function*(){if((null==this.assetAttributes||t)&&(this.assetAttributes=[]),this.realm||(this.realm=Ue().getRealm()),this.timePresetOptions||(this.timePresetOptions=this._getDefaultTimestampOptions()),this.timePresetKey||(this.timePresetKey=this.timePresetOptions.keys().next().value.toString()),!this.panelName)return;const e=window.location.hash,n=(yield Ue().console.retrieveData("OrChartConfig"))||[];Array.isArray(n)||Ue().console.storeData("OrChartConfig",[n]);let i=n.find((t=>t.realm===this.realm));if(!i)return;const r=i.views&&i.views[e]?i.views[e][this.panelName]:void 0;if(!r)return;if(!r.attributeRefs){delete i.views[e][this.panelName];const t=[...n.filter((t=>t.realm!==this.realm)),i];return void Ue().console.storeData("OrChartConfig",t)}const a=r.attributeRefs.map((t=>t.id));if(0!==a.length&&(this._loading=!0,!a.every((t=>!!this.assets.find((e=>e.id===t)))))){const t={ids:a};try{const e=(yield Ue().rest.api.AssetResource.queryAssets(t)).data||[];r.attributeRefs=r.attributeRefs.filter((t=>!!e.find((e=>e.id===t.id&&e.attributes&&e.attributes.hasOwnProperty(t.name))))),Ue().console.storeData("OrChartConfig",[...n.filter((t=>t.realm!==this.realm)),i]),this.assets=e.filter((t=>r.attributeRefs.find((e=>e.id===t.id))))}catch(t){console.error("Failed to get assets requested in settings",t)}this._loading=!1,this.assets&&this.assets.length>0&&(this.assetAttributes=r.attributeRefs.map((t=>{const e=this.assets.findIndex((e=>e.id===t.id)),n=e>=0?this.assets[e]:void 0;return n&&n.attributes?[e,n.attributes[t.name]]:void 0})).filter((t=>!!t)))}}))}saveSettings(){return Tp(this,void 0,void 0,(function*(){if(!this.panelName)return;const t=window.location.hash,e=(yield Ue().console.retrieveData("OrChartConfig"))||[];let n=e.find((t=>t.realm===this.realm));n||(n={realm:this.realm,views:{}}),n.views[t]||(n.views[t]={}),this.assets&&this.assetAttributes&&0!==this.assets.length&&0!==this.assetAttributes.length?(n.realm=this.realm,n.views[t][this.panelName]={attributeRefs:this.assetAttributes.map((([t,e])=>{const n=this.assets[t];return n?{id:n.id,name:e.name}:void 0})).filter((t=>!!t))}):delete n.views[t][this.panelName],Ue().console.storeData("OrChartConfig",[...e.filter((t=>t.realm!==this.realm)),n])}))}_openDialog(){up((new Jh.OrAttributePicker).setShowOnlyDatapointAttrs(!0).setMultiSelect(!0).setSelectedAttributes(this._getSelectedAttributes())).addEventListener(Jh.OrAttributePickerPickedEvent.NAME,(t=>this._addAttribute(t.detail)))}_openTimeDialog(t,e){const n=un(),i=un();up((new hp).setHeading(We.t("timeframe")).setContent((()=>N`
1036
+ `}_onTreeSelectionChanged(t){return Tp(this,void 0,void 0,(function*(){if(!Ue().events)return;const e=t.detail&&t.detail.newNodes.length>0?t.detail.newNodes[0]:void 0;if(e){const t=yield Ue().events.sendEventWithReply({eventType:"read-asset",assetId:e.asset.id});this.activeAsset=t.asset}else this.activeAsset=void 0}))}removeDatasetHighlight(t){this._chart&&this._chart.data&&this._chart.data.datasets&&(this._chart.data.datasets.map(((t,e)=>{t.borderColor&&"string"==typeof t.borderColor&&9===t.borderColor.length&&(t.borderColor=t.borderColor.slice(0,-2),t.backgroundColor=t.borderColor)})),this._chart.update())}addDatasetHighlight(t,e){t&&e&&this._chart&&this._chart.data&&this._chart.data.datasets&&(this._chart.data.datasets.map(((n,i)=>{n.assetId===t&&n.attrName===e||(n.borderColor=n.borderColor+"36",n.backgroundColor=n.borderColor)})),this._chart.update())}loadSettings(t){var e;return Tp(this,void 0,void 0,(function*(){if((null==this.assetAttributes||t)&&(this.assetAttributes=[]),this.realm||(this.realm=Ue().getRealm()),this.timePresetOptions||(this.timePresetOptions=this._getDefaultTimestampOptions()),this.timePresetKey||(this.timePresetKey=null===(e=this.timePresetOptions.keys().next().value)||void 0===e?void 0:e.toString()),!this.panelName)return;const n=window.location.hash,i=(yield Ue().console.retrieveData("OrChartConfig"))||[];Array.isArray(i)||Ue().console.storeData("OrChartConfig",[i]);let r=i.find((t=>t.realm===this.realm));if(!r)return;const a=r.views&&r.views[n]?r.views[n][this.panelName]:void 0;if(!a)return;if(!a.attributeRefs){delete r.views[n][this.panelName];const t=[...i.filter((t=>t.realm!==this.realm)),r];return void Ue().console.storeData("OrChartConfig",t)}const o=a.attributeRefs.map((t=>t.id));if(0!==o.length&&(this._loading=!0,!o.every((t=>!!this.assets.find((e=>e.id===t)))))){const t={ids:o};try{const e=(yield Ue().rest.api.AssetResource.queryAssets(t)).data||[];a.attributeRefs=a.attributeRefs.filter((t=>!!e.find((e=>e.id===t.id&&e.attributes&&e.attributes.hasOwnProperty(t.name))))),Ue().console.storeData("OrChartConfig",[...i.filter((t=>t.realm!==this.realm)),r]),this.assets=e.filter((t=>a.attributeRefs.find((e=>e.id===t.id))))}catch(t){console.error("Failed to get assets requested in settings",t)}this._loading=!1,this.assets&&this.assets.length>0&&(this.assetAttributes=a.attributeRefs.map((t=>{const e=this.assets.findIndex((e=>e.id===t.id)),n=e>=0?this.assets[e]:void 0;return n&&n.attributes?[e,n.attributes[t.name]]:void 0})).filter((t=>!!t)))}}))}saveSettings(){return Tp(this,void 0,void 0,(function*(){if(!this.panelName)return;const t=window.location.hash,e=(yield Ue().console.retrieveData("OrChartConfig"))||[];let n=e.find((t=>t.realm===this.realm));n||(n={realm:this.realm,views:{}}),n.views[t]||(n.views[t]={}),this.assets&&this.assetAttributes&&0!==this.assets.length&&0!==this.assetAttributes.length?(n.realm=this.realm,n.views[t][this.panelName]={attributeRefs:this.assetAttributes.map((([t,e])=>{const n=this.assets[t];return n?{id:n.id,name:e.name}:void 0})).filter((t=>!!t))}):delete n.views[t][this.panelName],Ue().console.storeData("OrChartConfig",[...e.filter((t=>t.realm!==this.realm)),n])}))}_openDialog(){up((new Jh.OrAttributePicker).setShowOnlyDatapointAttrs(!0).setMultiSelect(!0).setSelectedAttributes(this._getSelectedAttributes())).addEventListener(Jh.OrAttributePickerPickedEvent.NAME,(t=>this._addAttribute(t.detail)))}_openTimeDialog(t,e){const n=un(),i=un();up((new hp).setHeading(We.t("timeframe")).setContent((()=>N`
1037
1037
  <div>
1038
1038
  <or-mwc-input ${pn(n)} type="${Ca.DATETIME}" required label="${We.t("start")}" .value="${t}"></or-mwc-input>
1039
1039
  <or-mwc-input ${pn(i)} type="${Ca.DATETIME}" required label="${We.t("ending")}" .value="${e}"></or-mwc-input>
package/dist/umd/index.js CHANGED
@@ -1033,7 +1033,7 @@
1033
1033
  </div>
1034
1034
  `:void 0}
1035
1035
  </div>
1036
- `}_onTreeSelectionChanged(t){return qc(this,void 0,void 0,(function*(){if(!Ye().events)return;const e=t.detail&&t.detail.newNodes.length>0?t.detail.newNodes[0]:void 0;if(e){const t=yield Ye().events.sendEventWithReply({eventType:"read-asset",assetId:e.asset.id});this.activeAsset=t.asset}else this.activeAsset=void 0}))}removeDatasetHighlight(t){this._chart&&this._chart.data&&this._chart.data.datasets&&(this._chart.data.datasets.map(((t,e)=>{t.borderColor&&"string"==typeof t.borderColor&&9===t.borderColor.length&&(t.borderColor=t.borderColor.slice(0,-2),t.backgroundColor=t.borderColor)})),this._chart.update())}addDatasetHighlight(t,e){t&&e&&this._chart&&this._chart.data&&this._chart.data.datasets&&(this._chart.data.datasets.map(((n,i)=>{n.assetId===t&&n.attrName===e||(n.borderColor=n.borderColor+"36",n.backgroundColor=n.borderColor)})),this._chart.update())}loadSettings(t){return qc(this,void 0,void 0,(function*(){if((null==this.assetAttributes||t)&&(this.assetAttributes=[]),this.realm||(this.realm=Ye().getRealm()),this.timePresetOptions||(this.timePresetOptions=this._getDefaultTimestampOptions()),this.timePresetKey||(this.timePresetKey=this.timePresetOptions.keys().next().value.toString()),!this.panelName)return;const e=window.location.hash,n=(yield Ye().console.retrieveData("OrChartConfig"))||[];Array.isArray(n)||Ye().console.storeData("OrChartConfig",[n]);let i=n.find((t=>t.realm===this.realm));if(!i)return;const r=i.views&&i.views[e]?i.views[e][this.panelName]:void 0;if(!r)return;if(!r.attributeRefs){delete i.views[e][this.panelName];const t=[...n.filter((t=>t.realm!==this.realm)),i];return void Ye().console.storeData("OrChartConfig",t)}const o=r.attributeRefs.map((t=>t.id));if(0!==o.length&&(this._loading=!0,!o.every((t=>!!this.assets.find((e=>e.id===t)))))){const t={ids:o};try{const e=(yield Ye().rest.api.AssetResource.queryAssets(t)).data||[];r.attributeRefs=r.attributeRefs.filter((t=>!!e.find((e=>e.id===t.id&&e.attributes&&e.attributes.hasOwnProperty(t.name))))),Ye().console.storeData("OrChartConfig",[...n.filter((t=>t.realm!==this.realm)),i]),this.assets=e.filter((t=>r.attributeRefs.find((e=>e.id===t.id))))}catch(t){console.error("Failed to get assets requested in settings",t)}this._loading=!1,this.assets&&this.assets.length>0&&(this.assetAttributes=r.attributeRefs.map((t=>{const e=this.assets.findIndex((e=>e.id===t.id)),n=e>=0?this.assets[e]:void 0;return n&&n.attributes?[e,n.attributes[t.name]]:void 0})).filter((t=>!!t)))}}))}saveSettings(){return qc(this,void 0,void 0,(function*(){if(!this.panelName)return;const t=window.location.hash,e=(yield Ye().console.retrieveData("OrChartConfig"))||[];let n=e.find((t=>t.realm===this.realm));n||(n={realm:this.realm,views:{}}),n.views[t]||(n.views[t]={}),this.assets&&this.assetAttributes&&0!==this.assets.length&&0!==this.assetAttributes.length?(n.realm=this.realm,n.views[t][this.panelName]={attributeRefs:this.assetAttributes.map((([t,e])=>{const n=this.assets[t];return n?{id:n.id,name:e.name}:void 0})).filter((t=>!!t))}):delete n.views[t][this.panelName],Ye().console.storeData("OrChartConfig",[...e.filter((t=>t.realm!==this.realm)),n])}))}_openDialog(){Nc((new _c.OrAttributePicker).setShowOnlyDatapointAttrs(!0).setMultiSelect(!0).setSelectedAttributes(this._getSelectedAttributes())).addEventListener(_c.OrAttributePickerPickedEvent.NAME,(t=>this._addAttribute(t.detail)))}_openTimeDialog(t,e){const n=pn(),i=pn();Nc((new zc).setHeading(Be.t("timeframe")).setContent((()=>j`
1036
+ `}_onTreeSelectionChanged(t){return qc(this,void 0,void 0,(function*(){if(!Ye().events)return;const e=t.detail&&t.detail.newNodes.length>0?t.detail.newNodes[0]:void 0;if(e){const t=yield Ye().events.sendEventWithReply({eventType:"read-asset",assetId:e.asset.id});this.activeAsset=t.asset}else this.activeAsset=void 0}))}removeDatasetHighlight(t){this._chart&&this._chart.data&&this._chart.data.datasets&&(this._chart.data.datasets.map(((t,e)=>{t.borderColor&&"string"==typeof t.borderColor&&9===t.borderColor.length&&(t.borderColor=t.borderColor.slice(0,-2),t.backgroundColor=t.borderColor)})),this._chart.update())}addDatasetHighlight(t,e){t&&e&&this._chart&&this._chart.data&&this._chart.data.datasets&&(this._chart.data.datasets.map(((n,i)=>{n.assetId===t&&n.attrName===e||(n.borderColor=n.borderColor+"36",n.backgroundColor=n.borderColor)})),this._chart.update())}loadSettings(t){var e;return qc(this,void 0,void 0,(function*(){if((null==this.assetAttributes||t)&&(this.assetAttributes=[]),this.realm||(this.realm=Ye().getRealm()),this.timePresetOptions||(this.timePresetOptions=this._getDefaultTimestampOptions()),this.timePresetKey||(this.timePresetKey=null===(e=this.timePresetOptions.keys().next().value)||void 0===e?void 0:e.toString()),!this.panelName)return;const n=window.location.hash,i=(yield Ye().console.retrieveData("OrChartConfig"))||[];Array.isArray(i)||Ye().console.storeData("OrChartConfig",[i]);let r=i.find((t=>t.realm===this.realm));if(!r)return;const o=r.views&&r.views[n]?r.views[n][this.panelName]:void 0;if(!o)return;if(!o.attributeRefs){delete r.views[n][this.panelName];const t=[...i.filter((t=>t.realm!==this.realm)),r];return void Ye().console.storeData("OrChartConfig",t)}const a=o.attributeRefs.map((t=>t.id));if(0!==a.length&&(this._loading=!0,!a.every((t=>!!this.assets.find((e=>e.id===t)))))){const t={ids:a};try{const e=(yield Ye().rest.api.AssetResource.queryAssets(t)).data||[];o.attributeRefs=o.attributeRefs.filter((t=>!!e.find((e=>e.id===t.id&&e.attributes&&e.attributes.hasOwnProperty(t.name))))),Ye().console.storeData("OrChartConfig",[...i.filter((t=>t.realm!==this.realm)),r]),this.assets=e.filter((t=>o.attributeRefs.find((e=>e.id===t.id))))}catch(t){console.error("Failed to get assets requested in settings",t)}this._loading=!1,this.assets&&this.assets.length>0&&(this.assetAttributes=o.attributeRefs.map((t=>{const e=this.assets.findIndex((e=>e.id===t.id)),n=e>=0?this.assets[e]:void 0;return n&&n.attributes?[e,n.attributes[t.name]]:void 0})).filter((t=>!!t)))}}))}saveSettings(){return qc(this,void 0,void 0,(function*(){if(!this.panelName)return;const t=window.location.hash,e=(yield Ye().console.retrieveData("OrChartConfig"))||[];let n=e.find((t=>t.realm===this.realm));n||(n={realm:this.realm,views:{}}),n.views[t]||(n.views[t]={}),this.assets&&this.assetAttributes&&0!==this.assets.length&&0!==this.assetAttributes.length?(n.realm=this.realm,n.views[t][this.panelName]={attributeRefs:this.assetAttributes.map((([t,e])=>{const n=this.assets[t];return n?{id:n.id,name:e.name}:void 0})).filter((t=>!!t))}):delete n.views[t][this.panelName],Ye().console.storeData("OrChartConfig",[...e.filter((t=>t.realm!==this.realm)),n])}))}_openDialog(){Nc((new _c.OrAttributePicker).setShowOnlyDatapointAttrs(!0).setMultiSelect(!0).setSelectedAttributes(this._getSelectedAttributes())).addEventListener(_c.OrAttributePickerPickedEvent.NAME,(t=>this._addAttribute(t.detail)))}_openTimeDialog(t,e){const n=pn(),i=pn();Nc((new zc).setHeading(Be.t("timeframe")).setContent((()=>j`
1037
1037
  <div>
1038
1038
  <or-mwc-input ${fn(n)} type="${No.DATETIME}" required label="${Be.t("start")}" .value="${t}"></or-mwc-input>
1039
1039
  <or-mwc-input ${fn(i)} type="${No.DATETIME}" required label="${Be.t("ending")}" .value="${e}"></or-mwc-input>