From: Anthony Garcia Date: Tue, 19 Nov 2013 17:03:32 +0000 (+0100) Subject: fix raise_event X-Git-Tag: myslice-0.3-0~113^2~7^2~2 X-Git-Url: http://git.onelab.eu/?p=myslice.git;a=commitdiff_plain;h=c53dc9c19c4b4832d1258cb392774909b6d9a755 fix raise_event --- diff --git a/plugins/senslabmap/static/js/map.js b/plugins/senslabmap/static/js/map.js index df29b886..a75254a4 100644 --- a/plugins/senslabmap/static/js/map.js +++ b/plugins/senslabmap/static/js/map.js @@ -15,6 +15,17 @@ var Senslab = { node.site = info[1]; node.normalized = true; } + }, + notify: function(node) { + console.log("[Notify] node " + node.id + " is " + node.boot_state); + }, + createMaps: function($container, sites, nodes) { + var maps = {}; + $.each(sites, function(i, site) { + var $div = $("
").appendTo($container); + maps[site] = new Senslab.Map($div); + maps[site].addNodes(nodes[site]); + }); } }; @@ -153,6 +164,7 @@ Senslab.Map = function() { particle.id = parseInt(nodes[i].id); particle.arch = nodes[i].arch; particle.boot_state = nodes[i].boot_state; + particle.component_id = nodes[i].component_id; particle.position.x = (nodes[i].x - center.x) * 10; particle.position.y = (nodes[i].y - center.y) * 10; particle.position.z = (nodes[i].z - center.z) * 10; @@ -191,7 +203,7 @@ Senslab.Map = function() { function setState(node, state) { node.boot_state = state; setColor(node); - notify(node); + Senslab.notify(node); } function setColor(node) { @@ -273,10 +285,6 @@ Senslab.Map = function() { context.closePath(); context.fill(); }; - - var notify = function(node) { - console.log("[Notify] node " + node.id + " is " + node.boot_state); - }; return Map; }(); \ No newline at end of file diff --git a/plugins/senslabmap/static/js/senslabmap.js b/plugins/senslabmap/static/js/senslabmap.js index 3b92490b..3303c3af 100644 --- a/plugins/senslabmap/static/js/senslabmap.js +++ b/plugins/senslabmap/static/js/senslabmap.js @@ -35,16 +35,15 @@ }, on_all_query_done: function() { - var - self = this, - maps = {}, - $container = $('#maps-container'); - - $.each(this.sites, function(i, site) { - var $div = $("
").appendTo($container); - maps[site] = new Senslab.Map($div); - maps[site].addNodes(self.nodes[site]); - }); + var self = this; + + Senslab.createMaps($('#maps-container'), this.sites, this.nodes); + Senslab.notify = function(node) { + manifold.raise_event(self.options.query_uuid, + node.boot_state == "Alive" ? SET_REMOVED : SET_ADD, + node.component_id + ); + } } }); $.plugin('SensLabMap', SensLabMap);