145 lines
7.9 KiB
HTML
145 lines
7.9 KiB
HTML
<!--
|
|
|
|
Copyright © 2016-2021 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 [formGroup]="alarmScheduleForm" fxLayout="column">
|
|
<mat-form-field class="mat-block" hideRequiredMarker floatLabel="always">
|
|
<mat-label> </mat-label>
|
|
<mat-select formControlName="type" required placeholder="{{ 'device-profile.schedule-type' | translate }}">
|
|
<mat-option *ngFor="let alarmScheduleType of alarmScheduleTypes" [value]="alarmScheduleType">
|
|
{{ alarmScheduleTypeTranslate.get(alarmScheduleType) | translate }}
|
|
</mat-option>
|
|
</mat-select>
|
|
<mat-error *ngIf="alarmScheduleForm.get('type').hasError('required')">
|
|
{{ 'device-profile.schedule-type-required' | translate }}
|
|
</mat-error>
|
|
</mat-form-field>
|
|
<div *ngIf="alarmScheduleForm.get('type').value !== alarmScheduleType.ANY_TIME">
|
|
<tb-timezone-select
|
|
userTimezoneByDefault
|
|
required
|
|
formControlName="timezone">
|
|
</tb-timezone-select>
|
|
<section *ngIf="alarmScheduleForm.get('type').value === alarmScheduleType.SPECIFIC_TIME">
|
|
<div class="tb-small" style="margin-bottom: 0.5em" translate>device-profile.schedule-days</div>
|
|
<div fxLayout="column" fxLayout.gt-md="row" fxLayoutGap="16px">
|
|
<div fxLayout="row" fxLayoutGap="16px">
|
|
<mat-checkbox *ngFor="let day of firstRowDays" [formControl]="weeklyRepeatControl(day)">
|
|
{{ dayOfWeekTranslationsArray[day] | translate }}
|
|
</mat-checkbox>
|
|
</div>
|
|
<div fxLayout="row" fxLayoutGap="16px">
|
|
<mat-checkbox *ngFor="let day of secondRowDays" [formControl]="weeklyRepeatControl(day)">
|
|
{{ dayOfWeekTranslationsArray[day] | translate }}
|
|
</mat-checkbox>
|
|
</div>
|
|
</div>
|
|
<tb-error style="display: block;" [error]="alarmScheduleForm.get('daysOfWeek').hasError('dayOfWeeks')
|
|
? ('device-profile.schedule-days-of-week-required' | translate) : ''"></tb-error>
|
|
<div class="tb-small" style="margin-bottom: 0.5em" translate>device-profile.schedule-time</div>
|
|
<div fxLayout="row" fxLayout.xs="column" fxLayoutGap.gt-xs="8px">
|
|
<div fxLayout="row" fxLayoutGap="8px" fxFlex.gt-md>
|
|
<mat-form-field fxFlex.xs fxFlex.sm="150px" fxFlex.md="150px" fxFlex.gt-md>
|
|
<mat-label translate>device-profile.schedule-time-from</mat-label>
|
|
<mat-datetimepicker-toggle [for]="startTimePicker" matPrefix></mat-datetimepicker-toggle>
|
|
<mat-datetimepicker #startTimePicker type="time" openOnFocus="true"></mat-datetimepicker>
|
|
<input required matInput formControlName="startsOn" [matDatetimepicker]="startTimePicker">
|
|
</mat-form-field>
|
|
<mat-form-field fxFlex.xs fxFlex.sm="150px" fxFlex.md="150px" fxFlex.gt-md>
|
|
<mat-label translate>device-profile.schedule-time-to</mat-label>
|
|
<mat-datetimepicker-toggle [for]="endTimePicker" matPrefix></mat-datetimepicker-toggle>
|
|
<mat-datetimepicker #endTimePicker type="time" openOnFocus="true"></mat-datetimepicker>
|
|
<input required matInput formControlName="endsOn" [matDatetimepicker]="endTimePicker">
|
|
</mat-form-field>
|
|
</div>
|
|
<div fxFlex fxLayoutAlign="center center" style="margin: auto">
|
|
<div style="text-align: center"
|
|
[innerHTML]="getSchedulerRangeText(alarmScheduleForm)">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
<section *ngIf="alarmScheduleForm.get('type').value === alarmScheduleType.CUSTOM">
|
|
<mat-expansion-panel class="device-profile-alarm" fxFlex>
|
|
<mat-expansion-panel-header>
|
|
<div fxFlex fxLayout="row" fxLayoutAlign="start center">
|
|
<mat-panel-title>
|
|
<div fxLayout="row" fxFlex fxLayoutAlign="start center">
|
|
{{'filter.dynamic-value' | translate}}
|
|
</div>
|
|
</mat-panel-title>
|
|
<span fxFlex></span>
|
|
</div>
|
|
</mat-expansion-panel-header>
|
|
<ng-template matExpansionPanelContent>
|
|
<div fxFlex [formGroup] = "alarmScheduleForm.get('dynamicValue')" fxLayout="column">
|
|
<div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
|
|
<div fxFlex="40" fxLayout="column">
|
|
<mat-form-field floatLabel="always" hideRequiredMarker class="mat-block">
|
|
<mat-label></mat-label>
|
|
<mat-select formControlName="sourceType" placeholder="{{'filter.dynamic-source-type' | translate}}">
|
|
<mat-option [value]="null">
|
|
{{'filter.no-dynamic-value' | translate}}
|
|
</mat-option>
|
|
<mat-option *ngFor="let sourceType of dynamicValueSourceTypes" [value]="sourceType">
|
|
{{dynamicValueSourceTypeTranslations.get(sourceType) | translate}}
|
|
</mat-option>
|
|
</mat-select>
|
|
</mat-form-field>
|
|
</div>
|
|
<div fxFlex fxLayout="column">
|
|
<mat-form-field floatLabel="always" hideRequiredMarker class="mat-block source-attribute">
|
|
<mat-label></mat-label>
|
|
<input matInput formControlName="sourceAttribute" placeholder="{{'filter.source-attribute' | translate}}">
|
|
</mat-form-field>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</ng-template>
|
|
</mat-expansion-panel>
|
|
<div class="tb-small" style="margin-bottom: 0.5em; margin-top: 26px;" translate>device-profile.schedule-days</div>
|
|
<div *ngFor="let day of allDays" fxLayout="column" formArrayName="items" fxLayoutGap="1em">
|
|
<div fxLayout.xs="column" fxLayout="row" fxLayoutGap="8px" [formGroupName]="''+day" fxLayoutAlign="start center" fxLayoutAlign.xs="center start">
|
|
<mat-checkbox formControlName="enabled" fxFlex="17" (change)="changeCustomScheduler($event, day)">
|
|
{{ dayOfWeekTranslationsArray[day] | translate }}
|
|
</mat-checkbox>
|
|
<div fxLayout="row" fxLayoutGap="8px" fxFlex>
|
|
<mat-form-field fxFlex.xs fxFlex.sm="100px" fxFlex.md="100px">
|
|
<mat-label translate>device-profile.schedule-time-from</mat-label>
|
|
<mat-datetimepicker-toggle [for]="startTimePicker" matPrefix></mat-datetimepicker-toggle>
|
|
<mat-datetimepicker #startTimePicker type="time" openOnFocus="true"></mat-datetimepicker>
|
|
<input required matInput formControlName="startsOn" [matDatetimepicker]="startTimePicker">
|
|
</mat-form-field>
|
|
<mat-form-field fxFlex.xs fxFlex.sm="100px" fxFlex.md="100px">
|
|
<mat-label translate>device-profile.schedule-time-to</mat-label>
|
|
<mat-datetimepicker-toggle [for]="endTimePicker" matPrefix></mat-datetimepicker-toggle>
|
|
<mat-datetimepicker #endTimePicker type="time" openOnFocus="true"></mat-datetimepicker>
|
|
<input required matInput formControlName="endsOn" [matDatetimepicker]="endTimePicker">
|
|
</mat-form-field>
|
|
</div>
|
|
<div fxFlex fxLayoutAlign="center center"
|
|
style="text-align: center"
|
|
[innerHTML]="getSchedulerRangeText(itemsSchedulerForm.at(day))">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<tb-error style="display: block;" [error]="alarmScheduleForm.get('items').hasError('dayOfWeeks')
|
|
? ('device-profile.schedule-days-of-week-required' | translate) : ''"></tb-error>
|
|
</section>
|
|
</div>
|
|
</section>
|