Browse Source

Merge remote-tracking branch 'upstream/lts-4.3' into rc

pull/15827/head
Vladyslav_Prykhodko 1 month ago
parent
commit
20154d82bb
  1. 14
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-actions.service.ts
  2. 12
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.ts
  3. 6
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-installed-items-table.component.ts

14
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-actions.service.ts

@ -17,11 +17,9 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { Observable, of } from 'rxjs'; import { Observable, of } from 'rxjs';
import { map, mergeMap } from 'rxjs/operators';
import { MpItemVersionView } from '@shared/models/iot-hub/iot-hub-version.models'; import { MpItemVersionView } from '@shared/models/iot-hub/iot-hub-version.models';
import { ItemType } from '@shared/models/iot-hub/iot-hub-item.models'; import { ItemType } from '@shared/models/iot-hub/iot-hub-item.models';
import { DeviceInstalledItemDescriptor, IotHubInstalledItem } from '@shared/models/iot-hub/iot-hub-installed-item.models'; import { DeviceInstalledItemDescriptor, IotHubInstalledItem } from '@shared/models/iot-hub/iot-hub-installed-item.models';
import { IotHubApiService } from '@core/http/iot-hub-api.service';
import { EntityId } from '@shared/models/id/entity-id'; import { EntityId } from '@shared/models/id/entity-id';
import { TbIotHubAddItemDialogComponent, IotHubAddItemDialogData, IotHubAddItemDialogResult } from './iot-hub-add-item-dialog.component'; import { TbIotHubAddItemDialogComponent, IotHubAddItemDialogData, IotHubAddItemDialogResult } from './iot-hub-add-item-dialog.component';
import { TbIotHubItemDetailDialogComponent, IotHubItemDetailDialogData, IotHubItemDetailDialogMode } from './iot-hub-item-detail-dialog.component'; import { TbIotHubItemDetailDialogComponent, IotHubItemDetailDialogData, IotHubItemDetailDialogMode } from './iot-hub-item-detail-dialog.component';
@ -35,8 +33,7 @@ import { TbIotHubInstalledItemsDialogComponent, IotHubInstalledItemsDialogData }
export class IotHubActionsService { export class IotHubActionsService {
constructor( constructor(
private dialog: MatDialog, private dialog: MatDialog
private iotHubApiService: IotHubApiService
) {} ) {}
openItemDetail(item: MpItemVersionView, installedItem?: IotHubInstalledItem, installedItemsCount?: number, openItemDetail(item: MpItemVersionView, installedItem?: IotHubInstalledItem, installedItemsCount?: number,
@ -109,13 +106,8 @@ export class IotHubActionsService {
panelClass: ['tb-dialog'], panelClass: ['tb-dialog'],
disableClose: true, disableClose: true,
autoFocus: false, autoFocus: false,
data: { itemName: installedItem.itemName, itemType: installedItem.itemType } data: { installedItemId: installedItem.id.id, itemName: installedItem.itemName, itemType: installedItem.itemType }
}).afterClosed().pipe( }).afterClosed();
mergeMap((confirmed) =>
confirmed
? this.iotHubApiService.deleteInstalledItem(installedItem.id.id).pipe(map(() => true))
: of(false) )
);
} }
installDevice(item: MpItemVersionView): Observable<string> { installDevice(item: MpItemVersionView): Observable<string> {

12
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.ts

@ -20,8 +20,11 @@ import { Router } from '@angular/router';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state'; import { AppState } from '@core/core.state';
import { DialogComponent } from '@shared/components/dialog.component'; import { DialogComponent } from '@shared/components/dialog.component';
import { IotHubInstalledItem } from 'src/app/shared/models/iot-hub/iot-hub-installed-item.models';
import { IotHubApiService } from '@core/http/iot-hub-api.service';
export interface IotHubDeleteDialogData { export interface IotHubDeleteDialogData {
installedItemId: string;
itemName: string; itemName: string;
itemType?: string; itemType?: string;
} }
@ -38,13 +41,18 @@ export class TbIotHubDeleteDialogComponent extends DialogComponent<TbIotHubDelet
protected store: Store<AppState>, protected store: Store<AppState>,
protected router: Router, protected router: Router,
protected dialogRef: MatDialogRef<TbIotHubDeleteDialogComponent, boolean>, protected dialogRef: MatDialogRef<TbIotHubDeleteDialogComponent, boolean>,
@Inject(MAT_DIALOG_DATA) public data: IotHubDeleteDialogData @Inject(MAT_DIALOG_DATA) public data: IotHubDeleteDialogData,
private iotHubApiService: IotHubApiService
) { ) {
super(store, router, dialogRef); super(store, router, dialogRef);
} }
confirm(): void { confirm(): void {
this.dialogRef.close(true); this.iotHubApiService.deleteInstalledItem(this.data.installedItemId).subscribe(
() => {
this.dialogRef.close(true);
}
);
} }
cancel(): void { cancel(): void {

6
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-installed-items-table.component.ts

@ -156,12 +156,9 @@ export class TbIotHubInstalledItemsTableComponent implements OnInit, OnChanges,
} }
deleteItem(item: IotHubInstalledItem): void { deleteItem(item: IotHubInstalledItem): void {
this.isLoading = true;
this.iotHubActions.deleteItem(item).subscribe(deleted => { this.iotHubActions.deleteItem(item).subscribe(deleted => {
if (deleted) { if (deleted) {
this.loadData(); this.loadData();
} else {
this.isLoading = false;
} }
}); });
} }
@ -247,12 +244,9 @@ export class TbIotHubInstalledItemsTableComponent implements OnInit, OnChanges,
} }
updateItem(item: IotHubInstalledItem, publishedInfo: ItemPublishedVersionInfo): void { updateItem(item: IotHubInstalledItem, publishedInfo: ItemPublishedVersionInfo): void {
this.isLoading = true;
this.iotHubActions.updateItem(item, publishedInfo.publishedVersion, publishedInfo.publishedVersionId).subscribe(result => { this.iotHubActions.updateItem(item, publishedInfo.publishedVersion, publishedInfo.publishedVersionId).subscribe(result => {
if (result === 'updated') { if (result === 'updated') {
this.loadData(); this.loadData();
} else {
this.isLoading = false;
} }
}); });
} }

Loading…
Cancel
Save