various fixes - we now see the request sent on /manifold/api/json/ but
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Fri, 8 Mar 2013 08:45:24 +0000 (09:45 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Fri, 8 Mar 2013 08:45:24 +0000 (09:45 +0100)
there's nobody there yet

engine/pluginset.py
engine/static/js/manifold-async.js
plugins/simplelist.py
trash/dashboard.py

index 01442dc..1a0f54e 100644 (file)
@@ -33,21 +33,21 @@ class PluginSet:
     # the js async methods (see manifold_async_success)
     # offer the option to deliver the result to a specific DOM elt
     # otherwise it goes through the pubsub using query's uuid
-    def query_enqueue (self, query, domid=None):
+    def enqueue_query (self, query, domid=None):
         self._queue.append ( (query,domid,) )
 
     # return the javascript that triggers all the queries
     def exec_queue_asynchroneously (self):
         js = ""
-        js += "var manifold_query_array = new Array();"
+        js += "var manifold_query_array = new Array();\n"
         for (query,domid) in self._queue:
             qjson=query.to_json()
-            id="'%s'"%domid if domid else undefined
-            js += "manifold_query_array.push({'query':'%(qjson)s', 'id':%(id)s});"%locals()
+            id="'%s'"%domid if domid else 'undefined'
+            js += "manifold_query_array.push({'query':%(qjson)s, 'id':%(id)s});\n"%locals()
         js += "onFunctionAvailable('manifold_async_exec', function() {manifold_async_exec(manifold_query_array);}, this, true);"
         self.reset_queue()
         # run only once the document is ready
-        js = "jQuery(function(){%(js)s})"%locals()
+        js = "$(document).ready(function(){%(js)s})"%locals()
         self.add_js_chunks (js)
 
     #################### requirements/prelude management
index 83a97a7..ae35630 100644 (file)
@@ -16,61 +16,24 @@ function manifold_array_size(obj) {
 //
 function manifold_async_exec(arr)
 {
-
+    console.log('manifold_async_exec length='+ arr.length);
     // start spinners
-    //onObjectAvailable('Spinners', function(){ Spinners.create('.loading').play(); }, this, true);
-    jQuery('.loading').spin();
+    // xxx todo - I don't have the spinner jquery plugin yet
+//    jQuery('.loading').spin();
 
     // We use js function closure to be able to pass the query (array) to the
     // callback function used when data is received
-    var manifold_async_success_wrapper = function(query, id) {
-        return function(data, textStatus) {
-            manifold_async_success(data, query, id);
-        };
+    var manifold_async_success_closure = function(query, id) {
+        return function(data, textStatus) {manifold_async_success(data, query, id);}
     };
 
     // Loop through query array and issue XML/RPC queries
     jQuery.each(arr, function(index, elt) {
-        // we do rendering by default
-        jQuery.post(api_url, {'query': elt.query.to_hash()}, manifold_async_success_wrapper(elt.query, elt.id));
+       console.log ('sending POST on ' + api_url + " iterating on " + elt);
+        jQuery.post(api_url, {'query': elt.query.to_hash()}, manifold_async_success_closure(elt.query, elt.id));
     })
 }
 
-function manifold_async_exec_render(arr)
-{
-
-    // start spinners
-    //onObjectAvailable('Spinners', function(){ Spinners.create('.loading').play(); }, this, true);
-    jQuery('.loading').spin();
-
-    // We use js function closure to be able to pass the query (array) to the
-    // callback function used when data is received
-    var manifold_async_success_wrapper = function(query, id) {
-        return function(data, textStatus) {
-            manifold_async_success(data, query, id);
-        };
-    };
-
-    // Loop through query array and issue XML/RPC queries
-    jQuery.each(arr, function(index, elt) {
-        // we do rendering by default
-        jQuery.post(api_render_url, {'query': elt.query.to_hash()}, manifold_async_success_wrapper(elt.query, elt.id));
-    })
-}
-
-function manifold_async_render(data, query)
-{
-    // We use js function closure to be able to pass the query (array) to the
-    // callback function used when data is received
-    var manifold_async_render_success_wrapper = function(query) {
-        return function(data, textStatus) {
-            manifold_async_render_success(data, query);
-        };
-    };
-
-    jQuery.post(api_render_url, {'data': data, 'query': query.to_hash()}, manifold_async_render_success_wrapper(data, query));
-}
-
 function manifold_async_error(str) {
     var out = '<div class="error"><h2>Error</h2><dl id="system-message"><dt class="error">Notice</dt><dd class="error message"><ul><li>' + jQuery('<div />').text(str).html() + '</li></ul></dd></dl></div>';
     jQuery('#manifold_message').html(out);
@@ -78,6 +41,7 @@ function manifold_async_error(str) {
     jQuery('.loading').spin();
 }
 
+/* what the hell is this doing here ?
 function apply_format(key, value, type, method) {
     // type = type, key = 
     var link = {
@@ -120,6 +84,7 @@ function apply_format(key, value, type, method) {
         return key;
     }
 }
+*/
 
 function manifold_html_a(key, value, type) {
     if (type == 'network_hrn') {
index 19a7769..6eb0f44 100644 (file)
@@ -2,9 +2,7 @@ from engine.plugin import Plugin
 
 class SimpleList (Plugin) :
 
-    # it would make sense to *not* define any constructor here and let Plugin kick in
-    # however it feels nicer this way as we document the settings used in our own template
-    # plus it's less confusing for any subclass if they can be sure which constructor to call
+    # 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)
         self.list=list
@@ -22,9 +20,6 @@ class SimpleList (Plugin) :
             reqs['js_files'].append ("datatables/js/dataTables.js")
             reqs['js_files'].append ("js/with-datatables.js")
         return reqs
-# for tests
-#                 'js_chunks' : "/* a javascript chunk */",       
-#                 'css_chunks': "/* a css style */ ",
     
     def json_settings_list (self): return ['plugin_uuid', 'query','query_uuid','key','value']
 
index 246536e..e7ea899 100644 (file)
@@ -29,6 +29,7 @@ def dashboard_view (request):
                                   # we don't have the user's hrn yet
                                   # in addition this currently returns all slices anyways
                                   sort='slice_hrn',)
+    pluginset.enqueue_query (slices_query)
 
     main_plugin = SimpleList ( # setting visible attributes first
         pluginset=pluginset,