New: Testbeds list plugin
authorLoic Baron <loic.baron@lip6.fr>
Tue, 18 Mar 2014 18:13:04 +0000 (19:13 +0100)
committerLoic Baron <loic.baron@lip6.fr>
Tue, 18 Mar 2014 18:13:04 +0000 (19:13 +0100)
plugins/testbeds/__init__.py [new file with mode: 0644]
plugins/testbeds/static/css/myplugin.css [new file with mode: 0644]
plugins/testbeds/static/js/testbeds.js [new file with mode: 0644]
plugins/testbeds/templates/testbeds.html [new file with mode: 0644]

diff --git a/plugins/testbeds/__init__.py b/plugins/testbeds/__init__.py
new file mode 100644 (file)
index 0000000..14f4a7c
--- /dev/null
@@ -0,0 +1,34 @@
+from unfold.plugin import Plugin
+
+class TestbedsPlugin(Plugin):
+    
+    def __init__ (self, query=None, query_network=None, **settings):
+        Plugin.__init__ (self, **settings)
+
+        # Until we have a proper way to access queries in Python
+        self.query              = query
+        self.query_network      = query_network
+        self.query_network_uuid = query_network.query_uuid if query_network else None
+
+    def template_file (self):
+        return "testbeds.html"
+
+    def requirements (self):
+        reqs = {
+            'js_files' : [
+                'js/testbeds.js'
+            ],
+#            'css_files': [
+#                'css/myplugin.css',
+#            ]
+        }
+        return reqs
+
+    def json_settings_list (self):
+        # query_uuid will pass self.query results to the javascript
+        # and will be available as "record" in :
+        # on_new_record: function(record)
+        return ['plugin_uuid', 'domid', 'query_uuid', 'query_network_uuid']
+
+    def export_json_settings (self):
+        return True
diff --git a/plugins/testbeds/static/css/myplugin.css b/plugins/testbeds/static/css/myplugin.css
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/plugins/testbeds/static/js/testbeds.js b/plugins/testbeds/static/js/testbeds.js
new file mode 100644 (file)
index 0000000..e424c24
--- /dev/null
@@ -0,0 +1,113 @@
+/**
+ * TestbedsPlugin: List of testbeds plugin
+ * Version:     0.1
+ * Description: TODO -> generalize to a list of possible filters
+ *              This file is part of the Manifold project 
+ * Requires:    js/plugin.js
+ * URL:         http://www.myslice.info
+ * Author:      Loïc Baron <loic.baron@lip6.fr>
+ * Copyright:   Copyright 2012-2013 UPMC Sorbonne Universités
+ * License:     GPLv3
+ */
+
+(function($){
+
+    var TestbedsPlugin = Plugin.extend({
+
+        /** XXX to check
+         * @brief Plugin constructor
+         * @param options : an associative array of setting values
+         * @param element : 
+         * @return : a jQuery collection of objects on which the plugin is
+         *     applied, which allows to maintain chainability of calls
+         */
+        init: function(options, element) {
+           // for debugging tools
+           this.classname="testbedsplugin";
+            // Call the parent constructor, see FAQ when forgotten
+            this._super(options, element);
+
+            /* Member variables */
+
+            /* Plugin events */
+
+            /* Setup query and record handlers */
+
+            // Explain this will allow query events to be handled
+            // What happens when we don't define some events ?
+            // Some can be less efficient
+            this.listen_query(options.query_uuid);
+            this.listen_query(options.query_all_uuid, 'all');
+            this.listen_query(options.query_network_uuid, 'network');
+
+            /* GUI setup and event binding */
+            // call function
+
+        },
+
+        /* PLUGIN EVENTS */
+        // on_show like in querytable
+
+
+        /* GUI EVENTS */
+
+        // a function to bind events here: click change
+        // how to raise manifold events
+
+
+        /* GUI MANIPULATION */
+
+        // We advise you to write function to change behaviour of the GUI
+        // Will use naming helpers to access content _inside_ the plugin
+        // always refer to these functions in the remaining of the code
+
+        show_hide_button: function() 
+        {
+            // this.id, this.el, this.cl, this.elts
+            // same output as a jquery selector with some guarantees
+        },
+
+        /* TEMPLATES */
+
+        // see in the html template
+        // How to load a template, use of mustache
+
+        /* QUERY HANDLERS */
+
+        // How to make sure the plugin is not desynchronized
+        // He should manifest its interest in filters, fields or records
+        // functions triggered only if the proper listen is done
+
+        // no prefix
+
+        on_filter_added: function(filter)
+        {
+
+        },
+
+        // ... be sure to list all events here
+
+        /* RECORD HANDLERS */
+        on_network_new_record: function(record)
+        {
+            console.log(record);
+            row  = '<a href="#" class="list-group-item sl-platform" data-platform="'+record["network_hrn"]+'">';
+            row += '<span class="list-group-item-heading">'+record["platform"]+'</span>';
+            //row += '<span class="list-group-item-heading">'+record["network_hrn"]+'</span></a>';
+            row += '<p class="list-group-item-text">'+record["network_hrn"]+'</p></a>';
+            $('#testbeds-filter').append(row);
+        },
+
+        /* INTERNAL FUNCTIONS */
+        _dummy: function() {
+            // only convention, not strictly enforced at the moment
+        },
+
+    });
+
+    /* Plugin registration */
+    $.plugin('TestbedsPlugin', TestbedsPlugin);
+
+    // TODO Here use cases for instanciating plugins in different ways like in the pastie.
+
+})(jQuery);
diff --git a/plugins/testbeds/templates/testbeds.html b/plugins/testbeds/templates/testbeds.html
new file mode 100644 (file)
index 0000000..fe8c2ea
--- /dev/null
@@ -0,0 +1,3 @@
+<div id={{ domid }}>
+<div class="list-group-item sl-platform"><span class="list-group-item-heading">Testbeds</span></div>
+</div>