Skip to content

Commit

Permalink
Tweak emoncms logo to closer match other styles
Browse files Browse the repository at this point in the history
  • Loading branch information
dceejay committed Feb 14, 2014
1 parent 4a53c20 commit 3a6ffdf
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 50 deletions.
14 changes: 7 additions & 7 deletions io/emoncms/88-emoncms.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@
<input type="text" id="node-input-name" placeholder="Emoncms">
</div>
<div class="form-tips">Topic is not mandatory, if Topic is left blank <b>msg.topic</b> will used. Topic overrides <b>msg.topic</b></br>
Node Group (numeric) is not mandatory, if Node Group is left blank <b>msg.nodegrpup</b> will used. Node Group overrides <b>msg.nodegroup</b></div>
Node Group (numeric) is not mandatory, if Node Group is left blank <b>msg.nodegrpup</b> will used. Node Group overrides <b>msg.nodegroup</b></div>
</script>

<script type="text/x-red" data-help-name="emoncms">
<p>Performs post to Emoncms.</p>
<p>Topic is not mandatory, if Topic is left blank <b>msg.topic</b> will used. Topic overrides <b>msg.topic</b></p>
<p>Node Group (numeric) is not mandatory, if Node Group is left blank <b>msg.nodegrpup</b> will used. Node overrides <b>msg.nodegrpup</b></p>
<p>Performs post to Emoncms.</p>
<p>Topic is not mandatory, if Topic is left blank <b>msg.topic</b> will used. Topic overrides <b>msg.topic</b></p>
<p>Node Group (numeric) is not mandatory, if Node Group is left blank <b>msg.nodegrpup</b> will used. Node overrides <b>msg.nodegrpup</b></p>
</script>

<script type="text/javascript">
RED.nodes.registerType('emoncms',{
category: 'output',
color:"rgb(91, 192, 222)",
defaults: {
defaults: {
name: {value:"Emoncms"},
emonServer: {type:"emoncms-server", required:true},
topic: {value:""},
nodegroup: {value:""}
},
inputs:1,
outputs:0,
icon: "emoncms-logo.png",
icon: "emoncms.png",
align: "right",
label: function() {
return this.name||this.baseurl;
Expand Down Expand Up @@ -98,7 +98,7 @@
}
});
},
oneditsave: function() {
oneditsave: function() {
var newApikey = $('#node-config-input-apikey').val();
var credentials = {};
credentials.apikey = newApikey;
Expand Down
86 changes: 43 additions & 43 deletions io/emoncms/88-emoncms.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Henrik Olsson henols@gmail.com
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
Expand All @@ -22,8 +22,8 @@ function EmoncmsServerNode(n) {
this.name = n.name;
var credentials = RED.nodes.getCredentials(n.id);
if (credentials) {
this.apikey = credentials.apikey;
}
this.apikey = credentials.apikey;
}

}
RED.nodes.registerType("emoncms-server",EmoncmsServerNode);
Expand Down Expand Up @@ -64,48 +64,48 @@ RED.app.post('/emoncms-server/:id',function(req,res) {
});

function Emoncms(n) {
RED.nodes.createNode(this,n);
RED.nodes.createNode(this,n);
this.emonServer = n.emonServer;
var sc = RED.nodes.getNode(this.emonServer);

this.baseurl = sc.server;
this.apikey = sc.apikey;
this.baseurl = sc.server;
this.apikey = sc.apikey;

this.topic = n.topic ||"";
this.nodegroup = n.nodegroup || "";
var node = this;
if (this.baseurl.substring(0,5) === "https") { var http = require("https"); }
else { var http = require("http"); }
this.on("input", function(msg) {

this.topic = n.topic ||"";
this.nodegroup = n.nodegroup || "";
var node = this;
if (this.baseurl.substring(0,5) === "https") { var http = require("https"); }
else { var http = require("http"); }
this.on("input", function(msg) {

var topic = this.topic || msg.topic;
var nodegroup = this.nodegroup || msg.nodegroup;
this.url = this.baseurl + '/input/post.json?json={' + topic + ':' + msg.payload+'}&apikey='+this.apikey;
if(nodegroup != ""){
this.url += '&node='+nodegroup;
}
node.log("[emoncms] "+this.url);
http.get(this.url, function(res) {
node.log("Http response: " + res.statusCode);
msg.rc = res.statusCode;
msg.payload = "";
if ((msg.rc != 200) && (msg.rc != 404)) {
node.send(msg);
}
res.setEncoding('utf8');
res.on('data', function(chunk) {
msg.payload += chunk;
});
res.on('end', function() {
node.send(msg);
});
}).on('error', function(e) {
// node.error(e);
msg.rc = 503;
msg.payload = e;
node.send(msg);
});
});
var topic = this.topic || msg.topic;
var nodegroup = this.nodegroup || msg.nodegroup;
this.url = this.baseurl + '/input/post.json?json={' + topic + ':' + msg.payload+'}&apikey='+this.apikey;
if(nodegroup != ""){
this.url += '&node='+nodegroup;
}
node.log("[emoncms] "+this.url);
http.get(this.url, function(res) {
node.log("Http response: " + res.statusCode);
msg.rc = res.statusCode;
msg.payload = "";
if ((msg.rc != 200) && (msg.rc != 404)) {
node.send(msg);
}
res.setEncoding('utf8');
res.on('data', function(chunk) {
msg.payload += chunk;
});
res.on('end', function() {
node.send(msg);
});
}).on('error', function(e) {
// node.error(e);
msg.rc = 503;
msg.payload = e;
node.send(msg);
});
});
}

RED.nodes.registerType("emoncms",Emoncms);
Binary file added io/emoncms/icons/emoncms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3a6ffdf

Please sign in to comment.