Commit c048b0aad21729ca5be0c1c703db86bf31f6648f

Authored by Igor Kulikov
Committed by GitHub
2 parents f8fdbcaf a17383c6

Merge pull request #3592 from vvlladd28/improvment-device-wizard

UI: Added a rule chain field in the device profile to the device wizard
... ... @@ -91,6 +91,12 @@
91 91 </mat-error>
92 92 </mat-form-field>
93 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 100 </div>
95 101 <mat-checkbox formControlName="gateway" style="padding-bottom: 16px;">
96 102 {{ 'device.is-gateway' | translate }}
... ...
... ... @@ -42,6 +42,7 @@ import { ErrorStateMatcher } from '@angular/material/core';
42 42 import { StepperSelectionEvent } from '@angular/cdk/stepper';
43 43 import { BreakpointObserver, BreakpointState } from '@angular/cdk/layout';
44 44 import { MediaBreakpoints } from '@shared/models/constants';
  45 +import { RuleChainId } from '@shared/models/id/rule-chain-id';
45 46
46 47 @Component({
47 48 selector: 'tb-device-wizard',
... ... @@ -103,6 +104,7 @@ export class DeviceWizardDialogComponent extends
103 104 addProfileType: [0],
104 105 deviceProfileId: [null, Validators.required],
105 106 newDeviceProfileTitle: [{value: null, disabled: true}],
  107 + defaultRuleChainId: [{value: null, disabled: true}],
106 108 description: ['']
107 109 }
108 110 );
... ... @@ -114,6 +116,7 @@ export class DeviceWizardDialogComponent extends
114 116 this.deviceWizardFormGroup.get('deviceProfileId').enable();
115 117 this.deviceWizardFormGroup.get('newDeviceProfileTitle').setValidators(null);
116 118 this.deviceWizardFormGroup.get('newDeviceProfileTitle').disable();
  119 + this.deviceWizardFormGroup.get('defaultRuleChainId').disable();
117 120 this.deviceWizardFormGroup.updateValueAndValidity();
118 121 this.createProfile = false;
119 122 this.createTransportConfiguration = false;
... ... @@ -122,6 +125,7 @@ export class DeviceWizardDialogComponent extends
122 125 this.deviceWizardFormGroup.get('deviceProfileId').disable();
123 126 this.deviceWizardFormGroup.get('newDeviceProfileTitle').setValidators([Validators.required]);
124 127 this.deviceWizardFormGroup.get('newDeviceProfileTitle').enable();
  128 + this.deviceWizardFormGroup.get('defaultRuleChainId').enable();
125 129 this.deviceWizardFormGroup.updateValueAndValidity();
126 130 this.createProfile = true;
127 131 this.createTransportConfiguration = this.deviceWizardFormGroup.get('transportType').value &&
... ... @@ -274,6 +278,9 @@ export class DeviceWizardDialogComponent extends
274 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 284 return this.deviceProfileService.saveDeviceProfile(deviceProfile).pipe(
278 285 map(profile => profile.id),
279 286 tap((profileId) => {
... ...