Browse Source

ui updates

pull/3740/head
ShvaykaD 6 years ago
parent
commit
37c381996e
  1. 1
      common/data/src/main/java/org/thingsboard/server/common/data/device/profile/MqttTransportConfigurationDeserializer.java
  2. 13
      ui-ngx/src/app/modules/home/components/profile/device/mqtt-device-profile-transport-configuration.component.ts
  3. 1
      ui-ngx/src/app/shared/models/device.models.ts

1
common/data/src/main/java/org/thingsboard/server/common/data/device/profile/MqttTransportConfigurationDeserializer.java

@ -36,7 +36,6 @@ public class MqttTransportConfigurationDeserializer extends StdDeserializer<Mqtt
public MqttDeviceProfileTransportConfiguration deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { public MqttDeviceProfileTransportConfiguration deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
try { try {
JsonNode jsonNode = jsonParser.readValueAsTree(); JsonNode jsonNode = jsonParser.readValueAsTree();
if (jsonNode.hasNonNull("transportPayloadType") && jsonNode.get("transportPayloadType").asText().equals(TransportPayloadType.PROTOBUF.name())) { if (jsonNode.hasNonNull("transportPayloadType") && jsonNode.get("transportPayloadType").asText().equals(TransportPayloadType.PROTOBUF.name())) {
return jsonParser.getCodec().treeToValue(jsonNode, MqttProtoDeviceProfileTransportConfiguration.class); return jsonParser.getCodec().treeToValue(jsonNode, MqttProtoDeviceProfileTransportConfiguration.class);
} else { } else {

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

@ -111,6 +111,12 @@ export class MqttDeviceProfileTransportConfigurationComponent implements Control
writeValue(value: MqttDeviceProfileTransportConfiguration | null): void { writeValue(value: MqttDeviceProfileTransportConfiguration | null): void {
if (isDefinedAndNotNull(value)) { if (isDefinedAndNotNull(value)) {
let configurationFormGroup = this.mqttDeviceProfileTransportConfigurationFormGroup.controls.configuration as FormGroup;
let payloadType = value.transportPayloadType;
if (payloadType === MqttTransportPayloadType.PROTOBUF) {
configurationFormGroup.registerControl('deviceTelemetryProtoSchema', this.fb.control(null, Validators.required));
configurationFormGroup.registerControl('deviceAttributesProtoSchema', this.fb.control(null, Validators.required));
}
this.mqttDeviceProfileTransportConfigurationFormGroup.patchValue({configuration: value}, {emitEvent: false}); this.mqttDeviceProfileTransportConfigurationFormGroup.patchValue({configuration: value}, {emitEvent: false});
} }
} }
@ -121,9 +127,10 @@ export class MqttDeviceProfileTransportConfigurationComponent implements Control
configuration = this.mqttDeviceProfileTransportConfigurationFormGroup.getRawValue().configuration; configuration = this.mqttDeviceProfileTransportConfigurationFormGroup.getRawValue().configuration;
configuration.type = DeviceTransportType.MQTT; configuration.type = DeviceTransportType.MQTT;
let configurationFormGroup = this.mqttDeviceProfileTransportConfigurationFormGroup.controls.configuration as FormGroup; let configurationFormGroup = this.mqttDeviceProfileTransportConfigurationFormGroup.controls.configuration as FormGroup;
if (configuration.transportPayloadType === MqttTransportPayloadType.PROTOBUF) { let transportPayloadType = configuration.transportPayloadType;
configurationFormGroup.addControl('deviceTelemetryProtoSchema', this.fb.control(null, Validators.required)); if (transportPayloadType === MqttTransportPayloadType.PROTOBUF) {
configurationFormGroup.addControl('deviceAttributesProtoSchema', this.fb.control(null, Validators.required)); configurationFormGroup.registerControl('deviceTelemetryProtoSchema', this.fb.control(null, Validators.required));
configurationFormGroup.registerControl('deviceAttributesProtoSchema', this.fb.control(null, Validators.required));
} else { } else {
configurationFormGroup.removeControl('deviceTelemetryProtoSchema'); configurationFormGroup.removeControl('deviceTelemetryProtoSchema');
configurationFormGroup.removeControl('deviceAttributesProtoSchema'); configurationFormGroup.removeControl('deviceAttributesProtoSchema');

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

@ -148,6 +148,7 @@ export interface DefaultDeviceProfileTransportConfiguration {
export interface MqttDeviceProfileTransportConfiguration { export interface MqttDeviceProfileTransportConfiguration {
deviceTelemetryTopic?: string; deviceTelemetryTopic?: string;
deviceAttributesTopic?: string; deviceAttributesTopic?: string;
transportPayloadType?: MqttTransportPayloadType;
[key: string]: any; [key: string]: any;
} }

Loading…
Cancel
Save