<!--

    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.

-->
<mat-expansion-panel class="fixed-color-level" fxFlex [formGroup]="fixedColorLevelFormGroup" [(expanded)]="expanded">
  <mat-expansion-panel-header>
    <div fxFlex fxLayout="row" fxLayoutAlign="start center">
      <mat-panel-title>
        <div fxLayout="row" fxFlex fxLayoutAlign="start center">
          <div>{{ fixedColorLevelRangeText() }}</div>
          <div class="tb-color-preview" style="margin-left: 6px;">
            <div class="tb-color-result" [ngStyle]="{background: fixedColorLevelFormGroup.get('color').value}"></div>
          </div>
        </div>
      </mat-panel-title>
      <span fxFlex></span>
      <button *ngIf="!disabled" mat-icon-button style="min-width: 40px;"
              type="button"
              (click)="removeFixedColorLevel.emit()"
              matTooltip="{{ 'action.remove' | translate }}"
              matTooltipPosition="above">
        <mat-icon>delete</mat-icon>
      </button>
    </div>
  </mat-expansion-panel-header>
  <ng-template matExpansionPanelContent>
    <div fxLayout="column" fxLayoutGap="0.5em">
      <mat-divider></mat-divider>
      <section class="tb-widget-settings" fxLayout="column">
        <fieldset class="fields-group">
          <legend class="group-title" translate>widgets.gauge.from</legend>
          <tb-value-source formControlName="from" [aliasController]="aliasController"></tb-value-source>
        </fieldset>
        <fieldset class="fields-group">
          <legend class="group-title" translate>widgets.gauge.to</legend>
          <tb-value-source formControlName="to" [aliasController]="aliasController"></tb-value-source>
        </fieldset>
        <tb-color-input
          required
          formControlName="color"
          icon="format_color_fill"
          label="{{ 'widgets.gauge.color' | translate }}" openOnInput colorClearButton>
        </tb-color-input>
      </section>
    </div>
  </ng-template>
</mat-expansion-panel>
