Merge pull request #3592 from vvlladd28/improvment-device-wizard
UI: Added a rule chain field in the device profile to the device wizard
This commit is contained in:
commit
c048b0aad2
@ -91,6 +91,12 @@
|
|||||||
</mat-error>
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
<div fxLayout="column" fxLayoutAlign="flex-end start">
|
||||||
|
<tb-rule-chain-autocomplete
|
||||||
|
labelText="device-profile.default-rule-chain"
|
||||||
|
formControlName="defaultRuleChainId">
|
||||||
|
</tb-rule-chain-autocomplete>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<mat-checkbox formControlName="gateway" style="padding-bottom: 16px;">
|
<mat-checkbox formControlName="gateway" style="padding-bottom: 16px;">
|
||||||
{{ 'device.is-gateway' | translate }}
|
{{ 'device.is-gateway' | translate }}
|
||||||
|
|||||||
@ -42,6 +42,7 @@ import { ErrorStateMatcher } from '@angular/material/core';
|
|||||||
import { StepperSelectionEvent } from '@angular/cdk/stepper';
|
import { StepperSelectionEvent } from '@angular/cdk/stepper';
|
||||||
import { BreakpointObserver, BreakpointState } from '@angular/cdk/layout';
|
import { BreakpointObserver, BreakpointState } from '@angular/cdk/layout';
|
||||||
import { MediaBreakpoints } from '@shared/models/constants';
|
import { MediaBreakpoints } from '@shared/models/constants';
|
||||||
|
import { RuleChainId } from '@shared/models/id/rule-chain-id';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-device-wizard',
|
selector: 'tb-device-wizard',
|
||||||
@ -103,6 +104,7 @@ export class DeviceWizardDialogComponent extends
|
|||||||
addProfileType: [0],
|
addProfileType: [0],
|
||||||
deviceProfileId: [null, Validators.required],
|
deviceProfileId: [null, Validators.required],
|
||||||
newDeviceProfileTitle: [{value: null, disabled: true}],
|
newDeviceProfileTitle: [{value: null, disabled: true}],
|
||||||
|
defaultRuleChainId: [{value: null, disabled: true}],
|
||||||
description: ['']
|
description: ['']
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -114,6 +116,7 @@ export class DeviceWizardDialogComponent extends
|
|||||||
this.deviceWizardFormGroup.get('deviceProfileId').enable();
|
this.deviceWizardFormGroup.get('deviceProfileId').enable();
|
||||||
this.deviceWizardFormGroup.get('newDeviceProfileTitle').setValidators(null);
|
this.deviceWizardFormGroup.get('newDeviceProfileTitle').setValidators(null);
|
||||||
this.deviceWizardFormGroup.get('newDeviceProfileTitle').disable();
|
this.deviceWizardFormGroup.get('newDeviceProfileTitle').disable();
|
||||||
|
this.deviceWizardFormGroup.get('defaultRuleChainId').disable();
|
||||||
this.deviceWizardFormGroup.updateValueAndValidity();
|
this.deviceWizardFormGroup.updateValueAndValidity();
|
||||||
this.createProfile = false;
|
this.createProfile = false;
|
||||||
this.createTransportConfiguration = false;
|
this.createTransportConfiguration = false;
|
||||||
@ -122,6 +125,7 @@ export class DeviceWizardDialogComponent extends
|
|||||||
this.deviceWizardFormGroup.get('deviceProfileId').disable();
|
this.deviceWizardFormGroup.get('deviceProfileId').disable();
|
||||||
this.deviceWizardFormGroup.get('newDeviceProfileTitle').setValidators([Validators.required]);
|
this.deviceWizardFormGroup.get('newDeviceProfileTitle').setValidators([Validators.required]);
|
||||||
this.deviceWizardFormGroup.get('newDeviceProfileTitle').enable();
|
this.deviceWizardFormGroup.get('newDeviceProfileTitle').enable();
|
||||||
|
this.deviceWizardFormGroup.get('defaultRuleChainId').enable();
|
||||||
this.deviceWizardFormGroup.updateValueAndValidity();
|
this.deviceWizardFormGroup.updateValueAndValidity();
|
||||||
this.createProfile = true;
|
this.createProfile = true;
|
||||||
this.createTransportConfiguration = this.deviceWizardFormGroup.get('transportType').value &&
|
this.createTransportConfiguration = this.deviceWizardFormGroup.get('transportType').value &&
|
||||||
@ -274,6 +278,9 @@ export class DeviceWizardDialogComponent extends
|
|||||||
provisionConfiguration: deviceProvisionConfiguration
|
provisionConfiguration: deviceProvisionConfiguration
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if (this.deviceWizardFormGroup.get('defaultRuleChainId').value) {
|
||||||
|
deviceProfile.defaultRuleChainId = new RuleChainId(this.deviceWizardFormGroup.get('defaultRuleChainId').value);
|
||||||
|
}
|
||||||
return this.deviceProfileService.saveDeviceProfile(deviceProfile).pipe(
|
return this.deviceProfileService.saveDeviceProfile(deviceProfile).pipe(
|
||||||
map(profile => profile.id),
|
map(profile => profile.id),
|
||||||
tap((profileId) => {
|
tap((profileId) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user