From: Thierry Parmentelat Date: Thu, 21 Mar 2013 11:15:56 +0000 (+0100) Subject: remove old slice view, use this instead of haze X-Git-Tag: myslice-django-0.1-2~36 X-Git-Url: http://git.onelab.eu/?p=unfold.git;a=commitdiff_plain;h=72e1b6fd2be568712a4be6eb5805e0f686030ea3 remove old slice view, use this instead of haze --- diff --git a/myslice/urls.py b/myslice/urls.py index 5fa99b45..a2e06951 100644 --- a/myslice/urls.py +++ b/myslice/urls.py @@ -41,11 +41,10 @@ urlpatterns = patterns( # # various trash views # - (r'^slice/?$', 'trash.sampleviews.slice_view'), - (r'^slice/(?P[\w\.]+)/?$', 'trash.sampleviews.slice_view'), (r'^tab/?$', 'trash.sampleviews.tab_view'), (r'^scroll/?$', 'trash.sampleviews.scroll_view'), (r'^plugin/?$', 'trash.pluginview.test_plugin_view'), (r'^dashboard/?$', 'trash.dashboard.dashboard_view'), - (r'^hazelnut/?$', 'trash.haze.hazelnut_view'), + (r'^slice/?$', 'trash.sliceview.slice_view'), + (r'^slice/(?P[\w\.]+)/?$', 'trash.sliceview.slice_view'), ) diff --git a/myslice/viewutils.py b/myslice/viewutils.py index 99d74d29..669c4ca4 100644 --- a/myslice/viewutils.py +++ b/myslice/viewutils.py @@ -5,10 +5,9 @@ from copy import deepcopy standard_topmenu_items = [ { 'label':'Tab', 'href': '/tab/'}, { 'label':'Scroll', 'href': '/scroll/'}, - { 'label':'Slice', 'href': '/slice/'}, { 'label':'Plugin', 'href': '/plugin/'}, { 'label':'Dashboard', 'href': '/dashboard/'}, - { 'label':'Hazelnut', 'href': '/hazelnut/'}, + { 'label':'Slice', 'href': '/slice/'}, ] #login_out_items = { False: { 'label':'Login', 'href':'/login/'}, diff --git a/plugins/hazelnut/hazelnut.js b/plugins/hazelnut/hazelnut.js index a3d24f99..90dc75c7 100644 --- a/plugins/hazelnut/hazelnut.js +++ b/plugins/hazelnut/hazelnut.js @@ -56,7 +56,7 @@ $.subscribe(query_channel, function(e, query) { hazelnut.set_query(query); });; $.subscribe(update_channel, function(e, resources, instance) { hazelnut.set_resources(resources, instance); }); - $.subscribe(results_channel, function(e, rows) { hazelnut.update_table(rows); }); + $.subscribe(results_channel, $this, function(e, rows) { hazelnut.update_plugin(e,rows); }); }); // this.each }, // init @@ -264,24 +264,19 @@ } } - /** - * @brief - * @param plugin_uuid - * @param header - * @param field - * @param selected_str - * @param disabled_str - */ - this.checkbox = function(plugin_uuid, header, field, selected_str, disabled_str) { - /* Prefix id with plugin_uuid */ - return ""; - } - - this.update_table = function(rows) { - var o = this.options; - var object = this; + this.update_plugin = function(e, rows) { + if (debug) console.log("entering update_plugin"); + // e.data is what we passed in second argument to subscribe + // so here it is the jquery object attached to the plugin
+ var $plugindiv=e.data; + console.log("incoming plugindiv= " + $plugindiv); + // clear the spinning wheel: look up an ancestor that has the need-spin class + // do this before we might return + $plugindiv.closest('.need-spin').spin(false); + + var options = this.options; + var hazelnut = this; - $('#' + o.plugin_uuid).spin(false) if (rows.length==0) { this.table.html(errorDisplay("No Result")); return; @@ -300,10 +295,10 @@ // go through table headers to get column names we want // in order (we have temporarily hack some adjustments in names) - var cols = object.table.fnSettings().aoColumns; + var cols = hazelnut.table.fnSettings().aoColumns; var colnames = cols.map(function(x) {return x.sTitle}) var nb_col = colnames.length; - if (o.checkboxes) + if (options.checkboxes) nb_col -= 1; for (var j = 0; j < nb_col; j++) { if (typeof colnames[j] == 'undefined') { @@ -322,14 +317,14 @@ } } - if (o.checkboxes) { + if (options.checkboxes) { var checked = ''; if (typeof(obj['sliver']) != 'undefined') { /* It is equal to null when is present */ checked = 'checked '; - object.current_resources.push(obj['urn']); + hazelnut.current_resources.push(obj['urn']); } // Use a key instead of hostname (hard coded...) - newline.push(object.checkbox(o.plugin_uuid, obj['urn'], obj['type'], checked, false)); + newline.push(hazelnut.checkbox(options.plugin_uuid, obj['urn'], obj['type'], checked, false)); } newlines.push(newline); @@ -337,10 +332,22 @@ }); +// console.log ("end of each, newlines=" + newlines.length); this.table.fnAddData(newlines); - } - } +// console.log (" exiting update_plugin = "); + }; + + this.checkbox = function (plugin_uuid, header, field, selected_str, disabled_str) { + var result=""; + /* Prefix id with plugin_uuid */ + result += "subject, $is_unique); # $fields = Plugins::metadata_get_fields($query->subject); - env['subject_fields']=[ 'the','available','default','fields'] +# for now I am hard-coding the ones from haze.py + env['subject_fields']=[ 'hostname', 'hrn' ] return env def requirements (self): diff --git a/trash/sampleviews.py b/trash/sampleviews.py index 47334028..5e3c9420 100644 --- a/trash/sampleviews.py +++ b/trash/sampleviews.py @@ -33,19 +33,3 @@ def scroll_view (request): }, context_instance=RequestContext(request)) -# we take name from the URL and propagate in the template -@login_required -def slice_view (request, name=None): - title='Fake Slice Page' - if name: title += " for slice %s"%name - result=render_to_response ('view-slice.html', - {'name':name, - 'title':title, - 'topmenu_items' : topmenu_items('slice',request), - 'username':the_user (request), - 'slices': hard_wired_slice_names, - 'unfold1_main' : lorem, - }, - context_instance=RequestContext(request)) - - return result diff --git a/trash/haze.py b/trash/sliceview.py similarity index 94% rename from trash/haze.py rename to trash/sliceview.py index 6ea65aab..a410a71e 100644 --- a/trash/haze.py +++ b/trash/sliceview.py @@ -18,8 +18,10 @@ from myslice.viewutils import quickfilter_criterias from myslice.viewutils import topmenu_items, the_user +tmp_default_slice='ple.inria.sfatest' + @login_required -def hazelnut_view (request): +def slice_view (request, slicename=tmp_default_slice): page = Page(request) @@ -27,7 +29,7 @@ def hazelnut_view (request): subject='resource', timestamp='latest', fields=['hrn','hostname'], - filters= [ [ 'slice_hrn', '=', 'ple.inria.omftest', ] ], + filters= [ [ 'slice_hrn', '=', slicename, ] ], # xxx filter : should filter on the slices the logged user can see # we don't have the user's hrn yet # in addition this currently returns all slices anyways @@ -50,6 +52,7 @@ def hazelnut_view (request): page=page, title='xmlrpc code', query=main_query, + toggled=False, ), ]) diff --git a/trash/templates/view-slice.html b/trash/templates/view-slice.html deleted file mode 100644 index e6560f45..00000000 --- a/trash/templates/view-slice.html +++ /dev/null @@ -1,11 +0,0 @@ -{# -*-django-html-mumamo-mode-*- #} -{% extends 'layout-unfold1.html' %} - -{% block unfold1_main %} -{% if name %} -

We're getting the variable name= {{ name }} from the URL

-{% else %} -

This URL is not valid, you need to pass a slice name like in /slice/my.slice.name

-{% endif %} -{% endblock unfold1_main %} -