<!--

    Copyright © 2016-2023 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.

-->
<div [formGroup]="timewindowConfig" class="tb-form-panel">
  <div fxLayout="row" fxLayoutAlign="space-between center">
    <div class="tb-form-panel-title" translate>timewindow.timewindow</div>
    <tb-toggle-select formControlName="useDashboardTimewindow" selectMediaBreakpoint="xs">
      <tb-toggle-option [value]="true">{{ 'widget-config.use-dashboard-timewindow' | translate }}</tb-toggle-option>
      <tb-toggle-option [value]="false">{{ 'widget-config.use-widget-timewindow' | translate }}</tb-toggle-option>
    </tb-toggle-select>
  </div>
  <div class="tb-form-row column-xs">
    <mat-slide-toggle class="mat-slide" formControlName="displayTimewindow">
      {{ 'widget-config.display-timewindow' | translate }}
    </mat-slide-toggle>
    <div fxFlex fxLayout="row" fxLayoutAlign="space-between center">
      <tb-timewindow asButton="true"
                     strokedButton
                     noMargin
                     isEdit="true"
                     alwaysDisplayTypePrefix
                     [historyOnly]="onlyHistoryTimewindow"
                     quickIntervalOnly="{{ widgetType === widgetTypes.latest }}"
                     aggregation="{{ widgetType === widgetTypes.timeseries }}"
                     formControlName="timewindow"></tb-timewindow>
      <tb-timewindow-style formControlName="timewindowStyle"
                           [previewValue]="timewindowConfig.get('timewindow').value">
      </tb-timewindow-style>
    </div>
  </div>
</div>
