SliceList and TestbedList are specialized versions of SimpleList with related css
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Thu, 14 Nov 2013 14:39:03 +0000 (15:39 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Thu, 14 Nov 2013 14:39:03 +0000 (15:39 +0100)
13 files changed:
plugins/lists/simplelist.py
plugins/lists/slicelist.py
plugins/lists/static/css/simplelist.css
plugins/lists/static/css/slicelist.css [new file with mode: 0644]
plugins/lists/static/css/testbedlist.css [new file with mode: 0644]
plugins/lists/static/js/simplelist.js
plugins/lists/staticlist.py
plugins/lists/templates/simplelist.html
plugins/lists/testbedlist.py [new file with mode: 0644]
portal/dashboardview.py
portal/platformview.py
portal/static/css/onelab_marko.css
portal/templates/dashboard.html

index 69e47aa..2651030 100644 (file)
@@ -3,10 +3,12 @@ from unfold.plugin import Plugin
 class SimpleList (Plugin) :
 
     # only deal with our own stuff here and let Plugin handle the rest
-    def __init__ (self, key, with_datatables=False, **settings):
+    def __init__ (self, key, with_datatables=False, classname=None, **settings):
         Plugin.__init__ (self, **settings)
         self.key=key
         self.with_datatables = with_datatables
+        # the DOM classname
+        self.classname = classname if classname is not None else "simplelist"
 
     # SimpleList is useless per se anyways
     def template_file (self): 
@@ -18,6 +20,7 @@ class SimpleList (Plugin) :
         header=getattr(self,'header',None)
         if header: env['header']=header
         env['with_datatables']= "yes" if self.with_datatables else ""
+        env['classname']=self.classname
         return env
 
     def requirements (self):
@@ -34,5 +37,5 @@ class SimpleList (Plugin) :
             reqs['js_files'].append ("js/with-datatables.js")
         return reqs
     
-    def json_settings_list (self): return ['plugin_uuid','query_uuid','key']
+    def json_settings_list (self): return ['plugin_uuid','query_uuid','key','classname']
 
index b9220db..adfb9bf 100644 (file)
@@ -5,8 +5,13 @@ from plugins.lists.simplelist import SimpleList
 class SliceList (SimpleList):
     
     def __init__ (self, **settings):
-        SimpleList.__init__(self, key='slice_hrn', **settings)
+        SimpleList.__init__(self, key='slice.slice_hrn', classname='slicelist', **settings)
 
     # writing a js plugin for that would be overkill, just use SimpleList
     def plugin_classname (self):
         return 'SimpleList'
+
+    def requirements (self):
+        req = SimpleList.requirements(self)
+        req['css_files'] += [ 'css/slicelist.css' ]
+        return req
index bbf537e..77f80ce 100644 (file)
@@ -15,14 +15,9 @@ thead.simplelist>tr>th {
 tbody.simplelist i {
     padding-right: 8px;
 }
-/* make previous next buttons a bit nicer */
-div.paging_two_button>a { padding: 0px 4px 0px 4px; }
 
-/* ---------- */
-/* xxx this probably should be separated in something related to datatables */
-select { 
-    width: auto;
-}
-div.dataTables_filter input[type=text] {
-    width: 60;
+.simplelist {
+    font-size: 100%;
+    text-align: center !important;
+    margin: 0 auto;
 }
diff --git a/plugins/lists/static/css/slicelist.css b/plugins/lists/static/css/slicelist.css
new file mode 100644 (file)
index 0000000..34a427c
--- /dev/null
@@ -0,0 +1,23 @@
+/* font size for regular (non datatable'd) slicelists */
+tbody.slicelist {
+    font-size: 150%;
+}
+/* datatable'd tables behave differently */
+table.with-datatables>tbody.slicelist {
+    font-size: 80%;
+}
+/* larger headers */
+thead.slicelist>tr>th {
+    font-size: 150%;
+    padding: 10px 10px 20px 10px;
+}
+/* some space after the arrow */ 
+tbody.slicelist i {
+    padding-right: 8px;
+}
+
+.slicelist {
+    font-size: 100%;
+    text-align: center !important;
+    margin: 0 auto;
+}
diff --git a/plugins/lists/static/css/testbedlist.css b/plugins/lists/static/css/testbedlist.css
new file mode 100644 (file)
index 0000000..fd312ba
--- /dev/null
@@ -0,0 +1,23 @@
+/* font size for regular (non datatable'd) testbedlists */
+tbody.testbedlist {
+    font-size: 300%;
+}
+/* datatable'd tables behave differently */
+table.with-datatables>tbody.testbedlist {
+    font-size: 80%;
+}
+/* larger headers */
+thead.testbedlist>tr>th {
+    font-size: 150%;
+    padding: 10px 10px 20px 10px;
+}
+/* some space after the arrow */ 
+tbody.testbedlist i {
+    padding-right: 8px;
+}
+
+.testbedlist {
+    font-size: 100%;
+    text-align: center !important;
+    margin: 0 auto;
+}
index 6a61ca5..ad6985c 100644 (file)
@@ -7,7 +7,7 @@
 (function($){
 
     var debug=false;
-    // debug=true
+    debug=true
 
     $.fn.SimpleList = function( method ) {
         /* Method calling logic */
         // e.data is what we passed in second argument to subscribe
         // so here it is the jquery object attached to the plugin <div>
         var $plugindiv = e.data;
+        var options = $plugindiv.data().SimpleList;
+       var classname=options.classname;
         // locate the <table> element; with datatables in the way,
         // this might not be a direct son of the div-plugin
-        var $table = $plugindiv.find("table.simplelist").first();
+        var $table = $plugindiv.find("table."+classname).first();
         // also we may or may not have a header
-        var $tbody = $table.find("tbody.simplelist").first();
+        var $tbody = $table.find("tbody."+classname).first();
         var use_datatables = $table.hasClass("with-datatables");
         if (debug) 
-            messages.debug($plugindiv.attr('id') + " udt= " + use_datatables);
+            messages.debug($plugindiv.attr('id') + " udt= " + use_datatables + " rows="+rows.length);
        
        // clear the spinning wheel: look up an ancestor that has the need-spin class
        // do this before we might return
         }
 
         if (typeof rows[0].error != 'undefined') {
-               var error="ERROR: " + rows[0].error;
-               if (use_datatables) 
+           var error="ERROR: " + rows[0].error;
+           if (use_datatables) 
                 datatables_set_message ($table, $tbody, unfold.error(error));
-               else
-                       regular_set_message ($table, $tbody, unfold.error(error));
+           else
+               regular_set_message ($table, $tbody, unfold.error(error));
             return;
         }
 
-        var options = $plugindiv.data().SimpleList;
-           if (use_datatables) 
+       if (use_datatables)     
             datatables_update_table($table, $tbody, rows, options.key);
-           else
-                       regular_update_table($table, $tbody, rows, options.key);
+       else
+           regular_update_table($table, $tbody, rows, options.key, classname);
 
-        }
+    }
 
     // hard-wire a separate presentation depending on the key being used....
     function cell(key, value) {
        $tbody.html("<tr><td>"+message+"</td></tr>");
     }
 
-    function regular_update_table ($table, $tbody, rows, key) {
+    function regular_update_table ($table, $tbody, rows, key, classname) {
         if (debug)
-            messages.debug('regular_update_table ' + rows.length + " rows");
-           var html=$.map(rows, function (row) {
+            messages.debug('regular_update_table ' + rows.length + " rows" + " key=" + key + " classname=" + classname);
+       var html=$.map(rows, function (row) {
             value = row;
             $.each(key.split('.'), function(i, k) {
                 if ($.isArray(value)) {
                     value = value[k];
                 }
             });
-            if ($.isArray(value)) {
-                x = $.map(value, function(val, i) { return html_row ( cell (key, val)); });
+               if ($.isArray(value)) {
+                x = $.map(value, function(val, i) { 
+                   messages.debug("loop.loop val="+val+" i="+i);
+                   return html_row ( cell (key, val), classname); });
                 return x;
             } else {
-                return html_row ( cell (key, value));
+                return html_row ( cell (key, value), classname);
             }
         }).join();
        $tbody.html(html);
        $table.dataTable().fnDraw();
     }  
     
-    function html_row (cell) { 
-        return "<tr><td class='simplelist'>"+cell+"</td></tr>"; 
+    function html_row (cell, classname) { 
+        return "<tr><td class='"+classname+"'>"+cell+"</td></tr>"; 
     }
     
 })( jQuery );
index c5a254a..f53a2ac 100644 (file)
@@ -2,6 +2,12 @@ from unfold.plugin import Plugin
 
 class StaticList (Plugin) :
 
+    """ StaticList allows you to display an html list 
+    that you provide the contents for in the 'list' input argument
+    It is static in the sense that no query is going to be used to
+    manage this contents
+    """
+
     # only deal with our own stuff here and let Plugin handle the rest
     def __init__ (self, list=[], with_datatables=False, **settings):
         Plugin.__init__ (self, **settings)
index e34d087..c3e2954 100644 (file)
@@ -1,4 +1,4 @@
-<table class='simplelist{%if with_datatables %} with-datatables{% endif %}'>
-{% if header %} <thead class='simplelist'><tr><th class='simplelist'>{{ header }}</th></tr></thead> {% endif %}
-<tbody class='simplelist'></tbody>
+<table class='{{ classname }}{%if with_datatables %} with-datatables{% endif %}'>
+{% if header %} <thead class='{{ classname }}'><tr><th class='{{ classname }}'>{{ header }}</th></tr></thead> {% endif %}
+<tbody class='{{ classname }}'></tbody>
 </table>
diff --git a/plugins/lists/testbedlist.py b/plugins/lists/testbedlist.py
new file mode 100644 (file)
index 0000000..6496d90
--- /dev/null
@@ -0,0 +1,15 @@
+from plugins.lists.simplelist import SimpleList
+
+class TestbedList (SimpleList):
+    
+    def __init__ (self, **settings):
+        SimpleList.__init__(self, key='platform', classname='testbedlist', **settings)
+
+    # writing a js plugin for that would be overkill, just use SimpleList
+    def plugin_classname (self):
+        return 'SimpleList'
+
+    def requirements (self):
+        req = SimpleList.requirements(self)
+        req['css_files'] += [ 'css/testbedlist.css' ]
+        return req
index 1cc12e0..44a3ea9 100644 (file)
@@ -1,7 +1,8 @@
 from manifold.core.query         import Query
 from unfold.page                 import Page
 
-from plugins.lists.simplelist    import SimpleList
+from plugins.lists.testbedlist   import TestbedList
+from plugins.lists.slicelist     import SliceList
 
 from unfold.loginrequired        import LoginRequiredAutoLogoutView
 
@@ -22,32 +23,29 @@ class DashboardView (LoginRequiredAutoLogoutView):
 
         # Slow...
         #slice_query = Query().get('slice').filter_by('user.user_hrn', 'contains', user_hrn).select('slice_hrn')
-        auth_query  = Query().get('network').select('network_hrn','platform')
+        testbed_query  = Query().get('network').select('network_hrn','platform')
         # DEMO GEC18 Query only PLE
         slice_query = Query().get('user').filter_by('user_hrn', '==', '$user_hrn').select('user_hrn', 'slice.slice_hrn')
         page.enqueue_query(slice_query)
-        page.enqueue_query(auth_query)
+        page.enqueue_query(testbed_query)
 
         page.expose_js_metadata()
         page.expose_queries()
 
-        slicelist = SimpleList(
-            title = None,
+        slicelist = SliceList(
             page  = page,
-            key   = 'slice.slice_hrn',
+            title = "slices",
             query = slice_query,
         )
-        # XXX TODO: plugins/lists/static/js/simplelist.js => hardcoded keys that give links : slice_hrn & platform
-        authlist = SimpleList(
-            title = None,
+        testbedlist = TestbedList(
             page  = page,
-            key   = 'platform',
-            query = auth_query,
+            title = "testbeds",
+            query = testbed_query,
         )
  
         context = super(DashboardView, self).get_context_data(**kwargs)
         context['person']   = self.request.user
-        context['networks'] = authlist.render(self.request) 
+        context['testbeds'] = testbedlist.render(self.request) 
         context['slices']   = slicelist.render(self.request)
 
         # XXX This is repeated in all pages
index a81ba87..f3ea7f7 100644 (file)
@@ -61,6 +61,3 @@ class PlatformView(FreeAccessView):
         context.update(page.prelude_env())
 
         return context
-
-
-
index 0201e8b..a7b256c 100644 (file)
@@ -419,8 +419,3 @@ table.query-editor td {
     padding-left: 0 !important;
 }   
 
-.simplelist {
-    font-size: 100%;
-    text-align: center !important;
-    margin: 0 auto;
-}
index cd13608..e4c61b4 100644 (file)
@@ -28,7 +28,7 @@
                        <h2>Testbeds</h2>
                </div>
                <div class='ms-dashboard-content' id='tophat__list__platform__network_name'>
-               {{networks}}
+               {{testbeds}}
                </div>
    </div>