New: Testbeds list plugin
[unfold.git] / plugins / testbeds / static / js / testbeds.js
1 /**
2  * TestbedsPlugin: List of testbeds plugin
3  * Version:     0.1
4  * Description: TODO -> generalize to a list of possible filters
5  *              This file is part of the Manifold project 
6  * Requires:    js/plugin.js
7  * URL:         http://www.myslice.info
8  * Author:      Loïc Baron <loic.baron@lip6.fr>
9  * Copyright:   Copyright 2012-2013 UPMC Sorbonne Universités
10  * License:     GPLv3
11  */
12
13 (function($){
14
15     var TestbedsPlugin = Plugin.extend({
16
17         /** XXX to check
18          * @brief Plugin constructor
19          * @param options : an associative array of setting values
20          * @param element : 
21          * @return : a jQuery collection of objects on which the plugin is
22          *     applied, which allows to maintain chainability of calls
23          */
24         init: function(options, element) {
25             // for debugging tools
26             this.classname="testbedsplugin";
27             // Call the parent constructor, see FAQ when forgotten
28             this._super(options, element);
29
30             /* Member variables */
31
32             /* Plugin events */
33
34             /* Setup query and record handlers */
35
36             // Explain this will allow query events to be handled
37             // What happens when we don't define some events ?
38             // Some can be less efficient
39             this.listen_query(options.query_uuid);
40             this.listen_query(options.query_all_uuid, 'all');
41             this.listen_query(options.query_network_uuid, 'network');
42
43             /* GUI setup and event binding */
44             // call function
45
46         },
47
48         /* PLUGIN EVENTS */
49         // on_show like in querytable
50
51
52         /* GUI EVENTS */
53
54         // a function to bind events here: click change
55         // how to raise manifold events
56
57
58         /* GUI MANIPULATION */
59
60         // We advise you to write function to change behaviour of the GUI
61         // Will use naming helpers to access content _inside_ the plugin
62         // always refer to these functions in the remaining of the code
63
64         show_hide_button: function() 
65         {
66             // this.id, this.el, this.cl, this.elts
67             // same output as a jquery selector with some guarantees
68         },
69
70         /* TEMPLATES */
71
72         // see in the html template
73         // How to load a template, use of mustache
74
75         /* QUERY HANDLERS */
76
77         // How to make sure the plugin is not desynchronized
78         // He should manifest its interest in filters, fields or records
79         // functions triggered only if the proper listen is done
80
81         // no prefix
82
83         on_filter_added: function(filter)
84         {
85
86         },
87
88         // ... be sure to list all events here
89
90         /* RECORD HANDLERS */
91         on_network_new_record: function(record)
92         {
93             console.log(record);
94             row  = '<a href="#" class="list-group-item sl-platform" data-platform="'+record["network_hrn"]+'">';
95             row += '<span class="list-group-item-heading">'+record["platform"]+'</span>';
96             //row += '<span class="list-group-item-heading">'+record["network_hrn"]+'</span></a>';
97             row += '<p class="list-group-item-text">'+record["network_hrn"]+'</p></a>';
98             $('#testbeds-filter').append(row);
99         },
100
101         /* INTERNAL FUNCTIONS */
102         _dummy: function() {
103             // only convention, not strictly enforced at the moment
104         },
105
106     });
107
108     /* Plugin registration */
109     $.plugin('TestbedsPlugin', TestbedsPlugin);
110
111     // TODO Here use cases for instanciating plugins in different ways like in the pastie.
112
113 })(jQuery);