10 changed files with 461 additions and 12 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]="entitiesTableKeySettingsForm" 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]="entitiesTableKeySettingsForm.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', 'entity', 'ctx']" |
|||
functionTitle="{{ 'widgets.table.cell-style-function' | translate }}" |
|||
helpId="widget/lib/entity/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]="entitiesTableKeySettingsForm.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', 'entity', 'ctx']" |
|||
functionTitle="{{ 'widgets.table.cell-content-function' | translate }}" |
|||
helpId="widget/lib/entity/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-entities-table-key-settings', |
|||
templateUrl: './entities-table-key-settings.component.html', |
|||
styleUrls: ['./widget-settings.scss'] |
|||
}) |
|||
export class EntitiesTableKeySettingsComponent extends WidgetSettingsComponent { |
|||
|
|||
entitiesTableKeySettingsForm: FormGroup; |
|||
|
|||
constructor(protected store: Store<AppState>, |
|||
private fb: FormBuilder) { |
|||
super(store); |
|||
} |
|||
|
|||
protected settingsForm(): FormGroup { |
|||
return this.entitiesTableKeySettingsForm; |
|||
} |
|||
|
|||
protected defaultSettings(): WidgetSettings { |
|||
return { |
|||
columnWidth: '0px', |
|||
useCellStyleFunction: false, |
|||
cellStyleFunction: '', |
|||
useCellContentFunction: false, |
|||
cellContentFunction: '', |
|||
defaultColumnVisibility: 'visible', |
|||
columnSelectionToDisplay: 'enabled' |
|||
}; |
|||
} |
|||
|
|||
protected onSettingsSet(settings: WidgetSettings) { |
|||
this.entitiesTableKeySettingsForm = 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.entitiesTableKeySettingsForm.get('useCellStyleFunction').value; |
|||
const useCellContentFunction: boolean = this.entitiesTableKeySettingsForm.get('useCellContentFunction').value; |
|||
if (useCellStyleFunction) { |
|||
this.entitiesTableKeySettingsForm.get('cellStyleFunction').enable(); |
|||
} else { |
|||
this.entitiesTableKeySettingsForm.get('cellStyleFunction').disable(); |
|||
} |
|||
if (useCellContentFunction) { |
|||
this.entitiesTableKeySettingsForm.get('cellContentFunction').enable(); |
|||
} else { |
|||
this.entitiesTableKeySettingsForm.get('cellContentFunction').disable(); |
|||
} |
|||
this.entitiesTableKeySettingsForm.get('cellStyleFunction').updateValueAndValidity({emitEvent}); |
|||
this.entitiesTableKeySettingsForm.get('cellContentFunction').updateValueAndValidity({emitEvent}); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,116 @@ |
|||
<!-- |
|||
|
|||
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]="entitiesTableWidgetSettingsForm" 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.entities-table-title</mat-label> |
|||
<input matInput formControlName="entitiesTitle"> |
|||
</mat-form-field> |
|||
<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> |
|||
<mat-checkbox formControlName="enableSelectColumnDisplay" style="margin-bottom: 16px;"> |
|||
{{ 'widgets.table.enable-select-column-display' | 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"> |
|||
<section fxLayout="row" fxLayoutGap="8px" fxLayoutAlign="start center"> |
|||
<mat-slide-toggle fxFlex formControlName="displayEntityName"> |
|||
{{ 'widgets.table.display-entity-name' | translate }} |
|||
</mat-slide-toggle> |
|||
<mat-form-field fxFlex class="mat-block"> |
|||
<mat-label translate>widgets.table.entity-name-column-title</mat-label> |
|||
<input matInput formControlName="entityNameColumnTitle"> |
|||
</mat-form-field> |
|||
</section> |
|||
<section fxLayout="row" fxLayoutGap="8px" fxLayoutAlign="start center"> |
|||
<mat-slide-toggle fxFlex formControlName="displayEntityLabel"> |
|||
{{ 'widgets.table.display-entity-label' | translate }} |
|||
</mat-slide-toggle> |
|||
<mat-form-field fxFlex class="mat-block"> |
|||
<mat-label translate>widgets.table.entity-label-column-title</mat-label> |
|||
<input matInput formControlName="entityLabelColumnTitle"> |
|||
</mat-form-field> |
|||
</section> |
|||
<mat-slide-toggle formControlName="displayEntityType"> |
|||
{{ 'widgets.table.display-entity-type' | 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]="entitiesTableWidgetSettingsForm.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]="['entity', 'ctx']" |
|||
functionTitle="{{ 'widgets.table.row-style-function' | translate }}" |
|||
helpId="widget/lib/entity/row_style_fn"> |
|||
</tb-js-func> |
|||
</ng-template> |
|||
</mat-expansion-panel> |
|||
</fieldset> |
|||
</section> |
|||
@ -0,0 +1,118 @@ |
|||
///
|
|||
/// 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-entities-table-widget-settings', |
|||
templateUrl: './entities-table-widget-settings.component.html', |
|||
styleUrls: ['./widget-settings.scss'] |
|||
}) |
|||
export class EntitiesTableWidgetSettingsComponent extends WidgetSettingsComponent { |
|||
|
|||
entitiesTableWidgetSettingsForm: FormGroup; |
|||
|
|||
constructor(protected store: Store<AppState>, |
|||
private fb: FormBuilder) { |
|||
super(store); |
|||
} |
|||
|
|||
protected settingsForm(): FormGroup { |
|||
return this.entitiesTableWidgetSettingsForm; |
|||
} |
|||
|
|||
protected defaultSettings(): WidgetSettings { |
|||
return { |
|||
entitiesTitle: '', |
|||
enableSearch: true, |
|||
enableSelectColumnDisplay: true, |
|||
enableStickyHeader: true, |
|||
enableStickyAction: true, |
|||
reserveSpaceForHiddenAction: 'true', |
|||
displayEntityName: true, |
|||
entityNameColumnTitle: '', |
|||
displayEntityLabel: false, |
|||
entityLabelColumnTitle: '', |
|||
displayEntityType: true, |
|||
displayPagination: true, |
|||
defaultPageSize: 10, |
|||
defaultSortOrder: 'entityName', |
|||
useRowStyleFunction: false, |
|||
rowStyleFunction: '' |
|||
}; |
|||
} |
|||
|
|||
protected onSettingsSet(settings: WidgetSettings) { |
|||
this.entitiesTableWidgetSettingsForm = this.fb.group({ |
|||
entitiesTitle: [settings.entitiesTitle, []], |
|||
enableSearch: [settings.enableSearch, []], |
|||
enableSelectColumnDisplay: [settings.enableSelectColumnDisplay, []], |
|||
enableStickyHeader: [settings.enableStickyHeader, []], |
|||
enableStickyAction: [settings.enableStickyAction, []], |
|||
reserveSpaceForHiddenAction: [settings.reserveSpaceForHiddenAction, []], |
|||
displayEntityName: [settings.displayEntityName, []], |
|||
entityNameColumnTitle: [settings.entityNameColumnTitle, []], |
|||
displayEntityLabel: [settings.displayEntityLabel, []], |
|||
entityLabelColumnTitle: [settings.entityLabelColumnTitle, []], |
|||
displayEntityType: [settings.displayEntityType, []], |
|||
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', 'displayEntityName', 'displayEntityLabel']; |
|||
} |
|||
|
|||
protected updateValidators(emitEvent: boolean) { |
|||
const useRowStyleFunction: boolean = this.entitiesTableWidgetSettingsForm.get('useRowStyleFunction').value; |
|||
const displayPagination: boolean = this.entitiesTableWidgetSettingsForm.get('displayPagination').value; |
|||
const displayEntityName: boolean = this.entitiesTableWidgetSettingsForm.get('displayEntityName').value; |
|||
const displayEntityLabel: boolean = this.entitiesTableWidgetSettingsForm.get('displayEntityLabel').value; |
|||
if (useRowStyleFunction) { |
|||
this.entitiesTableWidgetSettingsForm.get('rowStyleFunction').enable(); |
|||
} else { |
|||
this.entitiesTableWidgetSettingsForm.get('rowStyleFunction').disable(); |
|||
} |
|||
if (displayPagination) { |
|||
this.entitiesTableWidgetSettingsForm.get('defaultPageSize').enable(); |
|||
} else { |
|||
this.entitiesTableWidgetSettingsForm.get('defaultPageSize').disable(); |
|||
} |
|||
if (displayEntityName) { |
|||
this.entitiesTableWidgetSettingsForm.get('entityNameColumnTitle').enable(); |
|||
} else { |
|||
this.entitiesTableWidgetSettingsForm.get('entityNameColumnTitle').disable(); |
|||
} |
|||
if (displayEntityLabel) { |
|||
this.entitiesTableWidgetSettingsForm.get('entityLabelColumnTitle').enable(); |
|||
} else { |
|||
this.entitiesTableWidgetSettingsForm.get('entityLabelColumnTitle').disable(); |
|||
} |
|||
this.entitiesTableWidgetSettingsForm.get('rowStyleFunction').updateValueAndValidity({emitEvent}); |
|||
this.entitiesTableWidgetSettingsForm.get('defaultPageSize').updateValueAndValidity({emitEvent}); |
|||
this.entitiesTableWidgetSettingsForm.get('entityNameColumnTitle').updateValueAndValidity({emitEvent}); |
|||
this.entitiesTableWidgetSettingsForm.get('entityLabelColumnTitle').updateValueAndValidity({emitEvent}); |
|||
} |
|||
|
|||
} |
|||
Loading…
Reference in new issue