UNPKG

node-red-contrib-ember

Version:

Interface to Ember+ automation standard

127 lines (123 loc) 5.68 kB
<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>&nbsp;</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>