From e8683bd85a21af516e89c746033dbd1e57d43684 Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Fri, 6 Nov 2026 10:12:36 +0200 Subject: [PATCH] fix(iot-hub): review of the device package update: new access tokens in the warning, a package's own entity stays its own, the close prompt only once entities may be gone - update-desc-device says again that the new devices get new access tokens - an existing entity the wizard created a moment ago is recorded as created, not use-existing - the close prompt shows only after the removal, a partial removal or a lost answer - query params go through InterceptorHttpParams (also fixes force losing the interceptor config) - one iotHubErrorMessage helper on parseHttpErrorMessage for the iot-hub dialogs - removingReplaced is one signal, stepError a field, no template method calls or extra detectChanges - fewer comments, readonly fields in the update dialog, cdr renamed to cd --- .../src/app/core/http/iot-hub-api.service.ts | 21 ++- .../device-install-dialog.component.html | 31 ++--- .../device-install-dialog.component.ts | 122 +++++++----------- .../iot-hub/iot-hub-actions.service.ts | 6 +- .../iot-hub-add-item-dialog.component.ts | 4 +- .../iot-hub-install-dialog.component.ts | 3 +- .../iot-hub-update-dialog.component.ts | 37 ++---- .../home/components/iot-hub/iot-hub-utils.ts | 8 ++ .../assets/locale/locale.constant-en_US.json | 2 +- 9 files changed, 100 insertions(+), 134 deletions(-) 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 07c1c9a64d..89df8e9d3b 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,20 +182,18 @@ export class IotHubApiService { replaceInstalledItemId?: string, config?: IotHubRequestConfig ): Observable { - // 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}${replace}`, + `/api/iot-hub/device/register`, { type: 'DEVICE', ...descriptor }, - { params: this.buildParams(config) } + { params: this.buildParams(config, { versionId, replaceInstalledItemId }) } ); } public removeDevicePackageEntities(installedItemId: string, versionId: string, config?: IotHubRequestConfig): Observable { return this.http.post( - `/api/iot-hub/installedItems/${installedItemId}/device/removeEntities?versionId=${versionId}`, + `/api/iot-hub/installedItems/${installedItemId}/device/removeEntities`, null, - { params: this.buildParams(config) } + { params: this.buildParams(config, { versionId }) } ); } @@ -223,10 +221,7 @@ export class IotHubApiService { } public updateItemVersion(installedItemId: string, versionId: string, config?: IotHubRequestConfig, force?: boolean): Observable { - let params = this.buildParams(config); - if (force) { - params = params.set('force', 'true'); - } + const params = this.buildParams(config, { force: force ? 'true' : undefined }); return this.http.post( `/api/iot-hub/installedItems/${installedItemId}/update/${versionId}`, null, @@ -294,9 +289,11 @@ export class IotHubApiService { ); } - private buildParams(config?: IotHubRequestConfig): HttpParams { + private buildParams(config?: IotHubRequestConfig, params?: Record): HttpParams { + const defined = Object.fromEntries(Object.entries(params ?? {}).filter(([, value]) => value != null)); return new InterceptorHttpParams( - new InterceptorConfig(config?.ignoreLoading ?? false, config?.ignoreErrors ?? false) + new InterceptorConfig(config?.ignoreLoading ?? false, config?.ignoreErrors ?? false), + defined ); } } 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 45060d91bc..93902b5338 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 @@ -133,24 +133,25 @@ {{ ('iot-hub.device-install-step-type-' + ep.step.type | translate) + ' — ' + (ep.resolvedName || ep.step.name) }} - @if (ep.status === 'success') { - {{ 'iot-hub.done' | translate }} - } - @if (ep.status === 'running') { - {{ 'iot-hub.in-progress' | translate }} + @switch (ep.status) { + @case ('success') { + {{ 'iot-hub.done' | translate }} + } + @case ('running') { + {{ 'iot-hub.in-progress' | translate }} + } } } } - @if (ws.removingReplaced) { + @if (removingReplaced()) {
{{ 'iot-hub.device-update-removing' | translate }}
- } - @if (stepLevelError(ws); as error) { - {{ error }} + } @else if (ws.stepError) { + {{ ws.stepError }} } } @@ -166,7 +167,7 @@ } @else {

{{ 'iot-hub.device-install-title' | translate:{ name: packageInfo?.name || data.item.name } }}

-
@@ -206,7 +207,7 @@ @for (ws of wizardSteps; track ws.label) { - {{ ws.label }} @@ -220,13 +221,13 @@ @if (allProgressDone) { } @else { - + } @if (!isFirstWizardStep) { - + } @if (currentWizardStep; as step) { @@ -261,7 +262,7 @@ } @case ('progress') { - @if (step.progressError) { + @if (step.progressError || step.stepError) { } - } @else if (!step.progressError) { + } @else {