Browse Source

UI: Tenant/Device profile data

pull/3477/head
Igor Kulikov 6 years ago
parent
commit
6f030fa8da
  1. 2
      ui-ngx/src/app/modules/home/components/profile/device-profile-data.component.html
  2. 9
      ui-ngx/src/app/modules/home/components/profile/device-profile.component.html
  3. 2
      ui-ngx/src/app/modules/home/components/profile/device-profile.component.ts
  4. 2
      ui-ngx/src/app/modules/home/components/profile/tenant-profile-data.component.ts
  5. 2
      ui-ngx/src/app/modules/home/pages/device-profile/device-profiles-table-config.resolver.ts
  6. 22
      ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts
  7. 10
      ui-ngx/src/app/shared/components/json-object-edit.component.ts
  8. 5
      ui-ngx/src/assets/locale/locale.constant-en_US.json

2
ui-ngx/src/app/modules/home/components/profile/device-profile-data.component.html

@ -15,7 +15,7 @@
limitations under the License.
-->
<div [formGroup]="deviceProfileDataFormGroup">
<div [formGroup]="deviceProfileDataFormGroup" style="padding-bottom: 16px;">
<mat-accordion multi="true">
<mat-expansion-panel [expanded]="true">
<mat-expansion-panel-header>

9
ui-ngx/src/app/modules/home/components/profile/device-profile.component.html

@ -49,6 +49,11 @@
{{ 'device-profile.name-required' | translate }}
</mat-error>
</mat-form-field>
<tb-entity-autocomplete
label="device-profile.default-rule-chain"
[entityType]="entityType.RULE_CHAIN"
formControlName="defaultRuleChainId">
</tb-entity-autocomplete>
<mat-form-field class="mat-block">
<mat-label translate>device-profile.type</mat-label>
<mat-select formControlName="type" required>
@ -64,10 +69,6 @@
formControlName="profileData"
required>
</tb-device-profile-data>
<tb-entity-autocomplete
[entityType]="entityType.RULE_CHAIN"
formControlName="defaultRuleChainId">
</tb-entity-autocomplete>
<mat-form-field class="mat-block">
<mat-label translate>tenant-profile.description</mat-label>
<textarea matInput formControlName="description" rows="2"></textarea>

2
ui-ngx/src/app/modules/home/components/profile/device-profile.component.ts

@ -96,7 +96,7 @@ export class DeviceProfileComponent extends EntityComponent<DeviceProfile> {
};
}
profileData.configuration = createDeviceProfileConfiguration(deviceProfileType);
this.entityForm.patchValue({profileData});
form.patchValue({profileData});
}
updateForm(entity: DeviceProfile) {

2
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);
}

2
ui-ngx/src/app/modules/home/pages/device-profile/device-profiles-table-config.resolver.ts

@ -48,6 +48,8 @@ export class DeviceProfilesTableConfigResolver implements Resolve<EntityTableCon
this.config.entityTranslations = entityTypeTranslations.get(EntityType.DEVICE_PROFILE);
this.config.entityResources = entityTypeResources.get(EntityType.DEVICE_PROFILE);
this.config.addDialogStyle = {width: '600px'};
this.config.columns.push(
new DateEntityTableColumn<DeviceProfile>('createdTime', 'common.created-time', this.datePipe, '150px'),
new EntityTableColumn<DeviceProfile>('name', 'device-profile.name', '20%'),

22
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;

10
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;
}
}

5
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} }?",

Loading…
Cancel
Save