@c8y/ngx-components 1023.90.1 → 1023.96.0
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/ai/agents/scada/index.d.ts +10 -0
- package/ai/agents/scada/index.d.ts.map +1 -0
- package/ai/ai-chat/index.d.ts +1 -1
- package/ai/ai-chat/index.d.ts.map +1 -1
- package/auth-configuration/index.d.ts +19 -1
- package/auth-configuration/index.d.ts.map +1 -1
- package/computed-asset-properties/index.d.ts +89 -1
- package/computed-asset-properties/index.d.ts.map +1 -1
- package/context-dashboard/index.d.ts +18 -8
- package/context-dashboard/index.d.ts.map +1 -1
- package/echart/index.d.ts +1 -1
- package/echart/models/index.d.ts +1 -1
- package/fesm2022/c8y-ngx-components-ai-agent-chat.mjs +2 -2
- package/fesm2022/c8y-ngx-components-ai-agent-chat.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-ai-agents-scada.mjs +893 -0
- package/fesm2022/c8y-ngx-components-ai-agents-scada.mjs.map +1 -0
- package/fesm2022/c8y-ngx-components-ai-ai-chat.mjs +1 -0
- package/fesm2022/c8y-ngx-components-ai-ai-chat.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-asset-properties.mjs +2 -2
- package/fesm2022/c8y-ngx-components-asset-properties.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-auth-configuration.mjs +73 -7
- package/fesm2022/c8y-ngx-components-auth-configuration.mjs.map +1 -1
- package/fesm2022/{c8y-ngx-components-computed-asset-properties-c8y-ngx-components-computed-asset-properties-Cy9R6Ixb.mjs → c8y-ngx-components-computed-asset-properties-c8y-ngx-components-computed-asset-properties-CHZX7ALq.mjs} +10 -9
- package/fesm2022/c8y-ngx-components-computed-asset-properties-c8y-ngx-components-computed-asset-properties-CHZX7ALq.mjs.map +1 -0
- package/fesm2022/{c8y-ngx-components-computed-asset-properties-fieldbus-item-status-config.component-LrmlAh6V.mjs → c8y-ngx-components-computed-asset-properties-fieldbus-item-status-config.component-DgWGXzEx.mjs} +2 -2
- package/fesm2022/{c8y-ngx-components-computed-asset-properties-fieldbus-item-status-config.component-LrmlAh6V.mjs.map → c8y-ngx-components-computed-asset-properties-fieldbus-item-status-config.component-DgWGXzEx.mjs.map} +1 -1
- package/fesm2022/{c8y-ngx-components-computed-asset-properties-last-measurement-config.component-f1u1TcCl.mjs → c8y-ngx-components-computed-asset-properties-last-measurement-config.component-yfc45-l_.mjs} +2 -2
- package/fesm2022/{c8y-ngx-components-computed-asset-properties-last-measurement-config.component-f1u1TcCl.mjs.map → c8y-ngx-components-computed-asset-properties-last-measurement-config.component-yfc45-l_.mjs.map} +1 -1
- package/fesm2022/c8y-ngx-components-computed-asset-properties.mjs +1 -1
- package/fesm2022/c8y-ngx-components-context-dashboard.mjs +44 -36
- package/fesm2022/c8y-ngx-components-context-dashboard.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-echart-models.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-echart.mjs +1 -1
- package/fesm2022/c8y-ngx-components-echart.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-global-context.mjs +112 -22
- package/fesm2022/c8y-ngx-components-global-context.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-repository-configuration.mjs +292 -115
- package/fesm2022/c8y-ngx-components-repository-configuration.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-repository-firmware.mjs +2 -2
- package/fesm2022/c8y-ngx-components-repository-firmware.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-repository-software.mjs +1 -1
- package/fesm2022/c8y-ngx-components-repository-software.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-widgets-definitions-html-widget.mjs +2 -1
- package/fesm2022/c8y-ngx-components-widgets-definitions-html-widget.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-widgets-definitions-scada.mjs +169 -0
- package/fesm2022/c8y-ngx-components-widgets-definitions-scada.mjs.map +1 -0
- package/fesm2022/c8y-ngx-components-widgets-definitions.mjs +2 -1
- package/fesm2022/c8y-ngx-components-widgets-definitions.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-widgets-exports.mjs +8 -1
- package/fesm2022/c8y-ngx-components-widgets-exports.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-widgets-implementations-alarms.mjs +2 -2
- package/fesm2022/c8y-ngx-components-widgets-implementations-alarms.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-widgets-implementations-datapoints-graph.mjs +3 -3
- package/fesm2022/c8y-ngx-components-widgets-implementations-datapoints-graph.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-widgets-implementations-datapoints-list.mjs +2 -2
- package/fesm2022/c8y-ngx-components-widgets-implementations-datapoints-list.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-widgets-implementations-datapoints-table.mjs +2 -2
- package/fesm2022/c8y-ngx-components-widgets-implementations-datapoints-table.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-widgets-implementations-events.mjs +2 -2
- package/fesm2022/c8y-ngx-components-widgets-implementations-events.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-widgets-implementations-html-widget.mjs +90 -32
- package/fesm2022/c8y-ngx-components-widgets-implementations-html-widget.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-widgets-implementations-kpi.mjs +2 -2
- package/fesm2022/c8y-ngx-components-widgets-implementations-kpi.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-widgets-implementations-scada.mjs +1698 -0
- package/fesm2022/c8y-ngx-components-widgets-implementations-scada.mjs.map +1 -0
- package/fesm2022/c8y-ngx-components.mjs +193 -40
- package/fesm2022/c8y-ngx-components.mjs.map +1 -1
- package/global-context/index.d.ts +58 -3
- package/global-context/index.d.ts.map +1 -1
- package/index.d.ts +77 -22
- package/index.d.ts.map +1 -1
- package/locales/de.po +170 -10
- package/locales/es.po +170 -10
- package/locales/fr.po +170 -10
- package/locales/ja_JP.po +162 -9
- package/locales/ko.po +170 -10
- package/locales/locales.pot +212 -7
- package/locales/nl.po +170 -10
- package/locales/pl.po +170 -10
- package/locales/pt_BR.po +170 -10
- package/locales/zh_CN.po +170 -10
- package/locales/zh_TW.po +170 -10
- package/package.json +1 -1
- package/repository/configuration/index.d.ts +64 -39
- package/repository/configuration/index.d.ts.map +1 -1
- package/widgets/cockpit-exports/index.d.ts +6 -0
- package/widgets/cockpit-exports/index.d.ts.map +1 -1
- package/widgets/definitions/index.d.ts +1 -0
- package/widgets/definitions/index.d.ts.map +1 -1
- package/widgets/definitions/scada/index.d.ts +6 -0
- package/widgets/definitions/scada/index.d.ts.map +1 -0
- package/widgets/device-management-exports/index.d.ts +6 -0
- package/widgets/device-management-exports/index.d.ts.map +1 -1
- package/widgets/exports/index.d.ts +8 -1
- package/widgets/exports/index.d.ts.map +1 -1
- package/widgets/implementations/html-widget/index.d.ts +30 -12
- package/widgets/implementations/html-widget/index.d.ts.map +1 -1
- package/widgets/implementations/scada/index.d.ts +415 -0
- package/widgets/implementations/scada/index.d.ts.map +1 -0
- package/fesm2022/c8y-ngx-components-computed-asset-properties-c8y-ngx-components-computed-asset-properties-Cy9R6Ixb.mjs.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { NgIf, NgClass, AsyncPipe } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { inject, Injectable, Input, Component, input, computed, ChangeDetectionStrategy, viewChild, SecurityContext, ViewChild, DestroyRef, signal } from '@angular/core';
|
|
3
|
+
import { inject, Injectable, Input, Component, input, computed, ChangeDetectionStrategy, viewChild, SecurityContext, EventEmitter, ViewChild, Output, DestroyRef, signal } from '@angular/core';
|
|
4
4
|
import * as i2 from '@angular/forms';
|
|
5
5
|
import { FormsModule } from '@angular/forms';
|
|
6
6
|
import { Router, RouterModule } from '@angular/router';
|
|
7
7
|
import { gettext } from '@c8y/ngx-components/gettext';
|
|
8
8
|
import * as i2$1 from '@c8y/ngx-components';
|
|
9
|
-
import { AppStateService, Permissions, IconDirective, C8yTranslatePipe, ManagedObjectRealtimeService, TabsModule, LoadingComponent, AlertService, OptionsService, ClipboardService,
|
|
9
|
+
import { AppStateService, Permissions, IconDirective, C8yTranslatePipe, ManagedObjectRealtimeService, TabsModule, LoadingComponent, AlertService, OptionsService, ClipboardService, DismissAlertStrategy, DynamicComponentAlert } from '@c8y/ngx-components';
|
|
10
10
|
import { WidgetConfigService, quoteAndEscape, WidgetConfigFeedbackComponent, AssetPropertyMappingsService, renamePropertyKeyInCode } from '@c8y/ngx-components/context-dashboard';
|
|
11
11
|
import * as i1 from 'ngx-bootstrap/popover';
|
|
12
12
|
import { PopoverModule } from 'ngx-bootstrap/popover';
|
|
@@ -23,7 +23,7 @@ import { PRESET_NAME, REFRESH_OPTION, LocalControlsComponent, GLOBAL_CONTEXT_DIS
|
|
|
23
23
|
import * as i4 from 'ngx-bootstrap/dropdown';
|
|
24
24
|
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
|
|
25
25
|
import { EditorComponent } from '@c8y/ngx-components/editor';
|
|
26
|
-
import { map as map$1, distinctUntilChanged as distinctUntilChanged$1, switchMap as switchMap$1, filter as filter$1 } from 'rxjs/operators';
|
|
26
|
+
import { map as map$1, distinctUntilChanged as distinctUntilChanged$1, switchMap as switchMap$1, filter as filter$1, tap, retry, take } from 'rxjs/operators';
|
|
27
27
|
import { AssetPropertyListComponent, AssetPropertyActionDirective } from '@c8y/ngx-components/asset-properties';
|
|
28
28
|
|
|
29
29
|
const INITIAL_HTML_FORMATTED = `<div>
|
|
@@ -364,6 +364,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImpo
|
|
|
364
364
|
class HtmlFrameComponent {
|
|
365
365
|
constructor() {
|
|
366
366
|
this.propertyValues$ = EMPTY;
|
|
367
|
+
/**
|
|
368
|
+
* Gates the managed-object realtime subscription. Defaults to always-on
|
|
369
|
+
* for backwards compatibility; callers that own a global time-context
|
|
370
|
+
* control (e.g. SCADA) can pass a live-mode observable to pause the MO
|
|
371
|
+
* updates when the widget is paused.
|
|
372
|
+
*/
|
|
373
|
+
this.realtimeControl$ = of(true);
|
|
367
374
|
/**
|
|
368
375
|
* If set to true, it will be ensured that a unique hash is generated
|
|
369
376
|
* for every webcomponent. This is useful if configured as otherwise it might
|
|
@@ -399,6 +406,8 @@ class HtmlFrameComponent {
|
|
|
399
406
|
this.alerts = [];
|
|
400
407
|
const div = this.hostElement();
|
|
401
408
|
div.nativeElement.innerHTML = '';
|
|
409
|
+
this.currentWebComponent = undefined;
|
|
410
|
+
this.currentLegacyElement = undefined;
|
|
402
411
|
this.reload$.next();
|
|
403
412
|
}
|
|
404
413
|
async initDiv(divHostElement) {
|
|
@@ -420,7 +429,11 @@ class HtmlFrameComponent {
|
|
|
420
429
|
}
|
|
421
430
|
// same goes for an HTML Element
|
|
422
431
|
if (defaultModule.default instanceof HTMLElement) {
|
|
432
|
+
if (this.currentLegacyElement?.parentNode === divHostElement) {
|
|
433
|
+
divHostElement.removeChild(this.currentLegacyElement);
|
|
434
|
+
}
|
|
423
435
|
divHostElement.appendChild(defaultModule.default);
|
|
436
|
+
this.currentLegacyElement = defaultModule.default;
|
|
424
437
|
// Find and execute scripts
|
|
425
438
|
const scripts = divHostElement.querySelectorAll('script');
|
|
426
439
|
scripts.forEach(script => {
|
|
@@ -473,15 +486,17 @@ class HtmlFrameComponent {
|
|
|
473
486
|
return merge(errorEvents$, rejectionEvents$);
|
|
474
487
|
}
|
|
475
488
|
createWebComponent(webComponentName, divHostElement, context) {
|
|
489
|
+
// Remove previous web component if it exists
|
|
490
|
+
if (this.currentWebComponent && this.currentWebComponent.parentNode === divHostElement) {
|
|
491
|
+
divHostElement.removeChild(this.currentWebComponent);
|
|
492
|
+
}
|
|
476
493
|
const webComponent = document.createElement(webComponentName);
|
|
477
494
|
const instantTranslate = this.translateService.instant.bind(this.translateService);
|
|
478
495
|
webComponent.c8yTranslate = instantTranslate;
|
|
479
|
-
// TODO: should c8yContext be updated in realtime and also connected under global time controls?
|
|
480
496
|
webComponent.c8yContext = context;
|
|
481
497
|
if (context?.id) {
|
|
482
|
-
this.
|
|
483
|
-
.onAll$(context.id)
|
|
484
|
-
.pipe(takeUntil(merge(this.reload$, this.destroy$)))
|
|
498
|
+
this.realtimeControl$
|
|
499
|
+
.pipe(switchMap(enabled => (enabled ? this.moRealtime.onAll$(context.id) : EMPTY)), takeUntil(merge(this.reload$, this.destroy$)))
|
|
485
500
|
.subscribe(res => {
|
|
486
501
|
webComponent.c8yContext = res.data;
|
|
487
502
|
});
|
|
@@ -490,6 +505,8 @@ class HtmlFrameComponent {
|
|
|
490
505
|
webComponent.c8yProperties = values;
|
|
491
506
|
});
|
|
492
507
|
divHostElement.appendChild(webComponent);
|
|
508
|
+
// Store reference to current component
|
|
509
|
+
this.currentWebComponent = webComponent;
|
|
493
510
|
return webComponent;
|
|
494
511
|
}
|
|
495
512
|
mapErrorEventToAlert(event) {
|
|
@@ -530,7 +547,7 @@ class HtmlFrameComponent {
|
|
|
530
547
|
return webComponentScript;
|
|
531
548
|
}
|
|
532
549
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: HtmlFrameComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
533
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.25", type: HtmlFrameComponent, isStandalone: true, selector: "c8y-html-frame", inputs: { config: "config", device: "device", propertyValues$: "propertyValues$", useSalt: "useSalt" }, host: { classAttribute: "d-contents" }, viewQueries: [{ propertyName: "hostElement", first: true, predicate: ["hostElement"], descendants: true, isSignal: true }], usesOnChanges: true, ngImport: i0, template: "@for (alert of alerts; track alert) {\n <div\n class=\"alert m-8\"\n role=\"alert\"\n [ngClass]=\"{\n 'alert-danger': alert.type === 'danger',\n 'alert-warning': alert.type === 'warning',\n 'alert-info': alert.type === 'info',\n 'alert-success': alert.type === 'success'\n }\"\n >\n <p><strong translate>There was an issue in the HTML widget:</strong></p>\n <pre>{{ alert.text }}</pre>\n </div>\n}\n<div\n class=\"fit-w fit-h\"\n #hostElement\n></div>\n", dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] }); }
|
|
550
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.25", type: HtmlFrameComponent, isStandalone: true, selector: "c8y-html-frame", inputs: { config: "config", device: "device", propertyValues$: "propertyValues$", realtimeControl$: "realtimeControl$", useSalt: "useSalt" }, host: { classAttribute: "d-contents" }, viewQueries: [{ propertyName: "hostElement", first: true, predicate: ["hostElement"], descendants: true, isSignal: true }], usesOnChanges: true, ngImport: i0, template: "@for (alert of alerts; track alert) {\n <div\n class=\"alert m-8\"\n role=\"alert\"\n [ngClass]=\"{\n 'alert-danger': alert.type === 'danger',\n 'alert-warning': alert.type === 'warning',\n 'alert-info': alert.type === 'info',\n 'alert-success': alert.type === 'success'\n }\"\n >\n <p><strong translate>There was an issue in the HTML widget:</strong></p>\n <pre>{{ alert.text }}</pre>\n </div>\n}\n<div\n class=\"fit-w fit-h\"\n #hostElement\n></div>\n", dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] }); }
|
|
534
551
|
}
|
|
535
552
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: HtmlFrameComponent, decorators: [{
|
|
536
553
|
type: Component,
|
|
@@ -541,6 +558,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImpo
|
|
|
541
558
|
type: Input
|
|
542
559
|
}], propertyValues$: [{
|
|
543
560
|
type: Input
|
|
561
|
+
}], realtimeControl$: [{
|
|
562
|
+
type: Input
|
|
544
563
|
}], useSalt: [{
|
|
545
564
|
type: Input
|
|
546
565
|
}], hostElement: [{ type: i0.ViewChild, args: ['hostElement', { isSignal: true }] }] } });
|
|
@@ -548,10 +567,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImpo
|
|
|
548
567
|
class WidgetCodeEditorComponent {
|
|
549
568
|
constructor() {
|
|
550
569
|
this.mode = 'code';
|
|
551
|
-
this.
|
|
570
|
+
this.showAdvancedSettings = true;
|
|
571
|
+
this.codeChange = new EventEmitter();
|
|
572
|
+
this.cssChange = new EventEmitter();
|
|
552
573
|
this.translate = inject(TranslateService);
|
|
553
574
|
this.widgetConfigService = inject(WidgetConfigService);
|
|
554
|
-
this.
|
|
575
|
+
this.defaultPropertyKeys$ = this.widgetConfigService.currentConfig$.pipe(map(config => Object.keys(config?.properties || {}).sort((a, b) => a.localeCompare(b))));
|
|
576
|
+
this.propertyKeys$ = this.defaultPropertyKeys$;
|
|
577
|
+
this.propertyPrefix = 'this.c8yProperties';
|
|
555
578
|
this.isAutoSaveEnabled = true;
|
|
556
579
|
this.language = 'html';
|
|
557
580
|
this.isLoading = false;
|
|
@@ -563,6 +586,11 @@ class WidgetCodeEditorComponent {
|
|
|
563
586
|
this.TAB_OUTLET_NAME = 'html-widget-tab-outlet';
|
|
564
587
|
this.destroy$ = new Subject();
|
|
565
588
|
this.suggestionProviders = [];
|
|
589
|
+
this.getFormattedPropertyExpression = (key) => {
|
|
590
|
+
const nonAlphanumericRegex = /[^a-zA-Z0-9]/;
|
|
591
|
+
const formattedKey = nonAlphanumericRegex.test(key) ? `[${quoteAndEscape(key)}]` : `${key}`;
|
|
592
|
+
return '${' + this.propertyPrefix + '?.' + formattedKey + '}';
|
|
593
|
+
};
|
|
566
594
|
}
|
|
567
595
|
ngOnDestroy() {
|
|
568
596
|
this.suggestionProviders.forEach(a => a.dispose());
|
|
@@ -624,10 +652,10 @@ class WidgetCodeEditorComponent {
|
|
|
624
652
|
saveCode(codeStr) {
|
|
625
653
|
const code = codeStr || this.editor.getValue();
|
|
626
654
|
if (this.mode === 'code') {
|
|
627
|
-
this.
|
|
655
|
+
this.codeChange.next(code);
|
|
628
656
|
return;
|
|
629
657
|
}
|
|
630
|
-
this.
|
|
658
|
+
this.cssChange.next(code);
|
|
631
659
|
}
|
|
632
660
|
insertPropertyAtCursor(key) {
|
|
633
661
|
if (!this.editor) {
|
|
@@ -646,6 +674,7 @@ class WidgetCodeEditorComponent {
|
|
|
646
674
|
if (!keys.length)
|
|
647
675
|
return;
|
|
648
676
|
const monaco = this.editorComponent.monaco;
|
|
677
|
+
const escapedPrefix = this.propertyPrefix.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
649
678
|
const providerOptions = {
|
|
650
679
|
triggerCharacters: ['$', '.', '[', "'"],
|
|
651
680
|
provideCompletionItems: (model, position) => {
|
|
@@ -661,8 +690,8 @@ class WidgetCodeEditorComponent {
|
|
|
661
690
|
startColumn,
|
|
662
691
|
endColumn: position.column
|
|
663
692
|
});
|
|
664
|
-
// Case 1: after dot access –
|
|
665
|
-
const dotMatch =
|
|
693
|
+
// Case 1: after dot access – <prefix>?. or <prefix>.
|
|
694
|
+
const dotMatch = new RegExp(escapedPrefix + '\\??\\.(' + '\\w*)$').exec(lineText);
|
|
666
695
|
if (dotMatch) {
|
|
667
696
|
const typed = dotMatch[1];
|
|
668
697
|
const startColumn = position.column - typed.length;
|
|
@@ -677,8 +706,8 @@ class WidgetCodeEditorComponent {
|
|
|
677
706
|
}));
|
|
678
707
|
return { suggestions };
|
|
679
708
|
}
|
|
680
|
-
// Case 2: after bracket access –
|
|
681
|
-
const bracketMatch =
|
|
709
|
+
// Case 2: after bracket access – <prefix>?.[ or <prefix>[
|
|
710
|
+
const bracketMatch = new RegExp(escapedPrefix + '(?:\\?\\.)?' + '\\[([^\\]]*)$').exec(lineText);
|
|
682
711
|
if (bracketMatch) {
|
|
683
712
|
const typed = bracketMatch[1];
|
|
684
713
|
const charAfterCursor = model.getValueInRange({
|
|
@@ -733,13 +762,8 @@ class WidgetCodeEditorComponent {
|
|
|
733
762
|
};
|
|
734
763
|
this.suggestionProviders.push(monaco.languages.registerCompletionItemProvider('html', providerOptions), monaco.languages.registerCompletionItemProvider('javascript', providerOptions));
|
|
735
764
|
}
|
|
736
|
-
getFormattedPropertyExpression(key) {
|
|
737
|
-
const nonAlphanumericRegex = /[^a-zA-Z0-9]/;
|
|
738
|
-
const formattedKey = nonAlphanumericRegex.test(key) ? `[${quoteAndEscape(key)}]` : `${key}`;
|
|
739
|
-
return '${this.c8yProperties?.' + formattedKey + '}';
|
|
740
|
-
}
|
|
741
765
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: WidgetCodeEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
742
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.25", type: WidgetCodeEditorComponent, isStandalone: true, selector: "c8y-widget-code-editor", inputs: { mode: "mode", config: "config" }, viewQueries: [{ propertyName: "editorComponent", first: true, predicate: EditorComponent, descendants: true }], usesOnChanges: true, ngImport: i0, template: "<c8y-widget-config-feedback>\n <div class=\"d-flex\">\n @if (config?.devMode && !config?.legacy) {\n <span\n class=\"tag tag--warning text-12\"\n translate\n >\n Advanced developer mode\n </span>\n }\n </div>\n <div class=\"d-flex\">\n @if (config?.legacy) {\n <span\n class=\"tag tag--warning text-12\"\n [title]=\"\n 'This widget is in legacy mode. Consider to upgrade this to a new HTML widget. Read our documentation on details to transform your widget'\n | translate\n \"\n translate\n >\n Legacy mode\n </span>\n }\n </div>\n</c8y-widget-config-feedback>\n\n<div class=\"d-flex d-col fit-h fit-w\">\n <c8y-html-widget-advanced-settings\n
|
|
766
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.25", type: WidgetCodeEditorComponent, isStandalone: true, selector: "c8y-widget-code-editor", inputs: { mode: "mode", config: "config", showAdvancedSettings: "showAdvancedSettings", propertyKeys$: "propertyKeys$", propertyPrefix: "propertyPrefix", getFormattedPropertyExpression: "getFormattedPropertyExpression" }, outputs: { codeChange: "codeChange", cssChange: "cssChange" }, viewQueries: [{ propertyName: "editorComponent", first: true, predicate: EditorComponent, descendants: true }], usesOnChanges: true, ngImport: i0, template: "<c8y-widget-config-feedback>\n <div class=\"d-flex\">\n @if (config?.devMode && !config?.legacy) {\n <span\n class=\"tag tag--warning text-12\"\n translate\n >\n Advanced developer mode\n </span>\n }\n </div>\n <div class=\"d-flex\">\n @if (config?.legacy) {\n <span\n class=\"tag tag--warning text-12\"\n [title]=\"\n 'This widget is in legacy mode. Consider to upgrade this to a new HTML widget. Read our documentation on details to transform your widget'\n | translate\n \"\n translate\n >\n Legacy mode\n </span>\n }\n </div>\n</c8y-widget-config-feedback>\n\n<div class=\"d-flex d-col fit-h fit-w\">\n @if (showAdvancedSettings) {\n <c8y-html-widget-advanced-settings\n [devMode]=\"config?.devMode\"\n [cssEncapsulation]=\"config?.options?.cssEncapsulation\"\n ></c8y-html-widget-advanced-settings>\n }\n\n <fieldset class=\"c8y-fieldset p-0 overflow-hidden\">\n <legend class=\"m-l-16 p-l-0\">{{ 'Code' | translate }}</legend>\n\n <div class=\"btn-group btn-group-sm m-l-0 p-t-8 p-b-8 p-l-16 p-r-16 fit-w d-flex\">\n <button\n class=\"btn btn-default\"\n [attr.aria-label]=\"'Undo' | translate\"\n [tooltip]=\"'Undo' | translate\"\n placement=\"top\"\n container=\"body\"\n type=\"button\"\n [delay]=\"500\"\n (click)=\"undo()\"\n >\n <i [c8yIcon]=\"'undo'\"></i>\n </button>\n\n <button\n class=\"btn btn-default\"\n [attr.aria-label]=\"'Redo' | translate\"\n [tooltip]=\"'Redo' | translate\"\n placement=\"top\"\n container=\"body\"\n type=\"button\"\n [delay]=\"500\"\n (click)=\"redo()\"\n >\n <i [c8yIcon]=\"'redo'\"></i>\n </button>\n\n <button\n class=\"btn btn-default\"\n [attr.aria-label]=\"'Format code' | translate\"\n [tooltip]=\"'Format code' | translate\"\n placement=\"top\"\n container=\"body\"\n type=\"button\"\n [delay]=\"500\"\n (click)=\"formatCode()\"\n >\n <i [c8yIcon]=\"'format-align-left'\"></i>\n </button>\n\n @let propertyKeys = propertyKeys$ | async;\n @if (mode !== 'css' && propertyKeys?.length) {\n <div\n class=\"btn-group btn-group-sm m-l-4\"\n container=\"body\"\n dropdown\n >\n <button\n class=\"btn btn-default\"\n [attr.aria-label]=\"'Insert property' | translate\"\n [tooltip]=\"'Insert property' | translate\"\n placement=\"top\"\n container=\"body\"\n type=\"button\"\n [delay]=\"500\"\n dropdownToggle\n >\n <i [c8yIcon]=\"'plus-circle'\"></i>\n </button>\n <ul\n class=\"dropdown-menu\"\n *dropdownMenu\n >\n @for (key of propertyKeys; track key) {\n <li>\n <button\n class=\"dropdown-item\"\n type=\"button\"\n (click)=\"insertPropertyAtCursor(key)\"\n >\n {{ key }}\n </button>\n </li>\n }\n </ul>\n </div>\n }\n\n <label class=\"c8y-switch m-l-auto\">\n <input\n type=\"checkbox\"\n [checked]=\"isAutoSaveEnabled\"\n (change)=\"isAutoSaveEnabled = !isAutoSaveEnabled\"\n />\n <span></span>\n <span translate>Auto save</span>\n </label>\n </div>\n\n <div\n class=\"btn-toolbar m-0 p-relative\"\n role=\"toolbar\"\n >\n <c8y-tabs-outlet\n class=\"elevation-none\"\n [outletName]=\"TAB_OUTLET_NAME\"\n [orientation]=\"'horizontal'\"\n [openFirstTab]=\"false\"\n ></c8y-tabs-outlet>\n <c8y-tab\n [icon]=\"'code'\"\n [label]=\"(config?.devMode ? TAB_WEBCOMPONENT_LABEL : TAB_HTML_LABEL) | translate\"\n [priority]=\"100\"\n [showAlways]=\"true\"\n [tabsOutlet]=\"TAB_OUTLET_NAME\"\n [isActive]=\"mode === 'code'\"\n (onSelect)=\"switchMode('code')\"\n ></c8y-tab>\n @if (!config?.devMode && !config?.legacy) {\n <c8y-tab\n [icon]=\"'c8y-css'\"\n [label]=\"TAB_CSS_LABEL | translate\"\n [priority]=\"0\"\n [tabsOutlet]=\"TAB_OUTLET_NAME\"\n [isActive]=\"mode === 'css'\"\n (onSelect)=\"switchMode('css')\"\n ></c8y-tab>\n }\n </div>\n\n @if (!isLoading) {\n @if (!(mode === 'css' && config?.devMode)) {\n <c8y-editor\n class=\"flex-grow d-block\"\n style=\"height: 450px\"\n [ngModel]=\"value\"\n (ngModelChange)=\"changeCode($event)\"\n [editorOptions]=\"{\n language,\n tabSize: 2,\n insertSpaces: true,\n minimap: { enabled: false }\n }\"\n (editorInit)=\"editorLoaded($event)\"\n ></c8y-editor>\n }\n } @else {\n <c8y-loading></c8y-loading>\n }\n </fieldset>\n</div>\n", dependencies: [{ kind: "component", type: EditorComponent, selector: "c8y-editor", inputs: ["editorOptions", "theme"], outputs: ["editorInit"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "component", type: WidgetConfigFeedbackComponent, selector: "c8y-widget-config-feedback" }, { kind: "ngmodule", type: TabsModule }, { kind: "component", type: i2$1.TabsOutletComponent, selector: "c8y-tabs-outlet,c8y-ui-tabs", inputs: ["tabs", "orientation", "navigatorOpen", "outletName", "context", "openFirstTab", "hasHeader"] }, { kind: "component", type: i2$1.TabComponent, selector: "c8y-tab", inputs: ["path", "label", "icon", "priority", "orientation", "injector", "tabsOutlet", "isActive", "text", "showAlways"], outputs: ["onSelect"] }, { kind: "ngmodule", type: TooltipModule }, { kind: "directive", type: i3.TooltipDirective, selector: "[tooltip], [tooltipHtml]", inputs: ["adaptivePosition", "tooltip", "placement", "triggers", "container", "containerClass", "boundariesElement", "isOpen", "isDisabled", "delay", "tooltipHtml", "tooltipPlacement", "tooltipIsOpen", "tooltipEnable", "tooltipAppendToBody", "tooltipAnimation", "tooltipClass", "tooltipContext", "tooltipPopupDelay", "tooltipFadeDuration", "tooltipTrigger"], outputs: ["tooltipChange", "onShown", "onHidden", "tooltipStateChanged"], exportAs: ["bs-tooltip"] }, { kind: "ngmodule", type: PopoverModule }, { kind: "ngmodule", type: BsDropdownModule }, { kind: "directive", type: i4.BsDropdownMenuDirective, selector: "[bsDropdownMenu],[dropdownMenu]", exportAs: ["bs-dropdown-menu"] }, { kind: "directive", type: i4.BsDropdownToggleDirective, selector: "[bsDropdownToggle],[dropdownToggle]", exportAs: ["bs-dropdown-toggle"] }, { kind: "directive", type: i4.BsDropdownDirective, selector: "[bsDropdown], [dropdown]", inputs: ["placement", "triggers", "container", "dropup", "autoClose", "isAnimated", "insideClick", "isDisabled", "isOpen"], outputs: ["isOpenChange", "onShown", "onHidden"], exportAs: ["bs-dropdown"] }, { kind: "component", type: LoadingComponent, selector: "c8y-loading", inputs: ["layout", "progress", "message"] }, { kind: "component", type: AdvancedSettingsComponent, selector: "c8y-html-widget-advanced-settings", inputs: ["devMode", "cssEncapsulation"] }, { kind: "pipe", type: AsyncPipe, name: "async" }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }] }); }
|
|
743
767
|
}
|
|
744
768
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: WidgetCodeEditorComponent, decorators: [{
|
|
745
769
|
type: Component,
|
|
@@ -756,14 +780,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImpo
|
|
|
756
780
|
BsDropdownModule,
|
|
757
781
|
LoadingComponent,
|
|
758
782
|
AdvancedSettingsComponent
|
|
759
|
-
], selector: 'c8y-widget-code-editor', template: "<c8y-widget-config-feedback>\n <div class=\"d-flex\">\n @if (config?.devMode && !config?.legacy) {\n <span\n class=\"tag tag--warning text-12\"\n translate\n >\n Advanced developer mode\n </span>\n }\n </div>\n <div class=\"d-flex\">\n @if (config?.legacy) {\n <span\n class=\"tag tag--warning text-12\"\n [title]=\"\n 'This widget is in legacy mode. Consider to upgrade this to a new HTML widget. Read our documentation on details to transform your widget'\n | translate\n \"\n translate\n >\n Legacy mode\n </span>\n }\n </div>\n</c8y-widget-config-feedback>\n\n<div class=\"d-flex d-col fit-h fit-w\">\n <c8y-html-widget-advanced-settings\n
|
|
783
|
+
], selector: 'c8y-widget-code-editor', template: "<c8y-widget-config-feedback>\n <div class=\"d-flex\">\n @if (config?.devMode && !config?.legacy) {\n <span\n class=\"tag tag--warning text-12\"\n translate\n >\n Advanced developer mode\n </span>\n }\n </div>\n <div class=\"d-flex\">\n @if (config?.legacy) {\n <span\n class=\"tag tag--warning text-12\"\n [title]=\"\n 'This widget is in legacy mode. Consider to upgrade this to a new HTML widget. Read our documentation on details to transform your widget'\n | translate\n \"\n translate\n >\n Legacy mode\n </span>\n }\n </div>\n</c8y-widget-config-feedback>\n\n<div class=\"d-flex d-col fit-h fit-w\">\n @if (showAdvancedSettings) {\n <c8y-html-widget-advanced-settings\n [devMode]=\"config?.devMode\"\n [cssEncapsulation]=\"config?.options?.cssEncapsulation\"\n ></c8y-html-widget-advanced-settings>\n }\n\n <fieldset class=\"c8y-fieldset p-0 overflow-hidden\">\n <legend class=\"m-l-16 p-l-0\">{{ 'Code' | translate }}</legend>\n\n <div class=\"btn-group btn-group-sm m-l-0 p-t-8 p-b-8 p-l-16 p-r-16 fit-w d-flex\">\n <button\n class=\"btn btn-default\"\n [attr.aria-label]=\"'Undo' | translate\"\n [tooltip]=\"'Undo' | translate\"\n placement=\"top\"\n container=\"body\"\n type=\"button\"\n [delay]=\"500\"\n (click)=\"undo()\"\n >\n <i [c8yIcon]=\"'undo'\"></i>\n </button>\n\n <button\n class=\"btn btn-default\"\n [attr.aria-label]=\"'Redo' | translate\"\n [tooltip]=\"'Redo' | translate\"\n placement=\"top\"\n container=\"body\"\n type=\"button\"\n [delay]=\"500\"\n (click)=\"redo()\"\n >\n <i [c8yIcon]=\"'redo'\"></i>\n </button>\n\n <button\n class=\"btn btn-default\"\n [attr.aria-label]=\"'Format code' | translate\"\n [tooltip]=\"'Format code' | translate\"\n placement=\"top\"\n container=\"body\"\n type=\"button\"\n [delay]=\"500\"\n (click)=\"formatCode()\"\n >\n <i [c8yIcon]=\"'format-align-left'\"></i>\n </button>\n\n @let propertyKeys = propertyKeys$ | async;\n @if (mode !== 'css' && propertyKeys?.length) {\n <div\n class=\"btn-group btn-group-sm m-l-4\"\n container=\"body\"\n dropdown\n >\n <button\n class=\"btn btn-default\"\n [attr.aria-label]=\"'Insert property' | translate\"\n [tooltip]=\"'Insert property' | translate\"\n placement=\"top\"\n container=\"body\"\n type=\"button\"\n [delay]=\"500\"\n dropdownToggle\n >\n <i [c8yIcon]=\"'plus-circle'\"></i>\n </button>\n <ul\n class=\"dropdown-menu\"\n *dropdownMenu\n >\n @for (key of propertyKeys; track key) {\n <li>\n <button\n class=\"dropdown-item\"\n type=\"button\"\n (click)=\"insertPropertyAtCursor(key)\"\n >\n {{ key }}\n </button>\n </li>\n }\n </ul>\n </div>\n }\n\n <label class=\"c8y-switch m-l-auto\">\n <input\n type=\"checkbox\"\n [checked]=\"isAutoSaveEnabled\"\n (change)=\"isAutoSaveEnabled = !isAutoSaveEnabled\"\n />\n <span></span>\n <span translate>Auto save</span>\n </label>\n </div>\n\n <div\n class=\"btn-toolbar m-0 p-relative\"\n role=\"toolbar\"\n >\n <c8y-tabs-outlet\n class=\"elevation-none\"\n [outletName]=\"TAB_OUTLET_NAME\"\n [orientation]=\"'horizontal'\"\n [openFirstTab]=\"false\"\n ></c8y-tabs-outlet>\n <c8y-tab\n [icon]=\"'code'\"\n [label]=\"(config?.devMode ? TAB_WEBCOMPONENT_LABEL : TAB_HTML_LABEL) | translate\"\n [priority]=\"100\"\n [showAlways]=\"true\"\n [tabsOutlet]=\"TAB_OUTLET_NAME\"\n [isActive]=\"mode === 'code'\"\n (onSelect)=\"switchMode('code')\"\n ></c8y-tab>\n @if (!config?.devMode && !config?.legacy) {\n <c8y-tab\n [icon]=\"'c8y-css'\"\n [label]=\"TAB_CSS_LABEL | translate\"\n [priority]=\"0\"\n [tabsOutlet]=\"TAB_OUTLET_NAME\"\n [isActive]=\"mode === 'css'\"\n (onSelect)=\"switchMode('css')\"\n ></c8y-tab>\n }\n </div>\n\n @if (!isLoading) {\n @if (!(mode === 'css' && config?.devMode)) {\n <c8y-editor\n class=\"flex-grow d-block\"\n style=\"height: 450px\"\n [ngModel]=\"value\"\n (ngModelChange)=\"changeCode($event)\"\n [editorOptions]=\"{\n language,\n tabSize: 2,\n insertSpaces: true,\n minimap: { enabled: false }\n }\"\n (editorInit)=\"editorLoaded($event)\"\n ></c8y-editor>\n }\n } @else {\n <c8y-loading></c8y-loading>\n }\n </fieldset>\n</div>\n" }]
|
|
760
784
|
}], propDecorators: { mode: [{
|
|
761
785
|
type: Input
|
|
762
786
|
}], config: [{
|
|
763
787
|
type: Input
|
|
788
|
+
}], showAdvancedSettings: [{
|
|
789
|
+
type: Input
|
|
790
|
+
}], codeChange: [{
|
|
791
|
+
type: Output
|
|
792
|
+
}], cssChange: [{
|
|
793
|
+
type: Output
|
|
794
|
+
}], propertyKeys$: [{
|
|
795
|
+
type: Input
|
|
796
|
+
}], propertyPrefix: [{
|
|
797
|
+
type: Input
|
|
764
798
|
}], editorComponent: [{
|
|
765
799
|
type: ViewChild,
|
|
766
800
|
args: [EditorComponent]
|
|
801
|
+
}], getFormattedPropertyExpression: [{
|
|
802
|
+
type: Input
|
|
767
803
|
}] } });
|
|
768
804
|
|
|
769
805
|
class HtmlWidgetConfigComponent {
|
|
@@ -781,7 +817,7 @@ class HtmlWidgetConfigComponent {
|
|
|
781
817
|
this.htmlWidgetConfigService = inject(HtmlWidgetConfigService);
|
|
782
818
|
this.widgetConfigService = inject(WidgetConfigService);
|
|
783
819
|
this.assetPropertyMappings = inject(AssetPropertyMappingsService);
|
|
784
|
-
this.controls = PRESET_NAME.
|
|
820
|
+
this.controls = PRESET_NAME.AUTO_REFRESH_ONLY_CONFIG;
|
|
785
821
|
this.destroyRef = inject(DestroyRef);
|
|
786
822
|
this.realtimeControl$ = this.widgetConfigService.currentConfig$.pipe(map$1(config => config?.refreshOption === REFRESH_OPTION.LIVE && config?.isAutoRefreshEnabled === true), distinctUntilChanged$1());
|
|
787
823
|
this.propertyValues$ = this.widgetConfigService.currentConfig$.pipe(switchMap$1(config => this.assetPropertyMappings.getValues$(config?.properties, this.realtimeControl$)));
|
|
@@ -796,6 +832,12 @@ class HtmlWidgetConfigComponent {
|
|
|
796
832
|
// it here.
|
|
797
833
|
this.htmlWidgetConfigService.destroy();
|
|
798
834
|
}
|
|
835
|
+
onCodeChange(value) {
|
|
836
|
+
this.htmlWidgetConfigService.changeCode(value);
|
|
837
|
+
}
|
|
838
|
+
onCssChange(value) {
|
|
839
|
+
this.htmlWidgetConfigService.changeCss(value);
|
|
840
|
+
}
|
|
799
841
|
handleRename(notification) {
|
|
800
842
|
const { oldKey, newKey } = notification;
|
|
801
843
|
const htmlWidgetConfig = this.widgetConfigService.currentConfig;
|
|
@@ -812,7 +854,7 @@ class HtmlWidgetConfigComponent {
|
|
|
812
854
|
this.alert.success(gettext('Renamed asset property and updated references in HTML code.'));
|
|
813
855
|
}
|
|
814
856
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: HtmlWidgetConfigComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
815
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.25", type: HtmlWidgetConfigComponent, isStandalone: true, selector: "c8y-html-widget-config", viewQueries: [{ propertyName: "htmlPreviewTemplate", first: true, predicate: ["htmlPreview"], descendants: true }], ngImport: i0, template: "<c8y-widget-code-editor\n [config]=\"htmlWidgetConfigService.config$ | async\"\n [mode]=\"'code'\"\n></c8y-widget-code-editor>\n\n<ng-template #htmlPreview>\n @if ((widgetConfigService.currentConfig$ | async)?.displayMode !== 'dashboard') {\n <c8y-local-controls\n [controls]=\"controls\"\n [displayMode]=\"(widgetConfigService.currentConfig$ | async)?.displayMode\"\n [config]=\"globalContextState$ | async\"\n [disabled]=\"true\"\n ></c8y-local-controls>\n }\n <c8y-html-frame\n [config]=\"htmlWidgetConfigService.codeEditorChangeConfig$ | async\"\n [device]=\"(widgetConfigService.currentConfig$ | async).device\"\n [propertyValues$]=\"propertyValues$\"\n [useSalt]=\"true\"\n ></c8y-html-frame>\n</ng-template>\n", dependencies: [{ kind: "ngmodule", type: RouterModule }, { kind: "ngmodule", type: FormsModule }, { kind: "component", type: HtmlFrameComponent, selector: "c8y-html-frame", inputs: ["config", "device", "propertyValues$", "useSalt"] }, { kind: "component", type: WidgetCodeEditorComponent, selector: "c8y-widget-code-editor", inputs: ["mode", "config"] }, { kind: "component", type: LocalControlsComponent, selector: "c8y-local-controls", inputs: ["controls", "displayMode", "config", "isLoading", "disabled", "emitRefresh", "dashboardChild"], outputs: ["configChange", "refresh"] }, { kind: "pipe", type: AsyncPipe, name: "async" }] }); }
|
|
857
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.25", type: HtmlWidgetConfigComponent, isStandalone: true, selector: "c8y-html-widget-config", viewQueries: [{ propertyName: "htmlPreviewTemplate", first: true, predicate: ["htmlPreview"], descendants: true }], ngImport: i0, template: "<c8y-widget-code-editor\n [config]=\"htmlWidgetConfigService.config$ | async\"\n [mode]=\"'code'\"\n (codeChange)=\"onCodeChange($event)\"\n (cssChange)=\"onCssChange($event)\"\n></c8y-widget-code-editor>\n\n<ng-template #htmlPreview>\n @if ((widgetConfigService.currentConfig$ | async)?.displayMode !== 'dashboard') {\n <c8y-local-controls\n [controls]=\"controls\"\n [displayMode]=\"(widgetConfigService.currentConfig$ | async)?.displayMode\"\n [config]=\"globalContextState$ | async\"\n [disabled]=\"true\"\n ></c8y-local-controls>\n }\n <c8y-html-frame\n [config]=\"htmlWidgetConfigService.codeEditorChangeConfig$ | async\"\n [device]=\"(widgetConfigService.currentConfig$ | async).device\"\n [propertyValues$]=\"propertyValues$\"\n [useSalt]=\"true\"\n ></c8y-html-frame>\n</ng-template>\n", dependencies: [{ kind: "ngmodule", type: RouterModule }, { kind: "ngmodule", type: FormsModule }, { kind: "component", type: HtmlFrameComponent, selector: "c8y-html-frame", inputs: ["config", "device", "propertyValues$", "realtimeControl$", "useSalt"] }, { kind: "component", type: WidgetCodeEditorComponent, selector: "c8y-widget-code-editor", inputs: ["mode", "config", "showAdvancedSettings", "propertyKeys$", "propertyPrefix", "getFormattedPropertyExpression"], outputs: ["codeChange", "cssChange"] }, { kind: "component", type: LocalControlsComponent, selector: "c8y-local-controls", inputs: ["controls", "displayMode", "config", "isLoading", "disabled", "propagateAutoRefresh", "emitRefresh", "dashboardChild"], outputs: ["configChange", "refresh"] }, { kind: "pipe", type: AsyncPipe, name: "async" }] }); }
|
|
816
858
|
}
|
|
817
859
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: HtmlWidgetConfigComponent, decorators: [{
|
|
818
860
|
type: Component,
|
|
@@ -823,7 +865,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImpo
|
|
|
823
865
|
HtmlFrameComponent,
|
|
824
866
|
WidgetCodeEditorComponent,
|
|
825
867
|
LocalControlsComponent
|
|
826
|
-
], template: "<c8y-widget-code-editor\n [config]=\"htmlWidgetConfigService.config$ | async\"\n [mode]=\"'code'\"\n></c8y-widget-code-editor>\n\n<ng-template #htmlPreview>\n @if ((widgetConfigService.currentConfig$ | async)?.displayMode !== 'dashboard') {\n <c8y-local-controls\n [controls]=\"controls\"\n [displayMode]=\"(widgetConfigService.currentConfig$ | async)?.displayMode\"\n [config]=\"globalContextState$ | async\"\n [disabled]=\"true\"\n ></c8y-local-controls>\n }\n <c8y-html-frame\n [config]=\"htmlWidgetConfigService.codeEditorChangeConfig$ | async\"\n [device]=\"(widgetConfigService.currentConfig$ | async).device\"\n [propertyValues$]=\"propertyValues$\"\n [useSalt]=\"true\"\n ></c8y-html-frame>\n</ng-template>\n" }]
|
|
868
|
+
], template: "<c8y-widget-code-editor\n [config]=\"htmlWidgetConfigService.config$ | async\"\n [mode]=\"'code'\"\n (codeChange)=\"onCodeChange($event)\"\n (cssChange)=\"onCssChange($event)\"\n></c8y-widget-code-editor>\n\n<ng-template #htmlPreview>\n @if ((widgetConfigService.currentConfig$ | async)?.displayMode !== 'dashboard') {\n <c8y-local-controls\n [controls]=\"controls\"\n [displayMode]=\"(widgetConfigService.currentConfig$ | async)?.displayMode\"\n [config]=\"globalContextState$ | async\"\n [disabled]=\"true\"\n ></c8y-local-controls>\n }\n <c8y-html-frame\n [config]=\"htmlWidgetConfigService.codeEditorChangeConfig$ | async\"\n [device]=\"(widgetConfigService.currentConfig$ | async).device\"\n [propertyValues$]=\"propertyValues$\"\n [useSalt]=\"true\"\n ></c8y-html-frame>\n</ng-template>\n" }]
|
|
827
869
|
}], ctorParameters: () => [], propDecorators: { htmlPreviewTemplate: [{
|
|
828
870
|
type: ViewChild,
|
|
829
871
|
args: ['htmlPreview']
|
|
@@ -874,8 +916,14 @@ class HtmlWidgetComponent {
|
|
|
874
916
|
constructor() {
|
|
875
917
|
this.config = input(...(ngDevMode ? [undefined, { debugName: "config" }] : []));
|
|
876
918
|
this.realtimeControl$ = new BehaviorSubject(false);
|
|
877
|
-
this.
|
|
878
|
-
this.
|
|
919
|
+
this.refresh$ = new Subject();
|
|
920
|
+
this.SERVER_ERROR_TEXT = gettext('Server error occurred.');
|
|
921
|
+
this.propertyValues$ = computed(() => this.assetPropertiesMappings
|
|
922
|
+
.getValues$(this.config()?.properties, this.realtimeControl$.asObservable(), this.refresh$.asObservable())
|
|
923
|
+
.pipe(tap({
|
|
924
|
+
next: () => this.isLoading.set(false),
|
|
925
|
+
error: () => this.isLoading.set(false)
|
|
926
|
+
}), retry({ delay: err => this.handleFetchError(err) })), ...(ngDevMode ? [{ debugName: "propertyValues$" }] : []));
|
|
879
927
|
this.displayMode = signal(GLOBAL_CONTEXT_DISPLAY_MODE.DASHBOARD, ...(ngDevMode ? [{ debugName: "displayMode" }] : []));
|
|
880
928
|
this.contextConfig = signal({}, ...(ngDevMode ? [{ debugName: "contextConfig" }] : []));
|
|
881
929
|
this.isLoading = signal(false, ...(ngDevMode ? [{ debugName: "isLoading" }] : []));
|
|
@@ -891,6 +939,7 @@ class HtmlWidgetComponent {
|
|
|
891
939
|
this.assetPropertiesMappings = inject(AssetPropertyMappingsService);
|
|
892
940
|
}
|
|
893
941
|
ngOnInit() {
|
|
942
|
+
this.alerts?.setAlertGroupDismissStrategy('warning', DismissAlertStrategy.TEMPORARY_OR_PERMANENT);
|
|
894
943
|
const config = this.config();
|
|
895
944
|
if (config?.html && !config.config) {
|
|
896
945
|
config.config = this.mapLegacyConfig(config);
|
|
@@ -913,9 +962,11 @@ class HtmlWidgetComponent {
|
|
|
913
962
|
const { context } = event;
|
|
914
963
|
this.contextConfig.set(context);
|
|
915
964
|
this.realtimeControl$.next(this.shouldEnableRealtime());
|
|
965
|
+
this.onRefresh();
|
|
916
966
|
}
|
|
917
|
-
|
|
918
|
-
|
|
967
|
+
onRefresh() {
|
|
968
|
+
this.isLoading.set(true);
|
|
969
|
+
this.refresh$.next();
|
|
919
970
|
}
|
|
920
971
|
shouldEnableRealtime() {
|
|
921
972
|
const ctx = this.contextConfig();
|
|
@@ -937,8 +988,15 @@ class HtmlWidgetComponent {
|
|
|
937
988
|
}
|
|
938
989
|
};
|
|
939
990
|
}
|
|
991
|
+
handleFetchError(err) {
|
|
992
|
+
this.alerts?.addAlerts(new DynamicComponentAlert({
|
|
993
|
+
type: 'warning',
|
|
994
|
+
text: err?.message ?? this.SERVER_ERROR_TEXT
|
|
995
|
+
}));
|
|
996
|
+
return this.refresh$.pipe(take(1));
|
|
997
|
+
}
|
|
940
998
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: HtmlWidgetComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
941
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.25", type: HtmlWidgetComponent, isStandalone: true, selector: "c8y-html-widget", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "@if (displayMode() === GLOBAL_CONTEXT_DISPLAY_MODE.DASHBOARD) {\n <c8y-global-context-connector\n [controls]=\"PRESET_NAME.
|
|
999
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.25", type: HtmlWidgetComponent, isStandalone: true, selector: "c8y-html-widget", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "@if (displayMode() === GLOBAL_CONTEXT_DISPLAY_MODE.DASHBOARD) {\n <c8y-global-context-connector\n [controls]=\"PRESET_NAME.AUTO_REFRESH_ONLY_CONFIG\"\n [config]=\"contextConfig()\"\n [isLoading]=\"isLoading()\"\n [linked]=\"isLinkedToGlobal()\"\n [propagateAutoRefresh]=\"false\"\n (configChange)=\"onContextChange($event)\"\n (refresh)=\"onRefresh()\"\n >\n </c8y-global-context-connector>\n} @else {\n <c8y-local-controls\n [controls]=\"PRESET_NAME.AUTO_REFRESH_ONLY_CONFIG\"\n [displayMode]=\"displayMode()\"\n [config]=\"contextConfig()\"\n [isLoading]=\"isLoading()\"\n [propagateAutoRefresh]=\"false\"\n (configChange)=\"onContextChange($event)\"\n (refresh)=\"onRefresh()\"\n >\n </c8y-local-controls>\n}\n\n<div class=\"p-16\">\n <c8y-html-frame\n [config]=\"config().config\"\n [device]=\"config().device\"\n [propertyValues$]=\"propertyValues$()\"\n ></c8y-html-frame>\n</div>\n", dependencies: [{ kind: "ngmodule", type: RouterModule }, { kind: "component", type: HtmlFrameComponent, selector: "c8y-html-frame", inputs: ["config", "device", "propertyValues$", "realtimeControl$", "useSalt"] }, { kind: "component", type: GlobalContextConnectorComponent, selector: "c8y-global-context-connector", inputs: ["controls", "config", "isLoading", "dashboardChild", "linked", "propagateAutoRefresh", "emitRefresh"], outputs: ["configChange", "refresh", "linkedChange"] }, { kind: "component", type: LocalControlsComponent, selector: "c8y-local-controls", inputs: ["controls", "displayMode", "config", "isLoading", "disabled", "propagateAutoRefresh", "emitRefresh", "dashboardChild"], outputs: ["configChange", "refresh"] }] }); }
|
|
942
1000
|
}
|
|
943
1001
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: HtmlWidgetComponent, decorators: [{
|
|
944
1002
|
type: Component,
|
|
@@ -947,7 +1005,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImpo
|
|
|
947
1005
|
HtmlFrameComponent,
|
|
948
1006
|
GlobalContextConnectorComponent,
|
|
949
1007
|
LocalControlsComponent
|
|
950
|
-
], template: "@if (displayMode() === GLOBAL_CONTEXT_DISPLAY_MODE.DASHBOARD) {\n <c8y-global-context-connector\n [controls]=\"PRESET_NAME.
|
|
1008
|
+
], template: "@if (displayMode() === GLOBAL_CONTEXT_DISPLAY_MODE.DASHBOARD) {\n <c8y-global-context-connector\n [controls]=\"PRESET_NAME.AUTO_REFRESH_ONLY_CONFIG\"\n [config]=\"contextConfig()\"\n [isLoading]=\"isLoading()\"\n [linked]=\"isLinkedToGlobal()\"\n [propagateAutoRefresh]=\"false\"\n (configChange)=\"onContextChange($event)\"\n (refresh)=\"onRefresh()\"\n >\n </c8y-global-context-connector>\n} @else {\n <c8y-local-controls\n [controls]=\"PRESET_NAME.AUTO_REFRESH_ONLY_CONFIG\"\n [displayMode]=\"displayMode()\"\n [config]=\"contextConfig()\"\n [isLoading]=\"isLoading()\"\n [propagateAutoRefresh]=\"false\"\n (configChange)=\"onContextChange($event)\"\n (refresh)=\"onRefresh()\"\n >\n </c8y-local-controls>\n}\n\n<div class=\"p-16\">\n <c8y-html-frame\n [config]=\"config().config\"\n [device]=\"config().device\"\n [propertyValues$]=\"propertyValues$()\"\n ></c8y-html-frame>\n</div>\n" }]
|
|
951
1009
|
}], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: false }] }] } });
|
|
952
1010
|
|
|
953
1011
|
/**
|