diff --git a/ui-ngx/src/app/modules/home/components/vc/auto-commit-settings.component.html b/ui-ngx/src/app/modules/home/components/vc/auto-commit-settings.component.html
index 053d0f5006..d80892664d 100644
--- a/ui-ngx/src/app/modules/home/components/vc/auto-commit-settings.component.html
+++ b/ui-ngx/src/app/modules/home/components/vc/auto-commit-settings.component.html
@@ -84,6 +84,9 @@
{{ 'version-control.export-relations' | translate }}
+
+ {{ 'version-control.export-calculated-fields' | translate }}
+
diff --git a/ui-ngx/src/app/modules/home/components/vc/auto-commit-settings.component.ts b/ui-ngx/src/app/modules/home/components/vc/auto-commit-settings.component.ts
index e0a88a3e09..d55515a959 100644
--- a/ui-ngx/src/app/modules/home/components/vc/auto-commit-settings.component.ts
+++ b/ui-ngx/src/app/modules/home/components/vc/auto-commit-settings.component.ts
@@ -25,7 +25,11 @@ import { TranslateService } from '@ngx-translate/core';
import { DialogService } from '@core/services/dialog.service';
import { catchError, map, mergeMap } from 'rxjs/operators';
import { Observable, of } from 'rxjs';
-import { EntityTypeVersionCreateConfig, exportableEntityTypes } from '@shared/models/vc.models';
+import {
+ EntityTypeVersionCreateConfig,
+ exportableEntityTypes,
+ typesWithCalculatedFields
+} from '@shared/models/vc.models';
import { EntityType, entityTypeTranslations } from '@shared/models/entity-type.models';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
@@ -43,6 +47,8 @@ export class AutoCommitSettingsComponent extends PageComponent implements OnInit
isReadOnly: Observable;
+ readonly typesWithCalculatedFields = typesWithCalculatedFields;
+
constructor(protected store: Store,
private adminService: AdminService,
private dialogService: DialogService,
@@ -104,7 +110,8 @@ export class AutoCommitSettingsComponent extends PageComponent implements OnInit
branch: null,
saveAttributes: true,
saveRelations: false,
- saveCredentials: true
+ saveCredentials: true,
+ saveCalculatedFields: true,
};
const allowed = this.allowedEntityTypes();
let entityType: EntityType = null;
@@ -206,7 +213,8 @@ export class AutoCommitSettingsComponent extends PageComponent implements OnInit
branch: [config.branch, []],
saveRelations: [config.saveRelations, []],
saveAttributes: [config.saveAttributes, []],
- saveCredentials: [config.saveCredentials, []]
+ saveCredentials: [config.saveCredentials, []],
+ saveCalculatedFields: [config.saveCalculatedFields, []]
})
}
);
diff --git a/ui-ngx/src/app/modules/home/components/vc/entity-types-version-create.component.html b/ui-ngx/src/app/modules/home/components/vc/entity-types-version-create.component.html
index b9a9a6c01c..8fdf22f6cd 100644
--- a/ui-ngx/src/app/modules/home/components/vc/entity-types-version-create.component.html
+++ b/ui-ngx/src/app/modules/home/components/vc/entity-types-version-create.component.html
@@ -72,6 +72,9 @@
{{ 'version-control.export-relations' | translate }}
+
+ {{ 'version-control.export-calculated-fields' | translate }}
+
diff --git a/ui-ngx/src/app/modules/home/components/vc/entity-types-version-create.component.ts b/ui-ngx/src/app/modules/home/components/vc/entity-types-version-create.component.ts
index 8b16905587..8618e405b0 100644
--- a/ui-ngx/src/app/modules/home/components/vc/entity-types-version-create.component.ts
+++ b/ui-ngx/src/app/modules/home/components/vc/entity-types-version-create.component.ts
@@ -33,7 +33,8 @@ import {
EntityTypeVersionCreateConfig,
exportableEntityTypes,
SyncStrategy,
- syncStrategyTranslationMap
+ syncStrategyTranslationMap,
+ typesWithCalculatedFields
} from '@shared/models/vc.models';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
@@ -79,6 +80,8 @@ export class EntityTypesVersionCreateComponent extends PageComponent implements
loading = true;
+ readonly typesWithCalculatedFields = typesWithCalculatedFields;
+
constructor(protected store: Store,
private translate: TranslateService,
private fb: UntypedFormBuilder,
@@ -150,6 +153,7 @@ export class EntityTypesVersionCreateComponent extends PageComponent implements
saveRelations: [config.saveRelations, []],
saveAttributes: [config.saveAttributes, []],
saveCredentials: [config.saveCredentials, []],
+ saveCalculatedFields: [config.saveCalculatedFields, []],
allEntities: [config.allEntities, []],
entityIds: [config.entityIds, [Validators.required]]
})
@@ -202,6 +206,7 @@ export class EntityTypesVersionCreateComponent extends PageComponent implements
saveAttributes: true,
saveRelations: true,
saveCredentials: true,
+ saveCalculatedFields: true,
allEntities: true,
entityIds: []
};
diff --git a/ui-ngx/src/app/modules/home/components/vc/entity-types-version-load.component.html b/ui-ngx/src/app/modules/home/components/vc/entity-types-version-load.component.html
index 4736bb1ee2..b877d19b63 100644
--- a/ui-ngx/src/app/modules/home/components/vc/entity-types-version-load.component.html
+++ b/ui-ngx/src/app/modules/home/components/vc/entity-types-version-load.component.html
@@ -72,6 +72,9 @@
{{ 'version-control.load-relations' | translate }}
+
+ {{ 'version-control.load-calculated-fields' | translate }}
+
diff --git a/ui-ngx/src/app/modules/home/components/vc/entity-types-version-load.component.ts b/ui-ngx/src/app/modules/home/components/vc/entity-types-version-load.component.ts
index 23f09ae977..f06abaf3a8 100644
--- a/ui-ngx/src/app/modules/home/components/vc/entity-types-version-load.component.ts
+++ b/ui-ngx/src/app/modules/home/components/vc/entity-types-version-load.component.ts
@@ -31,7 +31,8 @@ import { PageComponent } from '@shared/components/page.component';
import {
entityTypesWithoutRelatedData,
EntityTypeVersionLoadConfig,
- exportableEntityTypes
+ exportableEntityTypes,
+ typesWithCalculatedFields
} from '@shared/models/vc.models';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
@@ -75,6 +76,8 @@ export class EntityTypesVersionLoadComponent extends PageComponent implements On
loading = true;
+ readonly typesWithCalculatedFields = typesWithCalculatedFields;
+
constructor(protected store: Store,
private translate: TranslateService,
private popoverService: TbPopoverService,
@@ -145,6 +148,7 @@ export class EntityTypesVersionLoadComponent extends PageComponent implements On
loadRelations: [config.loadRelations, []],
loadAttributes: [config.loadAttributes, []],
loadCredentials: [config.loadCredentials, []],
+ loadCalculatedFields: [config.loadCalculatedFields, []],
removeOtherEntities: [config.removeOtherEntities, []],
findExistingEntityByName: [config.findExistingEntityByName, []]
})
@@ -180,6 +184,7 @@ export class EntityTypesVersionLoadComponent extends PageComponent implements On
loadAttributes: true,
loadRelations: true,
loadCredentials: true,
+ loadCalculatedFields: true,
removeOtherEntities: false,
findExistingEntityByName: true
};
diff --git a/ui-ngx/src/app/modules/home/components/vc/entity-version-create.component.html b/ui-ngx/src/app/modules/home/components/vc/entity-version-create.component.html
index 10c2dc5e40..da4c31a1b8 100644
--- a/ui-ngx/src/app/modules/home/components/vc/entity-version-create.component.html
+++ b/ui-ngx/src/app/modules/home/components/vc/entity-version-create.component.html
@@ -47,6 +47,9 @@
{{ 'version-control.export-relations' | translate }}
+
+ {{ 'version-control.export-calculated-fields' | translate }}
+
diff --git a/ui-ngx/src/app/modules/home/components/vc/entity-version-create.component.ts b/ui-ngx/src/app/modules/home/components/vc/entity-version-create.component.ts
index 48b2a2a174..0c4b696ad1 100644
--- a/ui-ngx/src/app/modules/home/components/vc/entity-version-create.component.ts
+++ b/ui-ngx/src/app/modules/home/components/vc/entity-version-create.component.ts
@@ -20,6 +20,7 @@ import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms
import {
entityTypesWithoutRelatedData,
SingleEntityVersionCreateRequest,
+ typesWithCalculatedFields,
VersionCreateRequestType,
VersionCreationResult
} from '@shared/models/vc.models';
@@ -71,6 +72,8 @@ export class EntityVersionCreateComponent extends PageComponent implements OnIni
private versionCreateResultSubscription: Subscription;
+ readonly typesWithCalculatedFields = typesWithCalculatedFields;
+
constructor(protected store: Store,
private entitiesVersionControlService: EntitiesVersionControlService,
private cd: ChangeDetectorRef,
@@ -115,7 +118,8 @@ export class EntityVersionCreateComponent extends PageComponent implements OnIni
? this.createVersionFormGroup.get('saveRelations').value : false,
saveAttributes: !entityTypesWithoutRelatedData.has(this.entityId.entityType)
? this.createVersionFormGroup.get('saveAttributes').value : false,
- saveCredentials: this.entityId.entityType === EntityType.DEVICE ? this.createVersionFormGroup.get('saveCredentials').value : false
+ saveCredentials: this.entityId.entityType === EntityType.DEVICE ? this.createVersionFormGroup.get('saveCredentials').value : false,
+ saveCalculatedFields: typesWithCalculatedFields.has(this.entityId.entityType) ? this.createVersionFormGroup.get('saveCalculatedFields').value : false,
},
type: VersionCreateRequestType.SINGLE_ENTITY
};
diff --git a/ui-ngx/src/app/modules/home/components/vc/entity-version-restore.component.html b/ui-ngx/src/app/modules/home/components/vc/entity-version-restore.component.html
index 4bc61757c4..1183223850 100644
--- a/ui-ngx/src/app/modules/home/components/vc/entity-version-restore.component.html
+++ b/ui-ngx/src/app/modules/home/components/vc/entity-version-restore.component.html
@@ -36,6 +36,9 @@
{{ 'version-control.load-relations' | translate }}
+
+ {{ 'version-control.load-calculated-fields' | translate }}
+
diff --git a/ui-ngx/src/app/modules/home/components/vc/entity-version-restore.component.ts b/ui-ngx/src/app/modules/home/components/vc/entity-version-restore.component.ts
index df2e8c19ff..4456eb7ce7 100644
--- a/ui-ngx/src/app/modules/home/components/vc/entity-version-restore.component.ts
+++ b/ui-ngx/src/app/modules/home/components/vc/entity-version-restore.component.ts
@@ -79,7 +79,8 @@ export class EntityVersionRestoreComponent extends PageComponent implements OnIn
this.restoreFormGroup = this.fb.group({
loadAttributes: [true, []],
loadRelations: [true, []],
- loadCredentials: [true, []]
+ loadCredentials: [true, []],
+ loadCalculatedFields: [true, []]
});
this.entitiesVersionControlService.getEntityDataInfo(this.externalEntityId, this.versionId).subscribe((data) => {
this.entityDataInfo = data;
@@ -110,7 +111,8 @@ export class EntityVersionRestoreComponent extends PageComponent implements OnIn
config: {
loadRelations: this.entityDataInfo.hasRelations ? this.restoreFormGroup.get('loadRelations').value : false,
loadAttributes: this.entityDataInfo.hasAttributes ? this.restoreFormGroup.get('loadAttributes').value : false,
- loadCredentials: this.entityDataInfo.hasCredentials ? this.restoreFormGroup.get('loadCredentials').value : false
+ loadCredentials: this.entityDataInfo.hasCredentials ? this.restoreFormGroup.get('loadCredentials').value : false,
+ loadCalculatedFields: this.entityDataInfo.hasCalculatedFields ? this.restoreFormGroup.get('loadCalculatedFields').value : false
},
type: VersionLoadRequestType.SINGLE_ENTITY
};
diff --git a/ui-ngx/src/app/shared/models/vc.models.ts b/ui-ngx/src/app/shared/models/vc.models.ts
index 6cc8de02eb..3795518ffc 100644
--- a/ui-ngx/src/app/shared/models/vc.models.ts
+++ b/ui-ngx/src/app/shared/models/vc.models.ts
@@ -49,6 +49,7 @@ export interface VersionCreateConfig {
saveRelations: boolean;
saveAttributes: boolean;
saveCredentials: boolean;
+ saveCalculatedFields: boolean;
}
export enum VersionCreateRequestType {
@@ -106,6 +107,7 @@ export function createDefaultEntityTypesVersionCreate(): {[entityType: string]:
syncStrategy: null,
saveAttributes: !entityTypesWithoutRelatedData.has(entityType),
saveRelations: !entityTypesWithoutRelatedData.has(entityType),
+ saveCalculatedFields: typesWithCalculatedFields.has(entityType),
saveCredentials: true,
allEntities: true,
entityIds: []
@@ -118,6 +120,7 @@ export interface VersionLoadConfig {
loadRelations: boolean;
loadAttributes: boolean;
loadCredentials: boolean;
+ loadCalculatedFields: boolean;
}
export enum VersionLoadRequestType {
@@ -154,6 +157,7 @@ export function createDefaultEntityTypesVersionLoad(): {[entityType: string]: En
loadAttributes: !entityTypesWithoutRelatedData.has(entityType),
loadRelations: !entityTypesWithoutRelatedData.has(entityType),
loadCredentials: true,
+ loadCalculatedFields: typesWithCalculatedFields.has(entityType),
removeOtherEntities: false,
findExistingEntityByName: true
};
@@ -254,4 +258,7 @@ export interface EntityDataInfo {
hasRelations: boolean;
hasAttributes: boolean;
hasCredentials: boolean;
+ hasCalculatedFields: boolean;
}
+
+export const typesWithCalculatedFields = new Set([EntityType.DEVICE, EntityType.ASSET, EntityType.ASSET_PROFILE, EntityType.DEVICE_PROFILE]);
diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json
index 02c604d8ae..6db2fa9ff1 100644
--- a/ui-ngx/src/assets/locale/locale.constant-en_US.json
+++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json
@@ -6320,6 +6320,7 @@
"export-relations": "Export relations",
"export-attributes": "Export attributes",
"export-credentials": "Export credentials",
+ "export-calculated-fields": "Export calculated fields",
"entity-versions": "Entity versions",
"versions": "Versions",
"created-time": "Created time",
@@ -6336,6 +6337,7 @@
"load-relations": "Load relations",
"load-attributes": "Load attributes",
"load-credentials": "Load credentials",
+ "load-calculated-fields": "Load calculated fields",
"compare-with-current": "Compare with current",
"diff-entity-with-version": "Diff with entity version '{{versionName}}'",
"previous-difference": "Previous Difference",