diff --git a/node-red-node-wot/package-lock.json b/node-red-node-wot/package-lock.json index 37cb19a..004a63b 100644 --- a/node-red-node-wot/package-lock.json +++ b/node-red-node-wot/package-lock.json @@ -36,7 +36,7 @@ "typescript": "^4.9.5" }, "engines": { - "node": ">=8.0.0" + "node": ">=14.0.0" } }, "node_modules/@babel/code-frame": { diff --git a/node-red-node-wot/package.json b/node-red-node-wot/package.json index d94d03e..da8fdb5 100644 --- a/node-red-node-wot/package.json +++ b/node-red-node-wot/package.json @@ -12,7 +12,7 @@ "node-red" ], "engines": { - "node": ">=8.0.0" + "node": ">=14.0.0" }, "repository": { "type": "git", @@ -34,7 +34,7 @@ "wot-server-event": "dist/wot-server-event.js", "wot-server-td": "dist/wot-server-td.js" }, - "version": ">=2.0.0" + "version": ">=1.3.7" }, "scripts": { "build": "npm run copy:src2dist && tsc", diff --git a/node-red-node-wot/src/locales/en-US/wot-thing-config.html b/node-red-node-wot/src/locales/en-US/wot-thing-config.html index 93aaaf7..2346340 100644 --- a/node-red-node-wot/src/locales/en-US/wot-thing-config.html +++ b/node-red-node-wot/src/locales/en-US/wot-thing-config.html @@ -11,12 +11,12 @@

Details

  • Description: Specify the description of the Thing.
  • - Thing ID: Specify the Thing ID. The specified Thing ID is used as the ID for Thing Description. - If omitted, the ID for Thing Description is automatically generated.
    + Thing ID: Specify the Thing ID. The specified Thing ID is used as the ID for Thing Description. If omitted, + the ID for Thing Description is automatically generated.
    Example of Thing ID: "urn:dev:ops:32473-WoTLamp-1234"
  • - Use basic authentication: Specifies whether Basic authentication is applied to the Thing.
    + Use basic authentication: Specifies whether Basic authentication is applied to the Thing.
    If you use Basic Authentication, please set your user name and password.
  • diff --git a/node-red-node-wot/src/locales/ja/wot-thing-config.html b/node-red-node-wot/src/locales/ja/wot-thing-config.html index 04afa04..28d3d81 100644 --- a/node-red-node-wot/src/locales/ja/wot-thing-config.html +++ b/node-red-node-wot/src/locales/ja/wot-thing-config.html @@ -12,11 +12,11 @@

    Details

  • 説明: Thingの説明を指定します。
  • Thing ID: Thing IDを指定します。指定したThing IDは、Thing - DescriptionのIDとして利用します。省略した場合は、Thing DescriptionのIDは自動的に生成されます。
    + DescriptionのIDとして利用します。省略した場合は、Thing DescriptionのIDは自動的に生成されます。
    Thing IDの例: "urn:dev:ops:32473-WoTLamp-1234"
  • - Basic認証利用: ThingにBasic認証をかけるかどうかを指定します。
    + Basic認証利用: ThingにBasic認証をかけるかどうかを指定します。
    Basic認証を利用する場合は、ユーザー名とパスワードを設定してください。
  • diff --git a/node-red-node-wot/src/wot-event.js b/node-red-node-wot/src/wot-event.js index 0afebc4..ba7a639 100644 --- a/node-red-node-wot/src/wot-event.js +++ b/node-red-node-wot/src/wot-event.js @@ -31,7 +31,7 @@ module.exports = function (RED) { subscription = undefined consumedThing = _consumedThing // Repeat until event subscription succeeds. - await new Promise((resolve, reject) => { + await new Promise((resolve) => { repeatId = setInterval(() => { consumedThing .subscribeEvent( diff --git a/node-red-node-wot/src/wot-property.js b/node-red-node-wot/src/wot-property.js index d9f5ee6..9d4e3ed 100644 --- a/node-red-node-wot/src/wot-property.js +++ b/node-red-node-wot/src/wot-property.js @@ -38,7 +38,7 @@ module.exports = function (RED) { return } // Repeat until observeProperty succeeds. - await new Promise((resolve, reject) => { + await new Promise((resolve) => { repeatId = setInterval(() => { consumedThing .observeProperty( diff --git a/node-red-node-wot/src/wot-server-action.html b/node-red-node-wot/src/wot-server-action.html index ae0c2b7..c3f20dd 100644 --- a/node-red-node-wot/src/wot-server-action.html +++ b/node-red-node-wot/src/wot-server-action.html @@ -5,16 +5,17 @@ color: "#a2dea0", defaults: { name: { value: "" }, - actionName: { value: "", required: true }, actionDescription: { value: "" }, actionInputDataType: { value: "string", required: true }, actionOutputDataType: { value: "string", required: true }, outParams1_actionArgsType: { value: "msg", + required: true, }, outParams1_actionArgsConstValue: { value: "payload", + required: true, }, woTServerConfig: { type: "wot-server-config", @@ -27,9 +28,6 @@ required: true, }, }, - credentials: { - outParams1_actionArgs: { type: "text" }, - }, inputs: 0, outputs: 1, outputLabels: function (index) { @@ -61,66 +59,14 @@ id: "tab-outParams1-settings", label: this._("editor.outParams1.tabLabel"), }) - prepareInOutParamSetting( - "outParams1", - { - name: "actionArgs", - types: ["msg"], - defaultType: "msg", - defaultValue: "payload", - required: true, - }, - this - ) - }, - oneditsave: function () { - saveInOutParamSetting( - "outParams1", - { - name: "actionArgs", - types: ["msg"], - defaultType: "msg", - defaultValue: "payload", - required: true, - }, - this - ) + $("#node-input-outParams1_actionArgsConstValue").typedInput({ + defaultType: "msg", + defaultValue: "payload", + types: ["msg"], + typeField: "#node-input-outParams1_actionArgsType", + }) }, }) - const prepareInOutParamSetting = (inOrOutParams, params, _this) => { - const { name, types, defaultType, defaultValue, required } = params - const varName = `${inOrOutParams}_${name}` - if (!_this[`${varName}Type`]) { - _this[`${varName}Type`] = defaultType - } - if (this[`${varName}Type`] == "str") { - $(`#node-input-${varName}ConstValue`).val("") - } else { - if (_this[`${varName}ConstValue`] == "") { - $(`#node-input-${varName}ConstValue`).val(_this.credentials[varName]) - } else { - _this.credentials[varName] = _this[`${varName}ConstValue`] - $(`#node-input-${varName}`).val(_this.credentials[`${varName}`]) - } - } - $(`#node-input-${varName}Type`).val(_this[`${varName}Type`]) - $(`#node-input-${varName}`).typedInput({ - default: defaultType, - typeField: $(`#node-input-${varName}Type`), - types: types, - }) - $(`#node-input-${varName}`).typedInput("type", _this[`${varName}Type`]) - } - const saveInOutParamSetting = (inOrOutParams, params, _this) => { - const varName = `${inOrOutParams}_${params.name}` - if ($(`#node-input-${varName}Type`).val() != "str") { - _this[`${varName}ConstValue`] = $(`#node-input-${varName}`).val() - $(`#node-input-${varName}ConstValue`).val(_this[`${varName}ConstValue`]) - } else { - $(`#node-input-${varName}ConstValue`).val("") - _this[`${varName}ConstValue`] = "" - } - } })() @@ -181,10 +127,9 @@
    - - + + -
    diff --git a/node-red-node-wot/src/wot-server-action.ts b/node-red-node-wot/src/wot-server-action.ts index 2659c5a..0ed7118 100644 --- a/node-red-node-wot/src/wot-server-action.ts +++ b/node-red-node-wot/src/wot-server-action.ts @@ -47,9 +47,5 @@ module.exports = function (RED) { const woTServerConfig = RED.nodes.getNode(config.woTServerConfig) woTServerConfig.addUserNode(node) } - RED.nodes.registerType("wot-server-action", WoTServerAction, { - credentials: { - outParams1_actionArgs: { type: "text" }, - }, - }) + RED.nodes.registerType("wot-server-action", WoTServerAction) } diff --git a/node-red-node-wot/src/wot-server-config.html b/node-red-node-wot/src/wot-server-config.html index 04c5c08..e1d4a5c 100644 --- a/node-red-node-wot/src/wot-server-config.html +++ b/node-red-node-wot/src/wot-server-config.html @@ -22,12 +22,9 @@ category: "config", defaults: { name: { value: "", required: true }, - bindingType: { value: "http" }, - bindingConfigType: { value: "json" }, - bindingConfigConstValue: { value: "{}" }, - }, - credentials: { - bindingConfig: { type: "object" }, + bindingType: { value: "http", required: true }, + bindingConfigType: { value: "json", required: true }, + bindingConfigConstValue: { value: "{}", required: true }, }, label: function () { return this.name || this._("editor.configLabel") @@ -37,16 +34,12 @@ }, oneditprepare: function () { // 入力パラメータの指定項目作成 - createInOutParamSetting( - { - name: "bindingConfig", - types: ["json"], - defaultType: "json", - defaultValue: "{}", - required: true, - }, - this - ) + $("#node-config-input-bindingConfigConstValue").typedInput({ + defaultType: "json", + defaultValue: "{}", + types: ["json"], + typeField: "#node-config-input-bindingConfigType", + }) BINDING_TYPE_LIST.forEach((type) => { $("#node-config-input-bindingType").append(``) @@ -57,62 +50,19 @@ $("#node-config-input-bindingType").on("change", () => { const selectedBindingType = $("#node-config-input-bindingType").val() if (selectedBindingType === this.bindingType && this.bindingConfigConstValue !== "{}") { - $("#node-config-input-bindingConfig").typedInput("value", this.bindingConfigConstValue) + $("#node-config-input-bindingConfigConstValue").typedInput( + "value", + this.bindingConfigConstValue + ) } else { - $("#node-config-input-bindingConfig").typedInput( + $("#node-config-input-bindingConfigConstValue").typedInput( "value", JSON.stringify(BINDING_CONFIG_DEFAULT[selectedBindingType]) ) } }) }, - oneditsave: function () { - saveInOutParamSetting( - { - name: "bindingConfig", - types: ["json"], - defaultType: "json", - defaultValue: "{}", - required: true, - }, - this - ) - }, }) - - const createInOutParamSetting = (params, _this) => { - const { name, types, defaultType, defaultValue, required } = params - if (!_this[name + "Type"]) { - _this[name + "Type"] = defaultType - } - if (_this[name + "Type"] == "str") { - $(`#node-config-input-${name}ConstValue`).val("") - } else { - if (_this[name + "ConstValue"] == "") { - $(`#node-config-input-${name}ConstValue`).val(_this.credentials[name]) - } else { - _this.credentials[name] = _this[name + "ConstValue"] - $(`#node-config-input-${name}`).val(_this.credentials[name]) - } - } - $(`#node-config-input-${name}Type`).val(_this[name + "Type"]) - $(`#node-config-input-${name}`).typedInput({ - default: defaultType, - typeField: $(`#node-config-input-${name}Type`), - types: types, - }) - $(`#node-config-input-${name}`).typedInput("type", _this[name + "Type"]) - } - const saveInOutParamSetting = (params, _this) => { - const { name } = params - if ($(`#node-config-input-${name}Type`).val() != "str") { - _this[`${name}ConstValue`] = $(`#node-config-input-${name}`).val() - $(`#node-config-input-${name}ConstValue`).val(_this[`${name}ConstValue`]) - } else { - $(`#node-config-input-${name}ConstValue`).val("") - _this[`${name}ConstValue`] = "" - } - } })() @@ -126,14 +76,14 @@
    - + -
    diff --git a/node-red-node-wot/src/wot-server-config.ts b/node-red-node-wot/src/wot-server-config.ts index aa069f5..d830c81 100644 --- a/node-red-node-wot/src/wot-server-config.ts +++ b/node-red-node-wot/src/wot-server-config.ts @@ -72,12 +72,10 @@ module.exports = function (RED) { const finish = (payload) => { resolve(payload) } - userNode.send([ - { - _wot: { finish }, - }, - null, - ]) + let msg = { + _wot: { finish }, + } + userNode.send([msg, null]) }) }) if (!props.content.readOnly) { @@ -100,13 +98,10 @@ module.exports = function (RED) { resolve() } } - userNode.send([ - null, - { - _wot: { finish }, - [props.outputAttr]: v, - }, - ]) + let msg = {} + setOutput("msg", props.outputAttr, msg, node.context(), v) + msg["_wot"] = { finish } + userNode.send([null, msg]) }) }) } @@ -119,10 +114,10 @@ module.exports = function (RED) { const finish = (payload) => { resolve(payload) } - userNode.send({ - _wot: { finish }, - [props.outputArgs]: args, - }) + let msg = {} + setOutput("msg", props.outputArgs, msg, node.context(), args) + msg["_wot"] = { finish } + userNode.send(msg) }) }) } @@ -287,9 +282,28 @@ module.exports = function (RED) { }) } - RED.nodes.registerType("wot-server-config", WoTServerConfig, { - credentials: { - bindingConfig: { type: "object" }, - }, - }) + RED.nodes.registerType("wot-server-config", WoTServerConfig) + + const setOutput = (type, valueName, msg, context, value) => { + if (type === "msg") { + const names = valueName.split(".") + let target = msg + for (let i = 0; i < names.length - 1; i++) { + let n = names[i] + if (target[n] && target[n] instanceof Object) { + target = target[n] + } else { + target[n] = {} + target = target[n] + } + } + target[names[names.length - 1]] = value + } else if (type === "node") { + context.set(valueName, value) + } else if (type === "flow") { + context.flow.set(valueName, value) + } else if (type === "global") { + context.global.set(valueName, value) + } + } } diff --git a/node-red-node-wot/src/wot-server-end.html b/node-red-node-wot/src/wot-server-end.html index 7ac3c6c..2288c8f 100644 --- a/node-red-node-wot/src/wot-server-end.html +++ b/node-red-node-wot/src/wot-server-end.html @@ -7,14 +7,13 @@ name: { value: "" }, inParams_returnValueType: { value: "msg", + required: true, }, inParams_returnValueConstValue: { value: "payload", + required: true, }, }, - credentials: { - inParams_returnValue: { type: "text" }, - }, inputs: 1, outputs: 0, icon: "arrow.png", @@ -45,66 +44,14 @@ label: this._("editor.inParams.tabLabel"), }) - prepareInOutParamSetting( - "inParams", - { - name: "returnValue", - types: ["msg"], - defaultType: "msg", - defaultValue: "payload", - required: true, - }, - this - ) - }, - oneditsave: function () { - saveInOutParamSetting( - "inParams", - { - name: "returnValue", - types: ["msg", "str", "num", "env"], - defaultType: "str", - defaultValue: "payload", - required: true, - }, - this - ) + $("#node-input-inParams_returnValueConstValue").typedInput({ + defaultType: "msg", + defaultValue: "payload", + types: ["msg"], + typeField: "#node-input-inParams_returnValueType", + }) }, }) - const prepareInOutParamSetting = (inOrOutParams, params, _this) => { - const { name, types, defaultType, defaultValue, required } = params - const varName = `${inOrOutParams}_${name}` - if (!_this[`${varName}Type`]) { - _this[`${varName}Type`] = defaultType - } - if (this[`${varName}Type`] == "str") { - $(`#node-input-${varName}ConstValue`).val("") - } else { - if (_this[`${varName}ConstValue`] == "") { - $(`#node-input-${varName}ConstValue`).val(_this.credentials[varName]) - } else { - _this.credentials[varName] = _this[`${varName}ConstValue`] - $(`#node-input-${varName}`).val(_this.credentials[`${varName}`]) - } - } - $(`#node-input-${varName}Type`).val(_this[`${varName}Type`]) - $(`#node-input-${varName}`).typedInput({ - default: defaultType, - typeField: $(`#node-input-${varName}Type`), - types: types, - }) - $(`#node-input-${varName}`).typedInput("type", _this[`${varName}Type`]) - } - const saveInOutParamSetting = (inOrOutParams, params, _this) => { - const varName = `${inOrOutParams}_${params.name}` - if ($(`#node-input-${varName}Type`).val() != "str") { - _this[`${varName}ConstValue`] = $(`#node-input-${varName}`).val() - $(`#node-input-${varName}ConstValue`).val(_this[`${varName}ConstValue`]) - } else { - $(`#node-input-${varName}ConstValue`).val("") - _this[`${varName}ConstValue`] = "" - } - } })() @@ -122,17 +69,15 @@
    - -
    diff --git a/node-red-node-wot/src/wot-server-end.ts b/node-red-node-wot/src/wot-server-end.ts index 6af98c1..42eb2bf 100644 --- a/node-red-node-wot/src/wot-server-end.ts +++ b/node-red-node-wot/src/wot-server-end.ts @@ -5,7 +5,6 @@ module.exports = function (RED) { node.on("input", async (msg, send, done) => { try { - node.inParams_returnValue = node.credentials.inParams_returnValue if (config.inParams_returnValueConstValue && config.inParams_returnValueType) { node.inParams_returnValue = RED.util.evaluateNodeProperty( config.inParams_returnValueConstValue, @@ -30,32 +29,5 @@ module.exports = function (RED) { done() }) } - RED.nodes.registerType("wot-server-end", WoTServerEnd, { - credentials: { - inParams_propertyName: { type: "text" }, - }, - }) - - const setOutput = (type, valueName, msg, context, value) => { - if (type === "msg") { - const names = valueName.split(".") - let target = msg - for (let i = 0; i < names.length - 1; i++) { - let n = names[i] - if (target[n] && target[n] instanceof Object) { - target = target[n] - } else { - target[n] = {} - target = target[n] - } - } - target[names[names.length - 1]] = value - } else if (type === "node") { - context.set(valueName, value) - } else if (type === "flow") { - context.flow.set(valueName, value) - } else if (type === "global") { - context.global.set(valueName, value) - } - } + RED.nodes.registerType("wot-server-end", WoTServerEnd) } diff --git a/node-red-node-wot/src/wot-server-event.html b/node-red-node-wot/src/wot-server-event.html index ffef77a..7087e3e 100644 --- a/node-red-node-wot/src/wot-server-event.html +++ b/node-red-node-wot/src/wot-server-event.html @@ -10,9 +10,11 @@ eventDataType: { value: "string", required: true }, inParams_eventValueType: { value: "msg", + required: true, }, inParams_eventValueConstValue: { value: "payload", + required: true, }, woTServerConfig: { type: "wot-server-config", @@ -25,9 +27,6 @@ required: true, }, }, - credentials: { - inParams_eventValue: { type: "text" }, - }, inputs: 1, outputs: 0, icon: "arrow.png", @@ -57,66 +56,14 @@ label: this._("editor.inParams.tabLabel"), }) - prepareInOutParamSetting( - "inParams", - { - name: "eventValue", - types: ["msg"], - defaultType: "msg", - defaultValue: "payload", - required: true, - }, - this - ) - }, - oneditsave: function () { - saveInOutParamSetting( - "inParams", - { - name: "eventValue", - types: ["msg"], - defaultType: "msg", - defaultValue: "payload", - required: true, - }, - this - ) + $("#node-input-inParams_eventValueConstValue").typedInput({ + defaultType: "msg", + defaultValue: "payload", + types: ["msg"], + typeField: "#node-input-inParams_eventValueType", + }) }, }) - const prepareInOutParamSetting = (inOrOutParams, params, _this) => { - const { name, types, defaultType, defaultValue, required } = params - const varName = `${inOrOutParams}_${name}` - if (!_this[`${varName}Type`]) { - _this[`${varName}Type`] = defaultType - } - if (this[`${varName}Type`] == "str") { - $(`#node-input-${varName}ConstValue`).val("") - } else { - if (_this[`${varName}ConstValue`] == "") { - $(`#node-input-${varName}ConstValue`).val(_this.credentials[varName]) - } else { - _this.credentials[varName] = _this[`${varName}ConstValue`] - $(`#node-input-${varName}`).val(_this.credentials[`${varName}`]) - } - } - $(`#node-input-${varName}Type`).val(_this[`${varName}Type`]) - $(`#node-input-${varName}`).typedInput({ - default: defaultType, - typeField: $(`#node-input-${varName}Type`), - types: types, - }) - $(`#node-input-${varName}`).typedInput("type", _this[`${varName}Type`]) - } - const saveInOutParamSetting = (inOrOutParams, params, _this) => { - const varName = `${inOrOutParams}_${params.name}` - if ($(`#node-input-${varName}Type`).val() != "str") { - _this[`${varName}ConstValue`] = $(`#node-input-${varName}`).val() - $(`#node-input-${varName}ConstValue`).val(_this[`${varName}ConstValue`]) - } else { - $(`#node-input-${varName}ConstValue`).val("") - _this[`${varName}ConstValue`] = "" - } - } })() @@ -165,10 +112,9 @@
    - - + + -
    diff --git a/node-red-node-wot/src/wot-server-event.ts b/node-red-node-wot/src/wot-server-event.ts index 1e3f82b..38d87b6 100644 --- a/node-red-node-wot/src/wot-server-event.ts +++ b/node-red-node-wot/src/wot-server-event.ts @@ -36,7 +36,6 @@ module.exports = function (RED) { try { const woTServerConfig = RED.nodes.getNode(config.woTServerConfig) - node.inParams_eventValue = node.credentials.inParams_eventValue if (config.inParams_eventValueConstValue && config.inParams_eventValueType) { node.inParams_eventValue = RED.util.evaluateNodeProperty( config.inParams_eventValueConstValue, @@ -69,32 +68,5 @@ module.exports = function (RED) { const woTServerConfig = RED.nodes.getNode(config.woTServerConfig) woTServerConfig?.addUserNode(node) } - RED.nodes.registerType("wot-server-event", WoTServerEvent, { - credentials: { - inParams_eventValue: { type: "text" }, - }, - }) - - const setOutput = (type, valueName, msg, context, value) => { - if (type === "msg") { - const names = valueName.split(".") - let target = msg - for (let i = 0; i < names.length - 1; i++) { - let n = names[i] - if (target[n] && target[n] instanceof Object) { - target = target[n] - } else { - target[n] = {} - target = target[n] - } - } - target[names[names.length - 1]] = value - } else if (type === "node") { - context.set(valueName, value) - } else if (type === "flow") { - context.flow.set(valueName, value) - } else if (type === "global") { - context.global.set(valueName, value) - } - } + RED.nodes.registerType("wot-server-event", WoTServerEvent) } diff --git a/node-red-node-wot/src/wot-server-property.html b/node-red-node-wot/src/wot-server-property.html index bdf3617..716d9e0 100644 --- a/node-red-node-wot/src/wot-server-property.html +++ b/node-red-node-wot/src/wot-server-property.html @@ -12,9 +12,11 @@ propertyObservableFlag: { value: true, required: true }, outParams2_writingValueType: { value: "msg", + required: true, }, outParams2_writingValueConstValue: { value: "payload", + required: true, }, woTServerConfig: { type: "wot-server-config", @@ -27,9 +29,6 @@ required: true, }, }, - credentials: { - outParams2_writingValue: { type: "text" }, - }, inputs: 1, outputs: 2, outputLabels: function (index) { @@ -62,66 +61,14 @@ label: this._("editor.outParams2.tabLabel"), }) - prepareInOutParamSetting( - "outParams2", - { - name: "writingValue", - types: ["msg"], - defaultType: "msg", - defaultValue: "payload", - required: true, - }, - this - ) - }, - oneditsave: function () { - saveInOutParamSetting( - "outParams2", - { - name: "writingValue", - types: ["msg"], - defaultType: "msg", - defaultValue: "payload", - required: true, - }, - this - ) + $("#node-input-outParams2_writingValueConstValue").typedInput({ + defaultType: "msg", + defaultValue: "payload", + types: ["msg"], + typeField: "#node-input-outParams2_writingValueType", + }) }, }) - const prepareInOutParamSetting = (inOrOutParams, params, _this) => { - const { name, types, defaultType, defaultValue, required } = params - const varName = `${inOrOutParams}_${name}` - if (!_this[`${varName}Type`]) { - _this[`${varName}Type`] = defaultType - } - if (this[`${varName}Type`] == "str") { - $(`#node-input-${varName}ConstValue`).val("") - } else { - if (_this[`${varName}ConstValue`] == "") { - $(`#node-input-${varName}ConstValue`).val(_this.credentials[varName]) - } else { - _this.credentials[varName] = _this[`${varName}ConstValue`] - $(`#node-input-${varName}`).val(_this.credentials[`${varName}`]) - } - } - $(`#node-input-${varName}Type`).val(_this[`${varName}Type`]) - $(`#node-input-${varName}`).typedInput({ - default: defaultType, - typeField: $(`#node-input-${varName}Type`), - types: types, - }) - $(`#node-input-${varName}`).typedInput("type", _this[`${varName}Type`]) - } - const saveInOutParamSetting = (inOrOutParams, params, _this) => { - const varName = `${inOrOutParams}_${params.name}` - if ($(`#node-input-${varName}Type`).val() != "str") { - _this[`${varName}ConstValue`] = $(`#node-input-${varName}`).val() - $(`#node-input-${varName}ConstValue`).val(_this[`${varName}ConstValue`]) - } else { - $(`#node-input-${varName}ConstValue`).val("") - _this[`${varName}ConstValue`] = "" - } - } })() @@ -179,10 +126,9 @@
    - - + + -
    diff --git a/node-red-node-wot/src/wot-server-property.ts b/node-red-node-wot/src/wot-server-property.ts index 76ab7af..c002f96 100644 --- a/node-red-node-wot/src/wot-server-property.ts +++ b/node-red-node-wot/src/wot-server-property.ts @@ -62,32 +62,5 @@ module.exports = function (RED) { const woTServerConfig = RED.nodes.getNode(config.woTServerConfig) woTServerConfig?.addUserNode(node) } - RED.nodes.registerType("wot-server-property", WoTServerProperty, { - credentials: { - outParams2_writingValue: { type: "text" }, - }, - }) - - const setOutput = (type, valueName, msg, context, value) => { - if (type === "msg") { - const names = valueName.split(".") - let target = msg - for (let i = 0; i < names.length - 1; i++) { - let n = names[i] - if (target[n] && target[n] instanceof Object) { - target = target[n] - } else { - target[n] = {} - target = target[n] - } - } - target[names[names.length - 1]] = value - } else if (type === "node") { - context.set(valueName, value) - } else if (type === "flow") { - context.flow.set(valueName, value) - } else if (type === "global") { - context.global.set(valueName, value) - } - } + RED.nodes.registerType("wot-server-property", WoTServerProperty) } diff --git a/node-red-node-wot/src/wot-server-td.html b/node-red-node-wot/src/wot-server-td.html index 99ba7a4..55310fb 100644 --- a/node-red-node-wot/src/wot-server-td.html +++ b/node-red-node-wot/src/wot-server-td.html @@ -26,9 +26,6 @@ required: true, }, }, - credentials: { - outParams1_td: { type: "text" }, - }, inputs: 1, outputs: 1, icon: "arrow.png", @@ -43,7 +40,6 @@ }, onpaletteadd: function () {}, oneditprepare: function () { - console.log("node oneditprepare") // Tab const tabs = RED.tabs.create({ id: "red-tabs", @@ -58,66 +54,14 @@ label: this._("editor.outParams1.tabLabel"), }) - prepareInOutParamSetting( - "outParams1", - { - name: "td", - types: ["msg"], - defaultType: "msg", - defaultValue: "payload", - required: true, - }, - this - ) - }, - oneditsave: function () { - saveInOutParamSetting( - "outParams1", - { - name: "td", - types: ["msg"], - defaultType: "msg", - defaultValue: "payload", - required: true, - }, - this - ) + $("#node-input-outParams1_tdConstValue").typedInput({ + defaultType: "msg", + defaultValue: "payload", + types: ["msg"], + typeField: "#node-input-outParams1_tdType", + }) }, }) - const prepareInOutParamSetting = (inOrOutParams, params, _this) => { - const { name, types, defaultType, defaultValue, required } = params - const varName = `${inOrOutParams}_${name}` - if (!_this[`${varName}Type`]) { - _this[`${varName}Type`] = defaultType - } - if (this[`${varName}Type`] == "str") { - $(`#node-input-${varName}ConstValue`).val("") - } else { - if (_this[`${varName}ConstValue`] == "") { - $(`#node-input-${varName}ConstValue`).val(_this.credentials[varName]) - } else { - _this.credentials[varName] = _this[`${varName}ConstValue`] - $(`#node-input-${varName}`).val(_this.credentials[`${varName}`]) - } - } - $(`#node-input-${varName}Type`).val(_this[`${varName}Type`]) - $(`#node-input-${varName}`).typedInput({ - default: defaultType, - typeField: $(`#node-input-${varName}Type`), - types: types, - }) - $(`#node-input-${varName}`).typedInput("type", _this[`${varName}Type`]) - } - const saveInOutParamSetting = (inOrOutParams, params, _this) => { - const varName = `${inOrOutParams}_${params.name}` - if ($(`#node-input-${varName}Type`).val() != "str") { - _this[`${varName}ConstValue`] = $(`#node-input-${varName}`).val() - $(`#node-input-${varName}ConstValue`).val(_this[`${varName}ConstValue`]) - } else { - $(`#node-input-${varName}ConstValue`).val("") - _this[`${varName}ConstValue`] = "" - } - } })() @@ -149,10 +93,9 @@
    - - + + -
    diff --git a/node-red-node-wot/src/wot-server-td.ts b/node-red-node-wot/src/wot-server-td.ts index 47002ff..959567c 100644 --- a/node-red-node-wot/src/wot-server-td.ts +++ b/node-red-node-wot/src/wot-server-td.ts @@ -46,32 +46,5 @@ module.exports = function (RED) { const woTServerConfig = RED.nodes.getNode(config.woTServerConfig) woTServerConfig?.addUserNode(node) } - RED.nodes.registerType("wot-server-td", WoTServerTD, { - credentials: { - outParams1_td: { type: "text" }, - }, - }) - - const setOutput = (type, valueName, msg, context, value) => { - if (type === "msg") { - const names = valueName.split(".") - let target = msg - for (let i = 0; i < names.length - 1; i++) { - let n = names[i] - if (target[n] && target[n] instanceof Object) { - target = target[n] - } else { - target[n] = {} - target = target[n] - } - } - target[names[names.length - 1]] = value - } else if (type === "node") { - context.set(valueName, value) - } else if (type === "flow") { - context.flow.set(valueName, value) - } else if (type === "global") { - context.global.set(valueName, value) - } - } + RED.nodes.registerType("wot-server-td", WoTServerTD) } diff --git a/node-red-node-wot/src/wot-thing-config.html b/node-red-node-wot/src/wot-thing-config.html index ff8a745..035591c 100644 --- a/node-red-node-wot/src/wot-thing-config.html +++ b/node-red-node-wot/src/wot-thing-config.html @@ -6,11 +6,10 @@ name: { value: "", required: true }, description: { value: "", required: false }, thingId: { value: "", required: false }, - basicAuth: { value:false }, - basicAuthUsername: { value:"", required:false }, - basicAuthPassword: { value:"", required:false }, + basicAuth: { value: false }, + basicAuthUsername: { value: "", required: false }, + basicAuthPassword: { value: "", required: false }, }, - credentials: {}, label: function () { return this.name || this._("editor.configLabel") }, @@ -30,42 +29,7 @@ // Toggle username and password when basic auth is enabled/disabled $basicAuth.change(toggleBasicAuthContainer) }, - oneditsave: function () {}, }) - - const createInOutParamSetting = (params, _this) => { - const { name, types, defaultType, defaultValue, required } = params - if (!_this[name + "Type"]) { - _this[name + "Type"] = defaultType - } - if (_this[name + "Type"] == "str") { - $(`#node-config-input-${name}ConstValue`).val("") - } else { - if (_this[name + "ConstValue"] == "") { - $(`#node-config-input-${name}ConstValue`).val(_this.credentials[name]) - } else { - _this.credentials[name] = _this[name + "ConstValue"] - $(`#node-config-input-${name}`).val(_this.credentials[name]) - } - } - $(`#node-config-input-${name}Type`).val(_this[name + "Type"]) - $(`#node-config-input-${name}`).typedInput({ - default: defaultType, - typeField: $(`#node-config-input-${name}Type`), - types: types, - }) - $(`#node-config-input-${name}`).typedInput("type", _this[name + "Type"]) - } - const saveInOutParamSetting = (params, _this) => { - const { name } = params - if ($(`#node-config-input-${name}Type`).val() != "str") { - _this[`${name}ConstValue`] = $(`#node-config-input-${name}`).val() - $(`#node-config-input-${name}ConstValue`).val(_this[`${name}ConstValue`]) - } else { - $(`#node-config-input-${name}ConstValue`).val("") - _this[`${name}ConstValue`] = "" - } - } })() diff --git a/node-red-node-wot/src/wot-thing-config.ts b/node-red-node-wot/src/wot-thing-config.ts index a780c24..ce47e80 100644 --- a/node-red-node-wot/src/wot-thing-config.ts +++ b/node-red-node-wot/src/wot-thing-config.ts @@ -3,11 +3,14 @@ module.exports = function (RED) { RED.nodes.createNode(this, config) const node = this node.getProps = () => { - return { + let props = { title: config.name, description: config.description, - id: config.thingId, } + if (config.thingId) { + props["id"] = config.thingId + } + return props } node.getCredentials = () => { return { @@ -24,7 +27,5 @@ module.exports = function (RED) { } } - RED.nodes.registerType("wot-thing-config", WoTThingConfig, { - credentials: {}, - }) + RED.nodes.registerType("wot-thing-config", WoTThingConfig) } diff --git a/node-red-node-wot/src/wot-update-td.html b/node-red-node-wot/src/wot-update-td.html index ae04e7d..16c670b 100644 --- a/node-red-node-wot/src/wot-update-td.html +++ b/node-red-node-wot/src/wot-update-td.html @@ -17,7 +17,7 @@ if (this.name) { return this.name } else { - return "Update-TD" + return "update-TD" } }, oneditprepare: function () { @@ -26,7 +26,7 @@ $("#node-input-tdSource").typedInput({ defaultType: "msg", defaultValue: "payload", - types: ["msg"], + types: ["msg", "json", "str"], typeField: "#node-input-tdSourceType", })