2023-01-12 12:38:03 +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.
|
|
|
|
|
|
|
|
|
|
-->
|
|
|
|
|
<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>
|
2023-01-17 18:26:25 +02:00
|
|
|
<div mat-dialog-content>
|
2023-01-30 10:23:36 +02:00
|
|
|
<mat-horizontal-stepper [linear]="true" labelPosition="end" #notificationTemplateStepper [orientation]="(stepperOrientation | async)"
|
2023-01-12 18:11:37 +02:00
|
|
|
(selectionChange)="changeStep($event)">
|
|
|
|
|
<ng-template matStepperIcon="edit">
|
|
|
|
|
<mat-icon>check</mat-icon>
|
|
|
|
|
</ng-template>
|
|
|
|
|
<mat-step [stepControl]="templateNotificationForm">
|
|
|
|
|
<ng-template matStepLabel>{{ 'notification.basic-settings' | translate }}</ng-template>
|
|
|
|
|
<form [formGroup]="templateNotificationForm" style="padding-bottom: 16px;">
|
|
|
|
|
<mat-form-field class="mat-block">
|
|
|
|
|
<mat-label translate>notification.target-name</mat-label>
|
|
|
|
|
<input matInput formControlName="name" required>
|
|
|
|
|
<mat-error *ngIf="templateNotificationForm.get('name').hasError('required')">
|
|
|
|
|
{{ 'notification.target-name-required' | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
</mat-form-field>
|
2023-01-31 17:46:12 +02:00
|
|
|
<label class="tb-title no-padding" style="margin-bottom: 8px">{{ 'notification.type' | translate }}</label>
|
|
|
|
|
<mat-radio-group formControlName="notificationType" fxLayout="column">
|
|
|
|
|
<mat-radio-button *ngFor="let notificationType of notificationTypes" [value]="notificationType" fxFlex>
|
2023-01-12 18:11:37 +02:00
|
|
|
<div fxLayout="column">
|
|
|
|
|
<div>{{ notificationTemplateTypeTranslateMap.get(notificationType).name | translate }}</div>
|
2023-01-31 17:46:12 +02:00
|
|
|
<div class="tb-hint">{{ notificationTemplateTypeTranslateMap.get(notificationType).hint | translate }}</div>
|
2023-01-12 18:11:37 +02:00
|
|
|
</div>
|
|
|
|
|
</mat-radio-button>
|
|
|
|
|
</mat-radio-group>
|
|
|
|
|
<section formGroupName="configuration">
|
|
|
|
|
<mat-form-field class="mat-block">
|
|
|
|
|
<mat-label translate>notification.subject</mat-label>
|
|
|
|
|
<input matInput formControlName="notificationSubject" required>
|
|
|
|
|
<mat-error *ngIf="templateNotificationForm.get('configuration.notificationSubject').hasError('required')">
|
|
|
|
|
{{ 'notification.subject-required' | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
<mat-form-field class="mat-block">
|
|
|
|
|
<mat-label translate>notification.message</mat-label>
|
|
|
|
|
<input matInput formControlName="defaultTextTemplate" required>
|
|
|
|
|
<mat-error *ngIf="templateNotificationForm.get('configuration.defaultTextTemplate').hasError('required')">
|
|
|
|
|
{{ 'notification.message-required' | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
</mat-form-field>
|
2023-01-17 18:26:25 +02:00
|
|
|
<label class="tb-title tb-required"
|
|
|
|
|
[ngClass]="{'tb-error': templateNotificationForm.get('configuration.deliveryMethodsTemplates').hasError('atLeastOne')}">
|
|
|
|
|
{{ "notification.delivery-methods" | translate }}
|
|
|
|
|
</label>
|
2023-01-12 18:11:37 +02:00
|
|
|
<section formGroupName="deliveryMethodsTemplates" fxLayout="row warap">
|
|
|
|
|
<section *ngFor="let deliveryMethods of notificationDeliveryMethods; even as isEven" class="delivery-method-container"
|
|
|
|
|
[formGroupName]="deliveryMethods" fxFlex="50%" [ngClass]={even:isEven}>
|
2023-01-17 18:26:25 +02:00
|
|
|
<mat-slide-toggle class="delivery-method" formControlName="enabled">
|
|
|
|
|
{{ notificationDeliveryMethodTranslateMap.get(deliveryMethods) | translate }}
|
|
|
|
|
</mat-slide-toggle>
|
2023-01-12 18:11:37 +02:00
|
|
|
</section>
|
|
|
|
|
</section>
|
2023-01-17 18:26:25 +02:00
|
|
|
<div class="tb-hint" translate>notification.at-least-one-should-be-selected</div>
|
2023-01-12 18:11:37 +02:00
|
|
|
</section>
|
|
|
|
|
</form>
|
|
|
|
|
</mat-step>
|
|
|
|
|
<mat-step optional *ngIf="templateNotificationForm.get('configuration.deliveryMethodsTemplates.PUSH.enabled').value"
|
|
|
|
|
[stepControl]="pushTemplateForm">
|
|
|
|
|
<ng-template matStepLabel>{{ 'notification.web-settings' | translate }}</ng-template>
|
|
|
|
|
<form [formGroup]="pushTemplateForm">
|
|
|
|
|
<mat-form-field class="mat-block" floatLabel="always">
|
|
|
|
|
<mat-label translate>notification.subject</mat-label>
|
|
|
|
|
<input matInput formControlName="subject" [placeholder]="templateNotificationForm.get('configuration.notificationSubject').value">
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
<mat-form-field class="mat-block" floatLabel="always">
|
|
|
|
|
<mat-label translate>notification.message</mat-label>
|
2023-01-31 17:06:55 +02:00
|
|
|
<textarea matInput
|
|
|
|
|
cdkTextareaAutosize
|
2023-01-31 17:46:12 +02:00
|
|
|
cols="1"
|
|
|
|
|
cdkAutosizeMinRows="1"
|
2023-01-31 17:06:55 +02:00
|
|
|
formControlName="body"
|
|
|
|
|
[placeholder]="templateNotificationForm.get('configuration.defaultTextTemplate').value">
|
|
|
|
|
</textarea>
|
2023-01-12 18:11:37 +02:00
|
|
|
</mat-form-field>
|
2023-01-20 18:08:30 +02:00
|
|
|
<section formGroupName="additionalConfig">
|
|
|
|
|
<section formGroupName="icon" class="additional-config-group">
|
|
|
|
|
<mat-slide-toggle formControlName="enabled" class="toggle">
|
|
|
|
|
{{ 'icon.icon' | translate }}
|
|
|
|
|
</mat-slide-toggle>
|
|
|
|
|
<div *ngIf="pushTemplateForm.get('additionalConfig.icon.enabled').value" fxLayout="row" fxLayoutGap="12px">
|
|
|
|
|
<tb-material-icon-select formControlName="icon" required fxFlex>
|
|
|
|
|
</tb-material-icon-select>
|
|
|
|
|
<tb-color-input formControlName="color" fxFlex>
|
|
|
|
|
</tb-color-input>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
<section formGroupName="actionButtonConfig" class="additional-config-group">
|
|
|
|
|
<mat-slide-toggle formControlName="enabled" class="toggle">
|
|
|
|
|
{{ 'notification.action-button' | translate }}
|
|
|
|
|
</mat-slide-toggle>
|
|
|
|
|
<div *ngIf="pushTemplateForm.get('additionalConfig.actionButtonConfig.enabled').value">
|
|
|
|
|
<div fxLayout="row" fxLayoutGap="12px">
|
|
|
|
|
<mat-form-field class="mat-block" fxFlex>
|
|
|
|
|
<mat-label translate>notification.button-text</mat-label>
|
|
|
|
|
<input matInput formControlName="text" required>
|
|
|
|
|
<mat-error *ngIf="pushTemplateForm.get('additionalConfig.actionButtonConfig.text').hasError('required')">
|
|
|
|
|
{{ 'notification.button-text-required' | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
<tb-color-input formControlName="color" fxFlex>
|
|
|
|
|
</tb-color-input>
|
|
|
|
|
</div>
|
|
|
|
|
<mat-form-field class="mat-block">
|
|
|
|
|
<mat-label translate>notification.link</mat-label>
|
|
|
|
|
<input matInput formControlName="link" required>
|
|
|
|
|
<mat-error *ngIf="pushTemplateForm.get('additionalConfig.actionButtonConfig.link').hasError('required')">
|
|
|
|
|
{{ 'notification.link-required' | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
</section>
|
2023-01-12 18:11:37 +02:00
|
|
|
</form>
|
|
|
|
|
</mat-step>
|
|
|
|
|
<mat-step optional *ngIf="templateNotificationForm.get('configuration.deliveryMethodsTemplates.EMAIL.enabled').value"
|
|
|
|
|
[stepControl]="emailTemplateForm">
|
|
|
|
|
<ng-template matStepLabel>{{ 'notification.email-settings' | translate }}</ng-template>
|
|
|
|
|
<ng-template matStepContent>
|
|
|
|
|
<form [formGroup]="emailTemplateForm">
|
|
|
|
|
<mat-form-field class="mat-block" floatLabel="always">
|
|
|
|
|
<mat-label translate>notification.subject</mat-label>
|
|
|
|
|
<input matInput formControlName="subject" [placeholder]="templateNotificationForm.get('configuration.notificationSubject').value">
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
<mat-label class="tb-title" translate>notification.message</mat-label>
|
|
|
|
|
<editor [init]="tinyMceOptions" formControlName="body"></editor>
|
|
|
|
|
</form>
|
|
|
|
|
</ng-template>
|
|
|
|
|
</mat-step>
|
|
|
|
|
<mat-step optional *ngIf="templateNotificationForm.get('configuration.deliveryMethodsTemplates.SMS.enabled').value"
|
|
|
|
|
[stepControl]="smsTemplateForm">
|
|
|
|
|
<ng-template matStepLabel>{{ 'notification.sms-settings' | translate }}</ng-template>
|
|
|
|
|
<form [formGroup]="smsTemplateForm">
|
|
|
|
|
<mat-form-field class="mat-block" floatLabel="always">
|
|
|
|
|
<mat-label translate>notification.message</mat-label>
|
2023-01-31 17:06:55 +02:00
|
|
|
<textarea matInput
|
|
|
|
|
cdkTextareaAutosize
|
2023-01-31 17:46:12 +02:00
|
|
|
cols="1"
|
|
|
|
|
cdkAutosizeMinRows="1"
|
2023-01-31 17:06:55 +02:00
|
|
|
formControlName="body"
|
|
|
|
|
[placeholder]="templateNotificationForm.get('configuration.defaultTextTemplate').value">
|
|
|
|
|
</textarea>
|
2023-01-12 18:11:37 +02:00
|
|
|
</mat-form-field>
|
|
|
|
|
</form>
|
|
|
|
|
</mat-step>
|
|
|
|
|
<mat-step optional *ngIf="templateNotificationForm.get('configuration.deliveryMethodsTemplates.SLACK.enabled').value"
|
|
|
|
|
[stepControl]="slackTemplateForm">
|
|
|
|
|
<ng-template matStepLabel>{{ 'notification.slack-settings' | translate }}</ng-template>
|
2023-01-26 13:36:55 +02:00
|
|
|
<form [formGroup]="slackTemplateForm" fxLayoutGap="8px">
|
2023-01-12 18:11:37 +02:00
|
|
|
<mat-form-field class="mat-block" floatLabel="always">
|
|
|
|
|
<mat-label translate>notification.message</mat-label>
|
2023-01-31 17:06:55 +02:00
|
|
|
<textarea matInput
|
|
|
|
|
cdkTextareaAutosize
|
2023-01-31 17:46:12 +02:00
|
|
|
cols="1"
|
|
|
|
|
cdkAutosizeMinRows="1"
|
2023-01-31 17:06:55 +02:00
|
|
|
formControlName="body"
|
|
|
|
|
[placeholder]="templateNotificationForm.get('configuration.defaultTextTemplate').value">
|
|
|
|
|
</textarea>
|
2023-01-12 18:11:37 +02:00
|
|
|
</mat-form-field>
|
|
|
|
|
</form>
|
|
|
|
|
</mat-step>
|
|
|
|
|
</mat-horizontal-stepper>
|
|
|
|
|
</div>
|
2023-01-12 12:38:03 +02:00
|
|
|
<mat-divider></mat-divider>
|
2023-01-12 18:11:37 +02:00
|
|
|
<div mat-dialog-actions fxLayout="row">
|
|
|
|
|
<button mat-stroked-button *ngIf="selectedIndex > 0"
|
|
|
|
|
(click)="backStep()">{{ 'action.back' | translate }}</button>
|
|
|
|
|
<span fxFlex></span>
|
|
|
|
|
<button *ngIf="selectedIndex > 0"
|
|
|
|
|
mat-button mat-stroked-button color="primary">
|
|
|
|
|
{{ 'notification.send-test-notification' | translate }}
|
|
|
|
|
</button>
|
2023-01-12 12:38:03 +02:00
|
|
|
<button mat-raised-button
|
|
|
|
|
color="primary"
|
2023-01-12 18:11:37 +02:00
|
|
|
(click)="nextStep()">{{ nextStepLabel() | translate }}</button>
|
2023-01-12 12:38:03 +02:00
|
|
|
</div>
|