diff --git a/node-red-node-wot/package.json b/node-red-node-wot/package.json index 50e1d95..9987ae9 100644 --- a/node-red-node-wot/package.json +++ b/node-red-node-wot/package.json @@ -1,6 +1,6 @@ { "name": "@thingweb/node-red-node-wot", - "version": "1.2.1", + "version": "1.2.2", "description": "Web of Things nodes for Node-RED using node-wot", "author": "Eclipse Thingweb (https://thingweb.io/)", "license": "MIT", diff --git a/node-red-node-wot/plugin-resources-src/node-wot-plugin-lib.ts b/node-red-node-wot/plugin-resources-src/node-wot-plugin-lib.ts index 6d53720..0ce0992 100644 --- a/node-red-node-wot/plugin-resources-src/node-wot-plugin-lib.ts +++ b/node-red-node-wot/plugin-resources-src/node-wot-plugin-lib.ts @@ -14,7 +14,7 @@ const DATATYPES = { }, boolean: { inputMode: "text", - typeConvert: "String", + typeConvert: "JSON.parse", }, object: { inputMode: "textarea", @@ -88,6 +88,7 @@ export const createClientFlowUsingDashboard = (tdString: string, existedNodes: a ...commonParams, propertyName, propertyDescription: tdProperty.description, + propertyObserve: tdProperty.observable, inputMode: DATATYPES[tdProperty.type || "propertyTypeNull"].inputMode, convert: DATATYPES[tdProperty.type || "propertyTypeNull"].typeConvert, } @@ -595,7 +596,7 @@ const PROPERTY_READ_TEMP = `[ "thing": "<%common-genid(1)%>", "property": "<%propertyName%>", "uriVariables": "{}", - "observe": true, + "observe": <%propertyObserve%>, "x": 480, "y": <%y1%>, "wires": [ diff --git a/node-red-node-wot/src/wot-property.html b/node-red-node-wot/src/wot-property.html index 10ac7a0..d6cb3b2 100644 --- a/node-red-node-wot/src/wot-property.html +++ b/node-red-node-wot/src/wot-property.html @@ -37,7 +37,19 @@ $("div#property-row").hide() $("#node-input-property").change(function () { - let property = this.value + showOrHideObserveCheckbox() + }) + + $("select#node-input-thing").change(function () { + if (this.value !== "_ADD_") { + showOptions() + } else { + hideOptions() + } + }) + + function showOrHideObserveCheckbox() { + let property = $("#node-input-property").val() let thingID = $("select#node-input-thing").val() if (thingID) { RED.nodes.eachConfig((config) => { @@ -46,20 +58,13 @@ if (properties[property] && properties[property].observable) { $("div#property-observe").show() } else { + $("#node-input-observe").removeAttr("checked").prop("checked", false).change() $("div#property-observe").hide() } } }) } - }) - - $("select#node-input-thing").change(function () { - if (this.value !== "_ADD_") { - showOptions() - } else { - hideOptions() - } - }) + } function showOptions() { let thingID = $("select#node-input-thing").val() @@ -86,6 +91,7 @@ }) // Show containing div $("div#property-row").show() + showOrHideObserveCheckbox() } }) }