Browse Source

Fix conflicts

pull/15851/head
Igor Kulikov 4 months ago
parent
commit
92fbb15451
  1. 23
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-actions.service.ts
  2. 10
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.ts
  3. 10
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-install-dialog.component.html
  4. 17
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-installed-items-table.component.html
  5. 1
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-installed-items-table.component.scss
  6. 10
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-installed-items-table.component.ts
  7. 4
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-item-detail-dialog.component.ts
  8. 8
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-search.component.ts
  9. 2
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-update-dialog.component.html
  10. 4
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-update-dialog.component.ts
  11. 31
      ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.ts
  12. 4
      ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-installed-items.component.html

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

@ -16,8 +16,8 @@
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, EMPTY } from 'rxjs'; import { Observable, of } from 'rxjs';
import { filter, mergeMap } from 'rxjs/operators'; 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';
@ -83,11 +83,11 @@ export class IotHubActionsService {
}).afterClosed(); }).afterClosed();
} }
updateItem(installedItem: IotHubInstalledItem, version: string, versionId: string): Observable<string> { updateItem(installedItem: IotHubInstalledItem, version: string, versionId: string): Observable<string | boolean> {
if (!installedItem) { if (!installedItem) {
return EMPTY; return of(false);
} }
return this.dialog.open(TbIotHubUpdateDialogComponent, { return this.dialog.open<TbIotHubUpdateDialogComponent, IotHubUpdateDialogData, string | boolean>(TbIotHubUpdateDialogComponent, {
panelClass: ['tb-dialog'], panelClass: ['tb-dialog'],
disableClose: true, disableClose: true,
autoFocus: false, autoFocus: false,
@ -97,7 +97,7 @@ export class IotHubActionsService {
itemType: installedItem.itemType as ItemType, itemType: installedItem.itemType as ItemType,
version, version,
versionId versionId
} as IotHubUpdateDialogData }
}).afterClosed(); }).afterClosed();
} }
@ -105,15 +105,16 @@ export class IotHubActionsService {
if (!installedItem) { if (!installedItem) {
return of(false); return of(false);
} }
return this.dialog.open(TbIotHubDeleteDialogComponent, { return this.dialog.open<TbIotHubDeleteDialogComponent, IotHubDeleteDialogData, boolean>(TbIotHubDeleteDialogComponent, {
panelClass: ['tb-dialog'], panelClass: ['tb-dialog'],
disableClose: true, disableClose: true,
autoFocus: false, autoFocus: false,
data: { itemName: installedItem.itemName, itemType: installedItem.itemType } as IotHubDeleteDialogData data: { itemName: installedItem.itemName, itemType: installedItem.itemType }
}).afterClosed().pipe( }).afterClosed().pipe(
filter(confirmed => !!confirmed), mergeMap((confirmed) =>
mergeMap(() => this.iotHubApiService.deleteInstalledItem(installedItem.id.id)), confirmed
mergeMap(() => of(true)) ? this.iotHubApiService.deleteInstalledItem(installedItem.id.id).pipe(map(() => true))
: of(false) )
); );
} }

10
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.ts

