turn off senslabmap warnings
[myslice.git] / plugins / senslabmap / static / js / senslabmap.js
1 (function($){
2   var SensLabMap = Plugin.extend({
3     init: function(options, element) {
4       this._super(options, element);
5       
6       this.elmt().on('show', this, this.on_show);
7
8       var query = manifold.query_store.find_analyzed_query(options.query_uuid);
9       this.method = query.object;
10       this.key = manifold.metadata.get_key(this.method);
11       
12       /* Setup query and record handlers */
13       this.listen_query(options.query_uuid);
14       this.listen_query(options.query_all_uuid, 'all');
15
16       this.sites = [];
17       this.nodes = {};
18     },
19     
20     on_show: function(e) {
21       e.data.refresh();
22     },
23     
24     on_all_new_record: function(node) {
25       Senslab.normalize(node);
26       if (node.normalized) {
27         var site = node.site;
28         if ($.inArray(site, this.sites) == -1) {
29           this.sites.push(site);
30           this.nodes[site] = [];
31         }
32         this.nodes[site].push(node);
33       } else {
34 // xxx would need a smarter way to report these only on nodes that deserve it
35 // these messages are all over the place in a PL setup and tend to hide helpful signal
36 //        console.warn("node has no site:");
37 //        console.warn(node);
38       }
39     },
40     
41     on_all_query_done: function() {
42       var self = this;
43       
44       Senslab.createMaps($('#maps-container'), this.sites, this.nodes);
45       Senslab.notify = function(node) {
46         manifold.raise_event(self.options.query_uuid,
47                              node.boot_state == "Alive" ? SET_REMOVED : SET_ADD,
48                              node[self.key]
49                             );
50       }
51     }
52   });
53   $.plugin('SensLabMap', SensLabMap);
54 })(jQuery);