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

265 lines
13 KiB
HTML
Raw Normal View History

2023-01-23 14:54:15 +02:00
<!--
Copyright © 2016-2023 The Thingsboard Authors
2023-01-23 14:54:15 +02:00
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">
2023-02-01 15:58:00 +02:00
<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
allowCreate
2023-02-01 15:58:00 +02:00
formControlName="templateId"
[notificationTypes]="ruleNotificationForm.get('triggerType').value">
2023-02-01 15:58:00 +02:00
</tb-template-autocomplete>
<section formGroupName="recipientsConfig"
*ngIf="ruleNotificationForm.get('triggerType').value !== triggerType.ALARM; else alarmTargesConfig">
<tb-entity-list
required
formControlName="targets"
[entityType]="entityType.NOTIFICATION_TARGET"
placeholderText="{{ 'notification.target' | translate }}">
<button #createTargetButton
mat-button color="primary" matSuffix
(click)="createTarget($event, createTargetButton)">
<span style="white-space: nowrap">{{ 'notification.create-new' | translate }}</span>
</button>
</tb-entity-list>
</section>
<ng-template #alarmTargesConfig>
<fieldset class="fields-group tb-hierarchy" formGroupName="recipientsConfig">
2023-03-15 13:28:31 +02:00
<legend translate>notification.notification-chain</legend>
<tb-escalations-component formControlName="escalationTable"></tb-escalations-component>
</fieldset>
</ng-template>
2023-02-01 15:58:00 +02:00
</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">
2023-02-02 15:25:04 +02:00
<section formGroupName="triggerConfig">
<fieldset class="fields-group tb-margin">
2023-02-02 15:25:04 +02:00
<legend translate>notification.filter</legend>
2023-02-13 16:11:23 +02:00
<tb-string-items-list
editable
2023-02-13 16:11:23 +02:00
label="{{ 'alarm.alarm-type-list' | translate }}"
placeholder="{{ !alarmTemplateForm.get('triggerConfig.alarmTypes').value?.length ? ('alarm.any-type' | translate) : '' }}"
floatLabel="always"
2023-02-02 15:25:04 +02:00
formControlName="alarmTypes">
2023-02-13 16:11:23 +02:00
</tb-string-items-list>
2023-01-27 15:47:08 +02:00
<mat-form-field fxFlex class="mat-block" floatLabel="always">
<mat-label translate>alarm.alarm-severity-list</mat-label>
<mat-select formControlName="alarmSeverities" multiple
placeholder="{{ !alarmTemplateForm.get('triggerConfig.alarmSeverities').value?.length ? ('alarm.any-severity' | translate) : '' }}">
<mat-option *ngFor="let alarmSeverity of alarmSeverities" [value]="alarmSeverity">
{{ alarmSeverityTranslationMap.get(alarmSeverity) | translate }}
</mat-option>
</mat-select>
</mat-form-field>
2023-02-02 15:25:04 +02:00
</fieldset>
2023-01-31 02:03:51 +02:00
2023-03-15 13:28:31 +02:00
<fieldset class="fields-group tb-margin-2" formGroupName="clearRule" *ngIf="countRecipientsChainConfig() > 1">
2023-02-02 15:25:04 +02:00
<legend translate>notification.clear-rule</legend>
<mat-form-field fxFlex class="mat-block" floatLabel="always">
<mat-label translate>alarm.alarm-status-list</mat-label>
2023-03-14 16:37:05 +02:00
<mat-select formControlName="alarmStatuses" multiple
placeholder="{{ !alarmTemplateForm.get('triggerConfig.clearRule.alarmStatuses').value?.length ? ('alarm.any-status' | translate) : '' }}">
2023-02-02 15:25:04 +02:00
<mat-option *ngFor="let searchStatus of alarmSearchStatuses" [value]="searchStatus">
{{ alarmSearchStatusTranslationMap.get(searchStatus) | translate }}
</mat-option>
</mat-select>
</mat-form-field>
</fieldset>
</section>
</form>
<form [formGroup]="ruleNotificationForm">
<section formGroupName="additionalConfig">
<mat-form-field class="mat-block">
<mat-label translate>notification.description</mat-label>
<input matInput formControlName="description">
</mat-form-field>
</section>
2023-02-01 15:58:00 +02:00
</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">
2023-02-02 15:25:04 +02:00
<section formGroupName="triggerConfig">
<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>
<ng-container *ngIf="deviceInactivityTemplateForm.get('triggerConfig.filterByDevice').value; else deviceProfile">
<tb-entity-list
formControlName="devices"
subscriptSizing="dynamic"
2023-02-02 15:25:04 +02:00
labelText="{{ 'notification.devices' | translate }}"
placeholderText="{{ 'notification.devices' | translate }}"
hint="{{ 'notification.device-list-rule-hint' | translate }}"
2023-02-02 15:25:04 +02:00
[entityType]="entityType.DEVICE">
</tb-entity-list>
</ng-container>
<ng-template #deviceProfile>
<tb-entity-list
formControlName="deviceProfiles"
subscriptSizing="dynamic"
2023-02-02 15:25:04 +02:00
labelText="{{ 'notification.device-profiles' | translate }}"
placeholderText="{{ 'notification.device-profiles' | translate }}"
hint="{{ 'notification.device-profiles-list-rule-hint' | translate }}"
2023-02-02 15:25:04 +02:00
[entityType]="entityType.DEVICE_PROFILE">
</tb-entity-list>
</ng-template>
</section>
</form>
<form [formGroup]="ruleNotificationForm">
<section formGroupName="additionalConfig">
<mat-form-field class="mat-block">
<mat-label translate>notification.description</mat-label>
<input matInput formControlName="description">
</mat-form-field>
</section>
2023-02-01 15:58:00 +02:00
</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 tb-margin" formGroupName="triggerConfig">
2023-02-01 15:58:00 +02:00
<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>
</form>
<form [formGroup]="ruleNotificationForm">
<section formGroupName="additionalConfig">
<mat-form-field class="mat-block">
<mat-label translate>notification.description</mat-label>
<input matInput formControlName="description">
</mat-form-field>
</section>
2023-02-01 15:58:00 +02:00
</form>
</mat-step>
<mat-step *ngIf="ruleNotificationForm.get('triggerType').value === triggerType.ALARM_COMMENT"
[stepControl]="alarmCommentTemplateForm">
<ng-template matStepLabel>{{ 'notification.alarm-comment-trigger-settings' | translate }}</ng-template>
<form [formGroup]="alarmCommentTemplateForm">
<section formGroupName="triggerConfig">
<fieldset class="fields-group tb-margin">
<legend translate>notification.filter</legend>
<tb-string-items-list
editable
label="{{ 'alarm.alarm-type-list' | translate }}"
placeholder="{{ !alarmCommentTemplateForm.get('triggerConfig.alarmTypes').value?.length ? ('alarm.any-type' | translate) : '' }}"
floatLabel="always"
formControlName="alarmTypes">
</tb-string-items-list>
<mat-form-field fxFlex class="mat-block" floatLabel="always">
<mat-label translate>alarm.alarm-severity-list</mat-label>
<mat-select formControlName="alarmSeverities" multiple
placeholder="{{ !alarmCommentTemplateForm.get('triggerConfig.alarmSeverities').value?.length ? ('alarm.any-severity' | translate) : '' }}">
<mat-option *ngFor="let alarmSeverity of alarmSeverities" [value]="alarmSeverity">
{{ alarmSeverityTranslationMap.get(alarmSeverity) | translate }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field fxFlex class="mat-block" floatLabel="always">
<mat-label translate>alarm.alarm-status-list</mat-label>
2023-03-14 16:37:05 +02:00
<mat-select formControlName="alarmStatuses" multiple
placeholder="{{ !alarmCommentTemplateForm.get('triggerConfig.alarmStatuses').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>
</section>
2023-02-02 15:25:04 +02:00
</form>
<form [formGroup]="ruleNotificationForm">
2023-03-09 17:10:09 +02:00
<section formGroupName="additionalConfig">
2023-02-02 15:25:04 +02:00
<mat-form-field class="mat-block">
<mat-label translate>notification.description</mat-label>
<input matInput formControlName="description">
</mat-form-field>
</section>
2023-02-01 15:58:00 +02:00
</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>