UI: Revert unnessery changes and change function order

This commit is contained in:
Vladyslav_Prykhodko 2023-05-26 16:57:50 +03:00
parent ee91cc3033
commit fdd6ebcb2c
5 changed files with 17 additions and 19 deletions

View File

@ -235,7 +235,7 @@ export class DashboardUtilsService {
}); });
if (type === widgetType.latest) { if (type === widgetType.latest) {
const onlyHistoryTimewindow = datasourcesHasOnlyComparisonAggregation(widgetConfig.datasources); const onlyHistoryTimewindow = datasourcesHasOnlyComparisonAggregation(widgetConfig.datasources);
widgetConfig.timewindow = initModelFromDefaultTimewindow(widgetConfig.timewindow, true, this.timeService, onlyHistoryTimewindow); widgetConfig.timewindow = initModelFromDefaultTimewindow(widgetConfig.timewindow, true, onlyHistoryTimewindow, this.timeService);
} }
if (type === widgetType.alarm) { if (type === widgetType.alarm) {
if (!widgetConfig.alarmFilterConfig) { if (!widgetConfig.alarmFilterConfig) {
@ -429,7 +429,7 @@ export class DashboardUtilsService {
targetLayout: DashboardLayoutId, targetLayout: DashboardLayoutId,
widget: Widget, widget: Widget,
originalColumns?: number, originalColumns?: number,
originalSize?: {sizeX: number; sizeY: number}, originalSize?: {sizeX: number, sizeY: number},
row?: number, row?: number,
column?: number): void { column?: number): void {
const dashboardConfiguration = dashboard.configuration; const dashboardConfiguration = dashboard.configuration;
@ -502,7 +502,7 @@ export class DashboardUtilsService {
this.removeUnusedWidgets(dashboard); this.removeUnusedWidgets(dashboard);
} }
public isSingleLayoutDashboard(dashboard: Dashboard): {state: string; layout: DashboardLayoutId} { public isSingleLayoutDashboard(dashboard: Dashboard): {state: string, layout: DashboardLayoutId} {
const dashboardConfiguration = dashboard.configuration; const dashboardConfiguration = dashboard.configuration;
const states = dashboardConfiguration.states; const states = dashboardConfiguration.states;
const stateKeys = Object.keys(states); const stateKeys = Object.keys(states);

View File

@ -40,11 +40,9 @@
<div fxLayout="row" fxLayoutAlign="start center" fxLayout.xs="column" fxLayoutAlign.xs="center start" class="title-container"> <div fxLayout="row" fxLayoutAlign="start center" fxLayout.xs="column" fxLayoutAlign.xs="center start" class="title-container">
<span *ngIf="entitiesTableConfig.tableTitle" class="tb-entity-table-title">{{ entitiesTableConfig.tableTitle }}</span> <span *ngIf="entitiesTableConfig.tableTitle" class="tb-entity-table-title">{{ entitiesTableConfig.tableTitle }}</span>
<tb-anchor #entityTableHeader></tb-anchor> <tb-anchor #entityTableHeader></tb-anchor>
<tb-timewindow *ngIf="entitiesTableConfig.useTimePageLink" <tb-timewindow *ngIf="entitiesTableConfig.useTimePageLink" [(ngModel)]="timewindow"
[(ngModel)]="timewindow" (ngModelChange)="onTimewindowChange()" (ngModelChange)="onTimewindowChange()"
asButton strokedButton historyOnly asButton strokedButton historyOnly [forAllTimeEnabled]="entitiesTableConfig.forAllTimeEnabled"></tb-timewindow>
[forAllTimeEnabled]="entitiesTableConfig.forAllTimeEnabled">
</tb-timewindow>
</div> </div>
<span fxFlex></span> <span fxFlex></span>
<div [fxShow]="addEnabled()"> <div [fxShow]="addEnabled()">

View File

@ -24,7 +24,6 @@ import {
EventEmitter, EventEmitter,
Input, Input,
OnChanges, OnChanges,
OnDestroy,
OnInit, OnInit,
SimpleChanges, SimpleChanges,
ViewChild ViewChild
@ -73,7 +72,7 @@ import { EntityDetailsPanelComponent } from '@home/components/entity/entity-deta
styleUrls: ['./entities-table.component.scss'], styleUrls: ['./entities-table.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush changeDetection: ChangeDetectionStrategy.OnPush
}) })
export class EntitiesTableComponent extends PageComponent implements IEntitiesTableComponent, AfterViewInit, OnInit, OnChanges, OnDestroy { export class EntitiesTableComponent extends PageComponent implements IEntitiesTableComponent, AfterViewInit, OnInit, OnChanges {
@Input() @Input()
entitiesTableConfig: EntityTableConfig<BaseData<HasId>>; entitiesTableConfig: EntityTableConfig<BaseData<HasId>>;
@ -163,7 +162,6 @@ export class EntitiesTableComponent extends PageComponent implements IEntitiesTa
} }
ngOnDestroy() { ngOnDestroy() {
super.ngOnDestroy();
if (this.widgetResize$) { if (this.widgetResize$) {
this.widgetResize$.disconnect(); this.widgetResize$.disconnect();
} }
@ -368,10 +366,12 @@ export class EntitiesTableComponent extends PageComponent implements IEntitiesTa
); );
if (this.displayPagination) { if (this.displayPagination) {
paginatorSubscription$ = this.paginator.page.asObservable().pipe( paginatorSubscription$ = this.paginator.page.asObservable().pipe(
map((data) => ({ map((data) => {
page: data.pageIndex === 0 ? null : data.pageIndex, return {
pageSize: data.pageSize === this.defaultPageSize ? null : data.pageSize page: data.pageIndex === 0 ? null : data.pageIndex,
})) pageSize: data.pageSize === this.defaultPageSize ? null : data.pageSize
};
})
); );
} }
this.updateDataSubscription = ((this.displayPagination ? merge(sortSubscription$, paginatorSubscription$) this.updateDataSubscription = ((this.displayPagination ? merge(sortSubscription$, paginatorSubscription$)
@ -421,8 +421,8 @@ export class EntitiesTableComponent extends PageComponent implements IEntitiesTa
} }
} }
private getTimePageLinkInterval(): {startTime?: number; endTime?: number} { private getTimePageLinkInterval(): {startTime?: number, endTime?: number} {
const interval: {startTime?: number; endTime?: number} = {}; const interval: {startTime?: number, endTime?: number} = {};
switch (this.timewindow.history.historyType) { switch (this.timewindow.history.historyType) {
case HistoryWindowType.LAST_INTERVAL: case HistoryWindowType.LAST_INTERVAL:
const currentTime = Date.now(); const currentTime = Date.now();

View File

@ -234,7 +234,7 @@ export class TimewindowComponent implements ControlValueAccessor {
} }
writeValue(obj: Timewindow): void { writeValue(obj: Timewindow): void {
this.innerValue = initModelFromDefaultTimewindow(obj, this.quickIntervalOnly, this.timeService, this.historyOnly); this.innerValue = initModelFromDefaultTimewindow(obj, this.quickIntervalOnly, this.historyOnly, this.timeService);
this.timewindowDisabled = this.isTimewindowDisabled(); this.timewindowDisabled = this.isTimewindowDisabled();
if (this.onHistoryOnlyChanged()) { if (this.onHistoryOnlyChanged()) {
setTimeout(() => { setTimeout(() => {

View File

@ -246,7 +246,7 @@ const getTimewindowType = (timewindow: Timewindow): TimewindowType => {
}; };
export const initModelFromDefaultTimewindow = (value: Timewindow, quickIntervalOnly: boolean, export const initModelFromDefaultTimewindow = (value: Timewindow, quickIntervalOnly: boolean,
timeService: TimeService, historyOnly: boolean): Timewindow => { historyOnly: boolean, timeService: TimeService): Timewindow => {
const model = defaultTimewindow(timeService); const model = defaultTimewindow(timeService);
if (value) { if (value) {
model.hideInterval = value.hideInterval; model.hideInterval = value.hideInterval;