diff --git a/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultIotHubService.java b/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultIotHubService.java index c4389517d0..ece9c0cad9 100644 --- a/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultIotHubService.java +++ b/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultIotHubService.java @@ -631,7 +631,11 @@ public class DefaultIotHubService implements IotHubService { if (versionInfo == null) { throw new IllegalArgumentException("Failed to get version info from IoT Hub"); } - checkSameItem(installedItem, UUID.fromString(versionInfo.get(FIELD_ITEM_ID).asText())); + String itemId = optText(versionInfo, FIELD_ITEM_ID); + if (itemId == null) { + throw new IllegalArgumentException("IoT Hub returned the version without its item"); + } + checkSameItem(installedItem, UUID.fromString(itemId)); DeviceInstalledItemDescriptor descriptor = (DeviceInstalledItemDescriptor) installedItem.getDescriptor(); deleteDevicePackageEntities(tenantId, descriptor.getCreatedEntityIds(), user); descriptor.setCreatedEntityIds(null); diff --git a/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java b/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java index b07b3c8195..0d6a8d49b8 100644 --- a/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java @@ -449,7 +449,7 @@ class DefaultIotHubServiceTest { assertThat(result.isSuccess()).isFalse(); assertThat(result.getErrorMessage()).contains("install wizard"); - verify(tbDeviceService, never()).delete(any(), any()); + verify(tbDeviceService, never()).delete(any(Device.class), any()); verify(iotHubInstalledItemService, never()).deleteById(any(), any()); verify(iotHubInstalledItemService, never()).save(any(), any()); } @@ -652,7 +652,7 @@ class DefaultIotHubServiceTest { service.removeDevicePackageEntities(user, item.getId(), newVersionId); - verify(tbDeviceService, never()).delete(any(), any()); + verify(tbDeviceService, never()).delete(any(Device.class), any()); } @Test @@ -672,7 +672,7 @@ class DefaultIotHubServiceTest { // The registration of that version would be refused: nothing may be removed for it. assertThatThrownBy(() -> service.removeDevicePackageEntities(user, item.getId(), otherVersionId)) .isInstanceOf(IllegalArgumentException.class); - verify(tbDeviceService, never()).delete(any(), any()); + verify(tbDeviceService, never()).delete(any(Device.class), any()); verify(iotHubInstalledItemService, never()).save(any(), any()); } } diff --git a/ui-ngx/src/app/core/http/iot-hub-api.service.ts b/ui-ngx/src/app/core/http/iot-hub-api.service.ts index ba19c0f6e6..07c1c9a64d 100644 --- a/ui-ngx/src/app/core/http/iot-hub-api.service.ts +++ b/ui-ngx/src/app/core/http/iot-hub-api.service.ts @@ -182,14 +182,12 @@ export class IotHubApiService { replaceInstalledItemId?: string, config?: IotHubRequestConfig ): Observable { - let params = this.buildParams(config); - if (replaceInstalledItemId) { - params = params.set('replaceInstalledItemId', replaceInstalledItemId); - } + // In the URL: HttpParams.set() would drop the interceptor config (ignoreLoading, ignoreErrors) of buildParams. + const replace = replaceInstalledItemId ? `&replaceInstalledItemId=${replaceInstalledItemId}` : ''; return this.http.post( - `/api/iot-hub/device/register?versionId=${versionId}`, + `/api/iot-hub/device/register?versionId=${versionId}${replace}`, { type: 'DEVICE', ...descriptor }, - { params } + { params: this.buildParams(config) } ); } diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.html b/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.html index 6db53d1cfb..45060d91bc 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.html @@ -206,7 +206,7 @@ @for (ws of wizardSteps; track ws.label) { - {{ ws.label }} diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts index c9aa546f23..51903723b1 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts @@ -878,11 +878,6 @@ export class TbDeviceInstallDialogComponent extends DialogComponent known.id === id.id)) { - this.packageEntityIds.push(id); - } - } const createdEntityIds = [...this.packageEntityIds]; const dashboardId = this.findCreatedDashboardId(); const result = await firstValueFrom( @@ -1215,23 +1210,6 @@ export class TbDeviceInstallDialogComponent extends DialogComponent