2013-10-30 21:38:23 +01:00
|
|
|
|
2014-06-29 00:34:59 +02:00
|
|
|
module.exports = function(RED) {
|
|
|
|
"use strict";
|
|
|
|
var growl = require('growl');
|
|
|
|
var imagefile = process.env.NODE_RED_HOME+"/public/node-red.png";
|
2013-10-30 21:38:23 +01:00
|
|
|
|
2014-06-29 00:34:59 +02:00
|
|
|
function NotifyNode(n) {
|
|
|
|
RED.nodes.createNode(this,n);
|
|
|
|
this.title = n.title;
|
|
|
|
var node = this;
|
2016-04-09 19:00:14 +02:00
|
|
|
node.on("input",function(msg) {
|
|
|
|
var titl = node.title || msg.topic;
|
2014-06-29 00:34:59 +02:00
|
|
|
if (typeof(msg.payload) == 'object') {
|
|
|
|
msg.payload = JSON.stringify(msg.payload);
|
|
|
|
}
|
|
|
|
if (typeof(titl) != 'undefined') {
|
|
|
|
growl(msg.payload, { title: titl, image: imagefile });
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
growl(msg.payload, { image: imagefile });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2013-10-30 21:38:23 +01:00
|
|
|
|
2014-06-29 00:34:59 +02:00
|
|
|
RED.nodes.registerType("notify",NotifyNode);
|
|
|
|
}
|