-
notification.first-recipient
-
+
notification.first-recipient
+
+
After
notification.notify
+
-
+
+
diff --git a/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/escalation-form.component.scss b/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/escalation-form.component.scss
index f80a0a7cef..1ce2454b8c 100644
--- a/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/escalation-form.component.scss
+++ b/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/escalation-form.component.scss
@@ -32,3 +32,13 @@
padding: 0 10px;
}
}
+
+:host ::ng-deep {
+ tb-timeinterval {
+ min-width: 100px;
+
+ .mat-form-field-infix {
+ width: 100%;
+ }
+ }
+}
diff --git a/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/escalation-form.component.ts b/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/escalation-form.component.ts
index e5c638ba3c..57510e8d3a 100644
--- a/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/escalation-form.component.ts
+++ b/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/escalation-form.component.ts
@@ -25,12 +25,17 @@ import {
Validator,
Validators
} from '@angular/forms';
-import { UtilsService } from '@core/services/utils.service';
import { isDefinedAndNotNull } from '@core/utils';
import { Subject } from 'rxjs';
-import { NonConfirmedNotificationEscalation } from '@shared/models/notification.models';
+import { NonConfirmedNotificationEscalation, NotificationTarget } from '@shared/models/notification.models';
import { EntityType } from '@shared/models/entity-type.models';
import { takeUntil } from 'rxjs/operators';
+import {
+ TargetNotificationDialogComponent,
+ TargetsNotificationDialogData
+} from '@home/pages/notification-center/targets-table/target-notification-dialog.componet';
+import { MatDialog } from '@angular/material/dialog';
+import { MatButton } from '@angular/material/button';
@Component({
selector: 'tb-escalation-form',
@@ -66,8 +71,8 @@ export class EscalationFormComponent implements ControlValueAccessor, OnInit, On
private propagateChangePending = false;
private destroy$ = new Subject();
- constructor(private utils: UtilsService,
- private fb: FormBuilder) {
+ constructor(private fb: FormBuilder,
+ private dialog: MatDialog) {
}
registerOnChange(fn: any): void {
@@ -120,6 +125,29 @@ export class EscalationFormComponent implements ControlValueAccessor, OnInit, On
}
}
+ createTarget($event: Event, button: MatButton) {
+ if ($event) {
+ $event.stopPropagation();
+ }
+ button._elementRef.nativeElement.blur();
+ this.dialog.open
(TargetNotificationDialogComponent, {
+ disableClose: true,
+ panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
+ data: {}
+ }).afterClosed()
+ .subscribe((res) => {
+ if (res) {
+ let formValue: string[] = this.escalationFormGroup.get('targets').value;
+ if (!formValue) {
+ formValue = [];
+ }
+ formValue.push(res.id.id);
+ this.escalationFormGroup.get('targets').patchValue(formValue);
+ }
+ });
+ }
+
public validate(c: FormControl) {
return (this.escalationFormGroup.valid) ? null : {
escalation: {
diff --git a/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/escalations.component.html b/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/escalations.component.html
index e11a1227f7..971832300b 100644
--- a/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/escalations.component.html
+++ b/ui-ngx/src/app/modules/home/pages/notification-center/rule-table/escalations.component.html
@@ -21,7 +21,10 @@
*ngFor="let escalationControl of escalationsFormArray.controls;
let $index = index; last as isLast;"
[ngStyle]="!isLast ? {paddingBottom: '8px'} : {}">
-
+
+
+
+ {{ 'notification.create-new' | translate }}
+
(TemplateNotificationDialogComponent, {
+ disableClose: true,
+ panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
+ data: {
+ predefinedType: this.notificationTypes
+ }
+ }).afterClosed()
+ .subscribe((res) => {
+ if (res) {
+ this.selectTemplateFormGroup.get('templateName').patchValue(res);
+ }
+ });
+ }
+
private updateView(value: EntityId | null) {
if (!isEqual(this.modelValue, value)) {
this.modelValue = value;
diff --git a/ui-ngx/src/app/modules/home/pages/notification-center/template-table/template-notification-dialog.component.html b/ui-ngx/src/app/modules/home/pages/notification-center/template-table/template-notification-dialog.component.html
index 0810138e59..2b597c32b0 100644
--- a/ui-ngx/src/app/modules/home/pages/notification-center/template-table/template-notification-dialog.component.html
+++ b/ui-ngx/src/app/modules/home/pages/notification-center/template-table/template-notification-dialog.component.html
@@ -43,7 +43,7 @@
{{ 'notification.target-name-required' | translate }}
-
+
notification.type
diff --git a/ui-ngx/src/app/modules/home/pages/notification-center/template-table/template-notification-dialog.component.ts b/ui-ngx/src/app/modules/home/pages/notification-center/template-table/template-notification-dialog.component.ts
index f09d8d67ca..94f207104a 100644
--- a/ui-ngx/src/app/modules/home/pages/notification-center/template-table/template-notification-dialog.component.ts
+++ b/ui-ngx/src/app/modules/home/pages/notification-center/template-table/template-notification-dialog.component.ts
@@ -29,7 +29,7 @@ import { Router } from '@angular/router';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { FormBuilder, FormGroup, ValidationErrors, Validators } from '@angular/forms';
import { NotificationService } from '@core/http/notification.service';
-import { deepClone, deepTrim } from '@core/utils';
+import { deepClone, deepTrim, isDefinedAndNotNull } from '@core/utils';
import { Observable, Subject } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { StepperOrientation, StepperSelectionEvent } from '@angular/cdk/stepper';
@@ -40,6 +40,7 @@ import { TranslateService } from '@ngx-translate/core';
export interface TemplateNotificationDialogData {
template?: NotificationTemplate;
+ predefinedType?: NotificationType;
isAdd?: boolean;
isCopy?: boolean;
}
@@ -69,6 +70,7 @@ export class TemplateNotificationDialogComponent
notificationDeliveryMethodTranslateMap = NotificationDeliveryMethodTranslateMap;
selectedIndex = 0;
+ hideSelectType = false;
tinyMceOptions: Record = {
base_url: '/assets/tinymce',
@@ -100,9 +102,13 @@ export class TemplateNotificationDialogComponent
this.stepperOrientation = this.breakpointObserver.observe(MediaBreakpoints['gt-xs'])
.pipe(map(({matches}) => matches ? 'horizontal' : 'vertical'));
+ if (isDefinedAndNotNull(this.data?.predefinedType)) {
+ this.hideSelectType = true;
+ }
+
this.templateNotificationForm = this.fb.group({
name: ['', Validators.required],
- notificationType: [NotificationType.GENERAL],
+ notificationType: [this.hideSelectType ? this.data.predefinedType : NotificationType.GENERAL],
configuration: this.fb.group({
notificationSubject: ['', Validators.required],
defaultTextTemplate: ['', Validators.required],
diff --git a/ui-ngx/src/app/shared/components/entity/entity-list.component.html b/ui-ngx/src/app/shared/components/entity/entity-list.component.html
index 7b89fb8999..2a14cea563 100644
--- a/ui-ngx/src/app/shared/components/entity/entity-list.component.html
+++ b/ui-ngx/src/app/shared/components/entity/entity-list.component.html
@@ -52,4 +52,7 @@
{{ requiredText }}
+
+
+
diff --git a/ui-ngx/src/app/shared/models/notification.models.ts b/ui-ngx/src/app/shared/models/notification.models.ts
index cf907dfe70..90e6cb93b3 100644
--- a/ui-ngx/src/app/shared/models/notification.models.ts
+++ b/ui-ngx/src/app/shared/models/notification.models.ts
@@ -131,7 +131,6 @@ export interface NonConfirmedNotificationEscalation {
export interface NotificationTarget extends Omit, 'label'>{
tenantId: TenantId;
- type: NotificationTargetType;
configuration: NotificationTargetConfig;
}
diff --git a/ui-ngx/src/app/shared/pipe/date-ago.pipe.ts b/ui-ngx/src/app/shared/pipe/date-ago.pipe.ts
index 6cfdc2d9bd..e746296355 100644
--- a/ui-ngx/src/app/shared/pipe/date-ago.pipe.ts
+++ b/ui-ngx/src/app/shared/pipe/date-ago.pipe.ts
@@ -39,14 +39,14 @@ export class DateAgoPipe implements PipeTransform {
transform(value: number): string {
if (value) {
- const seconds = Math.floor((+new Date() - +new Date(value)) / 1000);
- if (seconds < 29) { // less than 30 seconds ago will show as 'Just now'
+ const ms = Math.floor((+new Date() - +new Date(value)));
+ if (ms < 29 * SECOND) { // less than 30 seconds ago will show as 'Just now'
return this.translate.instant('timewindow.just-now');
}
let counter;
// tslint:disable-next-line:forin
for (const i in intervals) {
- counter = Math.floor(seconds / intervals[i]);
+ counter = Math.floor(ms / intervals[i]);
if (counter > 0) {
return this.translate.instant(`timewindow.${i}`, {[i]: counter});
}
diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json
index d6d6cb55ab..8a99967f57 100644
--- a/ui-ngx/src/assets/locale/locale.constant-en_US.json
+++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json
@@ -2710,6 +2710,7 @@
"copy-rule": "Copy rule",
"copy-template": "Copy template",
"create-target": "Create recipient",
+ "create-new": "Create new",
"created": "Created",
"created-time": "Created time",
"delete-request-text": "Be careful, after the confirmation the notification request will become unrecoverable.",