7 changed files with 422 additions and 6 deletions
@ -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]="alarmsTableKeySettingsForm" fxLayout="column"> |
|||
<mat-form-field fxFlex class="mat-block"> |
|||
<mat-label translate>widgets.table.column-width</mat-label> |
|||
<input matInput formControlName="columnWidth"> |
|||
</mat-form-field> |
|||
<fieldset class="fields-group fields-group-slider"> |
|||
<legend class="group-title" translate>widgets.table.cell-style</legend> |
|||
<mat-expansion-panel class="tb-settings" [expanded]="alarmsTableKeySettingsForm.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 required |
|||
formControlName="cellStyleFunction" |
|||
[globalVariables]="functionScopeVariables" |
|||
[functionArgs]="['value', 'alarm', 'ctx']" |
|||
functionTitle="{{ 'widgets.table.cell-style-function' | translate }}" |
|||
helpId="widget/lib/alarm/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]="alarmsTableKeySettingsForm.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 required |
|||
formControlName="cellContentFunction" |
|||
[globalVariables]="functionScopeVariables" |
|||
[functionArgs]="['value', 'alarm', 'ctx']" |
|||
functionTitle="{{ 'widgets.table.cell-content-function' | translate }}" |
|||
helpId="widget/lib/alarm/cell_content_fn"> |
|||
</tb-js-func> |
|||
</ng-template> |
|||
</mat-expansion-panel> |
|||
</fieldset> |
|||
<mat-form-field fxFlex class="mat-block"> |
|||
<mat-label translate>widgets.table.default-column-visibility</mat-label> |
|||
<mat-select formControlName="defaultColumnVisibility"> |
|||
<mat-option [value]="'visible'"> |
|||
{{ 'widgets.table.column-visibility-visible' | translate }} |
|||
</mat-option> |
|||
<mat-option [value]="'hidden'"> |
|||
{{ 'widgets.table.column-visibility-hidden' | translate }} |
|||
</mat-option> |
|||
</mat-select> |
|||
</mat-form-field> |
|||
<mat-form-field fxFlex class="mat-block"> |
|||
<mat-label translate>widgets.table.column-selection-to-display</mat-label> |
|||
<mat-select formControlName="columnSelectionToDisplay"> |
|||
<mat-option [value]="'enabled'"> |
|||
{{ 'widgets.table.column-selection-to-display-enabled' | translate }} |
|||
</mat-option> |
|||
<mat-option [value]="'disabled'"> |
|||
{{ 'widgets.table.column-selection-to-display-disabled' | translate }} |
|||
</mat-option> |
|||
</mat-select> |
|||
</mat-form-field> |
|||
</section> |
|||
@ -0,0 +1,86 @@ |
|||
///
|
|||
/// 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-alarms-table-key-settings', |
|||
templateUrl: './alarms-table-key-settings.component.html', |
|||
styleUrls: ['./../widget-settings.scss'] |
|||
}) |
|||
export class AlarmsTableKeySettingsComponent extends WidgetSettingsComponent { |
|||
|
|||
alarmsTableKeySettingsForm: FormGroup; |
|||
|
|||
constructor(protected store: Store<AppState>, |
|||
private fb: FormBuilder) { |
|||
super(store); |
|||
} |
|||
|
|||
protected settingsForm(): FormGroup { |
|||
return this.alarmsTableKeySettingsForm; |
|||
} |
|||
|
|||
protected defaultSettings(): WidgetSettings { |
|||
return { |
|||
columnWidth: '0px', |
|||
useCellStyleFunction: false, |
|||
cellStyleFunction: '', |
|||
useCellContentFunction: false, |
|||
cellContentFunction: '', |
|||
defaultColumnVisibility: 'visible', |
|||
columnSelectionToDisplay: 'enabled' |
|||
}; |
|||
} |
|||
|
|||
protected onSettingsSet(settings: WidgetSettings) { |
|||
this.alarmsTableKeySettingsForm = this.fb.group({ |
|||
columnWidth: [settings.columnWidth, []], |
|||
useCellStyleFunction: [settings.useCellStyleFunction, []], |
|||
cellStyleFunction: [settings.cellStyleFunction, [Validators.required]], |
|||
useCellContentFunction: [settings.useCellContentFunction, []], |
|||
cellContentFunction: [settings.cellContentFunction, [Validators.required]], |
|||
defaultColumnVisibility: [settings.defaultColumnVisibility, []], |
|||
columnSelectionToDisplay: [settings.columnSelectionToDisplay, []], |
|||
}); |
|||
} |
|||
|
|||
protected validatorTriggers(): string[] { |
|||
return ['useCellStyleFunction', 'useCellContentFunction']; |
|||
} |
|||
|
|||
protected updateValidators(emitEvent: boolean) { |
|||
const useCellStyleFunction: boolean = this.alarmsTableKeySettingsForm.get('useCellStyleFunction').value; |
|||
const useCellContentFunction: boolean = this.alarmsTableKeySettingsForm.get('useCellContentFunction').value; |
|||
if (useCellStyleFunction) { |
|||
this.alarmsTableKeySettingsForm.get('cellStyleFunction').enable(); |
|||
} else { |
|||
this.alarmsTableKeySettingsForm.get('cellStyleFunction').disable(); |
|||
} |
|||
if (useCellContentFunction) { |
|||
this.alarmsTableKeySettingsForm.get('cellContentFunction').enable(); |
|||
} else { |
|||
this.alarmsTableKeySettingsForm.get('cellContentFunction').disable(); |
|||
} |
|||
this.alarmsTableKeySettingsForm.get('cellStyleFunction').updateValueAndValidity({emitEvent}); |
|||
this.alarmsTableKeySettingsForm.get('cellContentFunction').updateValueAndValidity({emitEvent}); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,110 @@ |
|||
<!-- |
|||
|
|||
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]="alarmsTableWidgetSettingsForm" fxLayout="column"> |
|||
<fieldset class="fields-group"> |
|||
<legend class="group-title" translate>widgets.table.common-table-settings</legend> |
|||
<mat-form-field fxFlex class="mat-block"> |
|||
<mat-label translate>widgets.table.alarms-table-title</mat-label> |
|||
<input matInput formControlName="alarmsTitle"> |
|||
</mat-form-field> |
|||
<section fxLayout="column" fxLayout.gt-sm="row" fxLayoutGap="8px"> |
|||
<section fxLayout="column" fxFlex> |
|||
<mat-checkbox formControlName="enableSelection" style="margin-bottom: 16px;"> |
|||
{{ 'widgets.table.enable-alarms-selection' | translate }} |
|||
</mat-checkbox> |
|||
<mat-checkbox formControlName="enableSearch" style="margin-bottom: 16px;"> |
|||
{{ 'widgets.table.enable-alarms-search' | translate }} |
|||
</mat-checkbox> |
|||
<mat-checkbox formControlName="enableSelectColumnDisplay" style="margin-bottom: 16px;"> |
|||
{{ 'widgets.table.enable-select-column-display' | translate }} |
|||
</mat-checkbox> |
|||
<mat-checkbox formControlName="enableFilter" style="margin-bottom: 16px;"> |
|||
{{ 'widgets.table.enable-alarm-filter' | 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 fxFlex formControlName="displayDetails"> |
|||
{{ 'widgets.table.display-alarm-details' | translate }} |
|||
</mat-slide-toggle> |
|||
<mat-slide-toggle formControlName="allowAcknowledgment"> |
|||
{{ 'widgets.table.allow-alarms-ack' | translate }} |
|||
</mat-slide-toggle> |
|||
<mat-slide-toggle formControlName="allowClear"> |
|||
{{ 'widgets.table.allow-alarms-clear' | 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-form-field fxFlex class="mat-block"> |
|||
<mat-label translate>widgets.table.default-sort-order</mat-label> |
|||
<input matInput formControlName="defaultSortOrder"> |
|||
</mat-form-field> |
|||
</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]="alarmsTableWidgetSettingsForm.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 required |
|||
formControlName="rowStyleFunction" |
|||
[globalVariables]="functionScopeVariables" |
|||
[functionArgs]="['alarm', 'ctx']" |
|||
functionTitle="{{ 'widgets.table.row-style-function' | translate }}" |
|||
helpId="widget/lib/alarm/row_style_fn"> |
|||
</tb-js-func> |
|||
</ng-template> |
|||
</mat-expansion-panel> |
|||
</fieldset> |
|||
</section> |
|||
@ -0,0 +1,104 @@ |
|||
///
|
|||
/// 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-alarms-table-widget-settings', |
|||
templateUrl: './alarms-table-widget-settings.component.html', |
|||
styleUrls: ['./../widget-settings.scss'] |
|||
}) |
|||
export class AlarmsTableWidgetSettingsComponent extends WidgetSettingsComponent { |
|||
|
|||
alarmsTableWidgetSettingsForm: FormGroup; |
|||
|
|||
constructor(protected store: Store<AppState>, |
|||
private fb: FormBuilder) { |
|||
super(store); |
|||
} |
|||
|
|||
protected settingsForm(): FormGroup { |
|||
return this.alarmsTableWidgetSettingsForm; |
|||
} |
|||
|
|||
protected defaultSettings(): WidgetSettings { |
|||
return { |
|||
alarmsTitle: '', |
|||
enableSelection: true, |
|||
enableSearch: true, |
|||
enableSelectColumnDisplay: true, |
|||
enableFilter: true, |
|||
enableStickyHeader: true, |
|||
enableStickyAction: true, |
|||
reserveSpaceForHiddenAction: 'true', |
|||
displayDetails: true, |
|||
allowAcknowledgment: true, |
|||
allowClear: true, |
|||
displayPagination: true, |
|||
defaultPageSize: 10, |
|||
defaultSortOrder: '-createdTime', |
|||
useRowStyleFunction: false, |
|||
rowStyleFunction: '' |
|||
}; |
|||
} |
|||
|
|||
protected onSettingsSet(settings: WidgetSettings) { |
|||
this.alarmsTableWidgetSettingsForm = this.fb.group({ |
|||
alarmsTitle: [settings.alarmsTitle, []], |
|||
enableSelection: [settings.enableSelection, []], |
|||
enableSearch: [settings.enableSearch, []], |
|||
enableSelectColumnDisplay: [settings.enableSelectColumnDisplay, []], |
|||
enableFilter: [settings.enableFilter, []], |
|||
enableStickyHeader: [settings.enableStickyHeader, []], |
|||
enableStickyAction: [settings.enableStickyAction, []], |
|||
reserveSpaceForHiddenAction: [settings.reserveSpaceForHiddenAction, []], |
|||
displayDetails: [settings.displayDetails, []], |
|||
allowAcknowledgment: [settings.allowAcknowledgment, []], |
|||
allowClear: [settings.allowClear, []], |
|||
displayPagination: [settings.displayPagination, []], |
|||
defaultPageSize: [settings.defaultPageSize, [Validators.min(1)]], |
|||
defaultSortOrder: [settings.defaultSortOrder, []], |
|||
useRowStyleFunction: [settings.useRowStyleFunction, []], |
|||
rowStyleFunction: [settings.rowStyleFunction, [Validators.required]] |
|||
}); |
|||
} |
|||
|
|||
protected validatorTriggers(): string[] { |
|||
return ['useRowStyleFunction', 'displayPagination']; |
|||
} |
|||
|
|||
protected updateValidators(emitEvent: boolean) { |
|||
const useRowStyleFunction: boolean = this.alarmsTableWidgetSettingsForm.get('useRowStyleFunction').value; |
|||
const displayPagination: boolean = this.alarmsTableWidgetSettingsForm.get('displayPagination').value; |
|||
if (useRowStyleFunction) { |
|||
this.alarmsTableWidgetSettingsForm.get('rowStyleFunction').enable(); |
|||
} else { |
|||
this.alarmsTableWidgetSettingsForm.get('rowStyleFunction').disable(); |
|||
} |
|||
if (displayPagination) { |
|||
this.alarmsTableWidgetSettingsForm.get('defaultPageSize').enable(); |
|||
} else { |
|||
this.alarmsTableWidgetSettingsForm.get('defaultPageSize').disable(); |
|||
} |
|||
this.alarmsTableWidgetSettingsForm.get('rowStyleFunction').updateValueAndValidity({emitEvent}); |
|||
this.alarmsTableWidgetSettingsForm.get('defaultPageSize').updateValueAndValidity({emitEvent}); |
|||
} |
|||
|
|||
} |
|||
Loading…
Reference in new issue