From 6f030fa8da7d0b5aa374d12661398b1bd33cacda Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Thu, 3 Sep 2020 10:04:03 +0300 Subject: [PATCH] UI: Tenant/Device profile data --- .../device-profile-data.component.html | 2 +- .../profile/device-profile.component.html | 9 ++++---- .../profile/device-profile.component.ts | 2 +- .../profile/tenant-profile-data.component.ts | 2 +- .../device-profiles-table-config.resolver.ts | 2 ++ .../entity/entity-autocomplete.component.ts | 22 +++++++++++++++++++ .../components/json-object-edit.component.ts | 10 +++++++-- .../assets/locale/locale.constant-en_US.json | 5 +++-- 8 files changed, 43 insertions(+), 11 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/profile/device-profile-data.component.html b/ui-ngx/src/app/modules/home/components/profile/device-profile-data.component.html index 4666a31612..a0a548e33e 100644 --- a/ui-ngx/src/app/modules/home/components/profile/device-profile-data.component.html +++ b/ui-ngx/src/app/modules/home/components/profile/device-profile-data.component.html @@ -15,7 +15,7 @@ limitations under the License. --> -
+
diff --git a/ui-ngx/src/app/modules/home/components/profile/device-profile.component.html b/ui-ngx/src/app/modules/home/components/profile/device-profile.component.html index 7b8742cecc..4c528b9f30 100644 --- a/ui-ngx/src/app/modules/home/components/profile/device-profile.component.html +++ b/ui-ngx/src/app/modules/home/components/profile/device-profile.component.html @@ -49,6 +49,11 @@ {{ 'device-profile.name-required' | translate }} + + device-profile.type @@ -64,10 +69,6 @@ formControlName="profileData" required> - - tenant-profile.description diff --git a/ui-ngx/src/app/modules/home/components/profile/device-profile.component.ts b/ui-ngx/src/app/modules/home/components/profile/device-profile.component.ts index 0d3f286b3f..918d2cb785 100644 --- a/ui-ngx/src/app/modules/home/components/profile/device-profile.component.ts +++ b/ui-ngx/src/app/modules/home/components/profile/device-profile.component.ts @@ -96,7 +96,7 @@ export class DeviceProfileComponent extends EntityComponent { }; } profileData.configuration = createDeviceProfileConfiguration(deviceProfileType); - this.entityForm.patchValue({profileData}); + form.patchValue({profileData}); } updateForm(entity: DeviceProfile) { diff --git a/ui-ngx/src/app/modules/home/components/profile/tenant-profile-data.component.ts b/ui-ngx/src/app/modules/home/components/profile/tenant-profile-data.component.ts index 04970bd833..377b6f0978 100644 --- a/ui-ngx/src/app/modules/home/components/profile/tenant-profile-data.component.ts +++ b/ui-ngx/src/app/modules/home/components/profile/tenant-profile-data.component.ts @@ -85,7 +85,7 @@ export class TenantProfileDataComponent implements ControlValueAccessor, OnInit private updateModel() { let tenantProfileData: TenantProfileData = null; if (this.tenantProfileDataFormGroup.valid) { - tenantProfileData = this.tenantProfileDataFormGroup.getRawValue().profileData; + tenantProfileData = this.tenantProfileDataFormGroup.getRawValue().tenantProfileData; } this.propagateChange(tenantProfileData); } diff --git a/ui-ngx/src/app/modules/home/pages/device-profile/device-profiles-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/device-profile/device-profiles-table-config.resolver.ts index 3de52418eb..af1811cc57 100644 --- a/ui-ngx/src/app/modules/home/pages/device-profile/device-profiles-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/device-profile/device-profiles-table-config.resolver.ts @@ -48,6 +48,8 @@ export class DeviceProfilesTableConfigResolver implements Resolve('createdTime', 'common.created-time', this.datePipe, '150px'), new EntityTableColumn('name', 'device-profile.name', '20%'), diff --git a/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts b/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts index 86a45c8885..52c0df2a8c 100644 --- a/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts +++ b/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts @@ -89,6 +89,21 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit @Input() disabled: boolean; + labelValue: string; + + @Input() + set label(label: string) { + this.labelValue = label; + this.entityText = label; + } + + requiredTextValue: string; + + @Input() + set requiredText(requiredText: string) { + this.requiredTextValue = requiredText; + } + @ViewChild('entityInput', {static: true}) entityInput: ElementRef; entityText: string; @@ -212,6 +227,13 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit break; } } + if (this.labelValue) { + this.entityText = this.labelValue; + } + if (this.requiredTextValue) { + this.entityRequiredText = this.requiredTextValue; + } + const currentEntity = this.getCurrentEntity(); if (currentEntity) { const currentEntityType = currentEntity.id.entityType; diff --git a/ui-ngx/src/app/shared/components/json-object-edit.component.ts b/ui-ngx/src/app/shared/components/json-object-edit.component.ts index e8ae19519d..503b12c1a8 100644 --- a/ui-ngx/src/app/shared/components/json-object-edit.component.ts +++ b/ui-ngx/src/app/shared/components/json-object-edit.component.ts @@ -91,6 +91,8 @@ export class JsonObjectEditComponent implements OnInit, ControlValueAccessor, Va errorShowed = false; + ignoreChange = false; + private propagateChange = null; constructor(public elementRef: ElementRef, @@ -118,8 +120,10 @@ export class JsonObjectEditComponent implements OnInit, ControlValueAccessor, Va this.jsonEditor.session.setUseWrapMode(false); this.jsonEditor.setValue(this.contentValue ? this.contentValue : '', -1); this.jsonEditor.on('change', () => { - this.cleanupJsonErrors(); - this.updateView(); + if (!this.ignoreChange) { + this.cleanupJsonErrors(); + this.updateView(); + } }); this.editorResize$ = new ResizeObserver(() => { this.onAceEditorResize(); @@ -225,7 +229,9 @@ export class JsonObjectEditComponent implements OnInit, ControlValueAccessor, Va // } if (this.jsonEditor) { + this.ignoreChange = true; this.jsonEditor.setValue(this.contentValue ? this.contentValue : '', -1); + this.ignoreChange = false; } } 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 7f6416ab7a..7f07f26185 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -767,13 +767,14 @@ "copyId": "Copy device profile Id", "name": "Name", "name-required": "Name is required.", - "type": "Type", - "type-required": "Type is required.", + "type": "Profile type", + "type-required": "Profile type is required.", "type-default": "Default", "description": "Description", "default": "Default", "profile-configuration": "Profile configuration", "transport-configuration": "Transport configuration", + "default-rule-chain": "Default rule chain", "delete-device-profile-title": "Are you sure you want to delete the device profile '{{deviceProfileName}}'?", "delete-device-profile-text": "Be careful, after the confirmation the device profile and all related data will become unrecoverable.", "delete-device-profiles-title": "Are you sure you want to delete { count, plural, 1 {1 device profile} other {# device profiles} }?",