]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Load the datatable content after the component is initialized. 21595/head
authorVolker Theile <vtheile@suse.com>
Mon, 23 Apr 2018 10:34:38 +0000 (12:34 +0200)
committerVolker Theile <vtheile@suse.com>
Mon, 23 Apr 2018 11:36:40 +0000 (13:36 +0200)
Signed-off-by: Volker Theile <vtheile@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts

index a3da13b2f4411b572edbdedce110a6ca85e9a405..358a8cde5da2ff96908790fbcf8ef77958a9517f 100644 (file)
@@ -2,7 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
 import { FormsModule } from '@angular/forms';
 import { RouterTestingModule } from '@angular/router/testing';
 
-import { NgxDatatableModule, TableColumn } from '@swimlane/ngx-datatable';
+import { NgxDatatableModule } from '@swimlane/ngx-datatable';
 
 import { ComponentsModule } from '../../components/components.module';
 import { TableComponent } from './table.component';
@@ -10,7 +10,6 @@ import { TableComponent } from './table.component';
 describe('TableComponent', () => {
   let component: TableComponent;
   let fixture: ComponentFixture<TableComponent>;
-  const columns: TableColumn[] = [];
 
   const createFakeData = (n) => {
     const data = [];
index aa89fb4747a93095430e3759b1c0fb61a314bc0e..f2b03187e9997e48469ade359daaec0c75e860ac 100644 (file)
@@ -152,13 +152,14 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O
       return c;
     });
     this.tableColumns = this.columns.filter(c => !c.isHidden);
-    if (this.autoReload) {
-      // Also if nothing is bound to fetchData nothing will be triggered
-      // Force showing the loading indicator because it has been set to False in
-      // useData() when this method was triggered by ngOnChanges().
-      if (this.fetchData.observers.length > 0) {
-        this.loadingIndicator = true;
-      }
+    // Load the data table content every N ms or at least once.
+    // Force showing the loading indicator if there are subscribers to the fetchData
+    // event. This is necessary because it has been set to False in useData() when
+    // this method was triggered by ngOnChanges().
+    if (this.fetchData.observers.length > 0) {
+      this.loadingIndicator = true;
+    }
+    if (_.isInteger(this.autoReload) && (this.autoReload > 0)) {
       this.ngZone.runOutsideAngular(() => {
         this.subscriber = Observable.timer(0, this.autoReload).subscribe(x => {
           this.ngZone.run(() => {
@@ -166,6 +167,8 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O
           });
         });
       });
+    } else {
+      this.reloadData();
     }
   }