From 91dec1137db6f3b461ab40542f06b5fa93a2efa5 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Fri, 20 Dec 2013 12:19:24 +0100 Subject: [PATCH] adding some tracability into the plugins code we can now get some events traced right into plugins.js instead of having to instrument all callbacks --- manifold/static/js/plugin.js | 58 ++++++++++++++----- .../static/js/active_filters.js | 1 + plugins/googlemap/static/js/googlemap.js | 2 + plugins/lists/static/js/simplelist.js | 15 ++--- plugins/maddash/static/js/maddash.js | 1 + plugins/messages/static/js/messages.js | 1 + plugins/myplugin/static/js/myplugin.js | 2 + plugins/querygrid/static/js/querygrid.js | 1 + plugins/querytable/static/js/querytable.js | 4 +- .../queryupdater/static/js/queryupdater.js | 11 ++-- plugins/scheduler/static/js/scheduler.js | 1 + plugins/senslabmap/static/js/senslabmap.js | 1 + plugins/slicestat/static/js/slicestat.js | 1 + .../static/js/topmenuvalidation.js | 1 + 14 files changed, 72 insertions(+), 28 deletions(-) diff --git a/manifold/static/js/plugin.js b/manifold/static/js/plugin.js index 4530b518..24d41129 100644 --- a/manifold/static/js/plugin.js +++ b/manifold/static/js/plugin.js @@ -20,6 +20,13 @@ $.plugin = function(name, object) { }; }; +// set to either +// * false or undefined or none : no debug +// * true : trace all event calls +// * [ 'in_progress', 'query_done' ] : would only trace to these events +var plugin_debug=false; +plugin_debug = [ 'in_progress', 'query_done' ]; + var Plugin = Class.extend({ init: function(options, element) { @@ -42,35 +49,52 @@ var Plugin = Class.extend({ return (typeof this.on_filter_added === 'function'); }, + // do we need to log API calls ? + _is_in : function (obj, arr) { + for(var i=0; i element; with datatables in the way, // this might not be a direct son of the div-plugin - var $table = $plugindiv.find("table."+classname).first(); + var $table = $plugindiv.find("table."+this.classname).first(); // also we may or may not have a header - var $tbody = $table.find("tbody."+classname).first(); + var $tbody = $table.find("tbody."+this.classname).first(); var use_datatables = $table.hasClass("with-datatables"); var rows=self.buffered_records; self.buffered_records=[]; @@ -69,7 +69,7 @@ if (use_datatables) this._datatables_update_table($table, $tbody, rows, options.key); else - this._regular_update_table($table, $tbody, rows, options.key, classname); + this._regular_update_table($table, $tbody, rows, options.key, this.classname); }, _regular_set_message: function ($table, $tbody, message) { @@ -78,7 +78,8 @@ _regular_update_table: function ($table, $tbody, rows, key, classname) { if (debug) - messages.debug('regular_update_table ' + rows.length + " rows" + " key=" + key + " classname=" + classname); + messages.debug('regular_update_table ' + rows.length + " rows" + + " key=" + key + " classname=" + this.classname); var self=this; var html=$.map(rows, function (row) { var value = row; @@ -91,10 +92,10 @@ }); if ($.isArray(value)) { return $.map(value, function(val, i) { - return self._html_row ( self._cell (key, val), classname); + return self._html_row ( self._cell (key, val), this.classname); }); } else { - return self._html_row ( self._cell (key, value), classname); + return self._html_row ( self._cell (key, value), this.classname); } }).join(); $tbody.html(html); diff --git a/plugins/maddash/static/js/maddash.js b/plugins/maddash/static/js/maddash.js index 110eec13..ab5a7a5d 100644 --- a/plugins/maddash/static/js/maddash.js +++ b/plugins/maddash/static/js/maddash.js @@ -37,6 +37,7 @@ var colorscale = d3.scale.category10().range(["green", "yellow", "red", "orange" */ init: function(options, element) { // Call the parent constructor, see FAQ when forgotten + this.classname="maddash"; this._super(options, element); diff --git a/plugins/messages/static/js/messages.js b/plugins/messages/static/js/messages.js index a90a7452..07265e6c 100644 --- a/plugins/messages/static/js/messages.js +++ b/plugins/messages/static/js/messages.js @@ -9,6 +9,7 @@ var Messages = Plugin.extend ({ init: function (options, element) { + classname="messages"; this._super (options, element); // subscribe to the various messages channels var self=this; diff --git a/plugins/myplugin/static/js/myplugin.js b/plugins/myplugin/static/js/myplugin.js index 26a29922..a885ddf2 100644 --- a/plugins/myplugin/static/js/myplugin.js +++ b/plugins/myplugin/static/js/myplugin.js @@ -23,6 +23,8 @@ * applied, which allows to maintain chainability of calls */ init: function(options, element) { + // for debugging tools + this.classname="myplugin"; // Call the parent constructor, see FAQ when forgotten this._super(options, element); diff --git a/plugins/querygrid/static/js/querygrid.js b/plugins/querygrid/static/js/querygrid.js index 8f77eaa6..a5758e8b 100644 --- a/plugins/querygrid/static/js/querygrid.js +++ b/plugins/querygrid/static/js/querygrid.js @@ -38,6 +38,7 @@ var QueryGrid = Plugin.extend({ init: function(options, element) { + this.classname="querygrid"; this._super(options, element); /* Member variables */ diff --git a/plugins/querytable/static/js/querytable.js b/plugins/querytable/static/js/querytable.js index ca2c5da2..19ecd6cc 100644 --- a/plugins/querytable/static/js/querytable.js +++ b/plugins/querytable/static/js/querytable.js @@ -11,8 +11,8 @@ var QueryTable = Plugin.extend({ - init: function(options, element) - { + init: function(options, element) { + this.classname="querytable"; this._super(options, element); /* Member variables */ diff --git a/plugins/queryupdater/static/js/queryupdater.js b/plugins/queryupdater/static/js/queryupdater.js index abcd2d7f..b00f04fd 100644 --- a/plugins/queryupdater/static/js/queryupdater.js +++ b/plugins/queryupdater/static/js/queryupdater.js @@ -11,6 +11,9 @@ (function( $ ){ + var debug=false; + debug=true; + // XXX record selected (multiple selection ?) // XXX record disabled ? // XXX out of sync plugin ? @@ -25,8 +28,8 @@ var QueryUpdater = Plugin.extend({ - init: function(options, element) - { + init: function(options, element) { + this.classname="queryupdater"; this._super(options, element); var self = this; @@ -65,8 +68,7 @@ /***************************** GUI EVENTS *****************************/ - do_update: function(e) - { + do_update: function(e) { var self = e.data; // XXX check that the query is not disabled manifold.raise_event(self.options.query_uuid, RUN_UPDATE); @@ -268,6 +270,7 @@ on_query_in_progress: function() { + messages.debug("queryupdater.on_query_in_progress"); this.spin(); }, diff --git a/plugins/scheduler/static/js/scheduler.js b/plugins/scheduler/static/js/scheduler.js index 0929157e..c9b20968 100644 --- a/plugins/scheduler/static/js/scheduler.js +++ b/plugins/scheduler/static/js/scheduler.js @@ -45,6 +45,7 @@ var txt_otherslice = {"font": '"Trebuchet MS", Verdana, Arial, Helvetica, sans-s init: function(options, element) { + this.classname="scheduler"; this._super(options, element); /* Member variables */ diff --git a/plugins/senslabmap/static/js/senslabmap.js b/plugins/senslabmap/static/js/senslabmap.js index 519a5af1..e6a64b58 100644 --- a/plugins/senslabmap/static/js/senslabmap.js +++ b/plugins/senslabmap/static/js/senslabmap.js @@ -1,6 +1,7 @@ (function($){ var SensLabMap = Plugin.extend({ init: function(options, element) { + this.classname="senslabmap"; this._super(options, element); this.elmt().on('show', this, this.on_show); diff --git a/plugins/slicestat/static/js/slicestat.js b/plugins/slicestat/static/js/slicestat.js index da177222..a55a7973 100644 --- a/plugins/slicestat/static/js/slicestat.js +++ b/plugins/slicestat/static/js/slicestat.js @@ -23,6 +23,7 @@ * applied, which allows to maintain chainability of calls */ init: function(options, element) { + this.classname="slicestat"; // Call the parent constructor, see FAQ when forgotten this._super(options, element); diff --git a/plugins/topmenuvalidation/static/js/topmenuvalidation.js b/plugins/topmenuvalidation/static/js/topmenuvalidation.js index 6cfc383c..c29592b4 100644 --- a/plugins/topmenuvalidation/static/js/topmenuvalidation.js +++ b/plugins/topmenuvalidation/static/js/topmenuvalidation.js @@ -10,6 +10,7 @@ var TopmenuValidation = Plugin.extend({ init: function(options, element) { + this.classname="topmenuvalidation"; this._super(options, element); this.listen_query(options.query_uuid); this.triggered=false; -- 2.43.0