]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Handle errors during deletion 22029/head
authorVolker Theile <vtheile@suse.com>
Wed, 16 May 2018 12:34:34 +0000 (14:34 +0200)
committerVolker Theile <vtheile@suse.com>
Wed, 16 May 2018 14:37:11 +0000 (16:37 +0200)
- Take care that the deletion dialog gets notified about errors to stop the progress spinner and enable the delete button again.
- Prettify JS code.

Signed-off-by: Volker Theile <vtheile@suse.com>
(cherry picked from commit b2fa819fdfee93e6951666198720bce44c37b95d)

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-list/rgw-bucket-list.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-list/rgw-user-list.component.ts

index 1042a1a336ff3796594651def9fdae3f23f3c6b4..749460968e6f9bc08de681138e8323e2d9fbac3a 100644 (file)
@@ -20,16 +20,17 @@ import { CdTableSelection } from '../../../shared/models/cd-table-selection';
   styleUrls: ['./rgw-bucket-list.component.scss']
 })
 export class RgwBucketListComponent {
-
   @ViewChild(TableComponent) table: TableComponent;
 
   columns: CdTableColumn[] = [];
   buckets: object[] = [];
   selection: CdTableSelection = new CdTableSelection();
 
-  constructor(private router: Router,
-              private rgwBucketService: RgwBucketService,
-              private bsModalService: BsModalService) {
+  constructor(
+    private router: Router,
+    private rgwBucketService: RgwBucketService,
+    private bsModalService: BsModalService
+  ) {
     this.columns = [
       {
         name: 'Name',
@@ -45,14 +46,16 @@ export class RgwBucketListComponent {
   }
 
   getBucketList() {
-    this.rgwBucketService.list()
-      .subscribe((resp: object[]) => {
+    this.rgwBucketService.list().subscribe(
+      (resp: object[]) => {
         this.buckets = resp;
-      }, () => {
+      },
+      () => {
         // Force datatable to hide the loading indicator in
         // case of an error.
         this.buckets = [];
-      });
+      }
+    );
   }
 
   updateSelection(selection: CdTableSelection) {
@@ -65,19 +68,30 @@ export class RgwBucketListComponent {
       metaType: this.selection.hasSingleSelection ? 'bucket' : 'buckets',
       deletionObserver: (): Observable<any> => {
         return new Observable((observer: Subscriber<any>) => {
+          // Delete all selected data table rows.
           Observable.forkJoin(
             this.selection.selected.map((bucket: any) => {
               return this.rgwBucketService.delete(bucket.bucket);
-            }))
-            .subscribe(null, null, () => {
+            })
+          ).subscribe(
+            null,
+            (error) => {
+              // Forward the error to the observer.
+              observer.error(error);
+              // Reload the data table content because some deletions might
+              // have been executed successfully in the meanwhile.
+              this.table.refreshBtn();
+            },
+            () => {
+              // Notify the observer that we are done.
               observer.complete();
-              // Finally reload the data table content.
+              // Reload the data table content.
               this.table.refreshBtn();
-            });
+            }
+          );
         });
       },
       modalRef: modalRef
     });
   }
-
 }
index 3304841d7adf3a559b84f9a6e167c108a0155d38..0e6b129f323230c59ba9f2b85a144b5535c4ade5 100644 (file)
@@ -21,16 +21,17 @@ import { CdTableSelection } from '../../../shared/models/cd-table-selection';
   styleUrls: ['./rgw-user-list.component.scss']
 })
 export class RgwUserListComponent {
-
   @ViewChild(TableComponent) table: TableComponent;
 
   columns: CdTableColumn[] = [];
   users: object[] = [];
   selection: CdTableSelection = new CdTableSelection();
 
-  constructor(private router: Router,
-              private rgwUserService: RgwUserService,
-              private bsModalService: BsModalService) {
+  constructor(
+    private router: Router,
+    private rgwUserService: RgwUserService,
+    private bsModalService: BsModalService
+  ) {
     this.columns = [
       {
         name: 'Username',
@@ -62,14 +63,16 @@ export class RgwUserListComponent {
   }
 
   getUserList() {
-    this.rgwUserService.list()
-      .subscribe((resp: object[]) => {
+    this.rgwUserService.list().subscribe(
+      (resp: object[]) => {
         this.users = resp;
-      }, () => {
+      },
+      () => {
         // Force datatable to hide the loading indicator in
         // case of an error.
         this.users = [];
-      });
+      }
+    );
   }
 
   updateSelection(selection: CdTableSelection) {
@@ -82,15 +85,27 @@ export class RgwUserListComponent {
       metaType: this.selection.hasSingleSelection ? 'user' : 'users',
       deletionObserver: (): Observable<any> => {
         return new Observable((observer: Subscriber<any>) => {
+          // Delete all selected data table rows.
           Observable.forkJoin(
             this.selection.selected.map((user: any) => {
               return this.rgwUserService.delete(user.user_id);
-            }))
-            .subscribe(null, null, () => {
+            })
+          ).subscribe(
+            null,
+            (error) => {
+              // Forward the error to the observer.
+              observer.error(error);
+              // Reload the data table content because some deletions might
+              // have been executed successfully in the meanwhile.
+              this.table.refreshBtn();
+            },
+            () => {
+              // Notify the observer that we are done.
               observer.complete();
-              // Finally reload the data table content.
+              // Reload the data table content.
               this.table.refreshBtn();
-            });
+            }
+          );
         });
       },
       modalRef: modalRef