X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plugins%2Fsenslabmap%2Fstatic%2Fjs%2Fsenslabmap.js;h=3b92490b57b3332009a54c9b19a8483d5c5c263d;hb=54cf44ac08f8b60dd315a0fc5ced1cb6604aa49a;hp=1fe7810c2fb0cd7667e7a3aa87d65c53c5431ed1;hpb=f3b60376826a28db2d4d7e6fdf41276f57b951ed;p=myslice.git diff --git a/plugins/senslabmap/static/js/senslabmap.js b/plugins/senslabmap/static/js/senslabmap.js index 1fe7810c..3b92490b 100644 --- a/plugins/senslabmap/static/js/senslabmap.js +++ b/plugins/senslabmap/static/js/senslabmap.js @@ -10,41 +10,41 @@ /* Setup query and record handlers */ this.listen_query(options.query_uuid); this.listen_query(options.query_all_uuid, 'all'); - - /* GUI setup and event binding */ - this.initialize_map(); - }, - - initialize_map: function() { - this.nodes = []; - this.id = 0; - init(); - }, - - refresh: function() { - console.log("refresh"); - myrender(); + + this.sites = []; + this.nodes = {}; }, on_show: function(e) { e.data.refresh(); }, - on_all_new_record: function(n) { - // format is : [name, x, y, z, uid, state] - // state = "Busy", "Alive" or "Suspected" - if (n.x == null || n.y == null || n.z == null) { - console.log("Warning: no coord for " + n.hrn); - return; + on_all_new_record: function(node) { + Senslab.normalize(node); + if (node.normalized) { + var site = node.site; + if ($.inArray(site, this.sites) == -1) { + this.sites.push(site); + this.nodes[site] = []; + } + this.nodes[site].push(node); + } else { + console.warn("node has no site:"); + console.warn(node); } - this.id++; - node = [this.id, n.x, n.y, n.z, this.id, n.boot_state]; - this.nodes.push(node); }, on_all_query_done: function() { - drawNodes(this.nodes); - parseNodebox(); + 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]); + }); } }); $.plugin('SensLabMap', SensLabMap);