<!--

    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>
