Merge pull request #9522 from ArtemDzhereleiko/AD/bug-fix/display-columns-panel-scroll
Fixed display column panel in table widgets for scrolling long list columns
This commit is contained in:
commit
b84ad9ef0b
@ -503,17 +503,16 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit,
|
|||||||
$event.stopPropagation();
|
$event.stopPropagation();
|
||||||
}
|
}
|
||||||
const target = $event.target || $event.srcElement || $event.currentTarget;
|
const target = $event.target || $event.srcElement || $event.currentTarget;
|
||||||
const config = new OverlayConfig();
|
const config = new OverlayConfig({
|
||||||
config.backdropClass = 'cdk-overlay-transparent-backdrop';
|
panelClass: 'tb-panel-container',
|
||||||
config.hasBackdrop = true;
|
backdropClass: 'cdk-overlay-transparent-backdrop',
|
||||||
const connectedPosition: ConnectedPosition = {
|
hasBackdrop: true,
|
||||||
originX: 'end',
|
height: 'fit-content',
|
||||||
originY: 'bottom',
|
maxHeight: '75vh'
|
||||||
overlayX: 'end',
|
});
|
||||||
overlayY: 'top'
|
config.positionStrategy = this.overlay.position()
|
||||||
};
|
.flexibleConnectedTo(target as HTMLElement)
|
||||||
config.positionStrategy = this.overlay.position().flexibleConnectedTo(target as HTMLElement)
|
.withPositions(DEFAULT_OVERLAY_POSITIONS);
|
||||||
.withPositions([connectedPosition]);
|
|
||||||
|
|
||||||
const overlayRef = this.overlay.create(config);
|
const overlayRef = this.overlay.create(config);
|
||||||
overlayRef.backdropClick().subscribe(() => {
|
overlayRef.backdropClick().subscribe(() => {
|
||||||
@ -549,9 +548,18 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit,
|
|||||||
useValue: overlayRef
|
useValue: overlayRef
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const injector = Injector.create({parent: this.viewContainerRef.injector, providers});
|
const injector = Injector.create({parent: this.viewContainerRef.injector, providers});
|
||||||
overlayRef.attach(new ComponentPortal(DisplayColumnsPanelComponent,
|
const componentRef = overlayRef.attach(new ComponentPortal(DisplayColumnsPanelComponent,
|
||||||
this.viewContainerRef, injector));
|
this.viewContainerRef, injector));
|
||||||
|
|
||||||
|
const resizeWindows$ = fromEvent(window, 'resize').subscribe(() => {
|
||||||
|
overlayRef.updatePosition();
|
||||||
|
});
|
||||||
|
componentRef.onDestroy(() => {
|
||||||
|
resizeWindows$.unsubscribe();
|
||||||
|
});
|
||||||
|
|
||||||
this.ctx.detectChanges();
|
this.ctx.detectChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
min-width: 300px;
|
min-width: 300px;
|
||||||
overflow: hidden;
|
overflow: auto;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
box-shadow:
|
box-shadow:
|
||||||
|
|||||||
@ -46,7 +46,7 @@ import { deepClone, hashCode, isDefined, isNumber, isObject, isUndefined } from
|
|||||||
import cssjs from '@core/css/css';
|
import cssjs from '@core/css/css';
|
||||||
import { CollectionViewer, DataSource } from '@angular/cdk/collections';
|
import { CollectionViewer, DataSource } from '@angular/cdk/collections';
|
||||||
import { DataKeyType } from '@shared/models/telemetry/telemetry.models';
|
import { DataKeyType } from '@shared/models/telemetry/telemetry.models';
|
||||||
import { BehaviorSubject, merge, Observable, Subject } from 'rxjs';
|
import { BehaviorSubject, fromEvent, merge, Observable, Subject } from 'rxjs';
|
||||||
import { emptyPageData, PageData } from '@shared/models/page/page-data';
|
import { emptyPageData, PageData } from '@shared/models/page/page-data';
|
||||||
import { EntityId } from '@shared/models/id/entity-id';
|
import { EntityId } from '@shared/models/id/entity-id';
|
||||||
import { entityTypeTranslations } from '@shared/models/entity-type.models';
|
import { entityTypeTranslations } from '@shared/models/entity-type.models';
|
||||||
@ -83,7 +83,7 @@ import {
|
|||||||
TableWidgetSettings,
|
TableWidgetSettings,
|
||||||
widthStyle
|
widthStyle
|
||||||
} from '@home/components/widget/lib/table-widget.models';
|
} from '@home/components/widget/lib/table-widget.models';
|
||||||
import { ConnectedPosition, Overlay, OverlayConfig, OverlayRef } from '@angular/cdk/overlay';
|
import { Overlay, OverlayConfig, OverlayRef } from '@angular/cdk/overlay';
|
||||||
import { ComponentPortal } from '@angular/cdk/portal';
|
import { ComponentPortal } from '@angular/cdk/portal';
|
||||||
import {
|
import {
|
||||||
DISPLAY_COLUMNS_PANEL_DATA,
|
DISPLAY_COLUMNS_PANEL_DATA,
|
||||||
@ -106,6 +106,7 @@ import { ResizeObserver } from '@juggle/resize-observer';
|
|||||||
import { hidePageSizePixelValue } from '@shared/models/constants';
|
import { hidePageSizePixelValue } from '@shared/models/constants';
|
||||||
import { AggregationType } from '@shared/models/time/time.models';
|
import { AggregationType } from '@shared/models/time/time.models';
|
||||||
import { FormBuilder } from '@angular/forms';
|
import { FormBuilder } from '@angular/forms';
|
||||||
|
import { DEFAULT_OVERLAY_POSITIONS } from '@shared/models/overlay.models';
|
||||||
|
|
||||||
interface EntitiesTableWidgetSettings extends TableWidgetSettings {
|
interface EntitiesTableWidgetSettings extends TableWidgetSettings {
|
||||||
entitiesTitle: string;
|
entitiesTitle: string;
|
||||||
@ -462,18 +463,17 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
|
|||||||
if ($event) {
|
if ($event) {
|
||||||
$event.stopPropagation();
|
$event.stopPropagation();
|
||||||
}
|
}
|
||||||
const target = $event.target || $event.currentTarget;
|
const target = $event.target || $event.srcElement || $event.currentTarget;
|
||||||
const config = new OverlayConfig();
|
const config = new OverlayConfig({
|
||||||
config.backdropClass = 'cdk-overlay-transparent-backdrop';
|
panelClass: 'tb-panel-container',
|
||||||
config.hasBackdrop = true;
|
backdropClass: 'cdk-overlay-transparent-backdrop',
|
||||||
const connectedPosition: ConnectedPosition = {
|
hasBackdrop: true,
|
||||||
originX: 'end',
|
height: 'fit-content',
|
||||||
originY: 'bottom',
|
maxHeight: '75vh'
|
||||||
overlayX: 'end',
|
});
|
||||||
overlayY: 'top'
|
config.positionStrategy = this.overlay.position()
|
||||||
};
|
.flexibleConnectedTo(target as HTMLElement)
|
||||||
config.positionStrategy = this.overlay.position().flexibleConnectedTo(target as HTMLElement)
|
.withPositions(DEFAULT_OVERLAY_POSITIONS);
|
||||||
.withPositions([connectedPosition]);
|
|
||||||
|
|
||||||
const overlayRef = this.overlay.create(config);
|
const overlayRef = this.overlay.create(config);
|
||||||
overlayRef.backdropClick().subscribe(() => {
|
overlayRef.backdropClick().subscribe(() => {
|
||||||
@ -481,11 +481,11 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
|
|||||||
});
|
});
|
||||||
|
|
||||||
const columns: DisplayColumn[] = this.columns.map(column => ({
|
const columns: DisplayColumn[] = this.columns.map(column => ({
|
||||||
title: column.title,
|
title: column.title,
|
||||||
def: column.def,
|
def: column.def,
|
||||||
display: this.displayedColumns.indexOf(column.def) > -1,
|
display: this.displayedColumns.indexOf(column.def) > -1,
|
||||||
selectable: this.columnSelectionAvailability[column.def]
|
selectable: this.columnSelectionAvailability[column.def]
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const providers: StaticProvider[] = [
|
const providers: StaticProvider[] = [
|
||||||
{
|
{
|
||||||
@ -506,9 +506,18 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
|
|||||||
useValue: overlayRef
|
useValue: overlayRef
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const injector = Injector.create({parent: this.viewContainerRef.injector, providers});
|
const injector = Injector.create({parent: this.viewContainerRef.injector, providers});
|
||||||
overlayRef.attach(new ComponentPortal(DisplayColumnsPanelComponent,
|
const componentRef = overlayRef.attach(new ComponentPortal(DisplayColumnsPanelComponent,
|
||||||
this.viewContainerRef, injector));
|
this.viewContainerRef, injector));
|
||||||
|
|
||||||
|
const resizeWindows$ = fromEvent(window, 'resize').subscribe(() => {
|
||||||
|
overlayRef.updatePosition();
|
||||||
|
});
|
||||||
|
componentRef.onDestroy(() => {
|
||||||
|
resizeWindows$.unsubscribe();
|
||||||
|
});
|
||||||
|
|
||||||
this.ctx.detectChanges();
|
this.ctx.detectChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -56,7 +56,7 @@ import cssjs from '@core/css/css';
|
|||||||
import { PageLink } from '@shared/models/page/page-link';
|
import { PageLink } from '@shared/models/page/page-link';
|
||||||
import { Direction, SortOrder, sortOrderFromString } from '@shared/models/page/sort-order';
|
import { Direction, SortOrder, sortOrderFromString } from '@shared/models/page/sort-order';
|
||||||
import { CollectionViewer, DataSource } from '@angular/cdk/collections';
|
import { CollectionViewer, DataSource } from '@angular/cdk/collections';
|
||||||
import { BehaviorSubject, merge, Observable, of, Subject, Subscription } from 'rxjs';
|
import { BehaviorSubject, fromEvent, merge, Observable, of, Subject, Subscription } from 'rxjs';
|
||||||
import { emptyPageData, PageData } from '@shared/models/page/page-data';
|
import { emptyPageData, PageData } from '@shared/models/page/page-data';
|
||||||
import { catchError, debounceTime, distinctUntilChanged, map, skip, startWith, takeUntil } from 'rxjs/operators';
|
import { catchError, debounceTime, distinctUntilChanged, map, skip, startWith, takeUntil } from 'rxjs/operators';
|
||||||
import { MatPaginator } from '@angular/material/paginator';
|
import { MatPaginator } from '@angular/material/paginator';
|
||||||
@ -81,7 +81,7 @@ import {
|
|||||||
TableWidgetDataKeySettings,
|
TableWidgetDataKeySettings,
|
||||||
TableWidgetSettings
|
TableWidgetSettings
|
||||||
} from '@home/components/widget/lib/table-widget.models';
|
} from '@home/components/widget/lib/table-widget.models';
|
||||||
import { ConnectedPosition, Overlay, OverlayConfig, OverlayRef } from '@angular/cdk/overlay';
|
import { Overlay, OverlayConfig, OverlayRef } from '@angular/cdk/overlay';
|
||||||
import { SubscriptionEntityInfo } from '@core/api/widget-api.models';
|
import { SubscriptionEntityInfo } from '@core/api/widget-api.models';
|
||||||
import { DatePipe } from '@angular/common';
|
import { DatePipe } from '@angular/common';
|
||||||
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
||||||
@ -93,6 +93,7 @@ import {
|
|||||||
} from '@home/components/widget/lib/display-columns-panel.component';
|
} from '@home/components/widget/lib/display-columns-panel.component';
|
||||||
import { ComponentPortal } from '@angular/cdk/portal';
|
import { ComponentPortal } from '@angular/cdk/portal';
|
||||||
import { FormBuilder } from '@angular/forms';
|
import { FormBuilder } from '@angular/forms';
|
||||||
|
import { DEFAULT_OVERLAY_POSITIONS } from '@shared/models/overlay.models';
|
||||||
|
|
||||||
export interface TimeseriesTableWidgetSettings extends TableWidgetSettings {
|
export interface TimeseriesTableWidgetSettings extends TableWidgetSettings {
|
||||||
showTimestamp: boolean;
|
showTimestamp: boolean;
|
||||||
@ -411,23 +412,23 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI
|
|||||||
$event.stopPropagation();
|
$event.stopPropagation();
|
||||||
}
|
}
|
||||||
if (this.sources.length) {
|
if (this.sources.length) {
|
||||||
const target = $event.target || $event.currentTarget;
|
const target = $event.target || $event.srcElement || $event.currentTarget;
|
||||||
const config = new OverlayConfig();
|
const config = new OverlayConfig({
|
||||||
config.backdropClass = 'cdk-overlay-transparent-backdrop';
|
panelClass: 'tb-panel-container',
|
||||||
config.hasBackdrop = true;
|
backdropClass: 'cdk-overlay-transparent-backdrop',
|
||||||
const connectedPosition: ConnectedPosition = {
|
hasBackdrop: true,
|
||||||
originX: 'end',
|
height: 'fit-content',
|
||||||
originY: 'bottom',
|
maxHeight: '75vh'
|
||||||
overlayX: 'end',
|
});
|
||||||
overlayY: 'top'
|
config.positionStrategy = this.overlay.position()
|
||||||
};
|
.flexibleConnectedTo(target as HTMLElement)
|
||||||
config.positionStrategy = this.overlay.position().flexibleConnectedTo(target as HTMLElement)
|
.withPositions(DEFAULT_OVERLAY_POSITIONS);
|
||||||
.withPositions([connectedPosition]);
|
|
||||||
|
|
||||||
const overlayRef = this.overlay.create(config);
|
const overlayRef = this.overlay.create(config);
|
||||||
overlayRef.backdropClick().subscribe(() => {
|
overlayRef.backdropClick().subscribe(() => {
|
||||||
overlayRef.dispose();
|
overlayRef.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
const source = this.sources[this.sourceIndex];
|
const source = this.sources[this.sourceIndex];
|
||||||
|
|
||||||
this.prepareDisplayedColumn();
|
this.prepareDisplayedColumn();
|
||||||
@ -450,8 +451,16 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI
|
|||||||
];
|
];
|
||||||
|
|
||||||
const injector = Injector.create({parent: this.viewContainerRef.injector, providers});
|
const injector = Injector.create({parent: this.viewContainerRef.injector, providers});
|
||||||
overlayRef.attach(new ComponentPortal(DisplayColumnsPanelComponent,
|
const componentRef = overlayRef.attach(new ComponentPortal(DisplayColumnsPanelComponent,
|
||||||
this.viewContainerRef, injector));
|
this.viewContainerRef, injector));
|
||||||
|
|
||||||
|
const resizeWindows$ = fromEvent(window, 'resize').subscribe(() => {
|
||||||
|
overlayRef.updatePosition();
|
||||||
|
});
|
||||||
|
componentRef.onDestroy(() => {
|
||||||
|
resizeWindows$.unsubscribe();
|
||||||
|
});
|
||||||
|
|
||||||
this.ctx.detectChanges();
|
this.ctx.detectChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -268,7 +268,7 @@ pre.tb-highlight {
|
|||||||
letter-spacing: normal;
|
letter-spacing: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tb-timewindow-panel, .tb-legend-config-panel, .tb-filter-panel {
|
.tb-timewindow-panel, .tb-legend-config-panel, .tb-filter-panel, .tb-panel-container {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user