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) {
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 (!widgetConfig.alarmFilterConfig) {
@ -429,7 +429,7 @@ export class DashboardUtilsService {
targetLayout: DashboardLayoutId,
widget: Widget,
originalColumns?: number,
originalSize?: {sizeX: number; sizeY: number},
originalSize?: {sizeX: number, sizeY: number},
row?: number,
column?: number): void {
const dashboardConfiguration = dashboard.configuration;
@ -502,7 +502,7 @@ export class DashboardUtilsService {
this.removeUnusedWidgets(dashboard);
}
public isSingleLayoutDashboard(dashboard: Dashboard): {state: string; layout: DashboardLayoutId} {
public isSingleLayoutDashboard(dashboard: Dashboard): {state: string, layout: DashboardLayoutId} {
const dashboardConfiguration = dashboard.configuration;
const states = dashboardConfiguration.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">
<span *ngIf="entitiesTableConfig.tableTitle" class="tb-entity-table-title">{{ entitiesTableConfig.tableTitle }}</span>
<tb-anchor #entityTableHeader></tb-anchor>
<tb-timewindow *ngIf="entitiesTableConfig.useTimePageLink"
[(ngModel)]="timewindow" (ngModelChange)="onTimewindowChange()"
asButton strokedButton historyOnly
[forAllTimeEnabled]="entitiesTableConfig.forAllTimeEnabled">
</tb-timewindow>
<tb-timewindow *ngIf="entitiesTableConfig.useTimePageLink" [(ngModel)]="timewindow"
(ngModelChange)="onTimewindowChange()"
asButton strokedButton historyOnly [forAllTimeEnabled]="entitiesTableConfig.forAllTimeEnabled"></tb-timewindow>
</div>
<span fxFlex></span>
<div [fxShow]="addEnabled()">

View File

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

View File

@ -234,7 +234,7 @@ export class TimewindowComponent implements ControlValueAccessor {
}
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();
if (this.onHistoryOnlyChanged()) {
setTimeout(() => {

View File

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