diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.ts index 9520029fd3..d4a22603a4 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.ts @@ -354,7 +354,6 @@ export class DashboardWidgetSelectComponent implements OnInit { autoFocus: false, data: { item, - iotHubApiService: this.iotHubApiService, mode: 'add' } as IotHubItemDetailDialogData }); diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.ts index b30ad84564..d743a74cd1 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.ts @@ -437,7 +437,6 @@ export class TbIotHubBrowseComponent implements OnInit, OnDestroy { autoFocus: false, data: { item, - iotHubApiService: this.iotHubApiService, installedItem: this.getInstalledItem(item), mode: this.mode } as IotHubItemDetailDialogData @@ -465,7 +464,6 @@ export class TbIotHubBrowseComponent implements OnInit, OnDestroy { autoFocus: false, data: { item, - iotHubApiService: this.iotHubApiService } as IotHubInstallDialogData }); dialogRef.afterClosed().subscribe(result => { @@ -483,7 +481,7 @@ export class TbIotHubBrowseComponent implements OnInit, OnDestroy { panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], disableClose: true, autoFocus: false, - data: { item, zipData, iotHubApiService: this.iotHubApiService } as DeviceInstallDialogData + data: { item, zipData } as DeviceInstallDialogData }); dialogRef.afterClosed().subscribe(result => { if (result === 'installed') { @@ -508,7 +506,6 @@ export class TbIotHubBrowseComponent implements OnInit, OnDestroy { itemType: item.type, version: item.version, versionId: item.id, - iotHubApiService: this.iotHubApiService } as IotHubUpdateDialogData }); dialogRef.afterClosed().subscribe(result => { diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-item-detail-dialog.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-item-detail-dialog.component.ts index 732bd80754..0f9d899880 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-item-detail-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-item-detail-dialog.component.ts @@ -35,7 +35,6 @@ export type IotHubItemDetailDialogMode = 'default' | 'add'; export interface IotHubItemDetailDialogData { item: MpItemVersionView; - iotHubApiService: IotHubApiService; installedItem?: IotHubInstalledItem; mode?: IotHubItemDetailDialogMode; } @@ -65,7 +64,8 @@ export class TbIotHubItemDetailDialogComponent { private dialogRef: MatDialogRef, private dialog: MatDialog, private router: Router, - private translate: TranslateService + private translate: TranslateService, + private iotHubApiService: IotHubApiService ) { this.item = data.item; this.mode = data.mode || 'default'; @@ -86,7 +86,7 @@ export class TbIotHubItemDetailDialogComponent { } getPreviewUrl(): string | null { - return this.item.image ? this.data.iotHubApiService.resolveResourceUrl(this.item.image) : null; + return this.item.image ? this.iotHubApiService.resolveResourceUrl(this.item.image) : null; } getTypeChipClass(): string { @@ -253,7 +253,6 @@ export class TbIotHubItemDetailDialogComponent { panelClass: ['tb-dialog'], data: { item: this.item, - iotHubApiService: this.data.iotHubApiService } as IotHubInstallDialogData }); dialogRef.afterClosed().subscribe(result => { @@ -265,7 +264,7 @@ export class TbIotHubItemDetailDialogComponent { private installDevice(): void { const versionId = this.item.id as string; - this.data.iotHubApiService.getVersionFileData(versionId, { ignoreLoading: true }).subscribe({ + this.iotHubApiService.getVersionFileData(versionId, { ignoreLoading: true }).subscribe({ next: async (blob: Blob) => { const zipData = await blob.arrayBuffer(); const dialogRef = this.dialog.open(TbDeviceInstallDialogComponent, { @@ -275,7 +274,6 @@ export class TbIotHubItemDetailDialogComponent { data: { item: this.item, zipData, - iotHubApiService: this.data.iotHubApiService } as DeviceInstallDialogData }); dialogRef.afterClosed().subscribe(result => { @@ -296,7 +294,6 @@ export class TbIotHubItemDetailDialogComponent { itemType: this.item.type, version: this.item.version, versionId: this.item.id, - iotHubApiService: this.data.iotHubApiService } as IotHubUpdateDialogData }); dialogRef.afterClosed().subscribe(result => { @@ -366,7 +363,7 @@ export class TbIotHubItemDetailDialogComponent { }); deleteDialogRef.afterClosed().subscribe(confirmed => { if (confirmed) { - this.data.iotHubApiService.deleteInstalledItem(this.installedItem.id.id).subscribe(() => { + this.iotHubApiService.deleteInstalledItem(this.installedItem.id.id).subscribe(() => { this.dialogRef.close('deleted'); }); } @@ -390,19 +387,19 @@ export class TbIotHubItemDetailDialogComponent { ? screenshotResources : this.item.resources.filter(r => r.type === 'ICON'); this.carouselImages = allResources.map(r => - this.data.iotHubApiService.resolveResourceUrl(`/api/resources/${r.id}`) + this.iotHubApiService.resolveResourceUrl(`/api/resources/${r.id}`) ); } private loadReadme(): void { const versionId = this.item.id as string; - this.data.iotHubApiService.getVersionReadme(versionId, { ignoreLoading: true }).subscribe( + this.iotHubApiService.getVersionReadme(versionId, { ignoreLoading: true }).subscribe( content => this.readmeContent = this.prefixResourceUrls(content || '') ); } private prefixResourceUrls(markdown: string): string { - const baseUrl = this.data.iotHubApiService.baseUrl; + const baseUrl = this.iotHubApiService.baseUrl; return markdown.replace(/(\(|")(\/api\/resources\/[^)"]*)/g, `$1${baseUrl}$2`); } } diff --git a/ui-ngx/src/app/modules/home/pages/iot-hub/device-install-dialog/device-install-dialog.component.ts b/ui-ngx/src/app/modules/home/pages/iot-hub/device-install-dialog/device-install-dialog.component.ts index 7223e3fa6d..969729405b 100644 --- a/ui-ngx/src/app/modules/home/pages/iot-hub/device-install-dialog/device-install-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/pages/iot-hub/device-install-dialog/device-install-dialog.component.ts @@ -42,7 +42,6 @@ import { export interface DeviceInstallDialogData { item: MpItemVersionView; zipData: ArrayBuffer; - iotHubApiService: IotHubApiService; } export type WizardStepType = 'instruction' | 'form' | 'progress'; @@ -102,7 +101,8 @@ export class TbDeviceInstallDialogComponent implements OnInit { private deviceProfileService: DeviceProfileService, private deviceService: DeviceService, private dashboardService: DashboardService, - private ruleChainService: RuleChainService + private ruleChainService: RuleChainService, + private iotHubApiService: IotHubApiService ) {} async ngOnInit(): Promise { @@ -404,7 +404,7 @@ export class TbDeviceInstallDialogComponent implements OnInit { const createdEntityIds = this.collectCreatedEntityIds(); const dashboardId = this.findCreatedDashboardId(); await firstValueFrom( - this.data.iotHubApiService.registerDeviceInstall( + this.iotHubApiService.registerDeviceInstall( this.data.item.id as string, { createdEntityIds, dashboardId }, { ignoreLoading: true } 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 cc3fefd369..a4fbe448a8 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 @@ -319,7 +319,6 @@ export class TbIotHubHomeComponent implements OnInit, OnDestroy { autoFocus: false, data: { item, - iotHubApiService: this.iotHubApiService, installedItem } as IotHubItemDetailDialogData }); @@ -368,7 +367,6 @@ export class TbIotHubHomeComponent implements OnInit, OnDestroy { autoFocus: false, data: { item, - iotHubApiService: this.iotHubApiService } as IotHubInstallDialogData }); dialogRef.afterClosed().subscribe(result => { @@ -386,7 +384,7 @@ export class TbIotHubHomeComponent implements OnInit, OnDestroy { panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], disableClose: true, autoFocus: false, - data: { item, zipData, iotHubApiService: this.iotHubApiService } as DeviceInstallDialogData + data: { item, zipData } as DeviceInstallDialogData }); dialogRef.afterClosed().subscribe(result => { if (result === 'installed') { @@ -411,7 +409,6 @@ export class TbIotHubHomeComponent implements OnInit, OnDestroy { itemType: item.type, version: item.version, versionId: item.id, - iotHubApiService: this.iotHubApiService } as IotHubUpdateDialogData }); dialogRef.afterClosed().subscribe(result => { diff --git a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-install-dialog.component.ts b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-install-dialog.component.ts index 3b66341e08..3d27e598f5 100644 --- a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-install-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-install-dialog.component.ts @@ -32,7 +32,6 @@ import { SolutionInstallDialogComponent } from '@home/components/solution/soluti export interface IotHubInstallDialogData { item: MpItemVersionView; - iotHubApiService: IotHubApiService; } export type InstallState = 'select-entity' | 'confirm' | 'installing' | 'success' | 'error'; @@ -68,7 +67,8 @@ export class TbIotHubInstallDialogComponent { private dialogRef: MatDialogRef, private dialog: MatDialog, private router: Router, - private translate: TranslateService + private translate: TranslateService, + private iotHubApiService: IotHubApiService ) { this.item = data.item; } @@ -90,7 +90,7 @@ export class TbIotHubInstallDialogComponent { this.state = 'installing'; const versionId = this.item.id as string; const data = this.selectedEntityId ? { entityId: this.selectedEntityId } : undefined; - this.data.iotHubApiService.installItemVersion(versionId, { ignoreLoading: true }, data).subscribe({ + this.iotHubApiService.installItemVersion(versionId, { ignoreLoading: true }, data).subscribe({ next: (result) => { if (result.success) { if (result.descriptor?.type === 'SOLUTION_TEMPLATE') { diff --git a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-installed-items.component.ts b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-installed-items.component.ts index 631e1c15ff..54f5dead5b 100644 --- a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-installed-items.component.ts +++ b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-installed-items.component.ts @@ -214,7 +214,6 @@ export class TbIotHubInstalledItemsComponent implements OnInit, AfterViewInit { autoFocus: false, data: { item: versionView, - iotHubApiService: this.iotHubApiService, installedItem: item } as IotHubItemDetailDialogData }); @@ -287,7 +286,6 @@ export class TbIotHubInstalledItemsComponent implements OnInit, AfterViewInit { autoFocus: false, data: { item: versionView, - iotHubApiService: this.iotHubApiService, installedItem } as IotHubItemDetailDialogData }); @@ -308,7 +306,6 @@ export class TbIotHubInstalledItemsComponent implements OnInit, AfterViewInit { itemType: item.itemType as ItemType, version: publishedInfo.publishedVersion, versionId: publishedInfo.publishedVersionId, - iotHubApiService: this.iotHubApiService } as IotHubUpdateDialogData }); dialogRef.afterClosed().subscribe(result => { diff --git a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-search.component.ts b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-search.component.ts index 908227492c..64a1fadc0a 100644 --- a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-search.component.ts +++ b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-search.component.ts @@ -217,7 +217,6 @@ export class TbIotHubSearchComponent implements OnInit, OnDestroy { autoFocus: false, data: { item, - iotHubApiService: this.iotHubApiService, installedItem: this.getInstalledItem(item) } as IotHubItemDetailDialogData }); @@ -236,7 +235,7 @@ export class TbIotHubSearchComponent implements OnInit, OnDestroy { const dialogRef = this.dialog.open(TbIotHubInstallDialogComponent, { panelClass: ['tb-dialog'], autoFocus: false, - data: { item, iotHubApiService: this.iotHubApiService } as IotHubInstallDialogData + data: { item } as IotHubInstallDialogData }); dialogRef.afterClosed().subscribe(result => { if (result === 'installed') { @@ -253,7 +252,7 @@ export class TbIotHubSearchComponent implements OnInit, OnDestroy { panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], disableClose: true, autoFocus: false, - data: { item, zipData, iotHubApiService: this.iotHubApiService } as DeviceInstallDialogData + data: { item, zipData } as DeviceInstallDialogData }); dialogRef.afterClosed().subscribe(result => { if (result === 'installed') { @@ -276,7 +275,6 @@ export class TbIotHubSearchComponent implements OnInit, OnDestroy { itemType: item.type, version: item.version, versionId: item.id, - iotHubApiService: this.iotHubApiService } as IotHubUpdateDialogData }); dialogRef.afterClosed().subscribe(result => { diff --git a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-update-dialog.component.ts b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-update-dialog.component.ts index 9eee9e0e10..bb18a0cc72 100644 --- a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-update-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-update-dialog.component.ts @@ -35,7 +35,6 @@ export interface IotHubUpdateDialogData { itemType: ItemType; version: string; versionId: string; - iotHubApiService: IotHubApiService; } export type UpdateState = 'confirm' | 'updating' | 'success' | 'error'; @@ -67,7 +66,8 @@ export class TbIotHubUpdateDialogComponent { private dialog: MatDialog, private dialogService: DialogService, private router: Router, - private translate: TranslateService + private translate: TranslateService, + private iotHubApiService: IotHubApiService ) {} getTypeLabel(): string { @@ -77,7 +77,7 @@ export class TbIotHubUpdateDialogComponent { update(force = false): void { this.state = 'updating'; - this.data.iotHubApiService.updateItemVersion(this.data.installedItemId, this.data.versionId, { ignoreLoading: true }, force).subscribe({ + this.iotHubApiService.updateItemVersion(this.data.installedItemId, this.data.versionId, { ignoreLoading: true }, force).subscribe({ next: (result) => { if (result.success) { if (result.descriptor?.type === 'SOLUTION_TEMPLATE') {