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):
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):
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']
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
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;
}
--- /dev/null
+/* 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;
+}
--- /dev/null
+/* 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;
+}
(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 );
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)
-<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>
--- /dev/null
+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
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
# 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
context.update(page.prelude_env())
return context
-
-
-
padding-left: 0 !important;
}
-.simplelist {
- font-size: 100%;
- text-align: center !important;
- margin: 0 auto;
-}
<h2>Testbeds</h2>
</div>
<div class='ms-dashboard-content' id='tophat__list__platform__network_name'>
- {{networks}}
+ {{testbeds}}
</div>
</div>