diff --git a/js/console.js b/js/console.js index 3ca4f6431d..d32e7c1039 100644 --- a/js/console.js +++ b/js/console.js @@ -1100,6 +1100,13 @@ var PMA_consoleBookmarks = { }; var PMA_consoleDebug = { + _config: { + groupQueries: false + }, + _lastDebugInfo: { + debugInfo: null, + url: null + }, initialize: function() { // Try to get debug info after every AJAX request $( document ).ajaxSuccess(function(event, xhr, settings, data) { @@ -1108,6 +1115,29 @@ var PMA_consoleDebug = { } }); + // Initialize config + this._initConfig(); + + if (this.configParam('groupQueries')) { + $('#debug_console').addClass('grouped'); + } else { + $('#debug_console').addClass('ungrouped'); + } + + // Initialize actions in toolbar + $('#debug_console .button.group_queries').click(function() { + $('#debug_console').addClass('grouped'); + $('#debug_console').removeClass('ungrouped'); + PMA_consoleDebug.configParam('groupQueries', true); + PMA_consoleDebug.refresh(); + }); + $('#debug_console .button.ungroup_queries').click(function() { + $('#debug_console').addClass('ungrouped'); + $('#debug_console').removeClass('grouped'); + PMA_consoleDebug.configParam('groupQueries', false); + PMA_consoleDebug.refresh(); + }); + // Show SQL debug info for first page load if (typeof debugSQLInfo !== 'undefined' && debugSQLInfo !== 'null') { $('#pma_console .button.debug').removeClass('hide'); @@ -1117,6 +1147,19 @@ var PMA_consoleDebug = { } PMA_consoleDebug.showLog(debugSQLInfo); }, + _initConfig: function() { + var config = JSON.parse($.cookie('pma_console_dbg_config')); + if (config) { + this._config = config; + } + }, + configParam: function(name, value) { + if (typeof value === 'undefined') { + return this._config[name]; + } + this._config[name] = value; + $.cookie('pma_console_dbg_config', JSON.stringify(this._config)); + }, _formatFunctionCall: function(dbgStep) { var functionName = ''; if ('class' in dbgStep) { @@ -1126,8 +1169,7 @@ var PMA_consoleDebug = { functionName += dbgStep.function; if (dbgStep.args.length) { functionName += '(...)'; - } - else { + } else { functionName += '()'; } return functionName; @@ -1181,8 +1223,7 @@ var PMA_consoleDebug = { .append( $('').text(step) ); - } - else { + } else { if (typeof step.args === 'string' && step.args) { step.args = [step.args]; } @@ -1219,14 +1260,80 @@ var PMA_consoleDebug = { } return $traceElem; }, + _formatQueryOrGroup: function(queryInfo) { + var grouped, queryText, totalTime, count, i; + if (Array.isArray(queryInfo)) { + // It is grouped + grouped = true; + + queryText = queryInfo[0].query; + + totalTime = 0; + for (i in queryInfo) { + totalTime += queryInfo[i].time; + } + + count = queryInfo.length; + } else { + queryText = queryInfo.query; + totalTime = queryInfo.time; + } + + var $query = $('