@ -580,8 +580,7 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy
updateItem(item: MpItemVersionView): void { updateItem(item: MpItemVersionView): void {
const installedItem = this.getInstalledItem(item); const installedItem = this.getInstalledItem(item);
if (!installedItem) { return; } this.iotHubActions.updateItem(installedItem, item.version, item.id).subscribe(result => {
this.iotHubActions.updateItem(installedItem, item.version, item.id as string).subscribe(result => {
if (result === 'updated') { if (result === 'updated') {
this.reloadInstalledItems(); this.reloadInstalledItems();
} }
@ -590,9 +589,10 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy
deleteInstalledItem(item: MpItemVersionView): void { deleteInstalledItem(item: MpItemVersionView): void {
const installedItem = this.getInstalledItem(item); const installedItem = this.getInstalledItem(item);
if (!installedItem) { return; } this.iotHubActions.deleteItem(installedItem).subscribe((deleted) => {
this.iotHubActions.deleteItem(installedItem).subscribe(() => { if (deleted) {
this.reloadInstalledItems(); this.reloadInstalledItems();
}
}); });
} }

10
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-install-dialog.component.html

@ -157,7 +157,7 @@
<button mat-button [disabled]="resolvingPlan" (click)="cancel()">{{ 'action.cancel' | translate }}</button> <button mat-button [disabled]="resolvingPlan" (click)="cancel()">{{ 'action.cancel' | translate }}</button>
<button mat-flat-button color="primary" [disabled]="resolvingPlan" (click)="install()"> <button mat-flat-button color="primary" [disabled]="resolvingPlan" (click)="install()">
@if (resolvingPlan) { @if (resolvingPlan) {
<mat-spinner diameter="18" class="mr-2 inline-block align-middle"></mat-spinner> <mat-spinner matButtonIcon diameter="18" class="mr-2"></mat-spinner>
} }
{{ 'iot-hub.install' | translate }} {{ 'iot-hub.install' | translate }}
</button> </button>
@ -169,7 +169,7 @@
[disabled]="ruleChainInstallForm.invalid || resolvingPlan" [disabled]="ruleChainInstallForm.invalid || resolvingPlan"
(click)="onRuleChainInstall()"> (click)="onRuleChainInstall()">
@if (resolvingPlan) { @if (resolvingPlan) {
<mat-spinner diameter="18" class="mr-2 inline-block align-middle"></mat-spinner> <mat-spinner matButtonIcon diameter="18" class="mr-2"></mat-spinner>
} }
{{ 'iot-hub.install' | translate }} {{ 'iot-hub.install' | translate }}
</button> </button>
@ -178,7 +178,7 @@
[disabled]="(activeSelectEntityConfig.required && !selectedEntityId) || resolvingPlan" [disabled]="(activeSelectEntityConfig.required && !selectedEntityId) || resolvingPlan"
(click)="onEntitySelectInstall()"> (click)="onEntitySelectInstall()">
@if (resolvingPlan) { @if (resolvingPlan) {
<mat-spinner diameter="18" class="mr-2 inline-block align-middle"></mat-spinner> <mat-spinner matButtonIcon diameter="18" class="mr-2"></mat-spinner>
} }
{{ 'iot-hub.install' | translate }} {{ 'iot-hub.install' | translate }}
</button> </button>
@ -188,7 +188,7 @@
<button mat-button [disabled]="resolvingPlan" (click)="confirmOverwriteCancel()">{{ 'action.cancel' | translate }}</button> <button mat-button [disabled]="resolvingPlan" (click)="confirmOverwriteCancel()">{{ 'action.cancel' | translate }}</button>
<button mat-flat-button color="primary" [disabled]="resolvingPlan" (click)="confirmOverwriteReplace()"> <button mat-flat-button color="primary" [disabled]="resolvingPlan" (click)="confirmOverwriteReplace()">
@if (resolvingPlan) { @if (resolvingPlan) {
<mat-spinner diameter="18" class="mr-2 inline-block align-middle"></mat-spinner> <mat-spinner matButtonIcon diameter="18" class="mr-2"></mat-spinner>
} }
{{ 'iot-hub.rule-chain-overwrite-replace' | translate }} {{ 'iot-hub.rule-chain-overwrite-replace' | translate }}
</button> </button>
@ -204,7 +204,7 @@
@case ('installing') { @case ('installing') {
<button mat-button disabled>{{ 'action.cancel' | translate }}</button> <button mat-button disabled>{{ 'action.cancel' | translate }}</button>
<button mat-flat-button color="primary" disabled> <button mat-flat-button color="primary" disabled>
<mat-spinner diameter="18" class="mr-2 inline-block align-middle"></mat-spinner> <mat-spinner matButtonIcon diameter="18" class="mr-2"></mat-spinner>
{{ 'iot-hub.installing' | translate }} {{ 'iot-hub.installing' | translate }}
</button> </button>
} }

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

@ -135,14 +135,8 @@
<tr mat-row *matRowDef="let _row; columns: displayedColumns;"></tr> <tr mat-row *matRowDef="let _row; columns: displayedColumns;"></tr>
</table> </table>
@if (isLoading) {
<div class="flex flex-1 items-center justify-center py-12">
<mat-spinner diameter="40"></mat-spinner>
</div>
}
@if (!isLoading && dataSource.length === 0) { @if (!isLoading && dataSource.length === 0) {
<div class="tb-iot-hub-empty-state flex flex-1 flex-col items-center justify-center py-20 text-center"> <div class="tb-iot-hub-empty-state flex flex-1 flex-col items-center justify-center text-center">
<div class="tb-no-data-bg"></div> <div class="tb-no-data-bg"></div>
<h3>{{ 'iot-hub.no-installed-items' | translate }}</h3> <h3>{{ 'iot-hub.no-installed-items' | translate }}</h3>
<p>{{ 'iot-hub.no-installed-items-text' | translate }}</p> <p>{{ 'iot-hub.no-installed-items-text' | translate }}</p>
@ -166,4 +160,13 @@
(page)="onPageChange($event)" (page)="onPageChange($event)"
[showFirstLastButtons]="true"> [showFirstLastButtons]="true">
</mat-paginator> </mat-paginator>
@if (isLoading) {
<div class="absolute inset-0 backdrop-grayscale" style="background: rgba(255, 255, 255, 0.72); z-index: 100;">
<div class="flex h-full items-center justify-center">
<mat-spinner diameter="40"></mat-spinner>
</div>
</div>
}
</div> </div>

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

@ -25,6 +25,7 @@
// Table + paginator container — border // Table + paginator container — border
.tb-installed-table-container { .tb-installed-table-container {
position: relative;
border: 1px solid rgba(0, 0, 0, 0.12); border: 1px solid rgba(0, 0, 0, 0.12);
} }

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

@ -156,9 +156,12 @@ export class TbIotHubInstalledItemsTableComponent implements OnInit, OnChanges,
} }
deleteItem(item: IotHubInstalledItem): void { deleteItem(item: IotHubInstalledItem): void {
this.iotHubActions.deleteItem(item).subscribe(confirmed => { this.isLoading = true;
if (confirmed) { this.iotHubActions.deleteItem(item).subscribe(deleted => {
if (deleted) {
this.loadData(); this.loadData();
} else {
this.isLoading = false;
} }
}); });
} }
@ -244,9 +247,12 @@ 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;
} }
}); });
} }

