Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix read property set observe bug #26

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading