From 5d1e4c4b61dd853742f4aceb99e451234ff63647 Mon Sep 17 00:00:00 2001 From: Dominic Bosch Date: Thu, 24 Apr 2014 09:32:29 +0200 Subject: [PATCH] compiled updates --- coffee/http-listener.coffee | 6 +++++- js/dynamic-modules.js | 1 + js/engine.js | 2 ++ js/http-listener.js | 12 +++++++++++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/coffee/http-listener.coffee b/coffee/http-listener.coffee index 1f80909..ef6315c 100644 --- a/coffee/http-listener.coffee +++ b/coffee/http-listener.coffee @@ -47,7 +47,9 @@ exports = module.exports = ( args ) => indexEvent = ( event, body, resp ) -> try if typeof body is 'string' - obj = JSON.parse body + obj = payload: JSON.parse body + else + obj = payload: body timestamp = ( new Date() ).toISOString() rand = ( Math.floor Math.random() * 10e9 ).toString( 16 ).toUpperCase() obj.event = event @@ -67,6 +69,8 @@ activateWebHook = ( app, name ) => body += data req.on 'end', -> + console.log body + console.log typeof body indexEvent name, body, resp # This is a hack to quickly allow storing of public accessible data if name is 'uptimestatistics' diff --git a/js/dynamic-modules.js b/js/dynamic-modules.js index 71a6134..7885671 100644 --- a/js/dynamic-modules.js +++ b/js/dynamic-modules.js @@ -158,6 +158,7 @@ Dynamic Modules log: logFunc, debug: console.log, exports: {}, + setTimeout: setTimeout, pushEvent: fPushEvent(userId, oRule, modType) }; try { diff --git a/js/engine.js b/js/engine.js index 3d92316..05fd6e4 100644 --- a/js/engine.js +++ b/js/engine.js @@ -270,6 +270,8 @@ Engine try { if (cond.type === 'string') { val = selectedProperty[0]; + } else if (cond.type === 'bool') { + val = selectedProperty[0]; } else if (cond.type === 'value') { val = parseFloat(selectedProperty[0]) || 0; } diff --git a/js/http-listener.js b/js/http-listener.js index 4a633d1..906076b 100644 --- a/js/http-listener.js +++ b/js/http-listener.js @@ -51,7 +51,15 @@ HTTP Listener indexEvent = function(event, body, resp) { var err, obj, rand, timestamp; try { - obj = JSON.parse(body); + if (typeof body === 'string') { + obj = { + payload: JSON.parse(body) + }; + } else { + obj = { + payload: body + }; + } timestamp = (new Date()).toISOString(); rand = (Math.floor(Math.random() * 10e9)).toString(16).toUpperCase(); obj.event = event; @@ -75,6 +83,8 @@ HTTP Listener }); return req.on('end', function() { var fPath; + console.log(body); + console.log(typeof body); indexEvent(name, body, resp); if (name === 'uptimestatistics') { fPath = path.resolve(__dirname, '..', 'webpages', 'public', 'data', 'histochart.json');