2023-01-17 18:26:25 +02:00
|
|
|
<!--
|
|
|
|
|
|
2024-01-09 10:46:16 +02:00
|
|
|
Copyright © 2016-2024 The Thingsboard Authors
|
2023-01-17 18:26:25 +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.
|
|
|
|
|
|
|
|
|
|
-->
|
|
|
|
|
<mat-toolbar color="primary">
|
2023-01-30 10:23:36 +02:00
|
|
|
<h2>{{ dialogTitle | translate }}</h2>
|
2023-01-17 18:26:25 +02:00
|
|
|
<span fxFlex></span>
|
2023-04-21 15:30:27 +03:00
|
|
|
<div tb-help="sentNotification"></div>
|
2023-01-17 18:26:25 +02:00
|
|
|
<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 mat-dialog-content>
|
2023-03-22 17:08:10 +02:00
|
|
|
<mat-horizontal-stepper linear #createNotification
|
2024-02-07 17:50:47 +02:00
|
|
|
labelPosition="end"
|
2023-01-17 18:26:25 +02:00
|
|
|
[orientation]="(stepperOrientation | async)"
|
|
|
|
|
(selectionChange)="changeStep($event)">
|
|
|
|
|
<ng-template matStepperIcon="edit">
|
|
|
|
|
<mat-icon>check</mat-icon>
|
|
|
|
|
</ng-template>
|
|
|
|
|
<mat-step [stepControl]="notificationRequestForm">
|
2024-02-19 14:15:18 +02:00
|
|
|
<ng-template matStepLabel>{{ 'notification.setup' | translate }}</ng-template>
|
2023-02-20 11:30:26 +02:00
|
|
|
<form [formGroup]="notificationRequestForm">
|
2023-06-12 18:16:24 +03:00
|
|
|
<div fxLayoutAlign="center">
|
2024-02-14 15:59:41 +02:00
|
|
|
<tb-toggle-select formControlName="useTemplate" appearance="fill">
|
|
|
|
|
<tb-toggle-option [value]="false">{{ 'notification.start-from-scratch' | translate }}</tb-toggle-option>
|
|
|
|
|
<tb-toggle-option [value]="true">{{ 'notification.use-template' | translate }}</tb-toggle-option>
|
|
|
|
|
</tb-toggle-select>
|
2023-02-13 18:00:23 +02:00
|
|
|
</div>
|
2023-03-23 12:15:29 +02:00
|
|
|
<div *ngIf="notificationRequestForm.get('useTemplate').value; else scratchTemplate">
|
|
|
|
|
<tb-template-autocomplete
|
2023-05-19 18:01:37 +03:00
|
|
|
required allowCreate allowEdit
|
2023-03-23 12:15:29 +02:00
|
|
|
formControlName="templateId"
|
|
|
|
|
[notificationTypes]="notificationType.GENERAL">
|
|
|
|
|
</tb-template-autocomplete>
|
|
|
|
|
<ng-container *ngTemplateOutlet="recipientsList"></ng-container>
|
|
|
|
|
</div>
|
2023-02-13 18:00:23 +02:00
|
|
|
<ng-template #scratchTemplate>
|
2023-03-23 12:15:29 +02:00
|
|
|
<ng-container *ngTemplateOutlet="recipientsList"></ng-container>
|
2023-02-13 18:00:23 +02:00
|
|
|
<section formGroupName="template">
|
|
|
|
|
<section formGroupName="configuration">
|
2023-04-24 15:55:36 +03:00
|
|
|
<div class="delivery-title">
|
|
|
|
|
<div>
|
|
|
|
|
<label [ngClass]="{'tb-error': notificationRequestForm.get('template.configuration.deliveryMethodsTemplates').hasError('atLeastOne')}"
|
|
|
|
|
class="tb-title tb-required">{{ "notification.delivery-methods" | translate }}</label>
|
2024-02-14 15:59:41 +02:00
|
|
|
<div class="tb-form-hint" translate>notification.at-least-one-should-be-selected</div>
|
2023-04-24 15:55:36 +03:00
|
|
|
</div>
|
|
|
|
|
<button
|
2023-04-24 16:02:18 +03:00
|
|
|
matTooltip="{{ 'notification.refresh-allow-delivery-method' | translate }}"
|
2023-04-24 15:55:36 +03:00
|
|
|
matTooltipPosition="above"
|
|
|
|
|
(click)="refreshAllowDeliveryMethod()"
|
|
|
|
|
*ngIf="showRefresh"
|
|
|
|
|
mat-icon-button>
|
|
|
|
|
<mat-icon>refresh</mat-icon>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2023-04-24 13:18:41 +03:00
|
|
|
<section formGroupName="deliveryMethodsTemplates" class="delivery-methods-container">
|
|
|
|
|
<ng-container *ngFor="let deliveryMethods of notificationDeliveryMethods">
|
|
|
|
|
<a *ngIf="isInteractDeliveryMethod(deliveryMethods); else deliveryMethod"
|
2024-02-14 15:59:41 +02:00
|
|
|
class="tb-form-panel stroked delivery-method-container tb-pointer interact"
|
2023-04-24 13:18:41 +03:00
|
|
|
[routerLink]="configurationPage(deliveryMethods)"
|
|
|
|
|
[formGroupName]="deliveryMethods"
|
|
|
|
|
[matTooltip]="getDeliveryMethodsTooltip(deliveryMethods)"
|
|
|
|
|
matTooltipPosition="above">
|
|
|
|
|
<mat-slide-toggle class="delivery-method" formControlName="enabled">
|
2024-02-07 17:50:47 +02:00
|
|
|
{{ notificationDeliveryMethodInfoMap.get(deliveryMethods).name | translate }}
|
2023-04-24 13:18:41 +03:00
|
|
|
</mat-slide-toggle>
|
|
|
|
|
<mat-icon *ngIf="isInteractDeliveryMethod(deliveryMethods)">
|
|
|
|
|
chevron_right
|
|
|
|
|
</mat-icon>
|
|
|
|
|
</a>
|
|
|
|
|
<ng-template #deliveryMethod>
|
2024-02-14 15:59:41 +02:00
|
|
|
<section class="delivery-method-container tb-form-panel stroked"
|
2023-04-24 13:18:41 +03:00
|
|
|
[formGroupName]="deliveryMethods"
|
|
|
|
|
[matTooltip]="getDeliveryMethodsTooltip(deliveryMethods)"
|
|
|
|
|
[matTooltipDisabled]="getDeliveryMethodsTemplatesControl(deliveryMethods).enabled"
|
|
|
|
|
matTooltipPosition="above">
|
|
|
|
|
<mat-slide-toggle class="delivery-method" formControlName="enabled">
|
2024-02-07 17:50:47 +02:00
|
|
|
{{ notificationDeliveryMethodInfoMap.get(deliveryMethods).name | translate }}
|
2023-04-24 13:18:41 +03:00
|
|
|
</mat-slide-toggle>
|
|
|
|
|
</section>
|
|
|
|
|
</ng-template>
|
|
|
|
|
</ng-container>
|
2023-02-13 18:00:23 +02:00
|
|
|
</section>
|
|
|
|
|
</section>
|
|
|
|
|
</section>
|
|
|
|
|
</ng-template>
|
2023-03-23 12:15:29 +02:00
|
|
|
<ng-template #recipientsList>
|
|
|
|
|
<tb-entity-list
|
2024-08-19 18:31:06 +03:00
|
|
|
syncIdsWithDB
|
2023-03-23 12:15:29 +02:00
|
|
|
required
|
|
|
|
|
formControlName="targets"
|
2023-03-23 17:42:04 +02:00
|
|
|
labelText="{{ 'notification.recipients' | translate }}"
|
|
|
|
|
placeholderText="{{ 'notification.recipient' | translate }}"
|
|
|
|
|
requiredText="{{ 'notification.recipients-required' | translate }}"
|
2023-03-23 12:15:29 +02:00
|
|
|
entityType="{{ entityType.NOTIFICATION_TARGET }}"
|
|
|
|
|
subType="{{ notificationType.GENERAL }}">
|
|
|
|
|
<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>
|
|
|
|
|
</ng-template>
|
2024-02-14 15:59:41 +02:00
|
|
|
<section formGroupName="additionalConfig" class="tb-form-panel stroked no-padding-bottom no-gap">
|
2023-02-15 17:49:28 +02:00
|
|
|
<mat-slide-toggle formControlName="enabled" class="toggle">
|
|
|
|
|
{{ 'notification.scheduler-later' | translate }}
|
|
|
|
|
</mat-slide-toggle>
|
|
|
|
|
<div *ngIf="notificationRequestForm.get('additionalConfig.enabled').value" fxLayout="column">
|
|
|
|
|
<tb-timezone-select userTimezoneByDefault
|
|
|
|
|
required
|
|
|
|
|
formControlName="timezone">
|
|
|
|
|
</tb-timezone-select>
|
|
|
|
|
<mat-form-field>
|
|
|
|
|
<mat-label translate>notification.time</mat-label>
|
|
|
|
|
<mat-datetimepicker-toggle [for]="startTimePicker" matPrefix></mat-datetimepicker-toggle>
|
2023-05-08 17:08:32 +03:00
|
|
|
<mat-datetimepicker #startTimePicker type="datetime" openOnFocus="true"></mat-datetimepicker>
|
2023-02-15 17:49:28 +02:00
|
|
|
<input required matInput fxFlex formControlName="time" [min]="minDate()" [max]="maxDate()" [matDatetimepicker]="startTimePicker">
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
2023-02-13 18:00:23 +02:00
|
|
|
</form>
|
|
|
|
|
</mat-step>
|
2024-02-07 17:50:47 +02:00
|
|
|
<mat-step *ngIf="!notificationRequestForm.get('useTemplate').value"
|
|
|
|
|
[stepControl]="notificationTemplateConfigurationForm" #composeStep=matStep>
|
|
|
|
|
<ng-template matStepLabel>{{ 'notification.compose' | translate }}</ng-template>
|
2024-02-21 18:24:00 +02:00
|
|
|
<ng-template matStepContent>
|
|
|
|
|
<form [formGroup]="notificationTemplateConfigurationForm">
|
|
|
|
|
<tb-template-configuration
|
|
|
|
|
notificationType="{{ notificationType.GENERAL }}"
|
|
|
|
|
[predefinedDeliveryMethodsTemplate]="deliveryConfiguration"
|
|
|
|
|
[interacted]="composeStep.interacted"
|
|
|
|
|
formControlName="deliveryMethodsTemplates">
|
|
|
|
|
</tb-template-configuration>
|
|
|
|
|
</form>
|
|
|
|
|
</ng-template>
|
2023-05-10 18:20:58 +03:00
|
|
|
</mat-step>
|
2023-02-15 17:49:28 +02:00
|
|
|
<mat-step>
|
2023-01-17 18:26:25 +02:00
|
|
|
<ng-template matStepLabel>{{ 'notification.review' | translate }}</ng-template>
|
2024-02-21 18:24:00 +02:00
|
|
|
<div class="tb-loader" *ngIf="(isLoading$ | async) && !preview">
|
|
|
|
|
<mat-progress-spinner color="warn" mode="indeterminate"
|
|
|
|
|
strokeWidth="5">
|
|
|
|
|
</mat-progress-spinner>
|
|
|
|
|
</div>
|
2024-02-14 15:59:41 +02:00
|
|
|
<div *ngIf="preview" class="tb-form-panel no-padding no-border">
|
|
|
|
|
<section class="preview-group tb-form-panel stroked no-gap">
|
2023-01-20 18:08:30 +02:00
|
|
|
<div fxLayout="row" fxLayoutGap="8px" fxLayoutAlign="start center">
|
2024-02-14 15:59:41 +02:00
|
|
|
<tb-icon class="tb-mat-18">supervisor_account</tb-icon>
|
|
|
|
|
<div class="tb-form-panel-title">{{ 'notification.recipients-count' | translate : {count: preview.totalRecipientsCount} }}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="details-recipients" *ngIf="notificationRequestForm.get('targets').value?.length > 1">
|
|
|
|
|
<div *ngFor="let detail of preview.recipientsCountByTarget | keyvalue" class="details-recipient">
|
|
|
|
|
<span class="number">{{ detail.value }}</span>{{ detail.key }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<mat-divider class="divider"></mat-divider>
|
|
|
|
|
<mat-chip-listbox>
|
|
|
|
|
<mat-chip *ngFor="let recipientTitle of preview.recipientsPreview">
|
|
|
|
|
<span>{{ recipientTitle }}</span>
|
|
|
|
|
</mat-chip>
|
|
|
|
|
</mat-chip-listbox>
|
|
|
|
|
</section>
|
|
|
|
|
<section class="preview-group notification tb-form-panel stroked no-gap" *ngIf="preview.processedTemplates.WEB?.enabled">
|
|
|
|
|
<div fxLayout="row" fxLayoutGap="8px" fxLayoutAlign="start center">
|
|
|
|
|
<tb-icon class="tb-mat-18">mdi:bell-badge</tb-icon>
|
|
|
|
|
<div class="tb-form-panel-title" translate>notification.delivery-method.web-preview</div>
|
2023-01-20 18:08:30 +02:00
|
|
|
</div>
|
|
|
|
|
<div class="web-preview">
|
2023-03-15 13:28:31 +02:00
|
|
|
<tb-notification preview [notification]="preview.processedTemplates.WEB"></tb-notification>
|
2023-01-20 18:08:30 +02:00
|
|
|
</div>
|
|
|
|
|
</section>
|
2024-02-14 15:59:41 +02:00
|
|
|
<section class="preview-group notification tb-form-panel stroked no-gap" *ngIf="preview.processedTemplates.MOBILE_APP?.enabled">
|
2023-02-15 17:49:28 +02:00
|
|
|
<div fxLayout="row" fxLayoutGap="8px" fxLayoutAlign="start center">
|
2024-02-14 15:59:41 +02:00
|
|
|
<tb-icon class="tb-mat-18">mdi:cellphone-text</tb-icon>
|
|
|
|
|
<div class="tb-form-panel-title" translate>notification.delivery-method.mobile-app-preview</div>
|
2023-02-15 17:49:28 +02:00
|
|
|
</div>
|
|
|
|
|
<div class="notification-content">
|
2024-02-14 15:59:41 +02:00
|
|
|
<div class="subject">{{ preview.processedTemplates.MOBILE_APP.subject }}</div>
|
|
|
|
|
<div>{{ preview.processedTemplates.MOBILE_APP.body }}</div>
|
2023-02-15 17:49:28 +02:00
|
|
|
</div>
|
|
|
|
|
</section>
|
2024-02-14 15:59:41 +02:00
|
|
|
<section class="preview-group notification tb-form-panel stroked no-gap" *ngIf="preview.processedTemplates.SMS?.enabled">
|
2023-02-15 17:49:28 +02:00
|
|
|
<div fxLayout="row" fxLayoutGap="8px" fxLayoutAlign="start center">
|
2024-02-14 15:59:41 +02:00
|
|
|
<tb-icon class="tb-mat-18">mdi:message-processing</tb-icon>
|
|
|
|
|
<div class="tb-form-panel-title" translate>notification.delivery-method.sms-preview</div>
|
2023-02-15 17:49:28 +02:00
|
|
|
</div>
|
|
|
|
|
<div class="notification-content">
|
|
|
|
|
{{ preview.processedTemplates.SMS.body }}
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
2024-02-14 15:59:41 +02:00
|
|
|
<section class="preview-group notification tb-form-panel stroked no-gap" *ngIf="preview.processedTemplates.EMAIL?.enabled">
|
2023-02-15 17:49:28 +02:00
|
|
|
<div fxLayout="row" fxLayoutGap="8px" fxLayoutAlign="start center">
|
2024-02-14 15:59:41 +02:00
|
|
|
<tb-icon class="tb-mat-18">mdi:email</tb-icon>
|
|
|
|
|
<div class="tb-form-panel-title" translate>notification.delivery-method.email-preview</div>
|
2023-02-15 17:49:28 +02:00
|
|
|
</div>
|
|
|
|
|
<div class="notification-content">
|
2024-02-14 15:59:41 +02:00
|
|
|
<div class="subject">{{ preview.processedTemplates.EMAIL.subject }}</div>
|
|
|
|
|
<mat-divider></mat-divider>
|
|
|
|
|
<div class="html-content" [innerHTML]="(preview.processedTemplates.EMAIL.body | safe: 'html')"></div>
|
2023-02-15 17:49:28 +02:00
|
|
|
</div>
|
|
|
|
|
</section>
|
2024-02-14 15:59:41 +02:00
|
|
|
<section class="preview-group notification tb-form-panel stroked no-gap" *ngIf="preview.processedTemplates.SLACK?.enabled">
|
2023-05-10 18:20:58 +03:00
|
|
|
<div fxLayout="row" fxLayoutGap="8px" fxLayoutAlign="start center">
|
2024-02-14 15:59:41 +02:00
|
|
|
<tb-icon class="tb-mat-18">mdi:slack</tb-icon>
|
|
|
|
|
<div class="tb-form-panel-title" translate>notification.delivery-method.slack-preview</div>
|
2023-05-10 18:20:58 +03:00
|
|
|
</div>
|
|
|
|
|
<div class="notification-content">
|
2024-02-14 15:59:41 +02:00
|
|
|
{{ preview.processedTemplates.SLACK.body }}
|
2023-05-10 18:20:58 +03:00
|
|
|
</div>
|
|
|
|
|
</section>
|
2024-02-14 15:59:41 +02:00
|
|
|
<section class="preview-group notification tb-form-panel stroked no-gap" *ngIf="preview.processedTemplates.MICROSOFT_TEAMS?.enabled">
|
2023-07-25 17:50:39 +03:00
|
|
|
<div fxLayout="row" fxLayoutGap="8px" fxLayoutAlign="start center">
|
2024-02-14 15:59:41 +02:00
|
|
|
<tb-icon class="tb-mat-18">mdi:microsoft-teams</tb-icon>
|
|
|
|
|
<div class="tb-form-panel-title" translate>notification.delivery-method.microsoft-teams-preview</div>
|
2023-07-25 17:50:39 +03:00
|
|
|
</div>
|
|
|
|
|
<div class="notification-content mini">
|
|
|
|
|
<div class="subject">{{ preview.processedTemplates.MICROSOFT_TEAMS.subject }}</div>
|
|
|
|
|
{{ preview.processedTemplates.MICROSOFT_TEAMS.body }}
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
2023-01-17 18:26:25 +02:00
|
|
|
</div>
|
|
|
|
|
</mat-step>
|
|
|
|
|
</mat-horizontal-stepper>
|
|
|
|
|
</div>
|
|
|
|
|
<mat-divider></mat-divider>
|
2023-07-25 17:50:39 +03:00
|
|
|
<div mat-dialog-actions class="tb-dialog-actions">
|
2023-01-17 18:26:25 +02:00
|
|
|
<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>
|