fix raise_event
authorAnthony Garcia <anthony.garcia@inria.fr>
Tue, 19 Nov 2013 17:03:32 +0000 (18:03 +0100)
committerAnthony Garcia <anthony.garcia@inria.fr>
Tue, 19 Nov 2013 17:03:32 +0000 (18:03 +0100)
plugins/senslabmap/static/js/map.js
plugins/senslabmap/static/js/senslabmap.js

index df29b88..a75254a 100644 (file)
@@ -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 = $("<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
index 3b92490..3303c3a 100644 (file)
     },
     
     on_all_query_done: function() {
-      var
-        self = this,
-        maps = {},
-        $container = $('#maps-container');
-  
-      $.each(this.sites, function(i, site) {
-        var $div = $("<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);