diff --git a/ui-ngx/src/app/modules/common/modules-map.ts b/ui-ngx/src/app/modules/common/modules-map.ts index 85690447e3..9db2c7403d 100644 --- a/ui-ngx/src/app/modules/common/modules-map.ts +++ b/ui-ngx/src/app/modules/common/modules-map.ts @@ -121,6 +121,7 @@ import * as TbErrorComponent from '@shared/components/tb-error.component'; import * as TbCheatSheetComponent from '@shared/components/cheatsheet.component'; import * as BreadcrumbComponent from '@shared/components/breadcrumb.component'; import * as UserMenuComponent from '@shared/components/user-menu.component'; +import * as TimeUnitInputComponent from '@shared/components/time-unit-input.component'; import * as TimewindowComponent from '@shared/components/time/timewindow.component'; import * as TimewindowPanelComponent from '@shared/components/time/timewindow-panel.component'; import * as TimeintervalComponent from '@shared/components/time/timeinterval.component'; @@ -458,6 +459,7 @@ class ModulesMap implements IModulesMap { '@shared/components/cheatsheet.component': TbCheatSheetComponent, '@shared/components/breadcrumb.component': BreadcrumbComponent, '@shared/components/user-menu.component': UserMenuComponent, + '@shared/components/time-unit-input.component': TimeUnitInputComponent, '@shared/components/time/timewindow.component': TimewindowComponent, '@shared/components/time/timewindow-panel.component': TimewindowPanelComponent, '@shared/components/time/timeinterval.component': TimeintervalComponent, diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/calculated-field-arguments/calculated-field-argument-panel.component.html b/ui-ngx/src/app/modules/home/components/calculated-fields/components/calculated-field-arguments/calculated-field-argument-panel.component.html index 30533dc714..484f1f9238 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/calculated-field-arguments/calculated-field-argument-panel.component.html +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/calculated-field-arguments/calculated-field-argument-panel.component.html @@ -188,13 +188,15 @@ (click)="cancel()"> {{ 'action.cancel' | translate }} - + @if (!readonly) { + + } diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/calculated-field-arguments/calculated-field-argument-panel.component.ts b/ui-ngx/src/app/modules/home/components/calculated-fields/components/calculated-field-arguments/calculated-field-argument-panel.component.ts index 51d14c9478..d6271409f8 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/calculated-field-arguments/calculated-field-argument-panel.component.ts +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/calculated-field-arguments/calculated-field-argument-panel.component.ts @@ -88,6 +88,7 @@ export class CalculatedFieldArgumentPanelComponent implements OnInit, AfterViewI maxlength: 'calculated-fields.hint.argument-name-max-length', forbidden: 'calculated-fields.hint.argument-name-forbidden' }; + @Input() readonly = false; @ViewChild('entityAutocomplete') entityAutocomplete: EntityAutocompleteComponent; @@ -176,6 +177,11 @@ export class CalculatedFieldArgumentPanelComponent implements OnInit, AfterViewI this.argumentTypes = Object.values(ArgumentType) .filter(type => type !== ArgumentType.Rolling || this.isScript); + + if (this.readonly) { + this.argumentType.disable({emitEvent: false}); + this.argumentFormGroup.disable({emitEvent: false}); + } } ngAfterViewInit(): void { diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/calculated-field-arguments/calculated-field-arguments-table.component.html b/ui-ngx/src/app/modules/home/components/calculated-fields/components/calculated-field-arguments/calculated-field-arguments-table.component.html index 99b4225db2..c61ce4c467 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/calculated-field-arguments/calculated-field-arguments-table.component.html +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/calculated-field-arguments/calculated-field-arguments-table.component.html @@ -93,22 +93,33 @@
- + @if (disable) { + + } @else { + + } - + @if (!readonly) { + + }
diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/geofencing-configuration/calculated-field-geofencing-zone-groups-panel.component.ts b/ui-ngx/src/app/modules/home/components/calculated-fields/components/geofencing-configuration/calculated-field-geofencing-zone-groups-panel.component.ts index b75b9e3dcc..94b9e19056 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/geofencing-configuration/calculated-field-geofencing-zone-groups-panel.component.ts +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/geofencing-configuration/calculated-field-geofencing-zone-groups-panel.component.ts @@ -71,6 +71,7 @@ export class CalculatedFieldGeofencingZoneGroupsPanelComponent implements OnInit @Input() entityName: string; @Input() ownerId: EntityId; @Input() usedNames: string[]; + @Input() readonly = false; @ViewChild('entityAutocomplete') entityAutocomplete: EntityAutocompleteComponent; @@ -160,6 +161,10 @@ export class CalculatedFieldGeofencingZoneGroupsPanelComponent implements OnInit this.currentEntityFilter = getCalculatedFieldCurrentEntityFilter(this.entityName, this.entityId); this.updateEntityFilter(this.zone.refEntityId?.entityType); + + if (this.readonly) { + this.geofencingFormGroup.disable({emitEvent: false}); + } } fetchOptions(searchText: string): Observable> { diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/geofencing-configuration/calculated-field-geofencing-zone-groups-table.component.html b/ui-ngx/src/app/modules/home/components/calculated-fields/components/geofencing-configuration/calculated-field-geofencing-zone-groups-table.component.html index fa0ba32f22..d661f5021a 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/geofencing-configuration/calculated-field-geofencing-zone-groups-table.component.html +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/geofencing-configuration/calculated-field-geofencing-zone-groups-table.component.html @@ -96,20 +96,31 @@
- + @if (disable) { + + } @else { + + } @@ -119,7 +119,7 @@
@@ -213,12 +213,14 @@ (click)="cancel()"> {{ 'action.cancel' | translate }} - + @if (!readonly) { + + } diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/metrics/calculated-field-metrics-panel.component.ts b/ui-ngx/src/app/modules/home/components/calculated-fields/components/metrics/calculated-field-metrics-panel.component.ts index 811f7b87fa..49dca514d2 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/metrics/calculated-field-metrics-panel.component.ts +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/metrics/calculated-field-metrics-panel.component.ts @@ -42,7 +42,7 @@ interface CalculatedFieldAggMetricValuePanel extends CalculatedFieldAggMetricVal @Component({ selector: 'tb-calculated-field-metrics-panel', templateUrl: './calculated-field-metrics-panel.component.html', - styleUrl: '../common/calculated-field-panel.scss', + styleUrls: ['../common/calculated-field-panel.scss', '../../calculated-field.component.scss'], }) export class CalculatedFieldMetricsPanelComponent implements OnInit { @@ -54,6 +54,7 @@ export class CalculatedFieldMetricsPanelComponent implements OnInit { @Input() editorCompleter: TbEditorCompleter; @Input() highlightRules: AceHighlightRules; @Input({required: true}) testScript: (expression?: string) => Observable; + @Input() readonly = false; metricDataApplied = output(); filterExpanded = false; @@ -107,6 +108,10 @@ export class CalculatedFieldMetricsPanelComponent implements OnInit { if (this.simpleMode) { this.AggFunctions = this.AggFunctions.filter(aggFunc => aggFunc !== AggFunction.COUNT_UNIQUE); } + + if (this.readonly) { + this.metricForm.disable({emitEvent: false}); + } } saveMetric(): void { diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/metrics/calculated-field-metrics-table.component.html b/ui-ngx/src/app/modules/home/components/calculated-fields/components/metrics/calculated-field-metrics-table.component.html index 4693d3afb4..3b50b9e152 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/metrics/calculated-field-metrics-table.component.html +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/metrics/calculated-field-metrics-table.component.html @@ -93,15 +93,26 @@
- + @if (disable) { + + } @else { + + }