thingsboard/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/rule-notification-dialog.component.html

245 lines
12 KiB
HTML
Raw Normal View History

2023-01-23 14:54:15 +02:00
<!--
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.
-->
2023-02-01 15:58:00 +02:00
<mat-toolbar color="primary">
<h2>{{ dialogTitle | translate }}</h2>
<span fxFlex></span>
<button mat-icon-button
(click)="cancel()"
type="button">
<mat-icon class="material-icons">close</mat-icon>
</button>
</mat-toolbar>
<mat-progress-bar color="warn" mode="indeterminate" *ngIf="isLoading$ | async">
</mat-progress-bar>
<div style="height: 4px;" *ngIf="!(isLoading$ | async)"></div>
<div mat-dialog-content ngStyle.xs="padding: 0;">
<mat-horizontal-stepper [linear]="true" labelPosition="end" #addNotificationRule [orientation]="(stepperOrientation | async)"
(selectionChange)="changeStep($event)">
<ng-template matStepperIcon="edit">
<mat-icon>check</mat-icon>
</ng-template>
<mat-step [stepControl]="ruleNotificationForm">
<ng-template matStepLabel>{{ 'notification.basic-settings' | translate }}</ng-template>
<form [formGroup]="ruleNotificationForm" style="padding-bottom: 16px;">
<mat-form-field class="mat-block">
<mat-label translate>notification.rule-name</mat-label>
<input matInput formControlName="name" required>
<mat-error *ngIf="ruleNotificationForm.get('name').hasError('required')">
{{ 'notification.rule-name-required' | translate }}
</mat-error>
</mat-form-field>
<mat-form-field class="mat-block">
<mat-label translate>notification.trigger.trigger</mat-label>
<mat-select formControlName="triggerType" required>
<mat-option *ngFor="let trigger of triggerTypes" [value]="trigger">
{{ triggerTypeTranslationMap.get(trigger) | translate }}
</mat-option>
</mat-select>
<mat-error *ngIf="ruleNotificationForm.get('triggerType').hasError('required')">
{{ 'notification.trigger.trigger-required' | translate }}
</mat-error>
</mat-form-field>
<tb-template-autocomplete
required
formControlName="templateId"
[notificationTypes]="ruleNotificationForm.get('triggerType').value"
labelText="notification.template-name"
requiredText="notification.template-required">
</tb-template-autocomplete>
</form>
</mat-step>
<mat-step [stepControl]="alarmTemplateForm"
*ngIf="ruleNotificationForm.get('triggerType').value === triggerType.ALARM">
<ng-template matStepLabel>{{ 'notification.alarm-trigger-settings' | translate }}</ng-template>
<form [formGroup]="alarmTemplateForm">
<fieldset class="fields-group">
<legend translate>notification.filter</legend>
<mat-form-field fxFlex class="mat-block" floatLabel="always">
<mat-label translate>alarm.alarm-type-list</mat-label>
<mat-chip-list #alarmTypeChipList formControlName="alarmTypes">
<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="{{ !alarmTemplateForm.get('alarmTypes').value?.length ? ('alarm.any-type' | translate) : '' }}"
[matChipInputFor]="alarmTypeChipList"
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
matChipInputAddOnBlur
(matChipInputTokenEnd)="addAlarmType($event)">
</mat-chip-list>
2023-01-27 15:47:08 +02:00
</mat-form-field>
2023-02-01 15:58:00 +02:00
<mat-form-field fxFlex class="mat-block">
<mat-label translate>alarm.alarm-severity-list</mat-label>
<mat-chip-list #severitiesChipList formControlName="alarmSeverities"
required>
<mat-chip *ngFor="let severity of alarmTemplateForm.get('alarmSeverities').value"
[removable]="true" (removed)="onSeverityRemoved(severity)">
{{ alarmSeverityTranslationMap.get(severity) | translate }}
<mat-icon matChipRemove>cancel</mat-icon>
</mat-chip>
<input matInput
type="text"
placeholder="{{ !alarmTemplateForm.get('alarmSeverities').value?.length ? ('alarm.any-severity' | translate) : '' }}"
style="max-width: 200px;"
#severityInput
(focusin)="onSeverityInputFocus()"
matAutocompleteOrigin
#origin="matAutocompleteOrigin"
(input)="severityInputChange.next(severityInput.value)"
[matAutocompleteConnectedTo]="origin"
[matAutocomplete]="severityAutocomplete"
[matChipInputFor]="severitiesChipList"
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
(matChipInputTokenEnd)="addSeverityFromChipInput($event)">
</mat-chip-list>
<mat-autocomplete #severityAutocomplete="matAutocomplete"
class="tb-autocomplete"
(optionSelected)="severitySelected($event)"
[displayWith]="displaySeverityFn.bind(this)">
<mat-option *ngFor="let severity of filteredDisplaySeverities | async" [value]="severity">
<span [innerHTML]="alarmSeverityTranslationMap.get(alarmSeverityEnum[severity]) | translate | highlight:severitySearchText"></span>
</mat-option>
<mat-option *ngIf="(filteredDisplaySeverities | async)?.length === 0" [value]="null" class="tb-not-found">
<div class="tb-not-found-content" (click)="$event.stopPropagation()">
<div *ngIf="!textIsNotEmpty(severitySearchText); else searchNotEmpty">
<span translate>notification.no-severity-found</span>
2023-01-31 02:03:51 +02:00
</div>
2023-02-01 15:58:00 +02:00
<ng-template #searchNotEmpty>
<span>
{{ translate.get('notification.no-severity-matching',
{severity: truncate.transform(severitySearchText, true, 6, &apos;...&apos;)}) | async }}
</span>
</ng-template>
</div>
</mat-option>
</mat-autocomplete>
</mat-form-field>
</fieldset>
2023-01-31 02:03:51 +02:00
2023-02-01 15:58:00 +02:00
<fieldset class="fields-group" formGroupName="clearRule">
<legend translate>notification.clear-rule</legend>
<mat-form-field fxFlex class="mat-block" floatLabel="always">
<mat-label translate>alarm.alarm-status-list</mat-label>
<mat-select formControlName="alarmStatus"
placeholder="{{ !alarmTemplateForm.get('clearRule.alarmStatus').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>
</fieldset>
2023-01-31 02:03:51 +02:00
2023-02-01 15:58:00 +02:00
<fieldset class="fields-group">
<legend translate>notification.hierarchy-of-receiving</legend>
<tb-escalations-component formControlName="escalationTable"></tb-escalations-component>
</fieldset>
2023-01-27 15:47:08 +02:00
2023-02-01 15:58:00 +02:00
<mat-form-field class="mat-block">
<mat-label translate>notification.description</mat-label>
<input matInput formControlName="description">
</mat-form-field>
</form>
</mat-step>
2023-01-27 15:47:08 +02:00
2023-02-01 15:58:00 +02:00
<mat-step *ngIf="ruleNotificationForm.get('triggerType').value === triggerType.DEVICE_INACTIVITY"
[stepControl]="deviceInactivityTemplateForm">
<ng-template matStepLabel>{{ 'notification.device-inactivity-trigger-settings' | translate }}</ng-template>
<form [formGroup]="deviceInactivityTemplateForm">
<span translate>notification.filter-by</span>
<div fxFlex fxLayoutAlign="center center">
<mat-button-toggle-group class="tb-notification-unread-toggle-group"
style="width: 250px;"
formControlName="filterByDevice">
<mat-button-toggle fxFlex [value]=true>{{ 'notification.device' | translate }}</mat-button-toggle>
<mat-button-toggle fxFlex [value]=false>{{ 'notification.device-profile' | translate }}</mat-button-toggle>
</mat-button-toggle-group>
</div>
<tb-entity-list
*ngIf="deviceInactivityTemplateForm.get('filterByDevice').value; else deviceProfile"
required
formControlName="devices"
labelText="{{ 'notification.devices' | translate }}"
placeholderText="{{ 'notification.device' | translate }}"
[entityType]="entityType.DEVICE">
</tb-entity-list>
<ng-template #deviceProfile>
2023-01-31 02:03:51 +02:00
<tb-entity-list
required
formControlName="deviceProfiles"
2023-02-01 15:58:00 +02:00
labelText="{{ 'notification.device-profiles' | translate }}"
placeholderText="{{ 'notification.device-profile' | translate }}"
2023-01-31 02:03:51 +02:00
[entityType]="entityType.DEVICE_PROFILE">
</tb-entity-list>
2023-02-01 15:58:00 +02:00
</ng-template>
<tb-entity-list
required
formControlName="targets"
[entityType]="entityType.NOTIFICATION_TARGET"
placeholderText="{{ 'notification.target' | translate }}">
</tb-entity-list>
<mat-form-field class="mat-block">
<mat-label translate>notification.description</mat-label>
<input matInput formControlName="description">
</mat-form-field>
</form>
</mat-step>
2023-01-27 15:47:08 +02:00
2023-02-01 15:58:00 +02:00
<mat-step *ngIf="ruleNotificationForm.get('triggerType').value === triggerType.ENTITY_ACTION"
[stepControl]="entityActionTemplateForm">
<ng-template matStepLabel>{{ 'notification.entity-action-trigger-settings' | translate }}</ng-template>
<form [formGroup]="entityActionTemplateForm">
<fieldset class="fields-group">
<legend translate>notification.filter</legend>
<tb-entity-type-select required
showLabel
[allowedEntityTypes]="entityTypes"
formControlName="entityType">
</tb-entity-type-select>
<section fxLayout="column" fxLayoutGap="8px">
<span fxFlex translate>notification.status</span>
<mat-slide-toggle formControlName="created">{{ 'notification.created' | translate }}</mat-slide-toggle>
<mat-slide-toggle formControlName="updated">{{ 'notification.updated' | translate }}</mat-slide-toggle>
<mat-slide-toggle formControlName="deleted">{{ 'notification.deleted' | translate }}</mat-slide-toggle>
</section>
</fieldset>
<tb-entity-list
required
formControlName="targets"
[entityType]="entityType.NOTIFICATION_TARGET"
placeholderText="notification.target">
</tb-entity-list>
<mat-form-field class="mat-block">
<mat-label translate>notification.description</mat-label>
<input matInput formControlName="description">
</mat-form-field>
</form>
</mat-step>
</mat-horizontal-stepper>
</div>
<mat-divider></mat-divider>
<div mat-dialog-actions fxLayout="row">
<button mat-stroked-button *ngIf="selectedIndex > 0"
(click)="backStep()">{{ 'action.back' | translate }}</button>
<span fxFlex></span>
<button mat-raised-button
color="primary"
(click)="nextStep()">{{ nextStepLabel() | translate }}</button>
</div>