Commit d13116db194981f1db7e446cee9d0b7fd4580d6e

Authored by Igor Kulikov
1 parent c7b57ca5

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

... ... @@ -65,6 +65,9 @@ export class DeviceProfileAutocompleteComponent implements ControlValueAccessor,
65 65 selectDefaultProfile = false;
66 66
67 67 @Input()
  68 + selectFirstProfile = false;
  69 +
  70 + @Input()
68 71 displayAllOnEmpty = false;
69 72
70 73 @Input()
... ... @@ -183,12 +186,34 @@ export class DeviceProfileAutocompleteComponent implements ControlValueAccessor,
183 186 if (this.selectDefaultProfile && !this.modelValue) {
184 187 this.deviceProfileService.getDefaultDeviceProfileInfo().subscribe(
185 188 (profile) => {
186   - if (profile && !this.transportType || (profile.transportType === this.transportType)) {
  189 + if (profile && (!this.transportType || (profile.transportType === this.transportType))) {
187 190 this.selectDeviceProfileFormGroup.get('deviceProfile').patchValue(profile, {emitEvent: false});
188 191 this.updateView(profile);
  192 + } else {
  193 + this.selectFirstDeviceProfileIfNeeded();
189 194 }
190 195 }
191 196 );
  197 + } else {
  198 + this.selectFirstDeviceProfileIfNeeded();
  199 + }
  200 + }
  201 +
  202 + selectFirstDeviceProfileIfNeeded(): void {
  203 + if (this.selectFirstProfile && !this.modelValue) {
  204 + const pageLink = new PageLink(1, 0, null, {
  205 + property: 'createdTime',
  206 + direction: Direction.DESC
  207 + });
  208 + this.deviceProfileService.getDeviceProfileInfos(pageLink, this.transportType, {ignoreLoading: true}).subscribe(
  209 + (pageData => {
  210 + const data = pageData.data;
  211 + if (data.length) {
  212 + this.selectDeviceProfileFormGroup.get('deviceProfile').patchValue(data[0], {emitEvent: false});
  213 + this.updateView(data[0]);
  214 + }
  215 + })
  216 + );
192 217 }
193 218 }
194 219
... ...
... ... @@ -79,6 +79,7 @@
79 79 (deviceProfileChanged)="$event?.transportType ? deviceWizardFormGroup.get('transportType').patchValue($event?.transportType) : {}"
80 80 [addNewProfile]="false"
81 81 [selectDefaultProfile]="true"
  82 + [selectFirstProfile]="true"
82 83 [editProfileEnabled]="false">
83 84 </tb-device-profile-autocomplete>
84 85 <mat-form-field fxFlex class="mat-block">
... ...
... ... @@ -794,9 +794,9 @@
794 794 "transport-type": "Transport type",
795 795 "transport-type-required": "Transport type is required.",
796 796 "transport-type-default": "Default",
797   - "transport-type-default-hint": "Default transport type",
  797 + "transport-type-default-hint": "Refers to already existing transport configuration or basic MQTT, HTTP, CoAP settings",
798 798 "transport-type-mqtt": "MQTT",
799   - "transport-type-mqtt-hint": "MQTT transport type",
  799 + "transport-type-mqtt-hint": "Advanced MQTT topic filters and Device profile settings",
800 800 "transport-type-lwm2m": "LWM2M",
801 801 "transport-type-lwm2m-hint": "LWM2M transport type",
802 802 "description": "Description",
... ...