remove old slice view, use this instead of haze
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Thu, 21 Mar 2013 11:15:56 +0000 (12:15 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Thu, 21 Mar 2013 11:15:56 +0000 (12:15 +0100)
myslice/urls.py
myslice/viewutils.py
plugins/hazelnut/hazelnut.js
plugins/hazelnut/hazelnut.py
trash/sampleviews.py
trash/sliceview.py [moved from trash/haze.py with 94% similarity]
trash/templates/view-slice.html [deleted file]

index 5fa99b4..a2e0695 100644 (file)
@@ -41,11 +41,10 @@ urlpatterns = patterns(
     #
     # various trash views
     #
-    (r'^slice/?$', 'trash.sampleviews.slice_view'),
-    (r'^slice/(?P<name>[\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<slicename>[\w\.]+)/?$', 'trash.sliceview.slice_view'),
 )
index 99d74d2..669c4ca 100644 (file)
@@ -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/'},
index a3d24f9..90dc75c 100644 (file)
@@ -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
             }
         }
     
-        /**
-         * @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 "<input class='hazelnut-checkbox-" + plugin_uuid + "' id='hazelnut-checkbox-" + plugin_uuid + "-" + get_value(header) + "' name='" + get_value(field) + "' type='checkbox' " + selected_str + disabled_str + "autocomplete='off' value='" + get_value(header) + "'></input>";
-        }
-    
-        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 <div>
+           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;
     
                 // 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') {
                     }
                 }
     
-                if (o.checkboxes) {
+                if (options.checkboxes) {
                     var checked = '';
                     if (typeof(obj['sliver']) != 'undefined') { /* It is equal to null when <sliver/> 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);
     
             });
     
+//         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 += "<input class='hazelnut-checkbox-" + plugin_uuid + "' id='hazelnut-checkbox-" + plugin_uuid + "-" + get_value(header) + "'";
+           result += " name='" + get_value(field) + "' type='checkbox' " + selected_str + disabled_str + " autocomplete='off' value='" + get_value(header) + "'";
+           result +="></input>";
+           return result;
+        };
+    } // constructor
+
     /***************************************************************************
      * Private methods
      ***************************************************************************/
     }
 
     function hazelnut_draw_callback() {
-        var o = this.options;
+        var options = this.options;
         /* 
          * Handle clicks on checkboxes: reassociate checkbox click every time
          * the table is redrawn 
          */
-        $('.hazelnut-checkbox-' + o.plugin_uuid).unbind('click');
-        $('.hazelnut-checkbox-' + o.plugin_uuid).click({instance: this}, check_click);
+        $('.hazelnut-checkbox-' + options.plugin_uuid).unbind('click');
+        $('.hazelnut-checkbox-' + options.plugin_uuid).click({instance: this}, check_click);
 
         if (!this.table)
             return;
index bcc60cb..c03f99c 100644 (file)
@@ -15,7 +15,8 @@ class Hazelnut (Plugin):
         # xxx need to retrieve metadata
 # $subject_keys = Plugins::get_default_fields($query->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):
index 4733402..5e3c942 100644 (file)
@@ -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
similarity index 94%
rename from trash/haze.py
rename to trash/sliceview.py
index 6ea65aa..a410a71 100644 (file)
@@ -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 (file)
index e6560f4..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-{# -*-django-html-mumamo-mode-*- #}
-{% extends 'layout-unfold1.html' %}
-
-{% block unfold1_main %}
-{% if name %}
-<p class='well'>We're getting the variable <code>name= {{ name }}</code> from the URL </p>
-{% else %}
-<p class='well'>This URL is not valid, you need to pass a slice name like in <a href="/slice/my.slice.name">/slice/my.slice.name</a></p>
-{% endif %}
-{% endblock unfold1_main %}
-