Skip to content

Commit

Permalink
Merge pull request #26 from hidetak/fix-read-property-set-observe-bug
Browse files Browse the repository at this point in the history
Fix read property set observe bug
  • Loading branch information
egekorkan authored Jun 23, 2024
2 parents 2397825 + 68b2f02 commit be3eeaf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion node-red-node-wot/package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]> (https://thingweb.io/)",
"license": "MIT",
Expand Down
5 changes: 3 additions & 2 deletions node-red-node-wot/plugin-resources-src/node-wot-plugin-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const DATATYPES = {
},
boolean: {
inputMode: "text",
typeConvert: "String",
typeConvert: "JSON.parse",
},
object: {
inputMode: "textarea",
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -595,7 +596,7 @@ const PROPERTY_READ_TEMP = `[
"thing": "<%common-genid(1)%>",
"property": "<%propertyName%>",
"uriVariables": "{}",
"observe": true,
"observe": <%propertyObserve%>,
"x": 480,
"y": <%y1%>,
"wires": [
Expand Down
26 changes: 16 additions & 10 deletions node-red-node-wot/src/wot-property.html
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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()
Expand All @@ -86,6 +91,7 @@
})
// Show containing div
$("div#property-row").show()
showOrHideObserveCheckbox()
}
})
}
Expand Down

0 comments on commit be3eeaf

Please sign in to comment.