function debug_dict_keys (msg, o) {
var keys=[];
for (var k in o) keys.push(k);
- console.log ("debug_dict_keys: " + msg + " keys= " + keys);
+ messages.debug ("debug_dict_keys: " + msg + " keys= " + keys);
}
function debug_dict (msg, o) {
- for (var k in o) console.log ("debug_dict: " + msg + " [" + k + "]=" + o[k]);
+ for (var k in o) messages.debug ("debug_dict: " + msg + " [" + k + "]=" + o[k]);
}
function debug_value (msg, value) {
- console.log ("debug_value: " + msg + " " + value);
+ messages.debug ("debug_value: " + msg + " " + value);
}
function debug_query (msg, query) {
- if (query === undefined) console.log ("debug_query: " + msg + " -> undefined");
- else if (query == null) console.log ("debug_query: " + msg + " -> null");
- else if ('query_uuid' in query) console.log ("debug_query: " + msg + query.__repr());
- else console.log ("debug_query: " + msg + " query= " + query);
+ if (query === undefined) messages.debug ("debug_query: " + msg + " -> undefined");
+ else if (query == null) messages.debug ("debug_query: " + msg + " -> null");
+ else if ('query_uuid' in query) messages.debug ("debug_query: " + msg + query.__repr());
+ else messages.debug ("debug_query: " + msg + " query= " + query);
}
/* ------------------------------------------------------------ */
},
debug_all_queries : function (msg) {
for (var query_uuid in manifold.all_queries) {
- $.publish("/messages/debug","manifold.debug " + msg + " " + query_uuid + " -> " + manifold.all_queries[query_uuid]);
+ messages.debug("manifold.debug " + msg + " " + query_uuid + " -> " + manifold.all_queries[query_uuid]);
}
},
// in case the spin stuff was not loaded, let's make sure we proceed to the exit
try {
if (manifold.asynchroneous_debug)
- $.publish("/messages/debug","Turning on spin with " + jQuery(".need-spin").length + " matches for .need-spin");
+ messages.debug("Turning on spin with " + jQuery(".need-spin").length + " matches for .need-spin");
jQuery('.need-spin').spin(spin_presets);
- } catch (err) { console.log("Cannot turn on spins " + err); }
+ } catch (err) { messages.debug("Cannot turn on spins " + err); }
// We use js function closure to be able to pass the query (array) to the
// callback function used when data is received
// by default we publish using the same uuid of course
if (publish_uuid==undefined) publish_uuid=query.query_uuid;
if (manifold.asynchroneous_debug) {
- $.publish("/messages/debug","sending POST on " + manifold.proxy_url + " to be published on " + publish_uuid);
- $.publish("/messages/debug","... ctd... with actual query= " + query.__repr());
+ messages.debug("sending POST on " + manifold.proxy_url + " to be published on " + publish_uuid);
+ messages.debug("... ctd... with actual query= " + query.__repr());
}
// not quite sure what happens if we send a string directly, as POST data is named..
// this gets reconstructed on the proxy side with ManifoldQuery.fill_from_POST
// e.g. an updater wants to publish its results as if from the original (get) query
asynchroneous_success : function (data, query, publish_uuid, domid) {
if (manifold.asynchroneous_debug)
- $.publish("/messages/debug","received manifold result with code " + data.code);
+ messages.debug("received manifold result with code " + data.code);
// xxx should have a nicer declaration of that enum in sync with the python code somehow
if (data.code == 1) {
alert("Your session has expired, please log in again");
if (data) {
if (!!domid) {
/* Directly inform the requestor */
- if (manifold.asynchroneous_debug) $.publish("/messages/debug","directing results to " + domid);
+ if (manifold.asynchroneous_debug) messages.debug("directing results to " + domid);
jQuery('#' + domid).trigger('results', [data]);
} else {
/* Publish an update announce */
- if (manifold.asynchroneous_debug) $.publish("/messages/debug","publishing results on " + publish_uuid);
+ if (manifold.asynchroneous_debug) messages.debug("publishing results on " + publish_uuid);
jQuery.publish("/results/" + publish_uuid + "/changed", [data, query]);
}
except xmlrpclib.Fault, error:
### xxx this is very rough for now
# until we have some agreement about how the API calls should return error conditions
- # in some less unpolite way than this anoanymous exception, we assume it's a problem with the session
+ # in some less unpolite way than this anonymous exception, we assume it's a problem with the session
# that needs to be refreshed
if debug: print "Session Expired"
if error.faultCode == 8002:
answer=manifold_api.send_manifold_query (manifold_query)
if debug: print 'manifoldproxy.proxy: received from backend with code', answer['code']
json_answer=json.dumps(answer)
+ # if in debug mode we save this so we can use offline mode later
if (debug):
with (file(offline_filename,"w")) as f:
f.write(json_answer)
+ # this is an artificial delay added for debugging purposes only
if debug_spin:
import time
time.sleep(debug_spin)
$.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, $this, function(e, rows) { hazelnut.update_plugin(e,rows); });
- if (debug) console.log("hazelnut '" + this.id + "' subscribed to e.g." + results_channel);
+ if (debug) messages.debug("hazelnut '" + this.id + "' subscribed to e.g." + results_channel);
}); // this.each
}, // init
show : function( ) {
var $this=$(this);
// xxx wtf. why [1] ? would expect 0...
- if (debug) console.log("Hitting suspicious line in hazelnut.show");
+ if (debug) messages.debug("Hitting suspicious line in hazelnut.show");
var oTable = $($('.dataTable', $this)[1]).dataTable();
oTable.fnAdjustColumnSizing()
// xxx thierry : initialize this here - it was not, I expect this relied on set_query somehow..
//this.current_query = null;
this.current_query=manifold.find_query(this.options.query_uuid);
- if (debug) console.log("Hazelnut constructor: have set current_query -> " + this.current_query);
+ if (debug) messages.debug("Hazelnut constructor: have set current_query -> " + this.current_query);
this.query_update = null;
this.current_resources = Array();
previous_query = this.current_query;
/* Save the query as the current query */
this.current_query = query;
- if (debug) console.log("hazelnut.set_query, current_query is now -> " + this.current_query);
+ if (debug) messages.debug("hazelnut.set_query, current_query is now -> " + this.current_query);
/* We check all necessary fields : in column editor I presume XXX */
// XXX ID naming has no plugin_uuid
if (typeof(query.fields) != 'undefined') {
}
this.set_resources = function(resources, instance) {
- if (debug) console.log("entering hazelnut.set_resources");
+ if (debug) messages.debug("entering hazelnut.set_resources");
var options = this.options;
var previous_resources = this.current_resources;
this.current_resources = resources;
* XXX will be removed/replaced
*/
this.selected_changed = function(e, change) {
- if (debug) console.log("entering hazelnut.selected_changed");
+ if (debug) messages.debug("entering hazelnut.selected_changed");
var actions = change.split("/");
if (actions.length > 1) {
var oNodes = this.table.fnGetNodes();
// 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;
- if (debug) console.log("entering hazelnut.update_plugin on id '" + $plugindiv.attr('id') + "'");
+ if (debug) messages.debug("entering hazelnut.update_plugin on id '" + $plugindiv.attr('id') + "'");
// 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);
this.table.html(unfold.errorDisplay("No Result"));
return;
} else if (typeof(rows[0].error) != 'undefined') {
- if (debug) console.log ("undefined result");
+ if (debug) messages.debug ("undefined result");
this.table.html(unfold.errorDisplay(rows[0].error));
return;
}
});
this.table.fnClearTable();
- if (debug) console.log("hazelnut.update_plugin: total of " + newlines.length + " rows");
+ if (debug) messages.debug("hazelnut.update_plugin: total of " + newlines.length + " rows");
this.table.fnAddData(newlines);
};
/* font size for regular (non datatable'd) simplelists */
tbody.simplelist {
- font-size: 80%;
+ font-size: 120%;
}
/* datatable'd tables behave differently */
table.with-datatables>tbody.simplelist {
- font-size: 100%;
+ font-size: 80%;
}
/* larger headers */
thead.simplelist>tr>th {
var channel='/results/' + options.query_uuid + '/changed';
/* passing $this as 2nd arg: callbacks will retrieve $this as e.data */
$.subscribe(channel, $this, update_plugin);
- if (debug) window.console.log('subscribing to ' + channel);
+ if (debug) window.messages.debug('subscribing to ' + channel);
$this.data('SimpleList', options);
});
},
destroy : function( ) {
- if (debug) console.log("SimpleList.destroy...");
+ if (debug) messages.debug("SimpleList.destroy...");
return this.each(function(){
var $this = $(this), data = $this.data('SimpleList');
// xxx not too sure what this is about
});
},
update : function( content ) {
- if (debug) console.log("SimpleList.update...");
+ if (debug) messages.debug("SimpleList.update...");
},
}; // methods
// also we may or may not have a header
var $tbody=$table.find("tbody.simplelist").first();
var use_datatables = $table.hasClass("with-datatables");
- if (debug) console.log($plugindiv.attr('id') + " udt= " + use_datatables);
+ if (debug) messages.debug($plugindiv.attr('id') + " udt= " + use_datatables);
// clear the spinning wheel: look up an ancestor that has the need-spin class
// do this before we might return
}
function regular_update_table ($table, $tbody, rows, key) {
- if (debug) console.log('regular_update_table ' + rows.length + " rows");
+ if (debug) messages.debug('regular_update_table ' + rows.length + " rows");
var html=$.map(rows, function (row) { return html_row ( cell (key, row[key])); }).join();
$tbody.html(html);
}
}
function datatables_update_table ($table, $tbody, rows, key) {
- if (debug) console.log('datatables_update_table ' + rows.length + " rows");
+ if (debug) messages.debug('datatables_update_table ' + rows.length + " rows");
$table.dataTable().fnClearTable();
// the lambda here returns a [[]] because $.map is kind of broken; as per the doc:
// The function can return any value to add to the array. A returned array will be flattened into the resulting array.
$.subscribe("/messages/"+level, function (e, msg){ instance.display_message (msg,level)});
}) (instance,level);
}
+ // kind of patchy, notify the convenience functions that somebody is listening...
+ try {messages.ready=true;}
+ catch (err) { console.log("Could not set messages.ready");}
// this happens very early - even before the document is loaded
// so it won't show right away; no big deal though
- $.publish ("/messages/info", 'Subscribed to all 5 message channels');
+ $.publish ("/messages/info", 'Subscribed to all 5 message channels');
});
},
destroy : function( ) {
var methods = {
init : function (options) {
- if (debug) console.log("SyntaxHighlighter.all ...");
+ if (debug) messages.debug("SyntaxHighlighter.all ...");
SyntaxHighlighter.all();
return this.each(function() {
var $this=$(this);
var channel='/results/' + options.query_uuid + '/updated';
/* passing $this as 2nd arg: callbacks will retrieve $this as e.data */
$.subscribe(channel, $this, update_plugin);
- if (debug) console.log('subscribing to ' + channel);
+ if (debug) messages.debug('subscribing to ' + channel);
$this.data('QueryCode', {options: options});
// react to changes to the language selector
$this.find(".querycode-lang").change(change_language);
},
// destroy : function( ) {
-// if (debug) console.log("QueryCode.destroy...");
+// if (debug) messages.debug("QueryCode.destroy...");
// },
// update : function( content ) {
-// if (debug) console.log("QueryCode.update...");
+// if (debug) messages.debug("QueryCode.update...");
// },
} // methods
funname="translate_query_as_" + lang;
fun=eval(funname);
if (! fun) {
- console.log("Cannot find translator function for lang " + lang);
+ messages.debug("Cannot find translator function for lang " + lang);
return;
}
html_code=fun(query);
dom.html(html_code);
- if (debug) console.log("SyntaxHighlighter.highlight");
+ if (debug) messages.debug("SyntaxHighlighter.highlight");
SyntaxHighlighter.highlight()
}
// Remove first to clean up select boxes
var removed_filters = tmp.removed;
$.each(removed_filters, function(i,filter){
- console.log(filter[0]);
+ messages.debug(filter[0]);
allowedValues=metadata.property('resource', filter[0], 'allowed_values');
if (allowedValues!='' && allowedValues!="N/A") {
//if(MANIFOLD_METADATA[filter[0]]['allowed_values']!=''){
$('#QuickFilter_select_field').change( function () {
var field = $(this).val();
- console.log(field);
+ messages.debug(field);
$('input[id^="QuickFilter-string-"]').hide();
$('#QuickFilter_int_value_div').hide();
if(field=="#"){
});
$('.QuickFilter_select').change( function() {
- console.log(this.id);
+ messages.debug(this.id);
var query = data.current_query;
var f_value = $(this).val();
f_value = "";
*/
if(typeof(key[1])!="undefined"){
- console.log(key[1]+'='+f_value);
+ messages.debug(key[1]+'='+f_value);
if(f_value==""){
query.remove_filter(key[1],"","");
}else{
messages.debug("submit_update_request");
var query_uuid = e.data.options.query_uuid;
var update_query = e.data.update_query;
- $.publish("/messages/debug","Updater.submit_update_request " + update_query.__repr());
+ messages.debug("Updater.submit_update_request " + update_query.__repr());
// actually send the Update query, but publish results as if coming from the original query
manifold.asynchroneous_exec ( [ {'query_uuid': update_query.query_uuid, 'publish_uuid' : query_uuid} ]);
// looks like a previous attempt to disable the button while the query is flying
fields=['network','type','hrn','hostname'],
filters= [ [ 'slice_hrn', '=', slicename, ] ],
)
+ # don't run this one as nothing listens to this
page.enqueue_query (main_query, run_it=False)
main_plugin = \
title='thestack',
togglable=False,
sons=[ \
-# Hazelnut (page=page,
-# query=main_query,
-# ),
- Messages (
- page=page,
- title="Runtime messages",
- domid="msgs-pre",
- levels='ALL',
- ),
Updater (
page=page,
title="Update me",
query=main_query,
label="Update me",
+ domid="the-updater",
),
+ Messages (
+ page=page,
+ title="Runtime messages",
+ domid="msgs-pre",
+ levels='ALL',
+ ),
])
# define 'unfold1_main' to the template engine
page=page,
title="Runtime messages",
domid="msgs-pre",
+ levels="ALL",
),
Tabs (
page=page,
-// messages runtime -- convenience functions messages.fatal and the like
+// messages runtime -- convenience functions messages.debug and the like
// in addition, messages can get lost if the UI is not ready to accept them
// so we use console.log in this case
var messages = {
ready : false,
levels : ['fatal','error','warning','info','debug'],
handler : function (level,msg) {
- if (messages.ready) $.publish("/messages/"+level+"/",msg);
+ if (messages.ready) $.publish("/messages/"+level,msg);
else console.log("/messages/"+level+"/: "+msg);
},
};
-for (var i in messages.levels) { var level=messages.levels[i]; messages[level]=function (msg) {messages.handler (level,msg)};}
-$(function(){messages.ready=true;})
+for (var i in messages.levels) {
+ var level=messages.levels[i];
+ (function (level) { messages[level]=function (msg) {messages.handler (level,msg)};})(level);
+}
+// messages.ready is set by the messages plugin once it is ready to listen on the 5 channels
+// this way messages don't get lost if the view does not have a messages instance
+//$(function(){messages.ready=true;})
////////// use local storage to remember open/closed toggles
store_status : function (domid,status) {
var key='toggle.'+domid;
- if (plugin.debug) console.log("storing toggle status " + status + " for " + domid + " key=" + key);
+ if (plugin.debug) messages.debug("storing toggle status " + status + " for " + domid + " key=" + key);
$.localStorage.setItem(key,status);
},
// restore last status
var retrieved=$.localStorage.getItem(key);
// set default to true
if (retrieved==null) retrieved="true";
- if (plugin.debug) console.log ("retrieved toggle status for " + domid + " (key=" + key + ") -> " + retrieved);
+ if (plugin.debug) messages.debug ("retrieved toggle status for " + domid + " (key=" + key + ") -> " + retrieved);
return retrieved;
},
set_toggle_status : function (domid,status) {
},
set_from_saved_status : function (domid) {
var previous_status=plugin.retrieve_last_status (domid);
- if (plugin.debug) console.log("restoring initial status for domid " + domid + " -> " + previous_status);
+ if (plugin.debug) messages.debug("restoring initial status for domid " + domid + " -> " + previous_status);
plugin.set_toggle_status (domid,previous_status);
},
// triggered upon $(document).ready
if (maxdepth===undefined) maxdepth=5;
var up=null, counter=0;
while (true) {
- console.log(counter+" "+msg+" id='"+dom.id+"' ["+dom.classList+"]");
+ messages.debug(counter+" "+msg+" id='"+dom.id+"' ["+dom.classList+"]");
up=dom.parentNode;
counter += 1;
if ( (up == null) || (up === dom)) break;
- if (counter >= maxdepth) { console.log(counter+" "+msg+" -> ..."); break; }
+ if (counter >= maxdepth) { messages.debug(counter+" "+msg+" -> ..."); break; }
dom=up;
}
},
$(document).ready(function () {
var query_publish_dom_tuples = new Array();
{% for d in query_publish_dom_tuples %}try {query_publish_dom_tuples.push({'query_uuid':"{{ d.query_uuid }}"{%if d.domid %},'domid':"{{ d.domid }}"{% endif %}}) }
-catch(err){console.log ("Could not expose query {{ d.query_uuid }}")}
+catch(err){messages.debug ("Could not expose query {{ d.query_uuid }}")}
{% endfor %}
manifold.asynchroneous_exec(query_publish_dom_tuples);
})