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
This commit is contained in:
commit
5b1c1a2ce1
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
import { createProfilingChart } from '../chart';
|
||||
import { $ } from '../../utils/JqueryExtended';
|
||||
import '../../plugins/jquery/jquery.tablesorter';
|
||||
|
||||
/*
|
||||
* Profiling Chart
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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.
|
||||
|
||||
12
js/src/variables/InlineScripting.js
Normal file
12
js/src/variables/InlineScripting.js
Normal file
@ -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();
|
||||
};
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
3
sql.php
3
sql.php
@ -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();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user