diff --git a/ui-ngx/src/app/modules/home/components/profile/alarm/device-profile-alarm.component.html b/ui-ngx/src/app/modules/home/components/profile/alarm/device-profile-alarm.component.html
index cb1f7afb06..3468442b50 100644
--- a/ui-ngx/src/app/modules/home/components/profile/alarm/device-profile-alarm.component.html
+++ b/ui-ngx/src/app/modules/home/components/profile/alarm/device-profile-alarm.component.html
@@ -41,6 +41,9 @@
{{ 'device-profile.alarm-type-required' | translate }}
+
+ {{ 'device-profile.alarm-type-unique' | translate }}
+
diff --git a/ui-ngx/src/app/modules/home/components/profile/alarm/device-profile-alarm.component.ts b/ui-ngx/src/app/modules/home/components/profile/alarm/device-profile-alarm.component.ts
index cf4a55e6d8..fc0cee9639 100644
--- a/ui-ngx/src/app/modules/home/components/profile/alarm/device-profile-alarm.component.ts
+++ b/ui-ngx/src/app/modules/home/components/profile/alarm/device-profile-alarm.component.ts
@@ -133,6 +133,19 @@ export class DeviceProfileAlarmComponent implements ControlValueAccessor, OnInit
}
public validate(c: FormControl) {
+ if (c.parent) {
+ const alarmType = c.value.alarmType;
+ const profileAlarmsType = [];
+ c.parent.getRawValue().forEach((alarm: DeviceProfileAlarm) => {
+ profileAlarmsType.push(alarm.alarmType);
+ }
+ );
+ if (profileAlarmsType.filter(profileAlarmType => profileAlarmType === alarmType).length > 1) {
+ this.alarmFormGroup.get('alarmType').setErrors({
+ unique: true
+ });
+ }
+ }
return (this.alarmFormGroup.valid) ? null : {
alarm: {
valid: false,
diff --git a/ui-ngx/src/app/modules/home/components/profile/device-profile.component.ts b/ui-ngx/src/app/modules/home/components/profile/device-profile.component.ts
index d30c8b47b9..8c521dcd77 100644
--- a/ui-ngx/src/app/modules/home/components/profile/device-profile.component.ts
+++ b/ui-ngx/src/app/modules/home/components/profile/device-profile.component.ts
@@ -38,7 +38,7 @@ import {
} from '@shared/models/device.models';
import { EntityType } from '@shared/models/entity-type.models';
import { RuleChainId } from '@shared/models/id/rule-chain-id';
-import {ServiceType} from "@shared/models/queue.models";
+import { ServiceType } from '@shared/models/queue.models';
@Component({
selector: 'tb-device-profile',
@@ -176,10 +176,10 @@ export class DeviceProfileComponent extends EntityComponent {
transportConfiguration: entity.profileData?.transportConfiguration,
alarms: entity.profileData?.alarms,
provisionConfiguration: deviceProvisionConfiguration
- }});
- this.entityForm.patchValue({defaultRuleChainId: entity.defaultRuleChainId ? entity.defaultRuleChainId.id : null});
- this.entityForm.patchValue({defaultQueueName: entity.defaultQueueName});
- this.entityForm.patchValue({description: entity.description});
+ }}, {emitEvent: false});
+ this.entityForm.patchValue({defaultRuleChainId: entity.defaultRuleChainId ? entity.defaultRuleChainId.id : null}, {emitEvent: false});
+ this.entityForm.patchValue({defaultQueueName: entity.defaultQueueName}, {emitEvent: false});
+ this.entityForm.patchValue({description: entity.description}, {emitEvent: false});
}
prepareFormValue(formValue: any): any {
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 0b6ee1deeb..27e504d6ee 100644
--- a/ui-ngx/src/assets/locale/locale.constant-en_US.json
+++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json
@@ -909,6 +909,7 @@
"edit-alarm-rule": "Edit alarm rule",
"alarm-type": "Alarm type",
"alarm-type-required": "Alarm type is required.",
+ "alarm-type-unique": "Alarm type must be unique within the device profile alarm rules.",
"alarm-type-pattern-hint": "Alarm type pattern, use ${metaKeyName} to substitute variables from metadata",
"create-alarm-pattern": "Create {{alarmType}} alarm",
"create-alarm-rules": "Create alarm rules",