Skip to content

Commit

Permalink
mgr/dashboard: Load the datatable content after the component is init…
Browse files Browse the repository at this point in the history
…ialized.

Signed-off-by: Volker Theile <vtheile@suse.com>
  • Loading branch information
votdev committed Apr 23, 2018
1 parent baa095e commit 9dbb2df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Expand Up @@ -2,15 +2,14 @@ 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';

describe('TableComponent', () => {
let component: TableComponent;
let fixture: ComponentFixture<TableComponent>;
const columns: TableColumn[] = [];

const createFakeData = (n) => {
const data = [];
Expand Down
Expand Up @@ -152,20 +152,23 @@ 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(() => {
return this.reloadData();
});
});
});
} else {
this.reloadData();
}
}

Expand Down

0 comments on commit 9dbb2df

Please sign in to comment.