Commit f814162361f2a911fc03a3cf5b9660394e3c2e46

Authored by Igor Kulikov
Committed by GitHub
2 parents 2f0d90be bb5ac495

Merge pull request #4715 from vvlladd28/improvement/device-wizard/move-transport-configuration

UI: Device wizard - move transport type selector to step Transport configuration
@@ -48,20 +48,6 @@ @@ -48,20 +48,6 @@
48 <mat-label translate>device.label</mat-label> 48 <mat-label translate>device.label</mat-label>
49 <input matInput formControlName="label"> 49 <input matInput formControlName="label">
50 </mat-form-field> 50 </mat-form-field>
51 - <mat-form-field class="mat-block" style="padding-bottom: 14px;">  
52 - <mat-label translate>device-profile.transport-type</mat-label>  
53 - <mat-select formControlName="transportType" required>  
54 - <mat-option *ngFor="let type of deviceTransportTypes" [value]="type">  
55 - {{deviceTransportTypeTranslations.get(type) | translate}}  
56 - </mat-option>  
57 - </mat-select>  
58 - <mat-hint *ngIf="deviceWizardFormGroup.get('transportType').value">  
59 - {{deviceTransportTypeHints.get(deviceWizardFormGroup.get('transportType').value) | translate}}  
60 - </mat-hint>  
61 - <mat-error *ngIf="deviceWizardFormGroup.get('transportType').hasError('required')">  
62 - {{ 'device-profile.transport-type-required' | translate }}  
63 - </mat-error>  
64 - </mat-form-field>  
65 <div fxLayout="row" fxLayoutGap="16px"> 51 <div fxLayout="row" fxLayoutGap="16px">
66 <mat-radio-group fxLayout="column" formControlName="addProfileType" fxLayoutAlign="space-around"> 52 <mat-radio-group fxLayout="column" formControlName="addProfileType" fxLayoutAlign="space-around">
67 <mat-radio-button [value]="0" color="primary"> 53 <mat-radio-button [value]="0" color="primary">
@@ -74,13 +60,10 @@ @@ -74,13 +60,10 @@
74 <div fxLayout="column"> 60 <div fxLayout="column">
75 <tb-device-profile-autocomplete 61 <tb-device-profile-autocomplete
76 [required]="!createProfile" 62 [required]="!createProfile"
77 - [transportType]="deviceWizardFormGroup.get('transportType').value"  
78 formControlName="deviceProfileId" 63 formControlName="deviceProfileId"
79 [ngClass]="{invisible: deviceWizardFormGroup.get('addProfileType').value !== 0}" 64 [ngClass]="{invisible: deviceWizardFormGroup.get('addProfileType').value !== 0}"
80 - (deviceProfileChanged)="$event?.transportType ? deviceWizardFormGroup.get('transportType').patchValue($event?.transportType) : {}"  
81 [addNewProfile]="false" 65 [addNewProfile]="false"
82 [selectDefaultProfile]="true" 66 [selectDefaultProfile]="true"
83 - [selectFirstProfile]="true"  
84 [editProfileEnabled]="false"> 67 [editProfileEnabled]="false">
85 </tb-device-profile-autocomplete> 68 </tb-device-profile-autocomplete>
86 <mat-form-field fxFlex class="mat-block" 69 <mat-form-field fxFlex class="mat-block"
@@ -124,9 +107,22 @@ @@ -124,9 +107,22 @@
124 </fieldset> 107 </fieldset>
125 </form> 108 </form>
126 </mat-step> 109 </mat-step>
127 - <mat-step [stepControl]="transportConfigFormGroup" *ngIf="createTransportConfiguration"> 110 + <mat-step [stepControl]="transportConfigFormGroup" [optional]="true" *ngIf="createProfile">
128 <form [formGroup]="transportConfigFormGroup" style="padding-bottom: 16px;"> 111 <form [formGroup]="transportConfigFormGroup" style="padding-bottom: 16px;">
129 - <ng-template matStepLabel>{{ 'device-profile.transport-configuration' | translate }}</ng-template> 112 + <ng-template matStepLabel>{{ 'device-profile.transport-configuration' | translate }}</ng-template><mat-form-field class="mat-block" style="padding-bottom: 14px;">
  113 + <mat-label translate>device-profile.transport-type</mat-label>
  114 + <mat-select formControlName="transportType" required>
  115 + <mat-option *ngFor="let type of deviceTransportTypes" [value]="type">
  116 + {{deviceTransportTypeTranslations.get(type) | translate}}
  117 + </mat-option>
  118 + </mat-select>
  119 + <mat-hint *ngIf="transportConfigFormGroup.get('transportType').value">
  120 + {{deviceTransportTypeHints.get(transportConfigFormGroup.get('transportType').value) | translate}}
  121 + </mat-hint>
  122 + <mat-error *ngIf="transportConfigFormGroup.get('transportType').hasError('required')">
  123 + {{ 'device-profile.transport-type-required' | translate }}
  124 + </mat-error>
  125 + </mat-form-field>
