Add modif senslabmap
[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       this.method = query.object;
9       
10       /* Setup query and record handlers */
11       this.listen_query(options.query_uuid);
12       this.listen_query(options.query_all_uuid, 'all');
13       
14       /* GUI setup and event binding */
15       this.initialize_map();
16     },
17     
18     initialize_map: function() {
19       this.nodes = [];
20       this.id = 0;
21       init();
22     },
23     
24     refresh: function() {
25       console.log("refresh");
26       myrender();
27     },
28     
29     on_show: function(e) {
30       e.data.refresh();
31     },
32     
33     on_all_new_record: function(n) {
34       // format is : [name, x, y, z, uid, state]
35       // state = "Busy", "Alive" or "Suspected"
36       if (n.x == null || n.y == null || n.z == null) {
37         console.log("Warning: no coord for " + n.hrn);
38         return;
39       }
40       this.id++;
41       node = [this.id, n.x, n.y, n.z, this.id, n.boot_state];
42       this.nodes.push(node);
43     },
44     
45     on_all_query_done: function() {
46       drawNodes(this.nodes);
47       parseNodebox();
48     }
49   });
50   $.plugin('SensLabMap', SensLabMap);
51 })(jQuery);