forked from baycom/node-red-contrib-emberplus
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathemberplus.html
executable file
·127 lines (123 loc) · 5.54 KB
/
emberplus.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<script type="text/javascript">
RED.nodes.registerType('ember+', {
category: 'Ember Plus',
color: '#a6bbcf',
defaults: {
name: { value: "" },
server: { value: "", type: "emberplus-server" },
path: { value: "", required: false },
read: { value: true, required: false },
outputMode: { value: "value", required: true }
},
inputs: 1,
outputs: 1,
icon: "ember-plus-logo-60w.png",
label: function () {
return this.name || this.path || "ember+";
},
oneditprepare(a) {
const self = this;
try {
$('#node-input-path').autocomplete('destroy');
} catch (err) { }
$('#node-lookup-path').click(() => {
$('#node-lookup-path-icon').removeClass('fa-search');
$('#node-lookup-path-icon').addClass('spinner');
$('#node-lookup-path').addClass('disabled');
$.getJSON('emberplus/' + this.server + '/paths', data => {
$('#node-lookup-path-icon').addClass('fa-search');
$('#node-lookup-path-icon').removeClass('spinner');
$('#node-lookup-path').removeClass('disabled');
const paths = [];
$.each(data, (i, path) => {
console.log("paths: " + i + " path:" + JSON.stringify(path));
paths.push(path.id);
});
$('#node-input-path').autocomplete({
source: paths,
minLength: 0,
close(event, ui) {
$('#node-input-path').autocomplete('destroy');
}
}).autocomplete('search', '');
});
});
}
});
</script>
<script type="text/html" data-template-name="ember+">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-server"><i class="fa fa-tasks"></i> Ember+ Server</label>
<input type="text" id="node-input-server">
</div>
<div class="form-row">
<label for="node-input-path"><i class="fa fa-random"></i> path</label>
<input type="text" id="node-input-path" style="width:60%;" placeholder="e.g. 0.1.0"/>
<a id="node-lookup-path" class="btn"><i id="node-lookup-path-icon" class="fa fa-search"></i></a>
</div>
</div>
<div class="form-row">
<label for="node-input-outputMode"><i class="icon-tag"></i> Output Mode:</label>
<select id="node-input-outputMode">
<option value=""></option>
<option value="value">Output Ember parameter value</option>
<option value="json">Output json Ember node</option>
<option value="contents">Output Ember node contents</option>
<option value="full">Output full Ember node</option>
</select>
</div>
<div class="form-row">
<label> </label>
<input type="checkbox" id="node-input-read" style="display:inline-block; width:auto; vertical-align:top;">
<label for="node-input-read" style="width:70%;"><i class="icon-tag"></i> Read initial vale of path on deploy/restart?</label>
</div>
</script>
<script type="text/html" data-help-name="ember+">
<p>A newtwork node that connects to a Ember+ device.</p>
<h3>Inputs</h3>
<ol class="node-ports">
<li>Ember Parameter input
<dt>payload
<span class="property-type">string</span>
</dt>
<dd> A string that will be used to SET the value of the device parameter. </dd>
</li>
<li>Ember Function input
<dt>payload
<span class="property-type">object | string</span>
</dt>
<dd> A JavaScript object or JSON string.</dd>
</li>
</ol>
<h3>Outputs</h3>
<ol class="node-ports">
<li>Parameter output
<dl class="message-properties">
<dt>payload <span class="property-type">string</span></dt>
<dd>the value of the parameter.</dd>
</dl>
</li>
<li>Function output
<dl class="message-properties">
<dt>payload <span class="property-type">object</span></dt>
<dd>A JavaScript object containing the result of the function call.</dd>
</dl>
</li>
</ol>
<h3>Details</h3>
<p><code>msg.payload</code> is used as a string to set the value of the parameter in case of Ember Parameter.
For an Ember Function, it should contain the list of arguments to pass to the function.
It can be in the form of a string that will be converted to a javascript object.
Or you can pass a JSON object directly in <code>msg.payload.args</code>.</p>
<p>Each argument should have a type and a value. ie: <code>{"type": 1, value: 88}</code></p>
<p>The argument types are <code>1: integer, 2: real, 3: string, 4: bool, 5: trigger, 6: enum, 7: octets</code></p>
<p>The output for a function is the result of the function call. It is a javascript object like <code>{"invocationId":5,"success":true,"result":[{"type":"integer","value":105}]}</code></p>
<h3>References</h3>
<ul>
<li><a>https://github.com/dufourgilles/node-red-contrib-emberplus</a> - the nodes github repository</li>
</ul>
</script>