From aa18fd92149fb5ce9346e63f5777fa564b35580f Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Thu, 5 Nov 2026 12:56:29 +0200 Subject: [PATCH] fix(iot-hub): lead the update of a device package to the upgrade on lts-4.3 This version can only reinstall a device package. Update opens the same kind of window as an item that needs ThingsBoard 4.4 (#16231): it says so, leads to the Community Grant Program, and keeps "Update anyway" to reinstall through the install wizard. --- .../iot-hub/iot-hub-actions.service.ts | 20 ++++++-- .../iot-hub/iot-hub-components.module.ts | 3 ++ ...ot-hub-device-update-dialog.component.html | 29 ++++++++++++ .../iot-hub-device-update-dialog.component.ts | 47 +++++++++++++++++++ .../iot-hub-update-dialog.component.html | 8 ++-- .../iot-hub-update-dialog.component.ts | 21 ++------- 6 files changed, 102 insertions(+), 26 deletions(-) create mode 100644 ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-device-update-dialog.component.html create mode 100644 ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-device-update-dialog.component.ts diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-actions.service.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-actions.service.ts index 5ec83949bd..9027e71323 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-actions.service.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-actions.service.ts @@ -14,6 +14,10 @@ import { TbIotHubAddItemDialogComponent, IotHubAddItemDialogData, IotHubAddItemD import { TbIotHubItemDetailDialogComponent, IotHubItemDetailDialogData, IotHubItemDetailDialogMode } from './iot-hub-item-detail-dialog.component'; import { TbIotHubInstallDialogComponent, IotHubInstallDialogData } from './iot-hub-install-dialog.component'; import { TbIotHubUpdateDialogComponent, IotHubUpdateDialogData } from './iot-hub-update-dialog.component'; +import { + IotHubDeviceUpdateDialogData, + TbIotHubDeviceUpdateDialogComponent +} from './iot-hub-device-update-dialog.component'; import { TbIotHubDeleteDialogComponent, IotHubDeleteDialogData } from './iot-hub-delete-dialog.component'; import { TbDeviceInstallDialogComponent, DeviceInstallDialogData } from './device-install-dialog/device-install-dialog.component'; import { TbIotHubInstalledItemsDialogComponent, IotHubInstalledItemsDialogData } from './iot-hub-installed-items-dialog.component'; @@ -154,6 +158,18 @@ export class IotHubActionsService { if (!installedItem) { return of(false); } + if (installedItem.itemType === ItemType.DEVICE) { + // This version can only reinstall a device package: the dialog leads to the upgrade first. + return this.dialog.open( + TbIotHubDeviceUpdateDialogComponent, { + panelClass: ['tb-dialog'], + disableClose: true, + autoFocus: false, + data: { itemName: installedItem.itemName } + }).afterClosed().pipe( + switchMap(result => result === 'reinstall' ? this.reinstallDevice(installedItem, versionId) : of(result)) + ); + } return this.dialog.open(TbIotHubUpdateDialogComponent, { panelClass: ['tb-dialog'], disableClose: true, @@ -165,9 +181,7 @@ export class IotHubActionsService { version, versionId } - }).afterClosed().pipe( - switchMap(result => result === 'reinstall' ? this.reinstallDevice(installedItem, versionId) : of(result)) - ); + }).afterClosed(); } /** diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-components.module.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-components.module.ts index f6591ac8f8..d81a34e407 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-components.module.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-components.module.ts @@ -20,6 +20,7 @@ import { TbIotHubInstalledItemsDialogComponent } from './iot-hub-installed-items import { TbIotHubSelectCfEntityDialogComponent } from './iot-hub-select-cf-entity-dialog.component'; import { TbPeConnectivityMethodPromptComponent } from './pe-connectivity-method-prompt.component'; import { TbIotHubPeRequiredDialogComponent } from './iot-hub-pe-required-dialog.component'; +import { TbIotHubDeviceUpdateDialogComponent } from './iot-hub-device-update-dialog.component'; import { TbIotHubUpgradeRequiredDialogComponent } from './iot-hub-upgrade-required-dialog.component'; import { TbIotHubMarkdownComponent } from './iot-hub-markdown.component'; import { SolutionInstallDialogComponent } from './solution-install-dialog.component'; @@ -47,6 +48,7 @@ import { IotHubItemLinkModule } from './iot-hub-item-link-card/iot-hub-item-link SolutionInstallDialogComponent, InstallFormRendererComponent, TbIotHubPeRequiredDialogComponent, + TbIotHubDeviceUpdateDialogComponent, TbIotHubUpgradeRequiredDialogComponent ], imports: [ @@ -76,6 +78,7 @@ import { IotHubItemLinkModule } from './iot-hub-item-link-card/iot-hub-item-link TbIotHubMarkdownComponent, SolutionInstallDialogComponent, TbIotHubPeRequiredDialogComponent, + TbIotHubDeviceUpdateDialogComponent, TbIotHubUpgradeRequiredDialogComponent ] }) diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-device-update-dialog.component.html b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-device-update-dialog.component.html new file mode 100644 index 0000000000..4f7ca41696 --- /dev/null +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-device-update-dialog.component.html @@ -0,0 +1,29 @@ + +
+ + + + +

+ {{ 'iot-hub.update-confirm-title' | translate:{ name: data.itemName } }} +

+ +

+ +
+ + +
+
diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-device-update-dialog.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-device-update-dialog.component.ts new file mode 100644 index 0000000000..fb0cc99f03 --- /dev/null +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-device-update-dialog.component.ts @@ -0,0 +1,47 @@ +// SPDX-FileCopyrightText: Copyright The Thingsboard Authors +// SPDX-License-Identifier: Apache-2.0 +import { Component, Inject } from '@angular/core'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { Router } from '@angular/router'; +import { Store } from '@ngrx/store'; +import { AppState } from '@core/core.state'; +import { DialogComponent } from '@shared/components/dialog.component'; + +export interface IotHubDeviceUpdateDialogData { + itemName: string; +} + +/** + * Update of a device package. This version can only reinstall it, so the dialog leads to the upgrade that updates device + * packages without reinstalling, as the dialog of an item that needs a newer version does, and keeps the reinstall as + * the other way. Closes with 'reinstall' when the user chooses it. + */ +@Component({ + selector: 'tb-iot-hub-device-update-dialog', + standalone: false, + templateUrl: './iot-hub-device-update-dialog.component.html', + styleUrls: ['./iot-hub-pe-required-dialog.component.scss'] +}) +export class TbIotHubDeviceUpdateDialogComponent extends DialogComponent { + + constructor( + protected store: Store, + protected router: Router, + protected dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: IotHubDeviceUpdateDialogData + ) { + super(store, router, dialogRef); + } + + close(): void { + this.dialogRef.close(false); + } + + reinstall(): void { + this.dialogRef.close('reinstall'); + } + + viewUpgradeOptions(): void { + window.open('https://thingsboard.io/community-grant-program/', '_blank'); + } +} diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-update-dialog.component.html b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-update-dialog.component.html index f6fd5b7a04..a1fffb0a9d 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-update-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-update-dialog.component.html @@ -8,11 +8,11 @@ @switch (state) { @case ('confirm') {

{{ 'iot-hub.update-confirm-title' | translate:{ name: data.itemName } }}

-

+

{{ updateDescKey | translate }}

} @case ('updating') {

{{ 'iot-hub.update-confirm-title' | translate:{ name: data.itemName } }}

-

+

{{ updateDescKey | translate }}

} @case ('success') {

{{ 'iot-hub.update-success-title' | translate }}

@@ -35,9 +35,7 @@ @switch (state) { @case ('confirm') { - + } @case ('updating') { diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-update-dialog.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-update-dialog.component.ts index d2b1132938..e5472c45a1 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-update-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-update-dialog.component.ts @@ -59,33 +59,18 @@ export class TbIotHubUpdateDialogComponent extends DialogComponent {