From 5b7079e9ff1593c348552659d8bf0f9e9a04d8aa Mon Sep 17 00:00:00 2001 From: Piyush Vijay Date: Mon, 14 May 2018 23:48:40 +0530 Subject: [PATCH] Profiling working on table browsing and on running sql queries. Signed-Off-By: Piyush Vijay --- js/functions.js | 43 ---------------------------- js/src/consts/files.js | 3 +- js/src/functions.js | 4 --- js/src/functions/Sql/SqlProfiling.js | 2 ++ js/src/index.js | 2 ++ js/src/sql.js | 10 ++++--- js/src/utils/JqueryExtended.js | 1 + js/src/variables/InlineScripting.js | 12 ++++++++ libraries/classes/Sql.php | 8 ++---- libraries/common.inc.php | 8 ------ 10 files changed, 27 insertions(+), 66 deletions(-) create mode 100644 js/src/variables/InlineScripting.js diff --git a/js/functions.js b/js/functions.js index a3a33c546c..49708ff9dc 100644 --- a/js/functions.js +++ b/js/functions.js @@ -4258,49 +4258,6 @@ $(window).on('popstate', function (event, data) { return true; }); -/** - * Unbind all event handlers before tearing down a page - */ -AJAX.registerTeardown('functions.js', function () { - $(document).off('click', 'a.themeselect'); - $(document).off('change', '.autosubmit'); - $('a.take_theme').off('click'); -}); - -AJAX.registerOnload('functions.js', function () { - /** - * Theme selector. - */ - $(document).on('click', 'a.themeselect', function (e) { - window.open( - e.target, - 'themes', - 'left=10,top=20,width=510,height=350,scrollbars=yes,status=yes,resizable=yes' - ); - return false; - }); - - /** - * Automatic form submission on change. - */ - $(document).on('change', '.autosubmit', function (e) { - $(this).closest('form').submit(); - }); - - /** - * Theme changer. - */ - $('a.take_theme').on('click', function (e) { - var what = this.name; - if (window.opener && window.opener.document.forms.setTheme.elements.set_theme) { - window.opener.document.forms.setTheme.elements.set_theme.value = what; - window.opener.document.forms.setTheme.submit(); - window.close(); - return false; - } - return true; - }); -}); /** * Produce print preview diff --git a/js/src/consts/files.js b/js/src/consts/files.js index a309f9e0a4..b80545387d 100644 --- a/js/src/consts/files.js +++ b/js/src/consts/files.js @@ -25,7 +25,8 @@ const files = { db_search: ['db_search', 'sql'], server_sql: ['multi_column_sort', 'sql'], tbl_sql: ['sql'], - db_sql: ['sql'] + db_sql: ['sql'], + sql: ['sql'] }; export default files; diff --git a/js/src/functions.js b/js/src/functions.js index 53c1938ab4..2699a6364d 100644 --- a/js/src/functions.js +++ b/js/src/functions.js @@ -98,11 +98,7 @@ export function onload1 () { * Automatic form submission on change. */ $(document).on('change', '.autosubmit', function (e) { - e.preventDefault(); - debugger; - console.log($(this).closest('form').submit()); $(this).closest('form').submit(); - debugger; }); /** diff --git a/js/src/functions/Sql/SqlProfiling.js b/js/src/functions/Sql/SqlProfiling.js index 3fe91495ab..d2420c8d8d 100644 --- a/js/src/functions/Sql/SqlProfiling.js +++ b/js/src/functions/Sql/SqlProfiling.js @@ -1,4 +1,6 @@ import { createProfilingChart } from '../chart'; +import { $ } from '../../utils/extend_jquery'; +import '../../plugins/jquery/jquery.tablesorter'; /* * Profiling Chart diff --git a/js/src/index.js b/js/src/index.js index 24c29d5a28..f76aeb64c0 100644 --- a/js/src/index.js +++ b/js/src/index.js @@ -7,6 +7,7 @@ import './variables/import_variables'; import { $ } from './utils/JqueryExtended'; import { AJAX } from './ajax'; import './variables/get_config'; +import './variables/InlineScripting'; import files from './consts/files'; import Console from './console'; import { PMA_sprintf } from './utils/sprintf'; @@ -14,6 +15,7 @@ import { PMA_Messages as PMA_messages } from './variables/export_variables'; import { escapeHtml } from './utils/Sanitise'; import { PMA_ajaxShowMessage } from './utils/show_ajax_messages'; import PMA_commonParams from './variables/common_params'; +import PMA_MicroHistory from './classes/MicroHistory'; /** * Page load event handler diff --git a/js/src/sql.js b/js/src/sql.js index 4d1edefae3..68945d822e 100644 --- a/js/src/sql.js +++ b/js/src/sql.js @@ -38,7 +38,7 @@ var $data_a; /** * Unbind all event handlers before tearing down a page */ -export function teardown1 () { +export function teardownSqlQueryExecute () { $(document).off('click', 'a.delete_row.ajax'); $(document).off('submit', '.bookmarkQueryForm'); $('input#bkm_label').off('keyup'); @@ -67,6 +67,8 @@ export function teardown1 () { $('body').off('click', '#simulate_dml'); $('body').off('keyup', '#sqlqueryform'); $('body').off('click', 'form[name="resultsForm"].ajax button[name="submit_mult"], form[name="resultsForm"].ajax input[name="submit_mult"]'); + $('#tablefields').off('dblclick'); + $('#tablefieldsSubmitLinkMode,#tablefieldsSubmitNonLinkMode').off('click'); } /** @@ -85,7 +87,7 @@ export function teardown1 () { * @name document.ready * @memberOf jQuery */ -export function onload1 () { +export function onloadSqlQueryExecute () { if (sqlQueryOptions.codemirror_editor || document.sqlform) { setShowThisQuery(); } @@ -826,7 +828,7 @@ function browseForeignDialog ($this_a) { }); } -export function onload2 () { +export function onloadSqlBrowsing () { $('body').on('click', 'a.browse_foreign', function (e) { e.preventDefault(); browseForeignDialog($(this)); @@ -862,7 +864,7 @@ export function onload2 () { } } -export function onload4 () { +export function onloadSqlProfiling () { makeProfilingChart(); initProfilingTables(); } diff --git a/js/src/utils/JqueryExtended.js b/js/src/utils/JqueryExtended.js index cf3706db4c..0f5f9374fa 100644 --- a/js/src/utils/JqueryExtended.js +++ b/js/src/utils/JqueryExtended.js @@ -5,6 +5,7 @@ import 'jquery-ui-timepicker-addon'; import 'jquery-mousewheel'; import 'jquery.event.drag'; import 'jquery-validation'; +import '../plugins/jquery/jquery.uitablefilter'; import { methods } from './menu_resizer'; // TODO: To use this import for replacing variables used in this file for // extending various strings for localization. diff --git a/js/src/variables/InlineScripting.js b/js/src/variables/InlineScripting.js new file mode 100644 index 0000000000..c77fb59769 --- /dev/null +++ b/js/src/variables/InlineScripting.js @@ -0,0 +1,12 @@ +import { initProfilingTables, makeProfilingChart } from '../functions/Sql/SqlProfiling'; + +/** + * @function makeProfilingChartInline Function for creating profiling chart + * on clicking profiling checkbox + * + * @return void + */ +window.makeProfilingChartInline = function () { + makeProfilingChart(); + initProfilingTables(); +}; diff --git a/libraries/classes/Sql.php b/libraries/classes/Sql.php index 4ec14b9870..71d09f9428 100644 --- a/libraries/classes/Sql.php +++ b/libraries/classes/Sql.php @@ -324,10 +324,7 @@ EOT; $profiling_table .= '
'; $profiling_table .= '
'; $profiling_table .= ''; $profiling_table .= '' . "\n"; } else { @@ -2115,8 +2112,7 @@ EOT; } if (!isset($_REQUEST['printview']) || $_REQUEST['printview'] != '1') { - $scripts->addFile('makegrid.js'); - $scripts->addFile('sql.js'); + $scripts->addFile('sql'); unset($GLOBALS['message']); //we don't need to buffer the output in getMessage here. //set a global variable and check against it in the function diff --git a/libraries/common.inc.php b/libraries/common.inc.php index ed9e7a93dc..03668135b9 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -420,14 +420,6 @@ if (! defined('PMA_MINIMUM_COMMON')) { * pages like sql, tbl_sql, db_sql, tbl_select */ $response = Response::getInstance(); - if (isset($_SESSION['profiling'])) { - $scripts = $response->getHeader()->getScripts(); - $scripts->addFile('chart.js'); - $scripts->addFile('vendor/jqplot/jquery.jqplot.js'); - $scripts->addFile('vendor/jqplot/plugins/jqplot.pieRenderer.js'); - $scripts->addFile('vendor/jqplot/plugins/jqplot.highlighter.js'); - $scripts->addFile('vendor/jquery/jquery.tablesorter.js'); - } /* * There is no point in even attempting to process