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