19 changed files with 726 additions and 37 deletions
@ -0,0 +1,67 @@ |
|||||
|
<!-- |
||||
|
|
||||
|
Copyright © 2016-2022 The Thingsboard Authors |
||||
|
|
||||
|
Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
you may not use this file except in compliance with the License. |
||||
|
You may obtain a copy of the License at |
||||
|
|
||||
|
http://www.apache.org/licenses/LICENSE-2.0 |
||||
|
|
||||
|
Unless required by applicable law or agreed to in writing, software |
||||
|
distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
See the License for the specific language governing permissions and |
||||
|
limitations under the License. |
||||
|
|
||||
|
--> |
||||
|
<section class="tb-widget-settings" [formGroup]="timeseriesTableKeySettingsForm" fxLayout="column"> |
||||
|
<fieldset class="fields-group fields-group-slider"> |
||||
|
<legend class="group-title" translate>widgets.table.cell-style</legend> |
||||
|
<mat-expansion-panel class="tb-settings" [expanded]="timeseriesTableKeySettingsForm.get('useCellStyleFunction').value"> |
||||
|
<mat-expansion-panel-header fxLayout="row wrap"> |
||||
|
<mat-panel-title> |
||||
|
<mat-slide-toggle formControlName="useCellStyleFunction" (click)="$event.stopPropagation()" |
||||
|
fxLayoutAlign="center"> |
||||
|
{{ 'widgets.table.use-cell-style-function' | translate }} |
||||
|
</mat-slide-toggle> |
||||
|
</mat-panel-title> |
||||
|
<mat-panel-description fxLayoutAlign="end center" fxHide.xs translate> |
||||
|
widget-config.advanced-settings |
||||
|
</mat-panel-description> |
||||
|
</mat-expansion-panel-header> |
||||
|
<ng-template matExpansionPanelContent> |
||||
|
<tb-js-func formControlName="cellStyleFunction" |
||||
|
[globalVariables]="functionScopeVariables" |
||||
|
[functionArgs]="['value', 'rowData', 'ctx']" |
||||
|
functionTitle="{{ 'widgets.table.cell-style-function' | translate }}" |
||||
|
helpId="widget/lib/timeseries/cell_style_fn"> |
||||
|
</tb-js-func> |
||||
|
</ng-template> |
||||
|
</mat-expansion-panel> |
||||
|
</fieldset> |
||||
|
<fieldset class="fields-group fields-group-slider"> |
||||
|
<legend class="group-title" translate>widgets.table.cell-content</legend> |
||||
|
<mat-expansion-panel class="tb-settings" [expanded]="timeseriesTableKeySettingsForm.get('useCellContentFunction').value"> |
||||
|
<mat-expansion-panel-header fxLayout="row wrap"> |
||||
|
<mat-panel-title> |
||||
|
<mat-slide-toggle formControlName="useCellContentFunction" (click)="$event.stopPropagation()" |
||||
|
fxLayoutAlign="center"> |
||||
|
{{ 'widgets.table.use-cell-content-function' | translate }} |
||||
|
</mat-slide-toggle> |
||||
|
</mat-panel-title> |
||||
|
<mat-panel-description fxLayoutAlign="end center" fxHide.xs translate> |
||||
|
widget-config.advanced-settings |
||||
|
</mat-panel-description> |
||||
|
</mat-expansion-panel-header> |
||||
|
<ng-template matExpansionPanelContent> |
||||
|
<tb-js-func formControlName="cellContentFunction" |
||||
|
[globalVariables]="functionScopeVariables" |
||||
|
[functionArgs]="['value', 'rowData', 'ctx']" |
||||
|
functionTitle="{{ 'widgets.table.cell-content-function' | translate }}" |
||||
|
helpId="widget/lib/timeseries/cell_content_fn"> |
||||
|
</tb-js-func> |
||||
|
</ng-template> |
||||
|
</mat-expansion-panel> |
||||
|
</fieldset> |
||||
|
</section> |
||||
@ -0,0 +1,80 @@ |
|||||
|
///
|
||||
|
/// Copyright © 2016-2022 The Thingsboard Authors
|
||||
|
///
|
||||
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
/// you may not use this file except in compliance with the License.
|
||||
|
/// You may obtain a copy of the License at
|
||||
|
///
|
||||
|
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
///
|
||||
|
/// Unless required by applicable law or agreed to in writing, software
|
||||
|
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
/// See the License for the specific language governing permissions and
|
||||
|
/// limitations under the License.
|
||||
|
///
|
||||
|
|
||||
|
import { Component } from '@angular/core'; |
||||
|
import { WidgetSettings, WidgetSettingsComponent } from '@shared/models/widget.models'; |
||||
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; |
||||
|
import { Store } from '@ngrx/store'; |
||||
|
import { AppState } from '@core/core.state'; |
||||
|
|
||||
|
@Component({ |
||||
|
selector: 'tb-timeseries-table-key-settings', |
||||
|
templateUrl: './timeseries-table-key-settings.component.html', |
||||
|
styleUrls: ['./widget-settings.scss'] |
||||
|
}) |
||||
|
export class TimeseriesTableKeySettingsComponent extends WidgetSettingsComponent { |
||||
|
|
||||
|
timeseriesTableKeySettingsForm: FormGroup; |
||||
|
|
||||
|
constructor(protected store: Store<AppState>, |
||||
|
private fb: FormBuilder) { |
||||
|
super(store); |
||||
|
} |
||||
|
|
||||
|
protected settingsForm(): FormGroup { |
||||
|
return this.timeseriesTableKeySettingsForm; |
||||
|
} |
||||
|
|
||||
|
protected defaultSettings(): WidgetSettings { |
||||
|
return { |
||||
|
useCellStyleFunction: false, |
||||
|
cellStyleFunction: '', |
||||
|
useCellContentFunction: false, |
||||
|
cellContentFunction: '' |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
protected onSettingsSet(settings: WidgetSettings) { |
||||
|
this.timeseriesTableKeySettingsForm = this.fb.group({ |
||||
|
useCellStyleFunction: [settings.useCellStyleFunction, []], |
||||
|
cellStyleFunction: [settings.cellStyleFunction, [Validators.required]], |
||||
|
useCellContentFunction: [settings.useCellContentFunction, []], |
||||
|
cellContentFunction: [settings.cellContentFunction, [Validators.required]], |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
protected validatorTriggers(): string[] { |
||||
|
return ['useCellStyleFunction', 'useCellContentFunction']; |
||||
|
} |
||||
|
|
||||
|
protected updateValidators(emitEvent: boolean) { |
||||
|
const useCellStyleFunction: boolean = this.timeseriesTableKeySettingsForm.get('useCellStyleFunction').value; |
||||
|
const useCellContentFunction: boolean = this.timeseriesTableKeySettingsForm.get('useCellContentFunction').value; |
||||
|
if (useCellStyleFunction) { |
||||
|
this.timeseriesTableKeySettingsForm.get('cellStyleFunction').enable(); |
||||
|
} else { |
||||
|
this.timeseriesTableKeySettingsForm.get('cellStyleFunction').disable(); |
||||
|
} |
||||
|
if (useCellContentFunction) { |
||||
|
this.timeseriesTableKeySettingsForm.get('cellContentFunction').enable(); |
||||
|
} else { |
||||
|
this.timeseriesTableKeySettingsForm.get('cellContentFunction').disable(); |
||||
|
} |
||||
|
this.timeseriesTableKeySettingsForm.get('cellStyleFunction').updateValueAndValidity({emitEvent}); |
||||
|
this.timeseriesTableKeySettingsForm.get('cellContentFunction').updateValueAndValidity({emitEvent}); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,74 @@ |
|||||
|
<!-- |
||||
|
|
||||
|
Copyright © 2016-2022 The Thingsboard Authors |
||||
|
|
||||
|
Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
you may not use this file except in compliance with the License. |
||||
|
You may obtain a copy of the License at |
||||
|
|
||||
|
http://www.apache.org/licenses/LICENSE-2.0 |
||||
|
|
||||
|
Unless required by applicable law or agreed to in writing, software |
||||
|
distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
See the License for the specific language governing permissions and |
||||
|
limitations under the License. |
||||
|
|
||||
|
--> |
||||
|
<section class="tb-widget-settings" [formGroup]="timeseriesTableLatestKeySettingsForm" fxLayout="column"> |
||||
|
<mat-slide-toggle class="mat-slide" formControlName="show"> |
||||
|
{{ 'widgets.table.show-latest-data-column' | translate }} |
||||
|
</mat-slide-toggle> |
||||
|
<mat-form-field [fxShow]="timeseriesTableLatestKeySettingsForm.get('show').value" fxFlex class="mat-block"> |
||||
|
<mat-label translate>widgets.table.latest-data-column-order</mat-label> |
||||
|
<input matInput type="number" step="1" formControlName="order"> |
||||
|
</mat-form-field> |
||||
|
<fieldset [fxShow]="timeseriesTableLatestKeySettingsForm.get('show').value" class="fields-group fields-group-slider"> |
||||
|
<legend class="group-title" translate>widgets.table.cell-style</legend> |
||||
|
<mat-expansion-panel class="tb-settings" [expanded]="timeseriesTableLatestKeySettingsForm.get('useCellStyleFunction').value"> |
||||
|
<mat-expansion-panel-header fxLayout="row wrap"> |
||||
|
<mat-panel-title> |
||||
|
<mat-slide-toggle formControlName="useCellStyleFunction" (click)="$event.stopPropagation()" |
||||
|
fxLayoutAlign="center"> |
||||
|
{{ 'widgets.table.use-cell-style-function' | translate }} |
||||
|
</mat-slide-toggle> |
||||
|
</mat-panel-title> |
||||
|
<mat-panel-description fxLayoutAlign="end center" fxHide.xs translate> |
||||
|
widget-config.advanced-settings |
||||
|
</mat-panel-description> |
||||
|
</mat-expansion-panel-header> |
||||
|
<ng-template matExpansionPanelContent> |
||||
|
<tb-js-func formControlName="cellStyleFunction" |
||||
|
[globalVariables]="functionScopeVariables" |
||||
|
[functionArgs]="['value', 'rowData', 'ctx']" |
||||
|
functionTitle="{{ 'widgets.table.cell-style-function' | translate }}" |
||||
|
helpId="widget/lib/timeseries/cell_style_fn"> |
||||
|
</tb-js-func> |
||||
|
</ng-template> |
||||
|
</mat-expansion-panel> |
||||
|
</fieldset> |
||||
|
<fieldset [fxShow]="timeseriesTableLatestKeySettingsForm.get('show').value" class="fields-group fields-group-slider"> |
||||
|
<legend class="group-title" translate>widgets.table.cell-content</legend> |
||||
|
<mat-expansion-panel class="tb-settings" [expanded]="timeseriesTableLatestKeySettingsForm.get('useCellContentFunction').value"> |
||||
|
<mat-expansion-panel-header fxLayout="row wrap"> |
||||
|
<mat-panel-title> |
||||
|
<mat-slide-toggle formControlName="useCellContentFunction" (click)="$event.stopPropagation()" |
||||
|
fxLayoutAlign="center"> |
||||
|
{{ 'widgets.table.use-cell-content-function' | translate }} |
||||
|
</mat-slide-toggle> |
||||
|
</mat-panel-title> |
||||
|
<mat-panel-description fxLayoutAlign="end center" fxHide.xs translate> |
||||
|
widget-config.advanced-settings |
||||
|
</mat-panel-description> |
||||
|
</mat-expansion-panel-header> |
||||
|
<ng-template matExpansionPanelContent> |
||||
|
<tb-js-func formControlName="cellContentFunction" |
||||
|
[globalVariables]="functionScopeVariables" |
||||
|
[functionArgs]="['value', 'rowData', 'ctx']" |
||||
|
functionTitle="{{ 'widgets.table.cell-content-function' | translate }}" |
||||
|
helpId="widget/lib/timeseries/cell_content_fn"> |
||||
|
</tb-js-func> |
||||
|
</ng-template> |
||||
|
</mat-expansion-panel> |
||||
|
</fieldset> |
||||
|
</section> |
||||
@ -0,0 +1,96 @@ |
|||||
|
///
|
||||
|
/// Copyright © 2016-2022 The Thingsboard Authors
|
||||
|
///
|
||||
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
/// you may not use this file except in compliance with the License.
|
||||
|
/// You may obtain a copy of the License at
|
||||
|
///
|
||||
|
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
///
|
||||
|
/// Unless required by applicable law or agreed to in writing, software
|
||||
|
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
/// See the License for the specific language governing permissions and
|
||||
|
/// limitations under the License.
|
||||
|
///
|
||||
|
|
||||
|
import { Component } from '@angular/core'; |
||||
|
import { WidgetSettings, WidgetSettingsComponent } from '@shared/models/widget.models'; |
||||
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; |
||||
|
import { Store } from '@ngrx/store'; |
||||
|
import { AppState } from '@core/core.state'; |
||||
|
|
||||
|
@Component({ |
||||
|
selector: 'tb-timeseries-table-latest-key-settings', |
||||
|
templateUrl: './timeseries-table-latest-key-settings.component.html', |
||||
|
styleUrls: ['./widget-settings.scss'] |
||||
|
}) |
||||
|
export class TimeseriesTableLatestKeySettingsComponent extends WidgetSettingsComponent { |
||||
|
|
||||
|
timeseriesTableLatestKeySettingsForm: FormGroup; |
||||
|
|
||||
|
constructor(protected store: Store<AppState>, |
||||
|
private fb: FormBuilder) { |
||||
|
super(store); |
||||
|
} |
||||
|
|
||||
|
protected settingsForm(): FormGroup { |
||||
|
return this.timeseriesTableLatestKeySettingsForm; |
||||
|
} |
||||
|
|
||||
|
protected defaultSettings(): WidgetSettings { |
||||
|
return { |
||||
|
show: true, |
||||
|
useCellStyleFunction: false, |
||||
|
cellStyleFunction: '', |
||||
|
useCellContentFunction: false, |
||||
|
cellContentFunction: '' |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
protected onSettingsSet(settings: WidgetSettings) { |
||||
|
this.timeseriesTableLatestKeySettingsForm = this.fb.group({ |
||||
|
show: [settings.show, []], |
||||
|
order: [settings.order, []], |
||||
|
useCellStyleFunction: [settings.useCellStyleFunction, []], |
||||
|
cellStyleFunction: [settings.cellStyleFunction, [Validators.required]], |
||||
|
useCellContentFunction: [settings.useCellContentFunction, []], |
||||
|
cellContentFunction: [settings.cellContentFunction, [Validators.required]], |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
protected validatorTriggers(): string[] { |
||||
|
return ['show', 'useCellStyleFunction', 'useCellContentFunction']; |
||||
|
} |
||||
|
|
||||
|
protected updateValidators(emitEvent: boolean) { |
||||
|
const show: boolean = this.timeseriesTableLatestKeySettingsForm.get('show').value; |
||||
|
if (show) { |
||||
|
this.timeseriesTableLatestKeySettingsForm.get('order').enable(); |
||||
|
this.timeseriesTableLatestKeySettingsForm.get('useCellStyleFunction').enable({emitEvent: false}); |
||||
|
this.timeseriesTableLatestKeySettingsForm.get('useCellContentFunction').enable({emitEvent: false}); |
||||
|
const useCellStyleFunction: boolean = this.timeseriesTableLatestKeySettingsForm.get('useCellStyleFunction').value; |
||||
|
const useCellContentFunction: boolean = this.timeseriesTableLatestKeySettingsForm.get('useCellContentFunction').value; |
||||
|
if (useCellStyleFunction) { |
||||
|
this.timeseriesTableLatestKeySettingsForm.get('cellStyleFunction').enable(); |
||||
|
} else { |
||||
|
this.timeseriesTableLatestKeySettingsForm.get('cellStyleFunction').disable(); |
||||
|
} |
||||
|
if (useCellContentFunction) { |
||||
|
this.timeseriesTableLatestKeySettingsForm.get('cellContentFunction').enable(); |
||||
|
} else { |
||||
|
this.timeseriesTableLatestKeySettingsForm.get('cellContentFunction').disable(); |
||||
|
} |
||||
|
} else { |
||||
|
this.timeseriesTableLatestKeySettingsForm.get('order').disable(); |
||||
|
this.timeseriesTableLatestKeySettingsForm.get('useCellStyleFunction').disable({emitEvent: false}); |
||||
|
this.timeseriesTableLatestKeySettingsForm.get('cellStyleFunction').disable(); |
||||
|
this.timeseriesTableLatestKeySettingsForm.get('useCellContentFunction').disable({emitEvent: false}); |
||||
|
this.timeseriesTableLatestKeySettingsForm.get('cellContentFunction').disable(); |
||||
|
} |
||||
|
this.timeseriesTableLatestKeySettingsForm.get('order').updateValueAndValidity({emitEvent}); |
||||
|
this.timeseriesTableLatestKeySettingsForm.get('cellStyleFunction').updateValueAndValidity({emitEvent}); |
||||
|
this.timeseriesTableLatestKeySettingsForm.get('cellContentFunction').updateValueAndValidity({emitEvent}); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,95 @@ |
|||||
|
<!-- |
||||
|
|
||||
|
Copyright © 2016-2022 The Thingsboard Authors |
||||
|
|
||||
|
Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
you may not use this file except in compliance with the License. |
||||
|
You may obtain a copy of the License at |
||||
|
|
||||
|
http://www.apache.org/licenses/LICENSE-2.0 |
||||
|
|
||||
|
Unless required by applicable law or agreed to in writing, software |
||||
|
distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
See the License for the specific language governing permissions and |
||||
|
limitations under the License. |
||||
|
|
||||
|
--> |
||||
|
<section class="tb-widget-settings" [formGroup]="timeseriesTableWidgetSettingsForm" fxLayout="column"> |
||||
|
<fieldset class="fields-group"> |
||||
|
<legend class="group-title" translate>widgets.table.common-table-settings</legend> |
||||
|
<section fxLayout="column" fxLayout.gt-sm="row" fxLayoutGap="8px"> |
||||
|
<section fxLayout="column" fxFlex> |
||||
|
<mat-checkbox formControlName="enableSearch" style="margin-bottom: 16px;"> |
||||
|
{{ 'widgets.table.enable-search' | translate }} |
||||
|
</mat-checkbox> |
||||
|
</section> |
||||
|
<section fxLayout="column" fxFlex> |
||||
|
<mat-checkbox formControlName="enableStickyHeader" style="margin-bottom: 16px;"> |
||||
|
{{ 'widgets.table.enable-sticky-header' | translate }} |
||||
|
</mat-checkbox> |
||||
|
<mat-checkbox formControlName="enableStickyAction" style="margin-bottom: 16px;"> |
||||
|
{{ 'widgets.table.enable-sticky-action' | translate }} |
||||
|
</mat-checkbox> |
||||
|
</section> |
||||
|
</section> |
||||
|
<mat-form-field fxFlex class="mat-block"> |
||||
|
<mat-label translate>widgets.table.hidden-cell-button-display-mode</mat-label> |
||||
|
<mat-select formControlName="reserveSpaceForHiddenAction"> |
||||
|
<mat-option [value]="'true'"> |
||||
|
{{ 'widgets.table.show-empty-space-hidden-action' | translate }} |
||||
|
</mat-option> |
||||
|
<mat-option [value]="'false'"> |
||||
|
{{ 'widgets.table.dont-reserve-space-hidden-action' | translate }} |
||||
|
</mat-option> |
||||
|
</mat-select> |
||||
|
</mat-form-field> |
||||
|
<section fxLayout="column" fxLayoutGap="8px"> |
||||
|
<mat-slide-toggle formControlName="showTimestamp"> |
||||
|
{{ 'widgets.table.display-timestamp' | translate }} |
||||
|
</mat-slide-toggle> |
||||
|
<mat-slide-toggle formControlName="showMilliseconds"> |
||||
|
{{ 'widgets.table.display-milliseconds' | translate }} |
||||
|
</mat-slide-toggle> |
||||
|
<section fxLayout="row" fxLayoutGap="8px" fxLayoutAlign="start center"> |
||||
|
<mat-slide-toggle fxFlex formControlName="displayPagination"> |
||||
|
{{ 'widgets.table.display-pagination' | translate }} |
||||
|
</mat-slide-toggle> |
||||
|
<mat-form-field fxFlex class="mat-block"> |
||||
|
<mat-label translate>widgets.table.default-page-size</mat-label> |
||||
|
<input matInput type="number" min="1" step="1" formControlName="defaultPageSize"> |
||||
|
</mat-form-field> |
||||
|
</section> |
||||
|
<mat-slide-toggle formControlName="useEntityLabel"> |
||||
|
{{ 'widgets.table.use-entity-label-tab-name' | translate }} |
||||
|
</mat-slide-toggle> |
||||
|
<mat-slide-toggle formControlName="hideEmptyLines"> |
||||
|
{{ 'widgets.table.hide-empty-lines' | translate }} |
||||
|
</mat-slide-toggle> |
||||
|
</section> |
||||
|
</fieldset> |
||||
|
<fieldset class="fields-group fields-group-slider"> |
||||
|
<legend class="group-title" translate>widgets.table.row-style</legend> |
||||
|
<mat-expansion-panel class="tb-settings" [expanded]="timeseriesTableWidgetSettingsForm.get('useRowStyleFunction').value"> |
||||
|
<mat-expansion-panel-header fxLayout="row wrap"> |
||||
|
<mat-panel-title> |
||||
|
<mat-slide-toggle formControlName="useRowStyleFunction" (click)="$event.stopPropagation()" |
||||
|
fxLayoutAlign="center"> |
||||
|
{{ 'widgets.table.use-row-style-function' | translate }} |
||||
|
</mat-slide-toggle> |
||||
|
</mat-panel-title> |
||||
|
<mat-panel-description fxLayoutAlign="end center" fxHide.xs translate> |
||||
|
widget-config.advanced-settings |
||||
|
</mat-panel-description> |
||||
|
</mat-expansion-panel-header> |
||||
|
<ng-template matExpansionPanelContent> |
||||
|
<tb-js-func formControlName="rowStyleFunction" |
||||
|
[globalVariables]="functionScopeVariables" |
||||
|
[functionArgs]="['rowData', 'ctx']" |
||||
|
functionTitle="{{ 'widgets.table.row-style-function' | translate }}" |
||||
|
helpId="widget/lib/timeseries/row_style_fn"> |
||||
|
</tb-js-func> |
||||
|
</ng-template> |
||||
|
</mat-expansion-panel> |
||||
|
</fieldset> |
||||
|
</section> |
||||
@ -0,0 +1,98 @@ |
|||||
|
///
|
||||
|
/// Copyright © 2016-2022 The Thingsboard Authors
|
||||
|
///
|
||||
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
/// you may not use this file except in compliance with the License.
|
||||
|
/// You may obtain a copy of the License at
|
||||
|
///
|
||||
|
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
///
|
||||
|
/// Unless required by applicable law or agreed to in writing, software
|
||||
|
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
/// See the License for the specific language governing permissions and
|
||||
|
/// limitations under the License.
|
||||
|
///
|
||||
|
|
||||
|
import { Component } from '@angular/core'; |
||||
|
import { WidgetSettings, WidgetSettingsComponent } from '@shared/models/widget.models'; |
||||
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; |
||||
|
import { Store } from '@ngrx/store'; |
||||
|
import { AppState } from '@core/core.state'; |
||||
|
|
||||
|
@Component({ |
||||
|
selector: 'tb-timeseries-table-widget-settings', |
||||
|
templateUrl: './timeseries-table-widget-settings.component.html', |
||||
|
styleUrls: ['./widget-settings.scss'] |
||||
|
}) |
||||
|
export class TimeseriesTableWidgetSettingsComponent extends WidgetSettingsComponent { |
||||
|
|
||||
|
timeseriesTableWidgetSettingsForm: FormGroup; |
||||
|
|
||||
|
constructor(protected store: Store<AppState>, |
||||
|
private fb: FormBuilder) { |
||||
|
super(store); |
||||
|
} |
||||
|
|
||||
|
protected settingsForm(): FormGroup { |
||||
|
return this.timeseriesTableWidgetSettingsForm; |
||||
|
} |
||||
|
|
||||
|
protected defaultSettings(): WidgetSettings { |
||||
|
return { |
||||
|
enableSearch: true, |
||||
|
enableStickyHeader: true, |
||||
|
enableStickyAction: true, |
||||
|
reserveSpaceForHiddenAction: 'true', |
||||
|
showTimestamp: true, |
||||
|
showMilliseconds: false, |
||||
|
displayPagination: true, |
||||
|
useEntityLabel: false, |
||||
|
defaultPageSize: 10, |
||||
|
hideEmptyLines: false, |
||||
|
disableStickyHeader: false, |
||||
|
useRowStyleFunction: false, |
||||
|
rowStyleFunction: '' |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
protected onSettingsSet(settings: WidgetSettings) { |
||||
|
this.timeseriesTableWidgetSettingsForm = this.fb.group({ |
||||
|
enableSearch: [settings.enableSearch, []], |
||||
|
enableStickyHeader: [settings.enableStickyHeader, []], |
||||
|
enableStickyAction: [settings.enableStickyAction, []], |
||||
|
reserveSpaceForHiddenAction: [settings.reserveSpaceForHiddenAction, []], |
||||
|
showTimestamp: [settings.showTimestamp, []], |
||||
|
showMilliseconds: [settings.showMilliseconds, []], |
||||
|
displayPagination: [settings.displayPagination, []], |
||||
|
useEntityLabel: [settings.useEntityLabel, []], |
||||
|
defaultPageSize: [settings.defaultPageSize, [Validators.min(1)]], |
||||
|
hideEmptyLines: [settings.hideEmptyLines, []], |
||||
|
disableStickyHeader: [settings.disableStickyHeader, []], |
||||
|
useRowStyleFunction: [settings.useRowStyleFunction, []], |
||||
|
rowStyleFunction: [settings.rowStyleFunction, [Validators.required]] |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
protected validatorTriggers(): string[] { |
||||
|
return ['useRowStyleFunction', 'displayPagination']; |
||||
|
} |
||||
|
|
||||
|
protected updateValidators(emitEvent: boolean) { |
||||
|
const useRowStyleFunction: boolean = this.timeseriesTableWidgetSettingsForm.get('useRowStyleFunction').value; |
||||
|
const displayPagination: boolean = this.timeseriesTableWidgetSettingsForm.get('displayPagination').value; |
||||
|
if (useRowStyleFunction) { |
||||
|
this.timeseriesTableWidgetSettingsForm.get('rowStyleFunction').enable(); |
||||
|
} else { |
||||
|
this.timeseriesTableWidgetSettingsForm.get('rowStyleFunction').disable(); |
||||
|
} |
||||
|
if (displayPagination) { |
||||
|
this.timeseriesTableWidgetSettingsForm.get('defaultPageSize').enable(); |
||||
|
} else { |
||||
|
this.timeseriesTableWidgetSettingsForm.get('defaultPageSize').disable(); |
||||
|
} |
||||
|
this.timeseriesTableWidgetSettingsForm.get('rowStyleFunction').updateValueAndValidity({emitEvent}); |
||||
|
this.timeseriesTableWidgetSettingsForm.get('defaultPageSize').updateValueAndValidity({emitEvent}); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,113 @@ |
|||||
|
/** |
||||
|
* Copyright © 2016-2022 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0 |
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
:host { |
||||
|
.tb-widget-settings { |
||||
|
.fields-group { |
||||
|
padding: 0 16px 8px; |
||||
|
margin-bottom: 10px; |
||||
|
border: 1px groove rgba(0, 0, 0, .25); |
||||
|
border-radius: 4px; |
||||
|
|
||||
|
legend { |
||||
|
color: rgba(0, 0, 0, .7); |
||||
|
width: fit-content; |
||||
|
} |
||||
|
|
||||
|
legend + * { |
||||
|
margin-top: 16px; |
||||
|
} |
||||
|
|
||||
|
&.fields-group-slider { |
||||
|
padding: 0; |
||||
|
|
||||
|
legend { |
||||
|
margin-left: 16px; |
||||
|
} |
||||
|
|
||||
|
.tb-settings { |
||||
|
margin-top: 0; |
||||
|
padding: 0 16px 8px; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
:host ::ng-deep { |
||||
|
.tb-widget-settings { |
||||
|
.mat-checkbox-label { |
||||
|
white-space: normal; |
||||
|
} |
||||
|
|
||||
|
.mat-expansion-panel { |
||||
|
&.tb-settings { |
||||
|
box-shadow: none; |
||||
|
|
||||
|
.mat-content { |
||||
|
overflow: visible; |
||||
|
} |
||||
|
|
||||
|
.mat-expansion-panel-header { |
||||
|
padding: 0; |
||||
|
|
||||
|
&:hover { |
||||
|
background: none; |
||||
|
} |
||||
|
|
||||
|
.mat-expansion-indicator { |
||||
|
padding: 2px; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.mat-expansion-panel-header-description { |
||||
|
align-items: center; |
||||
|
} |
||||
|
|
||||
|
.mat-expansion-panel-body { |
||||
|
padding: 0; |
||||
|
} |
||||
|
|
||||
|
.mat-checkbox-layout { |
||||
|
margin: 5px 0; |
||||
|
} |
||||
|
|
||||
|
.mat-checkbox-inner-container { |
||||
|
margin-right: 12px; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.mat-expansion-panel-content { |
||||
|
font: inherit; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.mat-slide { |
||||
|
margin: 8px 0; |
||||
|
} |
||||
|
|
||||
|
.slide-block { |
||||
|
display: block; |
||||
|
|
||||
|
&:not(:last-child) { |
||||
|
margin-bottom: 8px; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.mat-slide-toggle-content { |
||||
|
white-space: normal; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue