@thingweb/node-red-node-wot
Version:
Web of Things nodes for Node-RED using node-wot
87 lines (81 loc) • 3.06 kB
HTML
<script type="text/javascript">
;(() => {
RED.nodes.registerType("wot-server-end", {
category: "Web of Things",
color: "#a2dea0",
defaults: {
name: { value: "" },
inParams_returnValueType: {
value: "msg",
required: true,
},
inParams_returnValueConstValue: {
value: "payload",
required: true,
},
},
inputs: 1,
outputs: 0,
icon: "arrow.png",
label: function () {
return this.name || this._("editor.paletteLabel") || "wot-server-end"
},
labelStyle: function () {
return this.name ? "node_label_italic" : ""
},
paletteLabel: function () {
return this._("editor.paletteLabel") || "node"
},
onpaletteadd: function () {},
oneditprepare: function () {
console.log("node oneditprepare")
// Tab
const tabs = RED.tabs.create({
id: "red-tabs",
onchange(tab) {
$("#tabs-content").children().hide()
$("#" + tab.id).show()
$("#red-tabs").resize()
},
})
tabs.addTab({
id: "tab-inParams-settings",
label: this._("editor.inParams.tabLabel"),
})
$("#node-input-inParams_returnValueConstValue").typedInput({
defaultType: "msg",
defaultValue: "payload",
types: ["msg"],
typeField: "#node-input-inParams_returnValueType",
})
},
})
})()
</script>
<script type="text/html" data-template-name="wot-server-end">
<div class="form-row">
<label for="node-input-name"><span data-i18n="editor.nameLabel"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]editor.nameLabel" />
</div>
<!-- Tab -->
<div class="form-row">
<ul style="min-width: 500px; margin-bottom: 20px;" id="red-tabs"></ul>
</div>
<!-- Tab contents -->
<div id="tabs-content" style="min-height:250px;">
<div id="tab-inParams-settings">
<div class="form-row">
<label for="node-input-inParams_returnValueConstValue"
><span data-i18n="editor.inParams.returnValue.label"></span
></label>
<input
type="text"
id="node-input-inParams_returnValueConstValue"
data-i18n="[placeholder]editor.inParams.returnValue.placeholder"
/>
<input type="hidden" id="node-input-inParams_returnValueType" />
</div>
</div>
</div>
</script>
<style></style>