<!--

    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.

-->
<form fxLayout="column" class="mat-content mat-padding" [formGroup]="alarmFilterFormGroup" (ngSubmit)="update()">
  <mat-form-field fxFlex class="mat-block" floatLabel="always">
    <mat-label translate>alarm.alarm-status-list</mat-label>
    <mat-select formControlName="alarmStatusList" multiple
                placeholder="{{ !alarmFilterFormGroup.get('alarmStatusList').value?.length ? ('alarm.any-status' | translate) : '' }}">
      <mat-option *ngFor="let searchStatus of alarmSearchStatuses" [value]="searchStatus">
        {{ alarmSearchStatusTranslationMap.get(searchStatus) | translate }}
      </mat-option>
    </mat-select>
  </mat-form-field>
  <mat-form-field fxFlex class="mat-block" floatLabel="always">
    <mat-label translate>alarm.alarm-severity-list</mat-label>
    <mat-select formControlName="alarmSeverityList" multiple
                placeholder="{{ !alarmFilterFormGroup.get('alarmSeverityList').value?.length ? ('alarm.any-severity' | translate) : '' }}">
      <mat-option *ngFor="let alarmSeverity of alarmSeverities" [value]="alarmSeverity">
        {{ alarmSeverityTranslationMap.get(alarmSeverityEnum[alarmSeverity]) | translate }}
      </mat-option>
    </mat-select>
  </mat-form-field>
  <mat-form-field fxFlex class="mat-block" floatLabel="always">
    <mat-label translate>alarm.alarm-type-list</mat-label>
    <mat-chip-list #alarmTypeChipList formControlName="alarmTypeList">
      <mat-chip *ngFor="let type of alarmTypeList()" [selectable]="true"
                [removable]="true" (removed)="removeAlarmType(type)">
        {{type}}
        <mat-icon matChipRemove>cancel</mat-icon>
      </mat-chip>
      <input placeholder="{{ !alarmFilterFormGroup.get('alarmTypeList').value?.length ? ('alarm.any-type' | translate) : '' }}"
             [matChipInputFor]="alarmTypeChipList"
             [matChipInputSeparatorKeyCodes]="separatorKeysCodes"
             matChipInputAddOnBlur
             (matChipInputTokenEnd)="addAlarmType($event)">
    </mat-chip-list>
  </mat-form-field>
  <div fxLayout="row" class="tb-panel-actions" fxLayoutAlign="end center">
    <button type="button"
            mat-button
            (click)="cancel()">
      {{ 'action.cancel' | translate }}
    </button>
    <button type="submit"
            mat-raised-button
            color="primary"
            [disabled]="alarmFilterFormGroup.invalid || !alarmFilterFormGroup.dirty">
      {{ 'action.update' | translate }}
    </button>
  </div>
</form>
