From b6a2ff745419d827f5ad8d8f070e53a08523f4e4 Mon Sep 17 00:00:00 2001 From: Max Stockner Date: Fri, 7 Oct 2016 02:44:15 +0200 Subject: [PATCH 1/2] config endpoint to get device and universe configuration --- dmx-web.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dmx-web.js b/dmx-web.js index cbe6db5..90b9714 100755 --- a/dmx-web.js +++ b/dmx-web.js @@ -56,6 +56,15 @@ function DMXWeb() { res.sendfile(__dirname + '/index.html') }) + app.get('/config', function(req, res) { + var response = {"devices": DMX.devices, "universes": {}} + Object.keys(config.universes).forEach(function(key) { + response.universes[key] = config.universes[key].devices + }) + + res.json(response) + }) + app.get('/state/:universe', function(req, res) { if(!(req.params.universe in dmx.universes)) { res.status(404).json({"error": "universe not found"}) From ef0ecab18e76b39ee7a7a8a0ecc0409e05c5d07c Mon Sep 17 00:00:00 2001 From: Max Stockner Date: Fri, 7 Oct 2016 02:45:26 +0200 Subject: [PATCH 2/2] endpoint to selectively update offsets (same spirit as the websockets update) --- dmx-web.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dmx-web.js b/dmx-web.js index 90b9714..f7698e0 100755 --- a/dmx-web.js +++ b/dmx-web.js @@ -77,6 +77,22 @@ function DMXWeb() { } res.json({"state": u}) }) + + app.post('/state/:universe', function(req, res) { + if(!(req.params.universe in dmx.universes)) { + res.status(404).json({"error": "universe not found"}) + return + } + + dmx.update(req.params.universe, req.body) + + var universe = dmx.universes[req.params.universe] + var u = {} + for(var i = 0; i < 256; i++) { + u[i] = universe.get(i) + } + res.json({"state": u}) + }) app.post('/animation/:universe', function(req, res) { try {