Browse Source

Update device transport type hints. Update device profile autocomplete - select first profile option

pull/3570/head
Igor Kulikov 6 years ago
parent
commit
d13116db19
  1. 27
      ui-ngx/src/app/modules/home/components/profile/device-profile-autocomplete.component.ts
  2. 1
      ui-ngx/src/app/modules/home/components/wizard/device-wizard-dialog.component.html
  3. 4
      ui-ngx/src/assets/locale/locale.constant-en_US.json

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

@ -64,6 +64,9 @@ export class DeviceProfileAutocompleteComponent implements ControlValueAccessor,
@Input()
selectDefaultProfile = false;
@Input()
selectFirstProfile = false;
@Input()
displayAllOnEmpty = false;
@ -183,12 +186,34 @@ export class DeviceProfileAutocompleteComponent implements ControlValueAccessor,
if (this.selectDefaultProfile && !this.modelValue) {
this.deviceProfileService.getDefaultDeviceProfileInfo().subscribe(
(profile) => {
if (profile && !this.transportType || (profile.transportType === this.transportType)) {
if (profile && (!this.transportType || (profile.transportType === this.transportType))) {
this.selectDeviceProfileFormGroup.get('deviceProfile').patchValue(profile, {emitEvent: false});
this.updateView(profile);
} else {
this.selectFirstDeviceProfileIfNeeded();
}
}
);
} else {
this.selectFirstDeviceProfileIfNeeded();
}
}
selectFirstDeviceProfileIfNeeded(): void {
if (this.selectFirstProfile && !this.modelValue) {
const pageLink = new PageLink(1, 0, null, {
property: 'createdTime',
direction: Direction.DESC
});
this.deviceProfileService.getDeviceProfileInfos(pageLink, this.transportType, {ignoreLoading: true}).subscribe(
(pageData => {
const data = pageData.data;
if (data.length) {
this.selectDeviceProfileFormGroup.get('deviceProfile').patchValue(data[0], {emitEvent: false});
this.updateView(data[0]);
}
})
);
}
}

1
ui-ngx/src/app/modules/home/components/wizard/device-wizard-dialog.component.html

@ -79,6 +79,7 @@
(deviceProfileChanged)="$event?.transportType ? deviceWizardFormGroup.get('transportType').patchValue($event?.transportType) : {}"
[addNewProfile]="false"
[selectDefaultProfile]="true"
[selectFirstProfile]="true"
[editProfileEnabled]="false">
</tb-device-profile-autocomplete>
<mat-form-field fxFlex class="mat-block">

4
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -794,9 +794,9 @@
"transport-type": "Transport type",
"transport-type-required": "Transport type is required.",
"transport-type-default": "Default",
"transport-type-default-hint": "Default transport type",
"transport-type-default-hint": "Refers to already existing transport configuration or basic MQTT, HTTP, CoAP settings",
"transport-type-mqtt": "MQTT",
"transport-type-mqtt-hint": "MQTT transport type",
"transport-type-mqtt-hint": "Advanced MQTT topic filters and Device profile settings",
"transport-type-lwm2m": "LWM2M",
"transport-type-lwm2m-hint": "LWM2M transport type",
"description": "Description",

Loading…
Cancel
Save