node-red-contrib-mnubo
Version:
Mnubo
201 lines (193 loc) • 8.56 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('mnubo owners', {
category: 'SmartObjects',
color: '#00a1e0',
defaults: {
name: { value: '' },
mnuboconfig: { value: '', type: 'mnubo config', required: true },
functionselection: { value: 'create', required: true },
inputtext: { value: '', type: 'text' },
},
inputs: 1,
outputs: 1,
icon: 'Owner.png',
align: 'left',
label: function() {
return this.name || 'owner ' + this.functionselection;
},
labelStyle: function() {
return this.name ? 'node_label_italic' : '';
},
button: {
onclick: function() {
var label = this.name || 'button';
var node = this;
$.ajax({
url: 'owners/' + this.id + '/button',
type: 'POST',
success: function(resp, textStatus, xhr) {
RED.notify(node._('local injection', { label: label }), 'success');
},
error: function(resp, textStatus, xhr) {
RED.notify(node._('local injection', { label: label }), 'error');
},
});
},
},
});
</script>
<script type="text/x-red" data-template-name="mnubo owners">
<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"></input>
</div>
<div class="form-row">
<label for="node-input-mnuboconfig"><i class="fa fa-database"></i> mnubo config</label>
<input type="text" id="node-input-mnuboconfig"></input>
</div>
<div class="form-row">
<label for="node-input-functionselection"><i class="fa fa-list"></i> Function</label>
<select type="text" id="node-input-functionselection" style="width: 70%;">
<option value="create">Create</option>
<option value="update">Update</option>
<option value="delete">Delete</option>
<option value="claim">Claim</option>
<option value="unclaim">unClaim</option>
<option value="exists">Exists</option>
</select>
</div>
<div class="form-row">
<label for="node-input-inputtext"><i class="fa fa-pencil" style="vertical-align: top;"></i> Input</label>
<textarea id="node-input-inputtext" rows="10" placeholder="optional input string" style="width: 70%;"></textarea>
</div>
</script>
<script type="text/x-red" data-help-name="mnubo owners">
<p>This is a SmartObjects Ingestion Owner node.</p>
<h3>Inputs</h3>
<ul>
<li>you can press the button to inject the input, using this node optional input.</li>
<li>you can inject the input of a "msg.payload".</li>
</ul>
<h3>Outputs</h3>
<ul>
<li>The straight response coming from SmartObjects Platform can be found on "msg.payload".</li>
<li>If <u>Report Result</u> flag is set to "true", you can also refer to "msg.errors" in order to check the errorMessage and the originalRequest that has produced the error.</li>
</ul>
<h3>Details</h3>
<ul>
<li><b>Create:</b> Allows to create an owner.</li>
<p><u>ONE OWNER CREATION</u></p>
<p>The input needs to be a valid JSON with mandatory <i>"username"</i> attribute.</p>
<p>Example:</p>
<pre style="font-size: 12px;line-height: normal;padding-top: 4px;padding-bottom: 4px;">msg.payload =
{
"username": "owner1@test.com",
"x_password": "12345678"
}</pre>
<p><u>MULTIPLE OWNERS CREATION</u></p>
<p>The input needs to be a valid JSON with mandatory <i>"username"</i> attribute.</p>
<p>Example:</p>
<pre style="font-size: 12px;line-height: normal;padding-top: 4px;padding-bottom: 4px;">msg.payload =
[
{
"username": "owner1@test.com",
"x_password": "12345678"
},
{
"username": "owner2@test.com",
"x_password": "fw23re2ffw444"
}
]</pre>
<li><b>Update:</b> Allows to update an attributes of an owner</li>
<p><u>ONE OWNER UPDATE</u></p>
<p>The input needs to be an "array" with [<i>"username"</i>, <i>"json body"</i>]</p>
<p>Example:</p>
<pre style="font-size: 12px;line-height: normal;padding-top: 4px;padding-bottom: 4px;">msg.payload =
["owner1@test.com",
{"email":"dummy@test.com"
"location": "Montreal"
}]</pre>
<p><u>MULTIPLE OWNERS UPDATE</u></p>
<p>The input needs to be a valid JSON.</p>
<p>Example:</p>
<pre style="font-size: 12px;line-height: normal;padding-top: 4px;padding-bottom: 4px;">msg.payload =
[
{
"username": "owner1@test.com",
"email": "dummy@test.com",
"location": "Toronto"
},
{
"username": "owner2@test.com",
"location": "Chicago"
}
... (upto 1000 objects)
]</pre>
<li><b>Claim:</b> Allows an owner to claim one or multiple objects.</li>
<p><u>ONE OBJECT CLAIM</u></p>
<p>The input needs to be an array with [<i>"username"</i>, <i>"x_device_id"</i>]</p>
<p>Example:</p>
<pre style="font-size: 12px;line-height: normal;padding-top: 4px;padding-bottom: 4px;">msg.payload =
["owner1@test.com"," "object_500"]</pre>
<p><u>MULTIPLE OBJECTS CLAIM</u></p>
<p>The input needs to be a valid JSON composed by <i>"username"</i>, <i>"x_device_id"</i> and <i>"x_timestamp" (optional)</i></p>
<p>Example:</p>
<pre style="font-size: 12px;line-height: normal;padding-top: 4px;padding-bottom: 4px;">msg.payload =
[
{
"username": "owner1@test.com",
"x_device_id": "object_500",
"x_timestamp": "23-10-2018T14:45:00Z"
},
{
"username": "owner1@test.com",
"x_device_id": "object_501",
"x_timestamp": "23-10-2018T14:39:00Z"
},
... (upto 1000 events)
]</pre>
<li><b>unClaim:</b> Allows an owner to unClaim one or multiple objects.</li>
<p><u>ONE OBJECT UnCLAIM</u></p>
<p>The input needs to be an array with [<i>"username"</i> and <i>"x_device_id"</i>]</p>
<p>Example:</p>
<pre style="font-size: 12px;line-height: normal;padding-top: 4px;padding-bottom: 4px;">msg.payload =
["owner1@test.com"," "object_500"]</pre>
<p><u>MULTIPLE OBJECTS UnCLAIM</u></p>
<p>The input needs to be a valid JSON composed by <i>"username"</i>, <i>"x_device_id"</i> and <i>"x_timestamp" (optional)</i></p>
<p>Example:</p>
<pre style="font-size: 12px;line-height: normal;padding-top: 4px;padding-bottom: 4px;">msg.payload =
[
{
"username": "owner1@test.com",
"x_device_id": "object_500",
"x_timestamp": "23-10-2018T14:45:00Z"
},
{
"username": "owner1@test.com",
"x_device_id": "object_501",
"x_timestamp": "23-10-2018T14:39:00Z"
},
... (upto 1000 events)
]</pre>
<li><b>Exist:</b> Allows to check if a specific Owner (username) already exists.</li>
<p>The input needs to be a "string" or an "array" with the <i>"username"</i> you want to check.</p>
<p>Example:</p>
<pre style="font-size: 12px;line-height: normal;padding-top: 4px;padding-bottom: 4px;">msg.payload = ["owner1@test.com", "owner2@test.com"]</pre>
<li><b>Delete:</b> Allows to Delete an Owner.</li>
<p>The input needs to be an "string" identifying the <i>"username"</i> you want to delete (you can delete one owner at the time).</p>
<p>Example:</p>
<pre style="font-size: 12px;line-height: normal;padding-top: 4px;padding-bottom: 4px;">msg.payload = "owner1@test.com"</pre>
</ul>
<h3>Requirements</h3>
<ol>
<li>
<b>Mnubo Configuration:</b> A valid Environment and Credentials.
</li>
</ol>
<p>To use SmartObjects nodes, you will need to have a valid mnubo account, with access granted on a namespace. To obtain your unique namespace in the SmartObjects platform, contact sales@mnubo.com . Please use the subject title <b>node-red-contrinb-mnubo</b> and include in the body of the email the name of your company, contact name and phone number.</p>
<h3>References</h3>
<ul>
<li><a href="https://smartobjects.mnubo.com/documentation/api_ingestion.html#owners" target="_blank">SmartObjects online documentation </a> - (under the API section) for details about this interface usage. </li>
<li><a href="https://github.com/mnubo/node-red-contrib-mnubo" target="_blank">GitHub</a> - the nodes github repository</li>
</ul>
</script>