Commit c048b0aad21729ca5be0c1c703db86bf31f6648f
Committed by
GitHub
Merge pull request #3592 from vvlladd28/improvment-device-wizard
UI: Added a rule chain field in the device profile to the device wizard
Showing
2 changed files
with
13 additions
and
0 deletions
@@ -91,6 +91,12 @@ | @@ -91,6 +91,12 @@ | ||
91 | </mat-error> | 91 | </mat-error> |
92 | </mat-form-field> | 92 | </mat-form-field> |
93 | </div> | 93 | </div> |
94 | + <div fxLayout="column" fxLayoutAlign="flex-end start"> | ||
95 | + <tb-rule-chain-autocomplete | ||
96 | + labelText="device-profile.default-rule-chain" | ||
97 | + formControlName="defaultRuleChainId"> | ||
98 | + </tb-rule-chain-autocomplete> | ||
99 | + </div> | ||
94 | </div> | 100 | </div> |
95 | <mat-checkbox formControlName="gateway" style="padding-bottom: 16px;"> | 101 | <mat-checkbox formControlName="gateway" style="padding-bottom: 16px;"> |
96 | {{ 'device.is-gateway' | translate }} | 102 | {{ 'device.is-gateway' | translate }} |
@@ -42,6 +42,7 @@ import { ErrorStateMatcher } from '@angular/material/core'; | @@ -42,6 +42,7 @@ import { ErrorStateMatcher } from '@angular/material/core'; | ||
42 | import { StepperSelectionEvent } from '@angular/cdk/stepper'; | 42 | import { StepperSelectionEvent } from '@angular/cdk/stepper'; |
43 | import { BreakpointObserver, BreakpointState } from '@angular/cdk/layout'; | 43 | import { BreakpointObserver, BreakpointState } from '@angular/cdk/layout'; |
44 | import { MediaBreakpoints } from '@shared/models/constants'; | 44 | import { MediaBreakpoints } from '@shared/models/constants'; |
45 | +import { RuleChainId } from '@shared/models/id/rule-chain-id'; | ||
45 | 46 | ||
46 | @Component({ | 47 | @Component({ |
47 | selector: 'tb-device-wizard', | 48 | selector: 'tb-device-wizard', |
@@ -103,6 +104,7 @@ export class DeviceWizardDialogComponent extends | @@ -103,6 +104,7 @@ export class DeviceWizardDialogComponent extends | ||
103 | addProfileType: [0], | 104 | addProfileType: [0], |
104 | deviceProfileId: [null, Validators.required], | 105 | deviceProfileId: [null, Validators.required], |
105 | newDeviceProfileTitle: [{value: null, disabled: true}], | 106 | newDeviceProfileTitle: [{value: null, disabled: true}], |
107 | + defaultRuleChainId: [{value: null, disabled: true}], | ||
106 | description: [''] | 108 | description: [''] |
107 | } | 109 | } |
108 | ); | 110 | ); |
@@ -114,6 +116,7 @@ export class DeviceWizardDialogComponent extends | @@ -114,6 +116,7 @@ export class DeviceWizardDialogComponent extends | ||
114 | this.deviceWizardFormGroup.get('deviceProfileId').enable(); | 116 | this.deviceWizardFormGroup.get('deviceProfileId').enable(); |
115 | this.deviceWizardFormGroup.get('newDeviceProfileTitle').setValidators(null); | 117 | this.deviceWizardFormGroup.get('newDeviceProfileTitle').setValidators(null); |
116 | this.deviceWizardFormGroup.get('newDeviceProfileTitle').disable(); | 118 | this.deviceWizardFormGroup.get('newDeviceProfileTitle').disable(); |
119 | + this.deviceWizardFormGroup.get('defaultRuleChainId').disable(); | ||
117 | this.deviceWizardFormGroup.updateValueAndValidity(); | 120 | this.deviceWizardFormGroup.updateValueAndValidity(); |
118 | this.createProfile = false; | 121 | this.createProfile = false; |
119 | this.createTransportConfiguration = false; | 122 | this.createTransportConfiguration = false; |
@@ -122,6 +125,7 @@ export class DeviceWizardDialogComponent extends | @@ -122,6 +125,7 @@ export class DeviceWizardDialogComponent extends | ||
122 | this.deviceWizardFormGroup.get('deviceProfileId').disable(); | 125 | this.deviceWizardFormGroup.get('deviceProfileId').disable(); |
123 | this.deviceWizardFormGroup.get('newDeviceProfileTitle').setValidators([Validators.required]); | 126 | this.deviceWizardFormGroup.get('newDeviceProfileTitle').setValidators([Validators.required]); |
124 | this.deviceWizardFormGroup.get('newDeviceProfileTitle').enable(); | 127 | this.deviceWizardFormGroup.get('newDeviceProfileTitle').enable(); |
128 | + this.deviceWizardFormGroup.get('defaultRuleChainId').enable(); | ||
125 | this.deviceWizardFormGroup.updateValueAndValidity(); | 129 | this.deviceWizardFormGroup.updateValueAndValidity(); |
126 | this.createProfile = true; | 130 | this.createProfile = true; |
127 | this.createTransportConfiguration = this.deviceWizardFormGroup.get('transportType').value && | 131 | this.createTransportConfiguration = this.deviceWizardFormGroup.get('transportType').value && |
@@ -274,6 +278,9 @@ export class DeviceWizardDialogComponent extends | @@ -274,6 +278,9 @@ export class DeviceWizardDialogComponent extends | ||
274 | provisionConfiguration: deviceProvisionConfiguration | 278 | provisionConfiguration: deviceProvisionConfiguration |
275 | } | 279 | } |
276 | }; | 280 | }; |
281 | + if (this.deviceWizardFormGroup.get('defaultRuleChainId').value) { | ||
282 | + deviceProfile.defaultRuleChainId = new RuleChainId(this.deviceWizardFormGroup.get('defaultRuleChainId').value); | ||
283 | + } | ||
277 | return this.deviceProfileService.saveDeviceProfile(deviceProfile).pipe( | 284 | return this.deviceProfileService.saveDeviceProfile(deviceProfile).pipe( |
278 | map(profile => profile.id), | 285 | map(profile => profile.id), |
279 | tap((profileId) => { | 286 | tap((profileId) => { |