From: Volker Theile Date: Mon, 23 Apr 2018 10:34:38 +0000 (+0200) Subject: mgr/dashboard: Load the datatable content after the component is initialized. X-Git-Tag: v13.1.0~125^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=9dbb2df40231c35198667c7c409c3863bb12f90a;p=ceph.git mgr/dashboard: Load the datatable content after the component is initialized. Signed-off-by: Volker Theile --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts index a3da13b2f4411..358a8cde5da2f 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts @@ -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; - const columns: TableColumn[] = []; const createFakeData = (n) => { const data = []; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts index aa89fb4747a93..f2b03187e9997 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts @@ -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(); } }