From fef9fcd43836ab12d4d2c178bc76ae79838abf11 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sun, 14 Aug 2016 14:14:24 +0300 Subject: Use angular for the front-end --- index.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'index.js') diff --git a/index.js b/index.js index 18efac7..f2f9210 100644 --- a/index.js +++ b/index.js @@ -20,16 +20,36 @@ statuscake .username(username) .key(password); +var currentStatus = {}; + app.get("/", function(req, res) { res.render("index.html"); }); +app.get("/status", function(req, res) { + res.json(currentStatus); +}); + app.listen(3000, function() { console.log("radiodiodi status display listening on port 3000."); }); -function allTests(err, data) { - console.log(data); + +function get_status(err, data) { + currentStatus = []; + for (var i = 0; i < data.length; i++) { + var is_up = data[i].Status == 'Up'; + + var system = {} + system.name = data[i].WebsiteName; + system.status = is_up; + system.uptime = data[i].Uptime; + currentStatus.push(system); + } + + console.log(currentStatus); } -statuscake.tests(allTests); +setInterval(function() { + statuscake.tests(get_status); +}, 5000); -- cgit v1.3