Browse Source

Improve device/device profile components, remove unnecessary transport configurations

pull/3576/head
Igor Kulikov 6 years ago
parent
commit
20c90c8a6f
  1. 4
      ui-ngx/src/app/modules/home/components/profile/device/device-profile-transport-configuration.component.html
  2. 2
      ui-ngx/src/app/modules/home/components/profile/device/lwm2m-device-profile-transport-configuration.component.ts
  3. 6
      ui-ngx/src/app/modules/home/components/wizard/device-wizard-dialog.component.ts
  4. 4
      ui-ngx/src/app/modules/home/pages/device/data/default-device-configuration.component.html
  5. 4
      ui-ngx/src/app/modules/home/pages/device/data/default-device-transport-configuration.component.html
  6. 4
      ui-ngx/src/app/modules/home/pages/device/data/device-transport-configuration.component.html
  7. 4
      ui-ngx/src/app/modules/home/pages/device/data/lwm2m-device-transport-configuration.component.html
  8. 2
      ui-ngx/src/app/modules/home/pages/device/data/lwm2m-device-transport-configuration.component.ts
  9. 4
      ui-ngx/src/app/modules/home/pages/device/data/mqtt-device-transport-configuration.component.html
  10. 22
      ui-ngx/src/app/shared/models/device.models.ts

4
ui-ngx/src/app/modules/home/components/profile/device/device-profile-transport-configuration.component.html

@ -29,11 +29,11 @@
formControlName="configuration"> formControlName="configuration">
</tb-mqtt-device-profile-transport-configuration> </tb-mqtt-device-profile-transport-configuration>
</ng-template> </ng-template>
<ng-template [ngSwitchCase]="deviceTransportType.LWM2M"> <!--ng-template [ngSwitchCase]="deviceTransportType.LWM2M">
<tb-lwm2m-device-profile-transport-configuration <tb-lwm2m-device-profile-transport-configuration
[required]="required" [required]="required"
formControlName="configuration"> formControlName="configuration">
</tb-lwm2m-device-profile-transport-configuration> </tb-lwm2m-device-profile-transport-configuration>
</ng-template> </ng-template-->
</div> </div>
</div> </div>

2
ui-ngx/src/app/modules/home/components/profile/device/lwm2m-device-profile-transport-configuration.component.ts

@ -89,7 +89,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
let configuration: DeviceProfileTransportConfiguration = null; let configuration: DeviceProfileTransportConfiguration = null;
if (this.lwm2mDeviceProfileTransportConfigurationFormGroup.valid) { if (this.lwm2mDeviceProfileTransportConfigurationFormGroup.valid) {
configuration = this.lwm2mDeviceProfileTransportConfigurationFormGroup.getRawValue().configuration; configuration = this.lwm2mDeviceProfileTransportConfigurationFormGroup.getRawValue().configuration;
configuration.type = DeviceTransportType.LWM2M; // configuration.type = DeviceTransportType.LWM2M;
} }
this.propagateChange(configuration); this.propagateChange(configuration);
} }

6
ui-ngx/src/app/modules/home/components/wizard/device-wizard-dialog.component.ts

