]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: RGW auto refresh is not working 34739/head
authorAvan Thakkar <athakkar@redhat.com>
Tue, 24 Mar 2020 12:44:02 +0000 (18:14 +0530)
committerVolker Theile <vtheile@suse.com>
Fri, 24 Apr 2020 14:14:09 +0000 (16:14 +0200)
Fixes: https://tracker.ceph.com/issues/44667
Signed-off-by: Avan Thakkar <athakkar@redhat.com>
(cherry picked from commit 33f6d61b2414490bb62371888936b7dbae28df02)

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-list/rgw-bucket-list.component.html
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.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-list/rgw-user-list.component.ts

index 37797e96e003992e1f9c7ef3e4559c69d8b1d6ad..1a2fbaeba02c4cfed5b1e9955973104abdbd2a05 100644 (file)
@@ -1,3 +1,7 @@
+<cd-alert-panel *ngIf="isStale"
+                type="warning"
+                size="slim"
+                i18n>The bucket list data might be stale. If needed, you can manually reload it.</cd-alert-panel>
 <cd-table #table
           [autoReload]="false"
           [data]="buckets"
index 24050ebb74aa46d55e78e788f41362b57a97dc04..8573c7395570d38eff8597a2b4c7bd46a81c06a5 100644 (file)
@@ -1,4 +1,4 @@
-import { Component, ViewChild } from '@angular/core';
+import { Component, NgZone, ViewChild } from '@angular/core';
 
 import { I18n } from '@ngx-translate/i18n-polyfill';
 import { BsModalService } from 'ngx-bootstrap/modal';
@@ -34,6 +34,8 @@ export class RgwBucketListComponent {
   columns: CdTableColumn[] = [];
   buckets: object[] = [];
   selection: CdTableSelection = new CdTableSelection();
+  isStale = false;
+  staleTimeout: number;
 
   constructor(
     private authStorageService: AuthStorageService,
@@ -41,7 +43,8 @@ export class RgwBucketListComponent {
     private bsModalService: BsModalService,
     private i18n: I18n,
     private urlBuilder: URLBuilderService,
-    public actionLabels: ActionLabelsI18n
+    public actionLabels: ActionLabelsI18n,
+    private ngZone: NgZone
   ) {
     this.permission = this.authStorageService.getPermissions().rgw;
     this.columns = [
@@ -80,9 +83,23 @@ export class RgwBucketListComponent {
       canBePrimary: (selection: CdTableSelection) => selection.hasMultiSelection
     };
     this.tableActions = [addAction, editAction, deleteAction];
+    this.timeConditionReached();
+  }
+
+  timeConditionReached() {
+    clearTimeout(this.staleTimeout);
+    this.ngZone.runOutsideAngular(() => {
+      this.staleTimeout = window.setTimeout(() => {
+        this.ngZone.run(() => {
+          this.isStale = true;
+        });
+      }, 10000);
+    });
   }
 
   getBucketList(context: CdTableFetchDataContext) {
+    this.isStale = false;
+    this.timeConditionReached();
     this.rgwBucketService.list().subscribe(
       (resp: object[]) => {
         this.buckets = resp;
index a154f1182e34a4d823716df8903c991df91389d9..f1d603536d4f229b7b20367491ae0e44abd9521c 100644 (file)
@@ -1,3 +1,7 @@
+<cd-alert-panel *ngIf="isStale"
+                type="warning"
+                size="slim"
+                i18n>The user list data might be stale. If needed, you can manually reload it.</cd-alert-panel>
 <cd-table #table
           [autoReload]="false"
           [data]="users"
index 46c402019635b7b7e5448987346caf0753f30752..8775220401b63f10acfc455015c008e5a721cb43 100644 (file)
@@ -1,4 +1,4 @@
-import { Component, ViewChild } from '@angular/core';
+import { Component, NgZone, ViewChild } from '@angular/core';
 
 import { I18n } from '@ngx-translate/i18n-polyfill';
 import { BsModalService } from 'ngx-bootstrap/modal';
@@ -29,12 +29,13 @@ const BASE_URL = 'rgw/user';
 export class RgwUserListComponent {
   @ViewChild(TableComponent, { static: true })
   table: TableComponent;
-
   permission: Permission;
   tableActions: CdTableAction[];
   columns: CdTableColumn[] = [];
   users: object[] = [];
   selection: CdTableSelection = new CdTableSelection();
+  isStale = false;
+  staleTimeout: number;
 
   constructor(
     private authStorageService: AuthStorageService,
@@ -42,7 +43,8 @@ export class RgwUserListComponent {
     private bsModalService: BsModalService,
     private i18n: I18n,
     private urlBuilder: URLBuilderService,
-    public actionLabels: ActionLabelsI18n
+    public actionLabels: ActionLabelsI18n,
+    private ngZone: NgZone
   ) {
     this.permission = this.authStorageService.getPermissions().rgw;
     this.columns = [
@@ -103,9 +105,23 @@ export class RgwUserListComponent {
       canBePrimary: (selection: CdTableSelection) => selection.hasMultiSelection
     };
     this.tableActions = [addAction, editAction, deleteAction];
+    this.timeConditionReached();
+  }
+
+  timeConditionReached() {
+    clearTimeout(this.staleTimeout);
+    this.ngZone.runOutsideAngular(() => {
+      this.staleTimeout = window.setTimeout(() => {
+        this.ngZone.run(() => {
+          this.isStale = true;
+        });
+      }, 10000);
+    });
   }
 
   getUserList(context: CdTableFetchDataContext) {
+    this.isStale = false;
+    this.timeConditionReached();
     this.rgwUserService.list().subscribe(
       (resp: object[]) => {
         this.users = resp;