130 <tb-device-profile-transport-configuration 126 <tb-device-profile-transport-configuration
131 formControlName="transportConfiguration" 127 formControlName="transportConfiguration"
132 required> 128 required>
@@ -29,7 +29,6 @@ import { @@ -29,7 +29,6 @@ import {
29 DeviceProvisionConfiguration, 29 DeviceProvisionConfiguration,
30 DeviceProvisionType, 30 DeviceProvisionType,
31 DeviceTransportType, 31 DeviceTransportType,
32 - deviceTransportTypeConfigurationInfoMap,  
33 deviceTransportTypeHintMap, 32 deviceTransportTypeHintMap,
34 deviceTransportTypeTranslationMap 33 deviceTransportTypeTranslationMap
35 } from '@shared/models/device.models'; 34 } from '@shared/models/device.models';
@@ -66,7 +65,6 @@ export class DeviceWizardDialogComponent extends @@ -66,7 +65,6 @@ export class DeviceWizardDialogComponent extends
66 showNext = true; 65 showNext = true;
67 66
68 createProfile = false; 67 createProfile = false;
69 - createTransportConfiguration = false;  
70 68
71 entityType = EntityType; 69 entityType = EntityType;
72 70
@@ -88,7 +86,7 @@ export class DeviceWizardDialogComponent extends @@ -88,7 +86,7 @@ export class DeviceWizardDialogComponent extends
88 86
89 customerFormGroup: FormGroup; 87 customerFormGroup: FormGroup;
90 88
91 - labelPosition = 'end'; 89 + labelPosition: MatHorizontalStepper['labelPosition'] = 'end';
92 90
93 serviceType = ServiceType.TB_RULE_ENGINE; 91 serviceType = ServiceType.TB_RULE_ENGINE;
94 92
@@ -109,7 +107,6 @@ export class DeviceWizardDialogComponent extends @@ -109,7 +107,6 @@ export class DeviceWizardDialogComponent extends
109 label: [''], 107 label: [''],
110 gateway: [false], 108 gateway: [false],
111 overwriteActivityTime: [false], 109 overwriteActivityTime: [false],
112 - transportType: [DeviceTransportType.DEFAULT, Validators.required],  
113 addProfileType: [0], 110 addProfileType: [0],
114 deviceProfileId: [null, Validators.required], 111 deviceProfileId: [null, Validators.required],
115 newDeviceProfileTitle: [{value: null, disabled: true}], 112 newDeviceProfileTitle: [{value: null, disabled: true}],
@@ -130,7 +127,6 @@ export class DeviceWizardDialogComponent extends @@ -130,7 +127,6 @@ export class DeviceWizardDialogComponent extends
130 this.deviceWizardFormGroup.get('defaultQueueName').disable(); 127 this.deviceWizardFormGroup.get('defaultQueueName').disable();
131 this.deviceWizardFormGroup.updateValueAndValidity(); 128 this.deviceWizardFormGroup.updateValueAndValidity();
132 this.createProfile = false; 129 this.createProfile = false;
133 - this.createTransportConfiguration = false;  
134 } else { 130 } else {
135 this.deviceWizardFormGroup.get('deviceProfileId').setValidators(null); 131 this.deviceWizardFormGroup.get('deviceProfileId').setValidators(null);
136 this.deviceWizardFormGroup.get('deviceProfileId').disable(); 132 this.deviceWizardFormGroup.get('deviceProfileId').disable();
@@ -141,18 +137,18 @@ export class DeviceWizardDialogComponent extends @@ -141,18 +137,18 @@ export class DeviceWizardDialogComponent extends
141 137
142 this.deviceWizardFormGroup.updateValueAndValidity(); 138 this.deviceWizardFormGroup.updateValueAndValidity();
143 this.createProfile = true; 139 this.createProfile = true;
144 - this.createTransportConfiguration = this.deviceWizardFormGroup.get('transportType').value &&  
145 - deviceTransportTypeConfigurationInfoMap.get(this.deviceWizardFormGroup.get('transportType').value).hasProfileConfiguration;  
146 } 140 }
147 } 141 }
148 )); 142 ));
149 143
150 this.transportConfigFormGroup = this.fb.group( 144 this.transportConfigFormGroup = this.fb.group(
151 { 145 {
  146 + transportType: [DeviceTransportType.DEFAULT, Validators.required],
152 transportConfiguration: [createDeviceProfileTransportConfiguration(DeviceTransportType.DEFAULT), Validators.required] 147 transportConfiguration: [createDeviceProfileTransportConfiguration(DeviceTransportType.DEFAULT), Validators.required]
153 } 148 }
154 ); 149 );
155 - this.subscriptions.push(this.deviceWizardFormGroup.get('transportType').valueChanges.subscribe((transportType) => { 150 +
  151 + this.subscriptions.push(this.transportConfigFormGroup.get('transportType').valueChanges.subscribe((transportType) => {
156 this.deviceProfileTransportTypeChanged(transportType); 152 this.deviceProfileTransportTypeChanged(transportType);
157 })); 153 }));
158 154
@@ -229,8 +225,6 @@ export class DeviceWizardDialogComponent extends @@ -229,8 +225,6 @@ export class DeviceWizardDialogComponent extends
229 if (index > 0) { 225 if (index > 0) {
230 if (!this.createProfile) { 226 if (!this.createProfile) {
231 index += 3; 227 index += 3;
232 - } else if (!this.createTransportConfiguration) {  
233 - index += 1;  
234 } 228 }
235 } 229 }
236 switch (index) { 230 switch (index) {
@@ -256,8 +250,6 @@ export class DeviceWizardDialogComponent extends @@ -256,8 +250,6 @@ export class DeviceWizardDialogComponent extends
256 private deviceProfileTransportTypeChanged(deviceTransportType: DeviceTransportType): void { 250 private deviceProfileTransportTypeChanged(deviceTransportType: DeviceTransportType): void {
257 this.transportConfigFormGroup.patchValue( 251 this.transportConfigFormGroup.patchValue(
258 {transportConfiguration: createDeviceProfileTransportConfiguration(deviceTransportType)}); 252 {transportConfiguration: createDeviceProfileTransportConfiguration(deviceTransportType)});
259 - this.createTransportConfiguration = this.createProfile && deviceTransportType &&  
260 - deviceTransportTypeConfigurationInfoMap.get(deviceTransportType).hasProfileConfiguration;  
261 } 253 }
262 254
263 add(): void { 255 add(): void {
@@ -281,7 +273,7 @@ export class DeviceWizardDialogComponent extends @@ -281,7 +273,7 @@ export class DeviceWizardDialogComponent extends
281 const deviceProfile: DeviceProfile = { 273 const deviceProfile: DeviceProfile = {
282 name: this.deviceWizardFormGroup.get('newDeviceProfileTitle').value, 274 name: this.deviceWizardFormGroup.get('newDeviceProfileTitle').value,
283 type: DeviceProfileType.DEFAULT, 275 type: DeviceProfileType.DEFAULT,
284 - transportType: this.deviceWizardFormGroup.get('transportType').value, 276 + transportType: this.transportConfigFormGroup.get('transportType').value,
285 provisionType: deviceProvisionConfiguration.type, 277 provisionType: deviceProvisionConfiguration.type,
286 provisionDeviceKey, 278 provisionDeviceKey,
287 profileData: { 279 profileData: {