Commit d13116db194981f1db7e446cee9d0b7fd4580d6e
1 parent
c7b57ca5
Update device transport type hints. Update device profile autocomplete - select first profile option
Showing
3 changed files
with
29 additions
and
3 deletions
@@ -65,6 +65,9 @@ export class DeviceProfileAutocompleteComponent implements ControlValueAccessor, | @@ -65,6 +65,9 @@ export class DeviceProfileAutocompleteComponent implements ControlValueAccessor, | ||
65 | selectDefaultProfile = false; | 65 | selectDefaultProfile = false; |
66 | 66 | ||
67 | @Input() | 67 | @Input() |
68 | + selectFirstProfile = false; | ||
69 | + | ||
70 | + @Input() | ||
68 | displayAllOnEmpty = false; | 71 | displayAllOnEmpty = false; |
69 | 72 | ||
70 | @Input() | 73 | @Input() |
@@ -183,12 +186,34 @@ export class DeviceProfileAutocompleteComponent implements ControlValueAccessor, | @@ -183,12 +186,34 @@ export class DeviceProfileAutocompleteComponent implements ControlValueAccessor, | ||
183 | if (this.selectDefaultProfile && !this.modelValue) { | 186 | if (this.selectDefaultProfile && !this.modelValue) { |
184 | this.deviceProfileService.getDefaultDeviceProfileInfo().subscribe( | 187 | this.deviceProfileService.getDefaultDeviceProfileInfo().subscribe( |
185 | (profile) => { | 188 | (profile) => { |
186 | - if (profile && !this.transportType || (profile.transportType === this.transportType)) { | 189 | + if (profile && (!this.transportType || (profile.transportType === this.transportType))) { |
187 | this.selectDeviceProfileFormGroup.get('deviceProfile').patchValue(profile, {emitEvent: false}); | 190 | this.selectDeviceProfileFormGroup.get('deviceProfile').patchValue(profile, {emitEvent: false}); |
188 | this.updateView(profile); | 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,6 +79,7 @@ | ||
79 | (deviceProfileChanged)="$event?.transportType ? deviceWizardFormGroup.get('transportType').patchValue($event?.transportType) : {}" | 79 | (deviceProfileChanged)="$event?.transportType ? deviceWizardFormGroup.get('transportType').patchValue($event?.transportType) : {}" |
80 | [addNewProfile]="false" | 80 | [addNewProfile]="false" |
81 | [selectDefaultProfile]="true" | 81 | [selectDefaultProfile]="true" |
82 | + [selectFirstProfile]="true" | ||
82 | [editProfileEnabled]="false"> | 83 | [editProfileEnabled]="false"> |
83 | </tb-device-profile-autocomplete> | 84 | </tb-device-profile-autocomplete> |
84 | <mat-form-field fxFlex class="mat-block"> | 85 | <mat-form-field fxFlex class="mat-block"> |
@@ -794,9 +794,9 @@ | @@ -794,9 +794,9 @@ | ||
794 | "transport-type": "Transport type", | 794 | "transport-type": "Transport type", |
795 | "transport-type-required": "Transport type is required.", | 795 | "transport-type-required": "Transport type is required.", |
796 | "transport-type-default": "Default", | 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 | "transport-type-mqtt": "MQTT", | 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 | "transport-type-lwm2m": "LWM2M", | 800 | "transport-type-lwm2m": "LWM2M", |
801 | "transport-type-lwm2m-hint": "LWM2M transport type", | 801 | "transport-type-lwm2m-hint": "LWM2M transport type", |
802 | "description": "Description", | 802 | "description": "Description", |