From f9268d054b24b8f6edfbcacaf0fa35395b5a2b29 Mon Sep 17 00:00:00 2001 From: Alex Karpov Date: Thu, 5 Sep 2024 19:12:47 +0300 Subject: [PATCH] NAS-130874 / 25.04 / snapshot batch delete button is deleting ALL snapshots, not just selected (#10602) * NAS-130874: snapshot batch delete button is deleting ALL snapshots, not just selected * NAS-130874: snapshot batch delete button is deleting ALL snapshots, not just selected --- .../docker-images-list.component.ts | 15 +++++++++++---- .../snapshot-list/snapshot-list.component.ts | 11 ++++++++--- .../components/disk-list/disk-list.component.ts | 15 +++++++++++---- .../bootenv-list/bootenv-list.component.ts | 12 +++++++++--- 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/app/pages/apps/components/docker-images/docker-images-list/docker-images-list.component.ts b/src/app/pages/apps/components/docker-images/docker-images-list/docker-images-list.component.ts index 234df3a86d9..b29f7dbe66b 100644 --- a/src/app/pages/apps/components/docker-images/docker-images-list/docker-images-list.component.ts +++ b/src/app/pages/apps/components/docker-images/docker-images-list/docker-images-list.component.ts @@ -4,7 +4,9 @@ import { import { MatDialog } from '@angular/material/dialog'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import { filter, map, tap } from 'rxjs/operators'; +import { + filter, map, take, tap, +} from 'rxjs/operators'; import { Role } from 'app/enums/role.enum'; import { ContainerImage } from 'app/interfaces/container-image.interface'; import { EmptyService } from 'app/modules/empty/empty.service'; @@ -50,9 +52,14 @@ export class DockerImagesListComponent implements OnInit { this.onListFiltered(this.filterString); }, onColumnCheck: (checked) => { - this.containerImages.forEach((image) => image.selected = checked); - this.dataProvider.setRows([]); - this.onListFiltered(this.filterString); + this.dataProvider.currentPage$.pipe( + take(1), + untilDestroyed(this), + ).subscribe((images) => { + images.forEach((image) => image.selected = checked); + this.dataProvider.setRows([]); + this.onListFiltered(this.filterString); + }); }, cssClass: 'checkboxs-column', }), diff --git a/src/app/pages/datasets/modules/snapshots/snapshot-list/snapshot-list.component.ts b/src/app/pages/datasets/modules/snapshots/snapshot-list/snapshot-list.component.ts index 81693c0b848..2d17a2bbf08 100644 --- a/src/app/pages/datasets/modules/snapshots/snapshot-list/snapshot-list.component.ts +++ b/src/app/pages/datasets/modules/snapshots/snapshot-list/snapshot-list.component.ts @@ -89,9 +89,14 @@ export class SnapshotListComponent implements OnInit { this.onListFiltered(this.filterString); }, onColumnCheck: (checked) => { - this.snapshots.forEach((bootenv) => bootenv.selected = checked); - this.dataProvider.setRows([]); - this.onListFiltered(this.filterString); + this.dataProvider.currentPage$.pipe( + take(1), + untilDestroyed(this), + ).subscribe((snapshots) => { + snapshots.forEach((snapshot) => snapshot.selected = checked); + this.dataProvider.setRows([]); + this.onListFiltered(this.filterString); + }); }, cssClass: 'checkboxs-column', }), diff --git a/src/app/pages/storage/modules/disks/components/disk-list/disk-list.component.ts b/src/app/pages/storage/modules/disks/components/disk-list/disk-list.component.ts index 49d8888f243..82bee551760 100644 --- a/src/app/pages/storage/modules/disks/components/disk-list/disk-list.component.ts +++ b/src/app/pages/storage/modules/disks/components/disk-list/disk-list.component.ts @@ -5,7 +5,9 @@ import { MatDialog } from '@angular/material/dialog'; import { Router } from '@angular/router'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import { filter, forkJoin, map } from 'rxjs'; +import { + filter, forkJoin, map, take, +} from 'rxjs'; import { Role } from 'app/enums/role.enum'; import { SmartTestResultPageType } from 'app/enums/smart-test-results-page-type.enum'; import { buildNormalizedFileSize } from 'app/helpers/file-size.utils'; @@ -55,9 +57,14 @@ export class DiskListComponent implements OnInit { this.onListFiltered(this.filterString); }, onColumnCheck: (checked) => { - this.disks.forEach((disk) => disk.selected = checked); - this.dataProvider.setRows([]); - this.onListFiltered(this.filterString); + this.dataProvider.currentPage$.pipe( + take(1), + untilDestroyed(this), + ).subscribe((disks) => { + disks.forEach((disk) => disk.selected = checked); + this.dataProvider.setRows([]); + this.onListFiltered(this.filterString); + }); }, }), textColumn({ diff --git a/src/app/pages/system/bootenv/bootenv-list/bootenv-list.component.ts b/src/app/pages/system/bootenv/bootenv-list/bootenv-list.component.ts index f799a0230a1..7df85938ea6 100644 --- a/src/app/pages/system/bootenv/bootenv-list/bootenv-list.component.ts +++ b/src/app/pages/system/bootenv/bootenv-list/bootenv-list.component.ts @@ -5,6 +5,7 @@ import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; import { filter, map, of, switchMap, + take, } from 'rxjs'; import { BootEnvironmentAction } from 'app/enums/boot-environment-action.enum'; import { BootEnvironmentActive } from 'app/enums/boot-environment-active.enum'; @@ -64,9 +65,14 @@ export class BootEnvironmentListComponent implements OnInit { this.onListFiltered(this.filterString); }, onColumnCheck: (checked) => { - this.bootenvs.forEach((bootenv) => bootenv.selected = checked); - this.dataProvider.setRows([]); - this.onListFiltered(this.filterString); + this.dataProvider.currentPage$.pipe( + take(1), + untilDestroyed(this), + ).subscribe((bootEnvs) => { + bootEnvs.forEach((bootEnv) => bootEnv.selected = checked); + this.dataProvider.setRows([]); + this.onListFiltered(this.filterString); + }); }, cssClass: 'checkboxs-column', }),