-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add wot-server-td node which is for getting td on server side
- Loading branch information
Showing
12 changed files
with
369 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<script type="text/html" data-help-name="wot-server-td"> | ||
<p>This is a node that outputs the Thing Description (TD) managed on the WoT server side.</p> | ||
<p>The TD is output at the following times:</p> | ||
<ul> | ||
<li>When the server start is complete.</li> | ||
<li>When there is an input to the node.</li> | ||
</ul> | ||
|
||
<h3>Inputs</h3> | ||
<dl class="message-properties"> | ||
<dt> | ||
Request for TD | ||
<span class="property-type">-</span> | ||
</dt> | ||
<dd>Request a TD by making an input to the node. There is no need to include a value in the input.</dd> | ||
</dl> | ||
|
||
<h3>Outputs</h3> | ||
<dl class="message-properties"> | ||
<dt>TD <span class="property-type">Object</span></dt> | ||
<dd>Outputs the TD managed by the server.</dd> | ||
</dl> | ||
|
||
<h3>Details</h3> | ||
<p>Specify the following items in the node's properties screen:</p> | ||
<ul> | ||
<li>Name: Specify the node name.</li> | ||
<li>Server config: Specify the server that will publish the property.</li> | ||
<li>Thing config: Specify the Thing that the property belongs to.</li> | ||
<li>TD output after server start: Specify whether to output the TD after the server start.</li> | ||
<li>TD destination: Specify where to output the TD.</li> | ||
</ul> | ||
<p> | ||
This node uses <a href="https://github.com/eclipse-thingweb/node-wot">eclipse-thingweb/node-wot</a> for WoT | ||
implementation. | ||
</p> | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"editor": { | ||
"paletteLabel": "Server-TD", | ||
"nameLabel": "Name", | ||
"serverConfigLabel": "Server config", | ||
"thingConfigLabel": "Thing config", | ||
"outputTDAfterServerStartFlagLabel": "TD output after server start", | ||
"outParams1": { | ||
"tabLabel": "Output TD", | ||
"outputLabel": "TD", | ||
"td": { | ||
"label": "TD destination", | ||
"description": "TD destination.", | ||
"placeholder": "TD destination" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<script type="text/html" data-help-name="wot-server-td"> | ||
<p>WoTのサーバ側で管理するThing Description(TD)を出力するノードです。</p> | ||
<p>TDは次のタイミングで出力します。</p> | ||
<ul> | ||
<li>サーバの起動が完了したタイミング。</li> | ||
<li>ノードに対して入力があったタイミング。</li> | ||
</ul> | ||
|
||
<h3>Inputs</h3> | ||
<dl class="message-properties"> | ||
<dt> | ||
TDの要求 | ||
<span class="property-type">-</span> | ||
</dt> | ||
<dd>ノードに入力を行うことでTDを要求します。入力に値を含める必要はありません。</dd> | ||
</dl> | ||
|
||
<h3>Outputs</h3> | ||
<dl class="message-properties"> | ||
<dt>TD <span class="property-type">Object</span></dt> | ||
<dd>サーバで管理するTDを出力します。</dd> | ||
</dl> | ||
|
||
<h3>Details</h3> | ||
<p>ノードのプロパティ画面では以下の項目を指定します。</p> | ||
<ul> | ||
<li>名前: ノード名を指定します。</li> | ||
<li>サーバ設定: 取得するTDを管理するサーバを指定します。</li> | ||
<li>Thing設定: 取得するTDのThingを指定します。</li> | ||
<li>サーバ起動後のTD出力: サーバ起動後にTDを出力するかどうかを指定します。</li> | ||
<li>TDの出力先: TDの出力先を指定します。</li> | ||
</ul> | ||
<p> | ||
本ノードでは、WoTの実装として<a href="https://github.com/eclipse-thingweb/node-wot">eclipse-thingweb/node-wot</a | ||
>を利用します。 | ||
</p> | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"editor": { | ||
"paletteLabel": "Server-TD", | ||
"nameLabel": "名前", | ||
"serverConfigLabel": "サーバ設定", | ||
"thingConfigLabel": "Thing設定", | ||
"outputTDAfterServerStartFlagLabel": "サーバ起動後のTD出力", | ||
"outParams1": { | ||
"tabLabel": "TD出力", | ||
"outputLabel": "TD", | ||
"td": { | ||
"label": "TDの出力先", | ||
"description": "取得したTDの出力先。", | ||
"placeholder": "取得したTDの出力先" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
<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, | ||
}, | ||
}, | ||
credentials: { | ||
outParams1_td: { type: "text" }, | ||
}, | ||
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 () { | ||
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-outParams1-settings", | ||
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 | ||
) | ||
}, | ||
}) | ||
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`] = "" | ||
} | ||
} | ||
})() | ||
</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_td'><span data-i18n="editor.outParams1.td.label"></span></label> | ||
<input required type='text' id='node-input-outParams1_td' data-i18n="[placeholder]editor.outParams1.td.placeholder"> | ||
<input type='hidden' id='node-input-outParams1_tdType'> | ||
<input type='hidden' id='node-input-outParams1_tdConstValue'> | ||
</div> | ||
</div> | ||
</div> | ||
</script> | ||
|
||
<style></style> |
Oops, something went wrong.