@ -26,7 +26,7 @@ import {
createDeviceProfileTransportConfiguration, createDeviceProfileTransportConfiguration,
DeviceProfile, DeviceProfile,
DeviceProfileType, DeviceProfileType,
DeviceTransportType, deviceTransportTypeHintMap, DeviceTransportType, deviceTransportTypeConfigurationInfoMap, deviceTransportTypeHintMap,
deviceTransportTypeTranslationMap deviceTransportTypeTranslationMap
} from '@shared/models/device.models'; } from '@shared/models/device.models';
import { MatHorizontalStepper } from '@angular/material/stepper'; import { MatHorizontalStepper } from '@angular/material/stepper';
@ -123,7 +123,7 @@ export class DeviceWizardDialogComponent extends
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 &&
DeviceTransportType.DEFAULT !== this.deviceWizardFormGroup.get('transportType').value; deviceTransportTypeConfigurationInfoMap.get(this.deviceWizardFormGroup.get('transportType').value).hasProfileConfiguration;
} }
} }
)); ));
@ -228,7 +228,7 @@ export class DeviceWizardDialogComponent extends
this.transportConfigFormGroup.patchValue( this.transportConfigFormGroup.patchValue(
{transportConfiguration: createDeviceProfileTransportConfiguration(deviceTransportType)}); {transportConfiguration: createDeviceProfileTransportConfiguration(deviceTransportType)});
this.createTransportConfiguration = this.createProfile && deviceTransportType && this.createTransportConfiguration = this.createProfile && deviceTransportType &&
DeviceTransportType.DEFAULT !== deviceTransportType; deviceTransportTypeConfigurationInfoMap.get(deviceTransportType).hasProfileConfiguration;
} }
add(): void { add(): void {

4
ui-ngx/src/app/modules/home/pages/device/data/default-device-configuration.component.html

@ -16,9 +16,9 @@
--> -->
<form [formGroup]="defaultDeviceConfigurationFormGroup" style="padding-bottom: 16px;"> <form [formGroup]="defaultDeviceConfigurationFormGroup" style="padding-bottom: 16px;">
<tb-json-object-edit <!--tb-json-object-edit
[required]="required" [required]="required"
label="{{ 'device-profile.type-default' | translate }}" label="{{ 'device-profile.type-default' | translate }}"
formControlName="configuration"> formControlName="configuration">
</tb-json-object-edit> </tb-json-object-edit-->
</form> </form>

4
ui-ngx/src/app/modules/home/pages/device/data/default-device-transport-configuration.component.html

@ -16,9 +16,9 @@
--> -->
<form [formGroup]="defaultDeviceTransportConfigurationFormGroup" style="padding-bottom: 16px;"> <form [formGroup]="defaultDeviceTransportConfigurationFormGroup" style="padding-bottom: 16px;">
<tb-json-object-edit <!--tb-json-object-edit
[required]="required" [required]="required"
label="{{ 'device-profile.transport-type-default' | translate }}" label="{{ 'device-profile.transport-type-default' | translate }}"
formControlName="configuration"> formControlName="configuration">
</tb-json-object-edit> </tb-json-object-edit-->
</form> </form>

4
ui-ngx/src/app/modules/home/pages/device/data/device-transport-configuration.component.html

@ -29,11 +29,11 @@
formControlName="configuration"> formControlName="configuration">
</tb-mqtt-device-transport-configuration> </tb-mqtt-device-transport-configuration>
</ng-template> </ng-template>
<ng-template [ngSwitchCase]="deviceTransportType.LWM2M"> <!--ng-template [ngSwitchCase]="deviceTransportType.LWM2M">
<tb-lwm2m-device-transport-configuration <tb-lwm2m-device-transport-configuration
[required]="required" [required]="required"
formControlName="configuration"> formControlName="configuration">
</tb-lwm2m-device-transport-configuration> </tb-lwm2m-device-transport-configuration>
</ng-template> </ng-template-->
</div> </div>
</div> </div>

4
ui-ngx/src/app/modules/home/pages/device/data/lwm2m-device-transport-configuration.component.html

@ -16,9 +16,9 @@
--> -->
<form [formGroup]="lwm2mDeviceTransportConfigurationFormGroup" style="padding-bottom: 16px;"> <form [formGroup]="lwm2mDeviceTransportConfigurationFormGroup" style="padding-bottom: 16px;">
<tb-json-object-edit <!--tb-json-object-edit
[required]="required" [required]="required"
label="{{ 'device-profile.transport-type-lwm2m' | translate }}" label="{{ 'device-profile.transport-type-lwm2m' | translate }}"
formControlName="configuration"> formControlName="configuration">
</tb-json-object-edit> </tb-json-object-edit-->
</form> </form>

2
ui-ngx/src/app/modules/home/pages/device/data/lwm2m-device-transport-configuration.component.ts

@ -89,7 +89,7 @@ export class Lwm2mDeviceTransportConfigurationComponent implements ControlValueA
let configuration: DeviceTransportConfiguration = null; let configuration: DeviceTransportConfiguration = null;
if (this.lwm2mDeviceTransportConfigurationFormGroup.valid) { if (this.lwm2mDeviceTransportConfigurationFormGroup.valid) {
configuration = this.lwm2mDeviceTransportConfigurationFormGroup.getRawValue().configuration; configuration = this.lwm2mDeviceTransportConfigurationFormGroup.getRawValue().configuration;
configuration.type = DeviceTransportType.LWM2M; // configuration.type = DeviceTransportType.LWM2M;
} }
this.propagateChange(configuration); this.propagateChange(configuration);
} }

4
ui-ngx/src/app/modules/home/pages/device/data/mqtt-device-transport-configuration.component.html

@ -16,9 +16,9 @@
--> -->
<form [formGroup]="mqttDeviceTransportConfigurationFormGroup" style="padding-bottom: 16px;"> <form [formGroup]="mqttDeviceTransportConfigurationFormGroup" style="padding-bottom: 16px;">
<tb-json-object-edit <!--tb-json-object-edit
[required]="required" [required]="required"
label="{{ 'device-profile.transport-type-mqtt' | translate }}" label="{{ 'device-profile.transport-type-mqtt' | translate }}"
formControlName="configuration"> formControlName="configuration">
</tb-json-object-edit> </tb-json-object-edit-->
</form> </form>