4
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-item-detail-dialog.component.ts

@ -220,8 +220,8 @@ export class TbIotHubItemDetailDialogComponent extends DialogComponent<TbIotHubI
} }
deleteItem(): void { deleteItem(): void {
this.iotHubActions.deleteItem(this.installedItem).subscribe(confirmed => { this.iotHubActions.deleteItem(this.installedItem).subscribe(deleted => {
if (confirmed) { if (deleted) {
this.dialogRef.close('deleted'); this.dialogRef.close('deleted');
} }
}); });

8
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-search.component.ts

@ -247,7 +247,6 @@ export class TbIotHubSearchComponent implements OnInit, OnDestroy {
updateItem(item: MpItemVersionView): void { updateItem(item: MpItemVersionView): void {
const installedItem = this.getInstalledItem(item); const installedItem = this.getInstalledItem(item);
if (!installedItem) { return; }
this.iotHubActions.updateItem(installedItem, item.version, item.id as string).subscribe(result => { this.iotHubActions.updateItem(installedItem, item.version, item.id as string).subscribe(result => {
if (result === 'updated') { if (result === 'updated') {
this.reloadInstalledItems(); this.reloadInstalledItems();
@ -257,9 +256,10 @@ export class TbIotHubSearchComponent implements OnInit, OnDestroy {
deleteInstalledItem(item: MpItemVersionView): void { deleteInstalledItem(item: MpItemVersionView): void {
const installedItem = this.getInstalledItem(item); const installedItem = this.getInstalledItem(item);
if (!installedItem) { return; } this.iotHubActions.deleteItem(installedItem).subscribe((deleted) => {
this.iotHubActions.deleteItem(installedItem).subscribe(() => { if (deleted) {
this.reloadInstalledItems(); this.reloadInstalledItems();
}
}); });
} }

2
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-update-dialog.component.html

@ -51,7 +51,7 @@
@case ('updating') { @case ('updating') {
<button mat-button disabled>{{ 'action.cancel' | translate }}</button> <button mat-button disabled>{{ 'action.cancel' | translate }}</button>
<button mat-flat-button color="primary" disabled> <button mat-flat-button color="primary" disabled>
<mat-spinner diameter="18" class="mr-2 inline-block align-middle"></mat-spinner> <mat-spinner matButtonIcon diameter="18" class="mr-2"></mat-spinner>
{{ 'iot-hub.updating' | translate }} {{ 'iot-hub.updating' | translate }}
</button> </button>
} }

4
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-update-dialog.component.ts

@ -46,7 +46,7 @@ export type UpdateState = 'confirm' | 'updating' | 'success' | 'error';
templateUrl: './iot-hub-update-dialog.component.html', templateUrl: './iot-hub-update-dialog.component.html',
styleUrls: ['./iot-hub-install-dialog.component.scss'] styleUrls: ['./iot-hub-install-dialog.component.scss']
}) })
export class TbIotHubUpdateDialogComponent extends DialogComponent<TbIotHubUpdateDialogComponent> { export class TbIotHubUpdateDialogComponent extends DialogComponent<TbIotHubUpdateDialogComponent, string | boolean> {
ItemType = ItemType; ItemType = ItemType;
@ -58,7 +58,7 @@ export class TbIotHubUpdateDialogComponent extends DialogComponent<TbIotHubUpdat
constructor( constructor(
protected store: Store<AppState>, protected store: Store<AppState>,
protected router: Router, protected router: Router,
protected dialogRef: MatDialogRef<TbIotHubUpdateDialogComponent>, protected dialogRef: MatDialogRef<TbIotHubUpdateDialogComponent, string | boolean>,
@Inject(MAT_DIALOG_DATA) public data: IotHubUpdateDialogData, @Inject(MAT_DIALOG_DATA) public data: IotHubUpdateDialogData,
private dialog: MatDialog, private dialog: MatDialog,
private dialogService: DialogService, private dialogService: DialogService,

31
ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.ts

@ -381,7 +381,6 @@ export class TbIotHubHomeComponent implements OnInit, OnDestroy {
updateItem(item: MpItemVersionView): void { updateItem(item: MpItemVersionView): void {
const installedItem = this.findInstalledItem(item); const installedItem = this.findInstalledItem(item);
if (!installedItem) { return; }
this.iotHubActions.updateItem(installedItem, item.version, item.id as string).subscribe(result => { this.iotHubActions.updateItem(installedItem, item.version, item.id as string).subscribe(result => {
if (result === 'updated') { if (result === 'updated') {
this.reloadInstalledItems(item.type); this.reloadInstalledItems(item.type);
@ -404,20 +403,22 @@ export class TbIotHubHomeComponent implements OnInit, OnDestroy {
deleteInstalledItem(item: MpItemVersionView): void { deleteInstalledItem(item: MpItemVersionView): void {
const installedItem = this.findInstalledItem(item); const installedItem = this.findInstalledItem(item);
if (!installedItem) { return; } if (!installedItem) { return; }
this.iotHubActions.deleteItem(installedItem).subscribe(() => { this.iotHubActions.deleteItem(installedItem).subscribe((deleted) => {
this.installedItemsCount = Math.max(0, this.installedItemsCount - 1); if (deleted) {
if (item.type === ItemType.WIDGET) { this.installedItemsCount = Math.max(0, this.installedItemsCount - 1);
this.installedWidgets = this.installedWidgets.filter(i => i.id.id !== installedItem.id.id); if (item.type === ItemType.WIDGET) {
} else if (item.type === ItemType.SOLUTION_TEMPLATE) { this.installedWidgets = this.installedWidgets.filter(i => i.id.id !== installedItem.id.id);
this.installedSolutionTemplates = this.installedSolutionTemplates.filter(i => i.id.id !== installedItem.id.id); } else if (item.type === ItemType.SOLUTION_TEMPLATE) {
} else if (item.type === ItemType.DEVICE && this.installedDeviceCounts[item.itemId]) { this.installedSolutionTemplates = this.installedSolutionTemplates.filter(i => i.id.id !== installedItem.id.id);
this.installedDeviceCounts[item.itemId] = Math.max(0, this.installedDeviceCounts[item.itemId] - 1); } else if (item.type === ItemType.DEVICE && this.installedDeviceCounts[item.itemId]) {
} else if (item.type === ItemType.CALCULATED_FIELD && this.installedCalcFieldCounts[item.itemId]) { this.installedDeviceCounts[item.itemId] = Math.max(0, this.installedDeviceCounts[item.itemId] - 1);
this.installedCalcFieldCounts[item.itemId] = Math.max(0, this.installedCalcFieldCounts[item.itemId] - 1); } else if (item.type === ItemType.CALCULATED_FIELD && this.installedCalcFieldCounts[item.itemId]) {
} else if (item.type === ItemType.ALARM_RULE && this.installedAlarmRuleCounts[item.itemId]) { this.installedCalcFieldCounts[item.itemId] = Math.max(0, this.installedCalcFieldCounts[item.itemId] - 1);
this.installedAlarmRuleCounts[item.itemId] = Math.max(0, this.installedAlarmRuleCounts[item.itemId] - 1); } else if (item.type === ItemType.ALARM_RULE && this.installedAlarmRuleCounts[item.itemId]) {
} else if (item.type === ItemType.RULE_CHAIN && this.installedRuleChainCounts[item.itemId]) { this.installedAlarmRuleCounts[item.itemId] = Math.max(0, this.installedAlarmRuleCounts[item.itemId] - 1);
this.installedRuleChainCounts[item.itemId] = Math.max(0, this.installedRuleChainCounts[item.itemId] - 1); } else if (item.type === ItemType.RULE_CHAIN && this.installedRuleChainCounts[item.itemId]) {
this.installedRuleChainCounts[item.itemId] = Math.max(0, this.installedRuleChainCounts[item.itemId] - 1);
}
} }
}); });
} }

4
ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-installed-items.component.html

@ -28,9 +28,9 @@
@if (!updatesChecked) { @if (!updatesChecked) {
<button mat-flat-button color="primary" (click)="checkForUpdates()" [disabled]="isCheckingUpdates"> <button mat-flat-button color="primary" (click)="checkForUpdates()" [disabled]="isCheckingUpdates">
@if (isCheckingUpdates) { @if (isCheckingUpdates) {
<mat-spinner diameter="18"></mat-spinner> <mat-spinner matButtonIcon class="mr-2" diameter="18"></mat-spinner>
} @else { } @else {
<mat-icon>update</mat-icon> <mat-icon matButtonIcon>update</mat-icon>
} }
{{ 'iot-hub.check-for-updates' | translate }} {{ 'iot-hub.check-for-updates' | translate }}
</button> </button>

Loading…
Cancel
Save