Browse Source

Merge remote-tracking branch 'klimov/feature/notification-system' into feature/notification-system

pull/7911/head
Vladyslav_Prykhodko 4 years ago
parent
commit
daa73dbf53
  1. 3
      ui-ngx/src/app/core/http/entity.service.ts
  2. 12
      ui-ngx/src/app/core/http/notification.service.ts
  3. 28
      ui-ngx/src/app/core/services/menu.service.ts
  4. 5
      ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html
  5. 1
      ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.ts
  6. 5
      ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits.models.ts
  7. 3
      ui-ngx/src/app/modules/home/pages/notification/rule/escalation-form.component.html
  8. 7
      ui-ngx/src/app/modules/home/pages/notification/rule/escalation-form.component.ts
  9. 3
      ui-ngx/src/app/modules/home/pages/notification/rule/rule-notification-dialog.component.html
  10. 3
      ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.component.html
  11. 4
      ui-ngx/src/app/shared/models/notification.models.ts
  12. 1
      ui-ngx/src/app/shared/models/tenant.model.ts
  13. 2
      ui-ngx/src/assets/locale/locale.constant-en_US.json

3
ui-ngx/src/app/core/http/entity.service.ts

@ -90,6 +90,7 @@ import { QueueService } from '@core/http/queue.service';
import { AssetProfileService } from '@core/http/asset-profile.service';
import { NotificationService } from '@core/http/notification.service';
import { TenantProfileService } from '@core/http/tenant-profile.service';
import { NotificationType } from '@shared/models/notification.models';
@Injectable({
providedIn: 'root'
@ -418,7 +419,7 @@ export class EntityService {
break;
case EntityType.NOTIFICATION_TARGET:
pageLink.sortOrder.property = 'name';
entitiesObservable = this.notificationService.getNotificationTargets(pageLink, config);
entitiesObservable = this.notificationService.getNotificationTargets(pageLink, subType as NotificationType, config);
break;
}
return entitiesObservable;

12
ui-ngx/src/app/core/http/notification.service.ts

@ -34,7 +34,7 @@ import {
SlackConversation
} from '@shared/models/notification.models';
import { User } from '@shared/models/user.model';
import { isDefinedAndNotNull } from '@core/utils';
import { isDefinedAndNotNull, isNotEmptyStr } from '@core/utils';
@Injectable({
providedIn: 'root'
@ -131,9 +131,13 @@ export class NotificationService {
defaultHttpOptionsFromConfig(config));
}
public getNotificationTargets(pageLink: PageLink, config?: RequestConfig): Observable<PageData<NotificationTarget>> {
return this.http.get<PageData<NotificationTarget>>(`/api/notification/targets${pageLink.toQuery()}`,
defaultHttpOptionsFromConfig(config));
public getNotificationTargets(pageLink: PageLink, type?: NotificationType,
config?: RequestConfig): Observable<PageData<NotificationTarget>> {
let url = `/api/notification/targets${pageLink.toQuery()}`;
if (isNotEmptyStr(type)) {
url += `&notificationType=${type}`;
}
return this.http.get<PageData<NotificationTarget>>(url, defaultHttpOptionsFromConfig(config));
}
public getRecipientsForNotificationTargetConfig(notificationTarget: NotificationTarget, pageLink: PageLink,

28
ui-ngx/src/app/core/services/menu.service.ts

@ -160,18 +160,18 @@ export class MenuService {
},
{
id: guid(),
name: 'notification.templates',
name: 'notification.recipients',
type: 'link',
path: '/notification/templates',
icon: 'mdi:message-draw',
isMdiIcon: true
path: '/notification/recipients',
icon: 'contacts'
},
{
id: guid(),
name: 'notification.recipients',
name: 'notification.templates',
type: 'link',
path: '/notification/recipients',
icon: 'contacts'
path: '/notification/templates',
icon: 'mdi:message-draw',
isMdiIcon: true
},
{
id: guid(),
@ -529,18 +529,18 @@ export class MenuService {
},
{
id: guid(),
name: 'notification.templates',
name: 'notification.recipients',
type: 'link',
path: '/notification/templates',
icon: 'mdi:message-draw',
isMdiIcon: true
path: '/notification/recipients',
icon: 'contacts'
},
{
id: guid(),
name: 'notification.recipients',
name: 'notification.templates',
type: 'link',
path: '/notification/recipients',
icon: 'contacts'
path: '/notification/templates',
icon: 'mdi:message-draw',
isMdiIcon: true
},
{
id: guid(),

5
ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html

@ -476,6 +476,11 @@
[type]="rateLimitsType.CASSANDRA_QUERY_TENANT_RATE_LIMITS_CONFIGURATION">
</tb-rate-limits>
</div>
<div fxFlex fxLayout="row" fxLayout.xs="column" fxLayoutGap.gt-xs="16px">
<tb-rate-limits fxFlex="50" formControlName="tenantNotificationRequestsRateLimit"
[type]="rateLimitsType.TENANT_NOTIFICATION_REQUEST_RATE_LIMIT">
</tb-rate-limits>
</div>
</ng-template>
</mat-expansion-panel>
</fieldset>

1
ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.ts

@ -72,6 +72,7 @@ export class DefaultTenantProfileConfigurationComponent implements ControlValueA
transportDeviceTelemetryDataPointsRateLimit: [null, []],
tenantEntityExportRateLimit: [null, []],
tenantEntityImportRateLimit: [null, []],
tenantNotificationRequestsRateLimit: [null, []],
maxTransportMessages: [null, [Validators.required, Validators.min(0)]],
maxTransportDataPoints: [null, [Validators.required, Validators.min(0)]],
maxREExecutions: [null, [Validators.required, Validators.min(0)]],

5
ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits.models.ts

@ -33,7 +33,8 @@ export enum RateLimitsType {
WS_UPDATE_PER_SESSION_RATE_LIMIT = 'WS_UPDATE_PER_SESSION_RATE_LIMIT',
CASSANDRA_QUERY_TENANT_RATE_LIMITS_CONFIGURATION = 'CASSANDRA_QUERY_TENANT_RATE_LIMITS_CONFIGURATION',
TENANT_ENTITY_EXPORT_RATE_LIMIT = 'TENANT_ENTITY_EXPORT_RATE_LIMIT',
TENANT_ENTITY_IMPORT_RATE_LIMIT = 'TENANT_ENTITY_IMPORT_RATE_LIMIT'
TENANT_ENTITY_IMPORT_RATE_LIMIT = 'TENANT_ENTITY_IMPORT_RATE_LIMIT',
TENANT_NOTIFICATION_REQUEST_RATE_LIMIT = 'TENANT_NOTIFICATION_REQUEST_RATE_LIMIT'
}
export const rateLimitsLabelTranslationMap = new Map<RateLimitsType, string>(
@ -50,6 +51,7 @@ export const rateLimitsLabelTranslationMap = new Map<RateLimitsType, string>(
[RateLimitsType.CASSANDRA_QUERY_TENANT_RATE_LIMITS_CONFIGURATION, 'tenant-profile.cassandra-tenant-limits-configuration'],
[RateLimitsType.TENANT_ENTITY_EXPORT_RATE_LIMIT, 'tenant-profile.tenant-entity-export-rate-limit'],
[RateLimitsType.TENANT_ENTITY_IMPORT_RATE_LIMIT, 'tenant-profile.tenant-entity-import-rate-limit'],
[RateLimitsType.TENANT_NOTIFICATION_REQUEST_RATE_LIMIT, 'tenant-profile.tenant-notification-request-rate-limit'],
]
);
@ -67,6 +69,7 @@ export const rateLimitsDialogTitleTranslationMap = new Map<RateLimitsType, strin
[RateLimitsType.CASSANDRA_QUERY_TENANT_RATE_LIMITS_CONFIGURATION, 'tenant-profile.rate-limits.edit-cassandra-tenant-limits-configuration-title'],
[RateLimitsType.TENANT_ENTITY_EXPORT_RATE_LIMIT, 'tenant-profile.rate-limits.edit-tenant-entity-export-rate-limit-title'],
[RateLimitsType.TENANT_ENTITY_IMPORT_RATE_LIMIT, 'tenant-profile.rate-limits.edit-tenant-entity-import-rate-limit-title'],
[RateLimitsType.TENANT_NOTIFICATION_REQUEST_RATE_LIMIT, 'tenant-profile.rate-limits.edit-tenant-notification-request-rate-limit-title'],
]
);

3
ui-ngx/src/app/modules/home/pages/notification/rule/escalation-form.component.html

@ -35,7 +35,8 @@
fxFlex="60"
formControlName="targets"
subscriptSizing="dynamic"
[entityType]="entityType.NOTIFICATION_TARGET"
entityType="{{ entityType.NOTIFICATION_TARGET }}"
subType="{{ notificationType.ALARM }}"
[placeholderText]="escalationFormGroup.get('targets').value ? '' : ('notification.add-target' | translate)">
<button #createTargetButton
mat-button [fxHide]="disabled" matSuffix

7
ui-ngx/src/app/modules/home/pages/notification/rule/escalation-form.component.ts

@ -27,7 +27,11 @@ import {
} from '@angular/forms';
import { isDefinedAndNotNull } from '@core/utils';
import { Subject } from 'rxjs';
import { NonConfirmedNotificationEscalation, NotificationTarget } from '@shared/models/notification.models';
import {
NonConfirmedNotificationEscalation,
NotificationTarget,
NotificationType
} from '@shared/models/notification.models';
import { EntityType } from '@shared/models/entity-type.models';
import { takeUntil } from 'rxjs/operators';
import {
@ -65,6 +69,7 @@ export class EscalationFormComponent implements ControlValueAccessor, OnInit, On
escalationFormGroup: FormGroup;
entityType = EntityType;
notificationType = NotificationType;
private modelValue;
private propagateChange = null;

3
ui-ngx/src/app/modules/home/pages/notification/rule/rule-notification-dialog.component.html

@ -65,7 +65,8 @@
<tb-entity-list
required
formControlName="targets"
[entityType]="entityType.NOTIFICATION_TARGET"
subType="{{ ruleNotificationForm.get('triggerType').value }}"
entityType="{{ entityType.NOTIFICATION_TARGET }}"
placeholderText="{{ 'notification.target' | translate }}">
<button #createTargetButton
mat-button color="primary" matSuffix

3
ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.component.html

@ -78,7 +78,8 @@
labelText="{{ 'notification.targets' | translate }}"
placeholderText="{{ 'notification.target' | translate }}"
requiredText="{{ 'notification.targets-required' | translate }}"
[entityType]="entityType.NOTIFICATION_TARGET">
entityType="{{ entityType.NOTIFICATION_TARGET }}"
subType="{{ notificationType.GENERAL }}">
<button #createTargetButton
mat-button color="primary" matSuffix
(click)="createTarget($event, createTargetButton)">

4
ui-ngx/src/app/shared/models/notification.models.ts

@ -355,7 +355,7 @@ export enum NotificationTargetConfigType {
CUSTOMER_USERS = 'CUSTOMER_USERS',
USER_LIST = 'USER_LIST',
ORIGINATOR_ENTITY_OWNER_USERS = 'ORIGINATOR_ENTITY_OWNER_USERS',
ACTION_TARGET_USER = 'ACTION_TARGET_USER'
AFFECTED_USER = 'AFFECTED_USER'
}
interface NotificationTargetConfigTypeInfo {
@ -390,7 +390,7 @@ export const NotificationTargetConfigTypeInfoMap = new Map<NotificationTargetCon
hint: 'notification.target-type.users-entity-owner-hint'
}
],
[NotificationTargetConfigType.ACTION_TARGET_USER,
[NotificationTargetConfigType.AFFECTED_USER,
{
name: 'notification.target-type.affected-user',
hint: 'notification.target-type.affected-user-hint'

1
ui-ngx/src/app/shared/models/tenant.model.ts

@ -43,6 +43,7 @@ export interface DefaultTenantProfileConfiguration {
tenantEntityExportRateLimit?: string;
tenantEntityImportRateLimit?: string;
tenantNotificationRequestsRateLimit?: string;
maxTransportMessages: number;
maxTransportDataPoints: number;

2
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -3534,6 +3534,7 @@
"transport-device-telemetry-data-points-rate-limit": "Transport device telemetry data points",
"tenant-entity-export-rate-limit": "Entity version creation",
"tenant-entity-import-rate-limit": "Entity version load",
"tenant-notification-request-rate-limit": "Notification requests",
"max-transport-messages": "Transport messages maximum number",
"max-transport-messages-required": "Transport messages maximum number is required.",
"max-transport-messages-range": "Transport messages maximum number can't be negative",
@ -3606,6 +3607,7 @@
"edit-cassandra-tenant-limits-configuration-title": "Edit Cassandra query for tenant rate limits",
"edit-tenant-entity-export-rate-limit-title": "Edit entity version creation rate limits",
"edit-tenant-entity-import-rate-limit-title": "Edit entity version load rate limits",
"edit-tenant-notification-request-rate-limit-title": "Edit notification requests rate limits",
"messages-per": "messages per",
"not-set": "Not set",
"number-of-messages": "Number of messages",

Loading…
Cancel
Save