From 6978e411c4f7c95bfb2681b8759f539b7e0973c1 Mon Sep 17 00:00:00 2001 From: anandtiwary <52081890+anandtiwary@users.noreply.github.com> Date: Thu, 29 Oct 2020 17:25:16 -0700 Subject: [PATCH] fix: fix table scrolling and loading issues - Load Async is built to show loaders for content rendered inside it. We are using it in table as a placeholder where the loader wrapper stays after the cdk table has loaded all data. This creates lots of layout issues especially when using with flex container - Introducing a new hide property in table loading state to remove the loader wrapper once loading is completed. In case of error or no data, the loader will automatically take the entire space. - removing host properties as it interferes with flex properties for parent container - adding flex grow to explorer table --- .../src/table/data/table-cdk-data-source.ts | 19 +- .../components/src/table/table.component.scss | 9 +- .../components/src/table/table.component.ts | 219 +++++++++--------- .../pages/explorer/explorer.component.scss | 3 +- 4 files changed, 133 insertions(+), 117 deletions(-) diff --git a/projects/components/src/table/data/table-cdk-data-source.ts b/projects/components/src/table/data/table-cdk-data-source.ts index df7032483..a9db7d254 100644 --- a/projects/components/src/table/data/table-cdk-data-source.ts +++ b/projects/components/src/table/data/table-cdk-data-source.ts @@ -34,10 +34,9 @@ export class TableCdkDataSource implements DataSource { private readonly cachedValues: Map = new Map(); private lastRowChange: StatefulTableRow | undefined; private readonly rowsChange$: Subject = new Subject(); - private readonly loadingStateSubject: Subject> = new Subject< - Observable - >(); - public loadingStateChange$: Observable> = this.loadingStateSubject.asObservable(); + private readonly loadingStateSubject: Subject = new Subject(); + + public loadingStateChange$: Observable = this.loadingStateSubject.asObservable(); public constructor( private readonly tableDataSourceProvider: TableDataSourceProvider, @@ -55,7 +54,7 @@ export class TableCdkDataSource implements DataSource { public connect(): Observable> { this.buildChangeObservable() .pipe( - tap(() => this.loadingStateSubject.next(NEVER)), + tap(() => this.loadingStateSubject.next({loading$: NEVER})), mergeMap(([columnConfigs, pageEvent, filter, changedColumn, changedRow]) => this.buildDataObservable(columnConfigs, pageEvent, filter, changedColumn, changedRow) ) @@ -65,7 +64,7 @@ export class TableCdkDataSource implements DataSource { return this.rowsChange$.pipe( tap(rows => this.cacheRows(rows)), tap(rows => this.cacheFilterableValues(rows)), - tap(rows => this.loadingStateSubject.next(of(rows))) + tap(rows => this.loadingStateSubject.next({loading$: of(rows), hide: rows.length > 1})) ); } @@ -271,7 +270,7 @@ export class TableCdkDataSource implements DataSource { : rows ), catchError(error => { - this.loadingStateSubject.next(throwError(error)); + this.loadingStateSubject.next({loading$: throwError(error)}); return []; }) @@ -331,3 +330,9 @@ export class TableCdkDataSource implements DataSource { } } } + + +export interface TableLoadingState { + loading$: Observable; + hide?: boolean; +} diff --git a/projects/components/src/table/table.component.scss b/projects/components/src/table/table.component.scss index 2010a3326..34d92be4e 100644 --- a/projects/components/src/table/table.component.scss +++ b/projects/components/src/table/table.component.scss @@ -1,11 +1,12 @@ @import 'mixins'; @import 'layout'; -:host { +.table { display: flex; flex-direction: column; height: 100%; width: 100%; + position: relative; } .title-row { @@ -18,6 +19,7 @@ .table { width: 100%; + flex: 1 1 0; overflow: auto; } @@ -122,7 +124,10 @@ } .state-watcher { - flex: 1 1; + height: 100%; + width: 100%; + position: absolute; + background: transparent; } .pagination-controls { diff --git a/projects/components/src/table/table.component.ts b/projects/components/src/table/table.component.ts index 35f04c9f4..7675baa70 100644 --- a/projects/components/src/table/table.component.ts +++ b/projects/components/src/table/table.component.ts @@ -45,126 +45,133 @@ import { } from './table-api'; import { TableColumnConfigExtended, TableService } from './table.service'; -// tslint:disable max-file-line-count +// tslint:disable: template-cyclomatic-complexity component-max-inline-declarations max-file-line-count @Component({ selector: 'ht-table', styleUrls: ['./table.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, template: ` - -
- -
+
+ +
+ +
- - - -
- - -
+ + +
+ + -
-
- +
+
+ + +
+ - - - - + + +
+
+ + + + + -
- - - - - - + + + + - - - - + + + + + + + + - - - - - - + + +
+ +
- - - -
- -
- - -
- + +
+ +
` }) diff --git a/projects/observability/src/pages/explorer/explorer.component.scss b/projects/observability/src/pages/explorer/explorer.component.scss index 41c06f9d4..e01cca1ac 100644 --- a/projects/observability/src/pages/explorer/explorer.component.scss +++ b/projects/observability/src/pages/explorer/explorer.component.scss @@ -16,7 +16,6 @@ .visualization-panel { padding-top: 8px; - .label { @include body-1-medium; } @@ -31,7 +30,7 @@ .results-panel { overflow: hidden; - + flex: 1 1 auto; .label { @include body-1-medium; }