diff --git a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-browse.component.ts b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-browse.component.ts index 083b858c70..4bb0ae9afe 100644 --- a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-browse.component.ts +++ b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-browse.component.ts @@ -34,6 +34,7 @@ import { ActivatedRoute, Router } from '@angular/router'; import { TbIotHubItemDetailDialogComponent, IotHubItemDetailDialogData } 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 { TbDeviceInstallDialogComponent, DeviceInstallDialogData } from './device-install-dialog/device-install-dialog.component'; interface SortOption { value: string; @@ -363,6 +364,10 @@ export class TbIotHubBrowseComponent implements OnInit, OnDestroy { } installItem(item: MpItemVersionView): void { + if (item.type === ItemType.DEVICE) { + this.installDevice(item); + return; + } const dialogRef = this.dialog.open(TbIotHubInstallDialogComponent, { panelClass: ['tb-dialog'], data: { @@ -377,6 +382,25 @@ export class TbIotHubBrowseComponent implements OnInit, OnDestroy { }); } + private installDevice(item: MpItemVersionView): void { + this.iotHubApiService.getVersionFileData(item.id as string, { ignoreLoading: true }).subscribe({ + next: async (blob: Blob) => { + const zipData = await blob.arrayBuffer(); + const dialogRef = this.dialog.open(TbDeviceInstallDialogComponent, { + panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], + disableClose: true, + autoFocus: false, + data: { item, zipData, iotHubApiService: this.iotHubApiService } as DeviceInstallDialogData + }); + dialogRef.afterClosed().subscribe(result => { + if (result === 'installed') { + this.loadItems(); + } + }); + } + }); + } + updateItem(item: MpItemVersionView): void { const installedItem = this.getInstalledItem(item); if (!installedItem) { diff --git a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.ts b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.ts index 7f8e5a77a7..f4fefef695 100644 --- a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.ts +++ b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.ts @@ -27,6 +27,7 @@ import { IotHubApiService } from '@core/http/iot-hub-api.service'; import { TbIotHubItemDetailDialogComponent, IotHubItemDetailDialogData } from './iot-hub-item-detail-dialog.component'; import { TbIotHubInstallDialogComponent, IotHubInstallDialogData } from './iot-hub-install-dialog.component'; import { TbIotHubDeleteDialogComponent, IotHubDeleteDialogData } from './iot-hub-delete-dialog.component'; +import { TbDeviceInstallDialogComponent, DeviceInstallDialogData } from './device-install-dialog/device-install-dialog.component'; interface CategoryCard { type: ItemType; @@ -210,6 +211,10 @@ export class TbIotHubHomeComponent implements OnInit, OnDestroy { } installItem(item: MpItemVersionView): void { + if (item.type === ItemType.DEVICE) { + this.installDevice(item); + return; + } const dialogRef = this.dialog.open(TbIotHubInstallDialogComponent, { panelClass: ['tb-dialog'], autoFocus: false, @@ -225,6 +230,25 @@ export class TbIotHubHomeComponent implements OnInit, OnDestroy { }); } + private installDevice(item: MpItemVersionView): void { + this.iotHubApiService.getVersionFileData(item.id as string, { ignoreLoading: true }).subscribe({ + next: async (blob: Blob) => { + const zipData = await blob.arrayBuffer(); + const dialogRef = this.dialog.open(TbDeviceInstallDialogComponent, { + panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], + disableClose: true, + autoFocus: false, + data: { item, zipData, iotHubApiService: this.iotHubApiService } as DeviceInstallDialogData + }); + dialogRef.afterClosed().subscribe(result => { + if (result === 'installed') { + this.reloadInstalledItems(item.type); + } + }); + } + }); + } + navigateToCreator(creatorId: string): void { this.router.navigate(['/iot-hub/creator', creatorId]); } diff --git a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-item-detail-dialog.component.ts b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-item-detail-dialog.component.ts index baef37c91a..5cfe0b3992 100644 --- a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-item-detail-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-item-detail-dialog.component.ts @@ -27,6 +27,7 @@ import { getEntityDetailsPageURL } from '@core/utils'; import { TbIotHubInstallDialogComponent, IotHubInstallDialogData } from './iot-hub-install-dialog.component'; import { TbIotHubUpdateDialogComponent, IotHubUpdateDialogData } from './iot-hub-update-dialog.component'; import { TbIotHubDeleteDialogComponent, IotHubDeleteDialogData } from './iot-hub-delete-dialog.component'; +import { TbDeviceInstallDialogComponent, DeviceInstallDialogData } from './device-install-dialog/device-install-dialog.component'; import { SolutionInstallDialogComponent } from '@home/components/solution/solution-install-dialog.component'; import { SolutionTemplateInstalledItemDescriptor } from '@shared/models/iot-hub/iot-hub-installed-item.models'; @@ -239,6 +240,10 @@ export class TbIotHubItemDetailDialogComponent { } install(): void { + if (this.item.type === ItemType.DEVICE) { + this.installDevice(); + return; + } const dialogRef = this.dialog.open(TbIotHubInstallDialogComponent, { panelClass: ['tb-dialog'], data: { @@ -253,6 +258,30 @@ export class TbIotHubItemDetailDialogComponent { }); } + private installDevice(): void { + const versionId = this.item.id as string; + this.data.iotHubApiService.getVersionFileData(versionId, { ignoreLoading: true }).subscribe({ + next: async (blob: Blob) => { + const zipData = await blob.arrayBuffer(); + const dialogRef = this.dialog.open(TbDeviceInstallDialogComponent, { + panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], + disableClose: true, + autoFocus: false, + data: { + item: this.item, + zipData, + iotHubApiService: this.data.iotHubApiService + } as DeviceInstallDialogData + }); + dialogRef.afterClosed().subscribe(result => { + if (result === 'installed') { + this.dialogRef.close('installed'); + } + }); + } + }); + } + updateItem(): void { const dialogRef = this.dialog.open(TbIotHubUpdateDialogComponent, { panelClass: ['tb-dialog'],