22
ui-ngx/src/app/shared/models/device.models.ts

@ -33,7 +33,7 @@ export enum DeviceProfileType {
export enum DeviceTransportType { export enum DeviceTransportType {
DEFAULT = 'DEFAULT', DEFAULT = 'DEFAULT',
MQTT = 'MQTT', MQTT = 'MQTT',
LWM2M = 'LWM2M' // LWM2M = 'LWM2M'
} }
export enum MqttTransportPayloadType { export enum MqttTransportPayloadType {
@ -68,7 +68,7 @@ export const deviceTransportTypeTranslationMap = new Map<DeviceTransportType, st
[ [
[DeviceTransportType.DEFAULT, 'device-profile.transport-type-default'], [DeviceTransportType.DEFAULT, 'device-profile.transport-type-default'],
[DeviceTransportType.MQTT, 'device-profile.transport-type-mqtt'], [DeviceTransportType.MQTT, 'device-profile.transport-type-mqtt'],
[DeviceTransportType.LWM2M, 'device-profile.transport-type-lwm2m'] // [DeviceTransportType.LWM2M, 'device-profile.transport-type-lwm2m']
] ]
); );
@ -76,7 +76,7 @@ export const deviceTransportTypeHintMap = new Map<DeviceTransportType, string>(
[ [
[DeviceTransportType.DEFAULT, 'device-profile.transport-type-default-hint'], [DeviceTransportType.DEFAULT, 'device-profile.transport-type-default-hint'],
[DeviceTransportType.MQTT, 'device-profile.transport-type-mqtt-hint'], [DeviceTransportType.MQTT, 'device-profile.transport-type-mqtt-hint'],
[DeviceTransportType.LWM2M, 'device-profile.transport-type-lwm2m-hint'] // [DeviceTransportType.LWM2M, 'device-profile.transport-type-lwm2m-hint']
] ]
); );
@ -101,16 +101,16 @@ export const deviceTransportTypeConfigurationInfoMap = new Map<DeviceTransportTy
DeviceTransportType.MQTT, DeviceTransportType.MQTT,
{ {
hasProfileConfiguration: true, hasProfileConfiguration: true,
hasDeviceConfiguration: true, hasDeviceConfiguration: false,
} }
], ],
[ /*[
DeviceTransportType.LWM2M, DeviceTransportType.LWM2M,
{ {
hasProfileConfiguration: true, hasProfileConfiguration: true,
hasDeviceConfiguration: true, hasDeviceConfiguration: false,
} }
] ]*/
] ]
); );
@ -188,10 +188,10 @@ export function createDeviceProfileTransportConfiguration(type: DeviceTransportT
}; };
transportConfiguration = {...mqttTransportConfiguration, type: DeviceTransportType.MQTT}; transportConfiguration = {...mqttTransportConfiguration, type: DeviceTransportType.MQTT};
break; break;
case DeviceTransportType.LWM2M: /*case DeviceTransportType.LWM2M:
const lwm2mTransportConfiguration: Lwm2mDeviceProfileTransportConfiguration = {}; const lwm2mTransportConfiguration: Lwm2mDeviceProfileTransportConfiguration = {};
transportConfiguration = {...lwm2mTransportConfiguration, type: DeviceTransportType.LWM2M}; transportConfiguration = {...lwm2mTransportConfiguration, type: DeviceTransportType.LWM2M};
break; break;*/
} }
} }
return transportConfiguration; return transportConfiguration;
@ -209,10 +209,10 @@ export function createDeviceTransportConfiguration(type: DeviceTransportType): D
const mqttTransportConfiguration: MqttDeviceTransportConfiguration = {}; const mqttTransportConfiguration: MqttDeviceTransportConfiguration = {};
transportConfiguration = {...mqttTransportConfiguration, type: DeviceTransportType.MQTT}; transportConfiguration = {...mqttTransportConfiguration, type: DeviceTransportType.MQTT};
break; break;
case DeviceTransportType.LWM2M: /* case DeviceTransportType.LWM2M:
const lwm2mTransportConfiguration: Lwm2mDeviceTransportConfiguration = {}; const lwm2mTransportConfiguration: Lwm2mDeviceTransportConfiguration = {};
transportConfiguration = {...lwm2mTransportConfiguration, type: DeviceTransportType.LWM2M}; transportConfiguration = {...lwm2mTransportConfiguration, type: DeviceTransportType.LWM2M};
break; break;*/
} }
} }
return transportConfiguration; return transportConfiguration;

Loading…
Cancel
Save