diff options
author | Deven Bansod <devenbansod@users.noreply.github.com> | 2018-08-16 17:56:51 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-16 17:56:51 +0300 |
commit | 5b1c1a2ce136d8a57fa284851f7c2dc8513f0d3e (patch) | |
tree | f95931e11a621a9b3267207fb1d49248199366f7 | |
parent | fc72f0d739cccd075a2ae87e215b910dbe5a252d (diff) | |
parent | fd21247e53efa3b737ac6bc6c2be5cb768294382 (diff) |
Merge pull request #14518 from Piyush3079/Mod_Js_Sql_Profiling
Add modular code for profiling of sql queries on related pages and structured some code
-rw-r--r-- | js/functions.js | 43 | ||||
-rw-r--r-- | js/src/consts/files.js | 7 | ||||
-rw-r--r-- | js/src/functions.js | 5 | ||||
-rw-r--r-- | js/src/functions/Sql/SqlProfiling.js | 2 | ||||
-rw-r--r-- | js/src/index.js | 4 | ||||
-rw-r--r-- | js/src/sql.js | 10 | ||||
-rw-r--r-- | js/src/utils/JqueryExtended.js | 1 | ||||
-rw-r--r-- | js/src/variables/InlineScripting.js | 12 | ||||
-rw-r--r-- | libraries/classes/Sql.php | 8 | ||||
-rw-r--r-- | libraries/common.inc.php | 8 | ||||
-rw-r--r-- | sql.php | 3 |
11 files changed, 32 insertions, 71 deletions
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..7b8c556a1c 100644 --- a/js/src/consts/files.js +++ b/js/src/consts/files.js @@ -23,9 +23,10 @@ const files = { server_export: ['export'], server_import: ['import'], db_search: ['db_search', 'sql'], - server_sql: ['multi_column_sort', 'sql'], - tbl_sql: ['sql'], - db_sql: ['sql'] + server_sql: ['sql', 'multi_column_sort'], + tbl_sql: ['sql', 'multi_column_sort'], + db_sql: ['sql', 'multi_column_sort'], + sql: ['sql', 'multi_column_sort'] }; export default files; diff --git a/js/src/functions.js b/js/src/functions.js index 53c1938ab4..798272e516 100644 --- a/js/src/functions.js +++ b/js/src/functions.js @@ -1,4 +1,5 @@ import { AJAX } from './ajax'; +import { $ } from './utils/JqueryExtended'; import CommonParams from './variables/common_params'; import { PMA_Messages as PMA_messages } from './variables/export_variables'; @@ -98,11 +99,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..fedb00716f 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/JqueryExtended'; +import '../../plugins/jquery/jquery.tablesorter'; /* * Profiling Chart diff --git a/js/src/index.js b/js/src/index.js index 24c29d5a28..3fc890bad1 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 @@ -111,7 +113,7 @@ $(document).ajaxError(function (event, request, settings) { * Adding common files for every page */ for (let i in files.global) { - AJAX.scriptHandler.add(files.global[i]); + AJAX.scriptHandler.add(files.global[i], 1); } /** * This block of code is for importing javascript files needed 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 .= '<div id="profilingchart" class="hide">'; $profiling_table .= '</div>'; $profiling_table .= '<script type="text/javascript">'; - $profiling_table .= "AJAX.registerOnload('sql.js', function () {"; - $profiling_table .= 'makeProfilingChart();'; - $profiling_table .= 'initProfilingTables();'; - $profiling_table .= '});'; + $profiling_table .= "makeProfilingChartInline();"; $profiling_table .= '</script>'; $profiling_table .= '</fieldset>' . "\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 @@ -27,11 +27,10 @@ PageSettings::showGroup('Browse'); $response = Response::getInstance(); $header = $response->getHeader(); $scripts = $header->getScripts(); -$scripts->addFile('vendor/jquery/jquery.uitablefilter.js'); $scripts->addFile('tbl_change.js'); $scripts->addFile('indexes.js'); $scripts->addFile('gis_data_editor.js'); -$scripts->addFile('multi_column_sort.js'); +$scripts->addFile('multi_column_sort'); $sql = new Sql(); |