@thingweb/node-red-node-wot
Version:
Web of Things nodes for Node-RED using node-wot
105 lines (99 loc) • 4.04 kB
HTML
<script type="text/javascript">
;(() => {
RED.nodes.registerType("wot-server-td", {
category: "Web of Things",
color: "#a2dea0",
defaults: {
name: { value: "" },
outParams1_tdType: {
value: "msg",
},
outParams1_tdConstValue: {
value: "payload",
},
woTServerConfig: {
type: "wot-server-config",
value: "",
required: true,
},
woTThingConfig: {
type: "wot-thing-config",
value: "",
required: true,
},
outputTDAfterServerStartFlag: {
value: true,
required: true,
},
},
inputs: 1,
outputs: 1,
icon: "arrow.png",
label: function () {
return this.name || this._("editor.paletteLabel") || "wot-server-td"
},
labelStyle: function () {
return this.name ? "node_label_italic" : ""
},
paletteLabel: function () {
return this._("editor.paletteLabel") || "node"
},
onpaletteadd: function () {},
oneditprepare: function () {
// 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-outParams1-settings",
label: this._("editor.outParams1.tabLabel"),
})
$("#node-input-outParams1_tdConstValue").typedInput({
defaultType: "msg",
defaultValue: "payload",
types: ["msg"],
typeField: "#node-input-outParams1_tdType",
})
},
})
})()
</script>
<script type="text/html" data-template-name="wot-server-td">
<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>
<div class='form-row'>
<label for='node-input-woTServerConfig' style='font-size: 95%;'><span data-i18n="editor.serverConfigLabel"></label>
<input required type='url' id='node-input-woTServerConfig' placeholder='[placeholder]editor.serverConfigLabel'>
</div>
<div class='form-row'>
<label for='node-input-woTThingConfig' style='font-size: 95%;'><span data-i18n="editor.thingConfigLabel"></label>
<input required type='url' id='node-input-woTThingConfig' placeholder='[placeholder]editor.thingConfigLabel'>
</div>
<div class="form-row">
<label for="node-input-outputTDAfterServerStartFlag"><span data-i18n="editor.outputTDAfterServerStartFlagLabel"></span></label>
<input type="checkbox" id="node-input-outputTDAfterServerStartFlag">
</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-outParams1-settings">
<div class='form-row'>
<label for='node-input-outParams1_tdConstValue'><span data-i18n="editor.outParams1.td.label"></span></label>
<input type='text' id='node-input-outParams1_tdConstValue' data-i18n="[placeholder]editor.outParams1.td.placeholder">
<input type='hidden' id='node-input-outParams1_tdType'>
</div>
</div>
</div>
</script>
<style></style>