node-red-contrib-artik-cloud
Version:
Nodes to interface with ARTIK Cloud
146 lines (131 loc) • 5.08 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('artik cloud out',{
category: 'artik',
color: '#b3ccff',
defaults: {
name: {value:""},
deviceid: {value:""},
token: {value:""}
},
credentials: {
deviceid: {type:"text"},
token: {type:"password"}
},
inputs:1,
outputs:0,
icon: "artik.png",
align: "right",
paletteLabel:"artik cloud",
label: function() {
return this.name||"artik cloud out";
}
});
</script>
<script type="text/x-red" data-template-name="artik cloud out">
<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">
<br>
<label for="node-input-deviceid"><i class="icon-tag"></i>
Device ID
</label>
<input type="text" id="node-input-deviceid" placeholder="Device ID">
<br>
<label for="node-input-token"><i class="icon-tag"></i>
Device Token
</label>
<input type="password" id="node-input-token" placeholder="Device Token">
</div>
</script>
<script type="text/x-red" data-help-name="artik cloud out">
<p>An ARTIK Cloud out node. Can stream data to ARTIK Cloud devices.</p>
<p></p>
<p>Once you set your device ID and device token, msg.payload will be sent to your specific device.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('artik cloud in',{
category: 'artik',
color: '#b3ccff',
defaults: {
name: {value:""},
uid: {value:""},
deviceid: {value:""},
token: {value:""},
enableMessage: {value:"true"},
enableAction: {value:"false"}
},
credentials: {
uid: {type:"text"},
deviceid: {type:"text"},
token: {type:"password"}
},
inputs:0,
outputs:1,
icon: "artik.png",
paletteLabel:"artik cloud",
label: function() {
return this.name||"artik cloud in";
},
oneditprepare: function(){
var setMessageState = function(){
if ($('#node-input-enableMessage').is(":checked")) {
$("#node-input-uid").show();
$("#node-label-uid").show();
$("#node-input-enableAction").prop('checked', false);
} else {
$("#node-input-uid").hide();
$("#node-label-uid").hide();
$("#node-input-enableAction").prop('checked', true);
}
};
var setActionState = function(){
if ($('#node-input-enableAction').is(":checked")) {
$("#node-input-uid").hide();
$("#node-label-uid").hide();
$("#node-input-enableMessage").prop('checked', false);
} else {
$("#node-input-uid").show();
$("#node-label-uid").show();
$("#node-input-enableMessage").prop('checked', true);
}
};
$("#node-input-enableMessage").change(function () { setMessageState(); });
$("#node-input-enableAction").change(function () { setActionState(); });
}
});
</script>
<script type="text/x-red" data-template-name="artik cloud in">
<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">
<br>
<input type="checkbox" id="node-input-enableMessage" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-enableMessage" style="width: 40%;">Receive Messages</label>
<input type="checkbox" id="node-input-enableAction" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-enableAction" style="width: 40%;">Receive Actions</label>
<br>
<label id="node-label-uid" for="node-input-uid"><i class="icon-tag"></i>
UID/User ID
</label>
<input type="text" id="node-input-uid" placeholder="User ID">
<br>
<label for="node-input-deviceid"><i class="icon-tag"></i>
Device ID
</label>
<input type="text" id="node-input-deviceid" placeholder="Device ID">
<br>
<label for="node-input-token"><i class="icon-tag"></i>
Token
</label>
<input type="password" id="node-input-token" placeholder="Token">
</div>
</script>
<script type="text/x-red" data-help-name="artik cloud in">
<p>An ARTIK Cloud in node that retrieves data from your specific device.</p>
<p></p>
<p>ARTIK Cloud in node is capable of receiving messages or actions(e.g, actions triggered by rules engine)</p>.
</script>