Some more javascript files structured properly.
Shortcut handler and page settings js files added in modular code. Signed-Off-By: Piyush Vijay <piyushvijay.1997@gmail.com>
This commit is contained in:
parent
91340d18e5
commit
c0810f98b2
@ -1,12 +1,20 @@
|
||||
import { PMA_ajaxShowMessage, PMA_ajaxRemoveMessage } from './utils/show_ajax_messages';
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
/**
|
||||
* Module import
|
||||
*/
|
||||
import { PMA_ajaxShowMessage,
|
||||
PMA_ajaxRemoveMessage
|
||||
} from './utils/show_ajax_messages';
|
||||
import { PMA_Messages as PMA_messages } from './variables/export_variables';
|
||||
import { PMA_commonParams } from './variables/common_params';
|
||||
import CommonParams from './variables/common_params';
|
||||
import { jQuery as $ } from './utils/JqueryExtended';
|
||||
import { PMA_getImage } from './functions/get_image';
|
||||
import { PMA_ensureNaviSettings, PMA_reloadNavigation,
|
||||
PMA_disableNaviSettings } from './functions/navigation';
|
||||
import { PMA_ensureNaviSettings,
|
||||
PMA_reloadNavigation,
|
||||
PMA_disableNaviSettings
|
||||
} from './functions/navigation';
|
||||
import { isStorageSupported } from './functions/config';
|
||||
|
||||
/**
|
||||
* This object handles ajax requests for pages. It also
|
||||
* handles the reloading of the main menu and scripts.
|
||||
@ -312,7 +320,7 @@ export let AJAX = {
|
||||
$('html, body').animate({ scrollTop: 0 }, 'fast');
|
||||
|
||||
var url = isLink ? href : $(this).attr('action');
|
||||
var argsep = PMA_commonParams.get('arg_separator');
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
var params = 'ajax_request=true' + argsep + 'ajax_page_request=true';
|
||||
var dataPost = AJAX.source.getPostData();
|
||||
if (! isLink) {
|
||||
@ -461,7 +469,7 @@ export let AJAX = {
|
||||
$('#selflink').find('> a').attr('href', data._selflink);
|
||||
}
|
||||
if (data._params) {
|
||||
PMA_commonParams.setAll(data._params);
|
||||
CommonParams.setAll(data._params);
|
||||
}
|
||||
if (data._scripts) {
|
||||
AJAX.scriptHandler.load(data._scripts);
|
||||
@ -590,7 +598,8 @@ export let AJAX = {
|
||||
if (checkNewCode(file)) {
|
||||
var fileImports = ['server_privileges', 'server_databases', 'error_report', 'navigation', 'server_status_advisor',
|
||||
'server_status_processes', 'server_status_variables', 'server_plugins', 'server_status_sorter', 'server_status_queries',
|
||||
'server_status_monitor', 'server_variables', 'server_user_groups', 'replication', 'export', 'import', 'config'
|
||||
'server_status_monitor', 'server_variables', 'server_user_groups', 'replication', 'export', 'import', 'config',
|
||||
'page_settings', 'shortcuts_handler'
|
||||
];
|
||||
if ($.inArray(file, fileImports) !== -1) {
|
||||
// Dynamic import to load the files dynamically
|
||||
@ -638,10 +647,10 @@ export let AJAX = {
|
||||
// Clear loaded scripts if they are from another version of phpMyAdmin.
|
||||
// Depends on common params being set before loading scripts in responseHandler
|
||||
if (self._scriptsVersion === null) {
|
||||
self._scriptsVersion = PMA_commonParams.get('PMA_VERSION');
|
||||
} else if (self._scriptsVersion !== PMA_commonParams.get('PMA_VERSION')) {
|
||||
self._scriptsVersion = CommonParams.get('PMA_VERSION');
|
||||
} else if (self._scriptsVersion !== CommonParams.get('PMA_VERSION')) {
|
||||
self._scripts = [];
|
||||
self._scriptsVersion = PMA_commonParams.get('PMA_VERSION');
|
||||
self._scriptsVersion = CommonParams.get('PMA_VERSION');
|
||||
}
|
||||
self._scriptsCompleted = false;
|
||||
self._scriptsToBeFired = [];
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { AJAX } from '../ajax';
|
||||
import { PMA_Messages as PMA_messages } from '../variables/export_variables';
|
||||
import { PMA_commonParams } from '../variables/common_params';
|
||||
import CommonParams from '../variables/common_params';
|
||||
import { PMA_ajaxShowMessage } from '../utils/show_ajax_messages';
|
||||
import { PMA_getImage } from '../functions/get_image';
|
||||
import TraceKit from 'tracekit';
|
||||
@ -45,7 +45,7 @@ var ErrorReport = {
|
||||
ErrorReport._last_exception = exception;
|
||||
$.get('error_report.php', {
|
||||
ajax_request: true,
|
||||
server: PMA_commonParams.get('server'),
|
||||
server: CommonParams.get('server'),
|
||||
get_settings: true,
|
||||
exception_type: 'js'
|
||||
}, function (data) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { PMA_ajaxShowMessage } from '../../utils/show_ajax_messages';
|
||||
import { PMA_highlightSQL } from '../../utils/sql';
|
||||
import { PMA_Messages as PMA_messages } from '../../variables/export_variables';
|
||||
import { PMA_commonParams } from '../../variables/common_params';
|
||||
import CommonParams from '../../variables/common_params';
|
||||
import { PMA_getImage } from '../../functions/get_image';
|
||||
import { escapeHtml } from '../../utils/Sanitise';
|
||||
import { jQuery as $ } from '../../utils/JqueryExtended';
|
||||
@ -35,7 +35,7 @@ class ProcessList {
|
||||
this.setRefreshLabel();
|
||||
if (this.refreshUrl === null) {
|
||||
this.refreshUrl = 'server_status_processes.php' +
|
||||
PMA_commonParams.get('common_query');
|
||||
CommonParams.get('common_query');
|
||||
}
|
||||
if (this.refreshInterval === null) {
|
||||
this.refreshInterval = $('#id_refreshRate').val();
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
* @type {Object} files
|
||||
*/
|
||||
const files = {
|
||||
global: ['error_report', 'navigation', 'config'],
|
||||
global: ['error_report', 'config', 'navigation', 'page_settings', 'shortcuts_handler'],
|
||||
server_privileges: ['server_privileges'],
|
||||
server_databases: ['server_databases'],
|
||||
server_status_advisor: ['server_status_advisor'],
|
||||
|
||||
@ -7,21 +7,21 @@ import {
|
||||
loadTemplate,
|
||||
updateTemplate,
|
||||
deleteTemplate,
|
||||
toggle_save_to_file,
|
||||
toggle_structure_data_opts,
|
||||
check_table_select_all,
|
||||
toggleSaveToFile,
|
||||
toggleStructureDataOpts,
|
||||
checkTableSelectAll,
|
||||
handleAddProcCheckbox,
|
||||
check_table_select_struture_or_data,
|
||||
check_table_selected,
|
||||
toggle_table_select,
|
||||
toggle_table_select_all_str,
|
||||
check_selected_tables,
|
||||
toggle_table_select_all_data,
|
||||
setup_table_structure_or_data,
|
||||
toggle_quick_or_custom,
|
||||
toggle_sql_include_comments,
|
||||
disable_dump_some_rows_sub_options,
|
||||
enable_dump_some_rows_sub_options,
|
||||
checkTableSelectStrutureOrData,
|
||||
checkTableSelected,
|
||||
toggleTableSelect,
|
||||
toggleTableSelectAllStr,
|
||||
checkSelectedTables,
|
||||
toggleTableSelectAllData,
|
||||
setupTableStructureOrData,
|
||||
toggleQuickOrCustom,
|
||||
toggleSqlIncludeComments,
|
||||
disableDumpSomeRowsSubOptions,
|
||||
enableDumpSomeRowsSubOptions,
|
||||
aliasToggleRow,
|
||||
addAlias,
|
||||
createAliasModal
|
||||
@ -164,8 +164,8 @@ function onloadExportTemplate () {
|
||||
}
|
||||
|
||||
function onloadSaveToFile () {
|
||||
toggle_save_to_file();
|
||||
$('input[type=\'radio\'][name=\'output_format\']').on('change', toggle_save_to_file);
|
||||
toggleSaveToFile();
|
||||
$('input[type=\'radio\'][name=\'output_format\']').on('change', toggleSaveToFile);
|
||||
}
|
||||
|
||||
function onloadExportOptions () {
|
||||
@ -192,7 +192,7 @@ function onloadExportOptions () {
|
||||
if (forceFile === 'true') {
|
||||
if ($('#radio_dump_asfile').prop('checked') !== true) {
|
||||
$('#radio_dump_asfile').prop('checked', true);
|
||||
toggle_save_to_file();
|
||||
toggleSaveToFile();
|
||||
}
|
||||
$('#radio_view_as_text').prop('disabled', true).parent().fadeTo('fast', 0.4);
|
||||
} else {
|
||||
@ -201,42 +201,42 @@ function onloadExportOptions () {
|
||||
});
|
||||
|
||||
$('input[type=\'radio\'][name$=\'_structure_or_data\']').on('change', function () {
|
||||
toggle_structure_data_opts();
|
||||
toggleStructureDataOpts();
|
||||
});
|
||||
|
||||
$('input[name="table_select[]"]').on('change', function () {
|
||||
toggle_table_select($(this).closest('tr'));
|
||||
check_table_select_all();
|
||||
toggleTableSelect($(this).closest('tr'));
|
||||
checkTableSelectAll();
|
||||
handleAddProcCheckbox();
|
||||
check_table_select_struture_or_data();
|
||||
checkTableSelectStrutureOrData();
|
||||
});
|
||||
|
||||
$('input[name="table_structure[]"]').on('change', function () {
|
||||
check_table_selected($(this).closest('tr'));
|
||||
check_table_select_all();
|
||||
checkTableSelected($(this).closest('tr'));
|
||||
checkTableSelectAll();
|
||||
handleAddProcCheckbox();
|
||||
check_table_select_struture_or_data();
|
||||
checkTableSelectStrutureOrData();
|
||||
});
|
||||
|
||||
$('input[name="table_data[]"]').on('change', function () {
|
||||
check_table_selected($(this).closest('tr'));
|
||||
check_table_select_all();
|
||||
checkTableSelected($(this).closest('tr'));
|
||||
checkTableSelectAll();
|
||||
handleAddProcCheckbox();
|
||||
check_table_select_struture_or_data();
|
||||
checkTableSelectStrutureOrData();
|
||||
});
|
||||
|
||||
$('#table_structure_all').on('change', function () {
|
||||
toggle_table_select_all_str();
|
||||
check_selected_tables();
|
||||
toggleTableSelectAllStr();
|
||||
checkSelectedTables();
|
||||
handleAddProcCheckbox();
|
||||
check_table_select_struture_or_data();
|
||||
checkTableSelectStrutureOrData();
|
||||
});
|
||||
|
||||
$('#table_data_all').on('change', function () {
|
||||
toggle_table_select_all_data();
|
||||
check_selected_tables();
|
||||
toggleTableSelectAllData();
|
||||
checkSelectedTables();
|
||||
handleAddProcCheckbox();
|
||||
check_table_select_struture_or_data();
|
||||
checkTableSelectStrutureOrData();
|
||||
});
|
||||
|
||||
if ($('input[name=\'export_type\']').val() === 'database') {
|
||||
@ -274,17 +274,17 @@ function onloadExportOptions () {
|
||||
.parent()
|
||||
.fadeTo('fast', 0.4);
|
||||
|
||||
setup_table_structure_or_data();
|
||||
setupTableStructureOrData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle force structure_or_data
|
||||
*/
|
||||
$('#plugins').on('change', setup_table_structure_or_data);
|
||||
$('#plugins').on('change', setupTableStructureOrData);
|
||||
}
|
||||
|
||||
function onloadExportSubmit () {
|
||||
$('input[type=\'radio\'][name=\'quick_or_custom\']').on('change', toggle_quick_or_custom);
|
||||
$('input[type=\'radio\'][name=\'quick_or_custom\']').on('change', toggleQuickOrCustom);
|
||||
|
||||
$('#scroll_to_options_msg').hide();
|
||||
$('#format_specific_opts').find('div.format_specific_options')
|
||||
@ -296,25 +296,25 @@ function onloadExportSubmit () {
|
||||
})
|
||||
.find('h3')
|
||||
.remove();
|
||||
toggle_quick_or_custom();
|
||||
toggle_structure_data_opts();
|
||||
toggle_sql_include_comments();
|
||||
check_table_select_all();
|
||||
toggleQuickOrCustom();
|
||||
toggleStructureDataOpts();
|
||||
toggleSqlIncludeComments();
|
||||
checkTableSelectAll();
|
||||
handleAddProcCheckbox();
|
||||
|
||||
/**
|
||||
* Initially disables the "Dump some row(s)" sub-options
|
||||
*/
|
||||
disable_dump_some_rows_sub_options();
|
||||
disableDumpSomeRowsSubOptions();
|
||||
|
||||
/**
|
||||
* Disables the "Dump some row(s)" sub-options when it is not selected
|
||||
*/
|
||||
$('input[type=\'radio\'][name=\'allrows\']').on('change', function () {
|
||||
if ($('input[type=\'radio\'][name=\'allrows\']').prop('checked')) {
|
||||
enable_dump_some_rows_sub_options();
|
||||
enableDumpSomeRowsSubOptions();
|
||||
} else {
|
||||
disable_dump_some_rows_sub_options();
|
||||
disableDumpSomeRowsSubOptions();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
63
js/src/functions/Server/ServerStatusVariables.js
Normal file
63
js/src/functions/Server/ServerStatusVariables.js
Normal file
@ -0,0 +1,63 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
/**
|
||||
* Filters the status variables by name/category/alert in the variables tab
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param {Object} textFilter Regular expression for filtering text
|
||||
*
|
||||
* @param {boolean} alertFilter For filtering alert variables
|
||||
*
|
||||
* @param {string} categoryFilter
|
||||
*
|
||||
* @param {string} text Text based filtering
|
||||
*/
|
||||
function filterVariables (
|
||||
textFilter,
|
||||
alertFilter,
|
||||
categoryFilter,
|
||||
text
|
||||
) {
|
||||
var usefulLinks = 0;
|
||||
var section = text;
|
||||
|
||||
if (categoryFilter.length > 0) {
|
||||
section = categoryFilter;
|
||||
}
|
||||
|
||||
if (section.length > 1) {
|
||||
$('#linkSuggestions').find('span').each(function () {
|
||||
if ($(this).attr('class').indexOf('status_' + section) !== -1) {
|
||||
usefulLinks++;
|
||||
$(this).css('display', '');
|
||||
} else {
|
||||
$(this).css('display', 'none');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (usefulLinks > 0) {
|
||||
$('#linkSuggestions').css('display', '');
|
||||
} else {
|
||||
$('#linkSuggestions').css('display', 'none');
|
||||
}
|
||||
|
||||
$('#serverstatusvariables').find('th.name').each(function () {
|
||||
if ((textFilter === null || textFilter.exec($(this).text())) &&
|
||||
(! alertFilter || $(this).next().find('span.attention').length > 0) &&
|
||||
(categoryFilter.length === 0 || $(this).parent().hasClass('s_' + categoryFilter))
|
||||
) {
|
||||
$(this).parent().css('display', '');
|
||||
} else {
|
||||
$(this).parent().css('display', 'none');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Module export
|
||||
*/
|
||||
export {
|
||||
filterVariables
|
||||
};
|
||||
114
js/src/functions/Server/ServerVariables.js
Normal file
114
js/src/functions/Server/ServerVariables.js
Normal file
@ -0,0 +1,114 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
/**
|
||||
* Module import
|
||||
*/
|
||||
import { PMA_Messages as messages } from '../../variables/export_variables';
|
||||
import {
|
||||
PMA_ajaxShowMessage,
|
||||
PMA_ajaxRemoveMessage
|
||||
} from '../../utils/show_ajax_messages';
|
||||
|
||||
/**
|
||||
* Allows the user to edit a server variable
|
||||
*
|
||||
* @param {Element} link Edit button element
|
||||
*
|
||||
* @param {Element} $saveLink Save button element
|
||||
*
|
||||
* @param {Element} $cancelLink Cancel button element
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
function editVariable (link, $saveLink, $cancelLink) {
|
||||
var $link = $(link);
|
||||
var $cell = $link.parent();
|
||||
var $valueCell = $link.parents('.var-row').find('.var-value');
|
||||
var varName = $link.data('variable');
|
||||
var $mySaveLink = $saveLink.clone().css('display', 'inline-block');
|
||||
var $myCancelLink = $cancelLink.clone().css('display', 'inline-block');
|
||||
var $msgbox = PMA_ajaxShowMessage();
|
||||
var $myEditLink = $cell.find('a.editLink');
|
||||
|
||||
$cell.addClass('edit'); // variable is being edited
|
||||
$myEditLink.remove(); // remove edit link
|
||||
|
||||
$mySaveLink.on('click', function () {
|
||||
var $msgbox = PMA_ajaxShowMessage(messages.strProcessingRequest);
|
||||
$.post($(this).attr('href'), {
|
||||
ajax_request: true,
|
||||
type: 'setval',
|
||||
varName: varName,
|
||||
varValue: $valueCell.find('input').val()
|
||||
}, function (data) {
|
||||
if (data.success) {
|
||||
$valueCell
|
||||
.html(data.variable)
|
||||
.data('content', data.variable);
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
} else {
|
||||
if (data.error === '') {
|
||||
PMA_ajaxShowMessage(messages.strRequestFailed, false);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
$valueCell.html($valueCell.data('content'));
|
||||
}
|
||||
$cell.removeClass('edit').html($myEditLink);
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$myCancelLink.on('click', function () {
|
||||
$valueCell.html($valueCell.data('content'));
|
||||
$cell.removeClass('edit').html($myEditLink);
|
||||
return false;
|
||||
});
|
||||
|
||||
$.get($mySaveLink.attr('href'), {
|
||||
ajax_request: true,
|
||||
type: 'getval',
|
||||
varName: varName
|
||||
}, function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
var $links = $('<div />')
|
||||
.append($myCancelLink)
|
||||
.append(' ')
|
||||
.append($mySaveLink);
|
||||
var $editor = $('<div />', { 'class': 'serverVariableEditor' })
|
||||
.append(
|
||||
$('<div/>').append(
|
||||
$('<input />', { type: 'text' }).val(data.message)
|
||||
)
|
||||
);
|
||||
// Save and replace content
|
||||
$cell
|
||||
.html($links)
|
||||
.children()
|
||||
.css('display', 'flex');
|
||||
$valueCell
|
||||
.data('content', $valueCell.html())
|
||||
.html($editor)
|
||||
.find('input')
|
||||
.focus()
|
||||
.on('keydown', function (event) { // Keyboard shortcuts
|
||||
if (event.keyCode === 13) { // Enter key
|
||||
$mySaveLink.trigger('click');
|
||||
} else if (event.keyCode === 27) { // Escape key
|
||||
$myCancelLink.trigger('click');
|
||||
}
|
||||
});
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
} else {
|
||||
$cell.removeClass('edit').html($myEditLink);
|
||||
PMA_ajaxShowMessage(data.error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Module export
|
||||
*/
|
||||
export {
|
||||
editVariable
|
||||
};
|
||||
@ -1,3 +1,6 @@
|
||||
import { PMA_ajaxShowMessage } from '../utils/show_ajax_messages';
|
||||
import { PMA_Messages as messages } from '../variables/export_variables';
|
||||
import CommonParams from '../variables/common_params';
|
||||
/**
|
||||
* Functions used in the export tab
|
||||
*
|
||||
@ -5,7 +8,7 @@
|
||||
/**
|
||||
* Disables the "Dump some row(s)" sub-options
|
||||
*/
|
||||
export function disable_dump_some_rows_sub_options () {
|
||||
export function disableDumpSomeRowsSubOptions () {
|
||||
$('label[for=\'limit_to\']').fadeTo('fast', 0.4);
|
||||
$('label[for=\'limit_from\']').fadeTo('fast', 0.4);
|
||||
$('input[type=\'text\'][name=\'limit_to\']').prop('disabled', 'disabled');
|
||||
@ -15,7 +18,7 @@ export function disable_dump_some_rows_sub_options () {
|
||||
/**
|
||||
* Enables the "Dump some row(s)" sub-options
|
||||
*/
|
||||
export function enable_dump_some_rows_sub_options () {
|
||||
export function enableDumpSomeRowsSubOptions () {
|
||||
$('label[for=\'limit_to\']').fadeTo('fast', 1);
|
||||
$('label[for=\'limit_from\']').fadeTo('fast', 1);
|
||||
$('input[type=\'text\'][name=\'limit_to\']').prop('disabled', '');
|
||||
@ -71,9 +74,9 @@ export function createTemplate (name) {
|
||||
|
||||
var params = {
|
||||
ajax_request : true,
|
||||
server : PMA_commonParams.get('server'),
|
||||
db : PMA_commonParams.get('db'),
|
||||
table : PMA_commonParams.get('table'),
|
||||
server : CommonParams.get('server'),
|
||||
db : CommonParams.get('db'),
|
||||
table : CommonParams.get('table'),
|
||||
exportType : $('input[name="export_type"]').val(),
|
||||
templateAction : 'create',
|
||||
templateName : name,
|
||||
@ -90,7 +93,7 @@ export function createTemplate (name) {
|
||||
$(this).prop('selected', true);
|
||||
}
|
||||
});
|
||||
PMA_ajaxShowMessage(PMA_messages.strTemplateCreated);
|
||||
PMA_ajaxShowMessage(messages.strTemplateCreated);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(response.error, false);
|
||||
}
|
||||
@ -105,9 +108,9 @@ export function createTemplate (name) {
|
||||
export function loadTemplate (id) {
|
||||
var params = {
|
||||
ajax_request : true,
|
||||
server : PMA_commonParams.get('server'),
|
||||
db : PMA_commonParams.get('db'),
|
||||
table : PMA_commonParams.get('table'),
|
||||
server : CommonParams.get('server'),
|
||||
db : CommonParams.get('db'),
|
||||
table : CommonParams.get('table'),
|
||||
exportType : $('input[name="export_type"]').val(),
|
||||
templateAction : 'load',
|
||||
templateId : id,
|
||||
@ -137,7 +140,7 @@ export function loadTemplate (id) {
|
||||
}
|
||||
});
|
||||
$('input[name="template_id"]').val(id);
|
||||
PMA_ajaxShowMessage(PMA_messages.strTemplateLoaded);
|
||||
PMA_ajaxShowMessage(messages.strTemplateLoaded);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(response.error, false);
|
||||
}
|
||||
@ -154,9 +157,9 @@ export function updateTemplate (id) {
|
||||
|
||||
var params = {
|
||||
ajax_request : true,
|
||||
server : PMA_commonParams.get('server'),
|
||||
db : PMA_commonParams.get('db'),
|
||||
table : PMA_commonParams.get('table'),
|
||||
server : CommonParams.get('server'),
|
||||
db : CommonParams.get('db'),
|
||||
table : CommonParams.get('table'),
|
||||
exportType : $('input[name="export_type"]').val(),
|
||||
templateAction : 'update',
|
||||
templateId : id,
|
||||
@ -166,7 +169,7 @@ export function updateTemplate (id) {
|
||||
PMA_ajaxShowMessage();
|
||||
$.post('tbl_export.php', params, function (response) {
|
||||
if (response.success === true) {
|
||||
PMA_ajaxShowMessage(PMA_messages.strTemplateUpdated);
|
||||
PMA_ajaxShowMessage(messages.strTemplateUpdated);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(response.error, false);
|
||||
}
|
||||
@ -181,9 +184,9 @@ export function updateTemplate (id) {
|
||||
export function deleteTemplate (id) {
|
||||
var params = {
|
||||
ajax_request : true,
|
||||
server : PMA_commonParams.get('server'),
|
||||
db : PMA_commonParams.get('db'),
|
||||
table : PMA_commonParams.get('table'),
|
||||
server : CommonParams.get('server'),
|
||||
db : CommonParams.get('db'),
|
||||
table : CommonParams.get('table'),
|
||||
exportType : $('input[name="export_type"]').val(),
|
||||
templateAction : 'delete',
|
||||
templateId : id,
|
||||
@ -193,22 +196,22 @@ export function deleteTemplate (id) {
|
||||
$.post('tbl_export.php', params, function (response) {
|
||||
if (response.success === true) {
|
||||
$('#template').find('option[value="' + id + '"]').remove();
|
||||
PMA_ajaxShowMessage(PMA_messages.strTemplateDeleted);
|
||||
PMA_ajaxShowMessage(messages.strTemplateDeleted);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(response.error, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function setup_table_structure_or_data () {
|
||||
export function setupTableStructureOrData () {
|
||||
if ($('input[name=\'export_type\']').val() !== 'database') {
|
||||
return;
|
||||
}
|
||||
var pluginName = $('#plugins').find('option:selected').val();
|
||||
var formElemName = pluginName + '_structure_or_data';
|
||||
var force_structure_or_data = !($('input[name=\'' + formElemName + '_default\']').length);
|
||||
var forceStructureOrData = !($('input[name=\'' + formElemName + '_default\']').length);
|
||||
|
||||
if (force_structure_or_data === true) {
|
||||
if (forceStructureOrData === true) {
|
||||
$('input[name="structure_or_data_forced"]').val(1);
|
||||
$('.export_structure input[type="checkbox"], .export_data input[type="checkbox"]')
|
||||
.prop('disabled', true);
|
||||
@ -219,16 +222,16 @@ export function setup_table_structure_or_data () {
|
||||
.prop('disabled', false);
|
||||
$('.export_structure, .export_data').fadeTo('fast', 1);
|
||||
|
||||
var structure_or_data = $('input[name="' + formElemName + '_default"]').val();
|
||||
var structureOrData = $('input[name="' + formElemName + '_default"]').val();
|
||||
|
||||
if (structure_or_data === 'structure') {
|
||||
if (structureOrData === 'structure') {
|
||||
$('.export_data input[type="checkbox"]')
|
||||
.prop('checked', false);
|
||||
} else if (structure_or_data === 'data') {
|
||||
} else if (structureOrData === 'data') {
|
||||
$('.export_structure input[type="checkbox"]')
|
||||
.prop('checked', false);
|
||||
}
|
||||
if (structure_or_data === 'structure' || structure_or_data === 'structure_and_data') {
|
||||
if (structureOrData === 'structure' || structureOrData === 'structure_and_data') {
|
||||
if (!$('.export_structure input[type="checkbox"]:checked').length) {
|
||||
$('input[name="table_select[]"]:checked')
|
||||
.closest('tr')
|
||||
@ -236,7 +239,7 @@ export function setup_table_structure_or_data () {
|
||||
.prop('checked', true);
|
||||
}
|
||||
}
|
||||
if (structure_or_data === 'data' || structure_or_data === 'structure_and_data') {
|
||||
if (structureOrData === 'data' || structureOrData === 'structure_and_data') {
|
||||
if (!$('.export_data input[type="checkbox"]:checked').length) {
|
||||
$('input[name="table_select[]"]:checked')
|
||||
.closest('tr')
|
||||
@ -245,9 +248,9 @@ export function setup_table_structure_or_data () {
|
||||
}
|
||||
}
|
||||
|
||||
check_selected_tables();
|
||||
check_table_select_all();
|
||||
check_table_select_struture_or_data();
|
||||
checkSelectedTables();
|
||||
checkTableSelectAll();
|
||||
checkTableSelectStrutureOrData();
|
||||
}
|
||||
}
|
||||
|
||||
@ -255,7 +258,7 @@ export function setup_table_structure_or_data () {
|
||||
* Toggles the hiding and showing of plugin structure-specific and data-specific
|
||||
* options
|
||||
*/
|
||||
export function toggle_structure_data_opts () {
|
||||
export function toggleStructureDataOpts () {
|
||||
var pluginName = $('select#plugins').val();
|
||||
var radioFormName = pluginName + '_structure_or_data';
|
||||
var dataDiv = '#' + pluginName + '_data';
|
||||
@ -277,7 +280,7 @@ export function toggle_structure_data_opts () {
|
||||
/**
|
||||
* Toggles the disabling of the "save to file" options
|
||||
*/
|
||||
export function toggle_save_to_file () {
|
||||
export function toggleSaveToFile () {
|
||||
var $ulSaveAsfile = $('#ul_save_asfile');
|
||||
if (!$('#radio_dump_asfile').prop('checked')) {
|
||||
$ulSaveAsfile.find('> li').fadeTo('fast', 0.4);
|
||||
@ -293,7 +296,7 @@ export function toggle_save_to_file () {
|
||||
/**
|
||||
* For SQL plugin, toggles the disabling of the "display comments" options
|
||||
*/
|
||||
export function toggle_sql_include_comments () {
|
||||
export function toggleSqlIncludeComments () {
|
||||
$('#checkbox_sql_include_comments').on('change', function () {
|
||||
var $ulIncludeComments = $('#ul_include_comments');
|
||||
if (!$('#checkbox_sql_include_comments').prop('checked')) {
|
||||
@ -311,116 +314,116 @@ export function toggle_sql_include_comments () {
|
||||
});
|
||||
}
|
||||
|
||||
export function check_table_select_all () {
|
||||
export function checkTableSelectAll () {
|
||||
var total = $('input[name="table_select[]"]').length;
|
||||
var str_checked = $('input[name="table_structure[]"]:checked').length;
|
||||
var data_checked = $('input[name="table_data[]"]:checked').length;
|
||||
var str_all = $('#table_structure_all');
|
||||
var data_all = $('#table_data_all');
|
||||
var strChecked = $('input[name="table_structure[]"]:checked').length;
|
||||
var dataChecked = $('input[name="table_data[]"]:checked').length;
|
||||
var strAll = $('#table_structure_all');
|
||||
var dataAll = $('#table_data_all');
|
||||
|
||||
if (str_checked === total) {
|
||||
str_all
|
||||
if (strChecked === total) {
|
||||
strAll
|
||||
.prop('indeterminate', false)
|
||||
.prop('checked', true);
|
||||
} else if (str_checked === 0) {
|
||||
str_all
|
||||
} else if (strChecked === 0) {
|
||||
strAll
|
||||
.prop('indeterminate', false)
|
||||
.prop('checked', false);
|
||||
} else {
|
||||
str_all
|
||||
strAll
|
||||
.prop('indeterminate', true)
|
||||
.prop('checked', false);
|
||||
}
|
||||
|
||||
if (data_checked === total) {
|
||||
data_all
|
||||
if (dataChecked === total) {
|
||||
dataAll
|
||||
.prop('indeterminate', false)
|
||||
.prop('checked', true);
|
||||
} else if (data_checked === 0) {
|
||||
data_all
|
||||
} else if (dataChecked === 0) {
|
||||
dataAll
|
||||
.prop('indeterminate', false)
|
||||
.prop('checked', false);
|
||||
} else {
|
||||
data_all
|
||||
dataAll
|
||||
.prop('indeterminate', true)
|
||||
.prop('checked', false);
|
||||
}
|
||||
}
|
||||
|
||||
export function check_table_select_struture_or_data () {
|
||||
var str_checked = $('input[name="table_structure[]"]:checked').length;
|
||||
var data_checked = $('input[name="table_data[]"]:checked').length;
|
||||
var auto_increment = $('#checkbox_sql_auto_increment');
|
||||
export function checkTableSelectStrutureOrData () {
|
||||
var strChecked = $('input[name="table_structure[]"]:checked').length;
|
||||
var dataChecked = $('input[name="table_data[]"]:checked').length;
|
||||
var autoIncrement = $('#checkbox_sql_auto_increment');
|
||||
|
||||
var pluginName = $('select#plugins').val();
|
||||
var dataDiv = '#' + pluginName + '_data';
|
||||
var structureDiv = '#' + pluginName + '_structure';
|
||||
|
||||
if (str_checked === 0) {
|
||||
if (strChecked === 0) {
|
||||
$(structureDiv).slideUp('slow');
|
||||
} else {
|
||||
$(structureDiv).slideDown('slow');
|
||||
}
|
||||
|
||||
if (data_checked === 0) {
|
||||
if (dataChecked === 0) {
|
||||
$(dataDiv).slideUp('slow');
|
||||
auto_increment.prop('disabled', true).parent().fadeTo('fast', 0.4);
|
||||
autoIncrement.prop('disabled', true).parent().fadeTo('fast', 0.4);
|
||||
} else {
|
||||
$(dataDiv).slideDown('slow');
|
||||
auto_increment.prop('disabled', false).parent().fadeTo('fast', 1);
|
||||
autoIncrement.prop('disabled', false).parent().fadeTo('fast', 1);
|
||||
}
|
||||
}
|
||||
|
||||
export function toggle_table_select_all_str () {
|
||||
var str_all = $('#table_structure_all').is(':checked');
|
||||
if (str_all) {
|
||||
export function toggleTableSelectAllStr () {
|
||||
var strAll = $('#table_structure_all').is(':checked');
|
||||
if (strAll) {
|
||||
$('input[name="table_structure[]"]').prop('checked', true);
|
||||
} else {
|
||||
$('input[name="table_structure[]"]').prop('checked', false);
|
||||
}
|
||||
}
|
||||
|
||||
export function toggle_table_select_all_data () {
|
||||
var data_all = $('#table_data_all').is(':checked');
|
||||
if (data_all) {
|
||||
export function toggleTableSelectAllData () {
|
||||
var dataAll = $('#table_data_all').is(':checked');
|
||||
if (dataAll) {
|
||||
$('input[name="table_data[]"]').prop('checked', true);
|
||||
} else {
|
||||
$('input[name="table_data[]"]').prop('checked', false);
|
||||
}
|
||||
}
|
||||
|
||||
export function check_selected_tables (argument) {
|
||||
export function checkSelectedTables () {
|
||||
$('.export_table_select tbody tr').each(function () {
|
||||
check_table_selected(this);
|
||||
checkTableSelected(this);
|
||||
});
|
||||
}
|
||||
|
||||
export function check_table_selected (row) {
|
||||
export function checkTableSelected (row) {
|
||||
var $row = $(row);
|
||||
var table_select = $row.find('input[name="table_select[]"]');
|
||||
var str_check = $row.find('input[name="table_structure[]"]');
|
||||
var data_check = $row.find('input[name="table_data[]"]');
|
||||
var tableSelect = $row.find('input[name="table_select[]"]');
|
||||
var strCheck = $row.find('input[name="table_structure[]"]');
|
||||
var dataCheck = $row.find('input[name="table_data[]"]');
|
||||
|
||||
var data = data_check.is(':checked:not(:disabled)');
|
||||
var structure = str_check.is(':checked:not(:disabled)');
|
||||
var data = dataCheck.is(':checked:not(:disabled)');
|
||||
var structure = strCheck.is(':checked:not(:disabled)');
|
||||
|
||||
if (data && structure) {
|
||||
table_select.prop({ checked: true, indeterminate: false });
|
||||
tableSelect.prop({ checked: true, indeterminate: false });
|
||||
$row.addClass('marked');
|
||||
} else if (data || structure) {
|
||||
table_select.prop({ checked: true, indeterminate: true });
|
||||
tableSelect.prop({ checked: true, indeterminate: true });
|
||||
$row.removeClass('marked');
|
||||
} else {
|
||||
table_select.prop({ checked: false, indeterminate: false });
|
||||
tableSelect.prop({ checked: false, indeterminate: false });
|
||||
$row.removeClass('marked');
|
||||
}
|
||||
}
|
||||
|
||||
export function toggle_table_select (row) {
|
||||
export function toggleTableSelect (row) {
|
||||
var $row = $(row);
|
||||
var table_selected = $row.find('input[name="table_select[]"]').is(':checked');
|
||||
var tableSelected = $row.find('input[name="table_select[]"]').is(':checked');
|
||||
|
||||
if (table_selected) {
|
||||
if (tableSelected) {
|
||||
$row.find('input[type="checkbox"]:not(:disabled)').prop('checked', true);
|
||||
$row.addClass('marked');
|
||||
} else {
|
||||
@ -442,7 +445,7 @@ export function handleAddProcCheckbox () {
|
||||
/**
|
||||
* Toggles display of options when quick and custom export are selected
|
||||
*/
|
||||
export function toggle_quick_or_custom () {
|
||||
export function toggleQuickOrCustom () {
|
||||
if ($('input[name=\'quick_or_custom\']').length === 0 // custom_no_form option
|
||||
|| $('#radio_custom_export').prop('checked') // custom
|
||||
) {
|
||||
@ -451,8 +454,8 @@ export function toggle_quick_or_custom () {
|
||||
$('#output').show();
|
||||
$('#format_specific_opts').show();
|
||||
$('#output_quick_export').hide();
|
||||
var selected_plugin_name = $('#plugins').find('option:selected').val();
|
||||
$('#' + selected_plugin_name + '_options').show();
|
||||
var selectedPluginName = $('#plugins').find('option:selected').val();
|
||||
$('#' + selectedPluginName + '_options').show();
|
||||
} else { // quick
|
||||
$('#databases_and_tables').hide();
|
||||
$('#rows').hide();
|
||||
@ -462,12 +465,12 @@ export function toggle_quick_or_custom () {
|
||||
}
|
||||
}
|
||||
var time_out;
|
||||
export function check_time_out (time_limit) {
|
||||
if (typeof time_limit === 'undefined' || time_limit === 0) {
|
||||
export function check_time_out (timeLimit) {
|
||||
if (typeof timeLimit === 'undefined' || timeLimit === 0) {
|
||||
return true;
|
||||
}
|
||||
// margin of one second to avoid race condition to set/access session variable
|
||||
time_limit = time_limit + 1;
|
||||
timeLimit = timeLimit + 1;
|
||||
var href = 'export.php';
|
||||
var params = {
|
||||
'ajax_request' : true,
|
||||
@ -479,13 +482,13 @@ export function check_time_out (time_limit) {
|
||||
if (data.message === 'timeout') {
|
||||
PMA_ajaxShowMessage(
|
||||
'<div class="error">' +
|
||||
PMA_messages.strTimeOutError +
|
||||
messages.strTimeOutError +
|
||||
'</div>',
|
||||
false
|
||||
);
|
||||
}
|
||||
});
|
||||
}, time_limit * 1000);
|
||||
}, timeLimit * 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -534,7 +537,7 @@ export function aliasSelectHandler (event) {
|
||||
export function createAliasModal (event) {
|
||||
event.preventDefault();
|
||||
var dlgButtons = {};
|
||||
dlgButtons[PMA_messages.strSaveAndClose] = function () {
|
||||
dlgButtons[messages.strSaveAndClose] = function () {
|
||||
$(this).dialog('close');
|
||||
$('#alias_modal').parent().appendTo($('form[name="dump"]'));
|
||||
};
|
||||
@ -546,7 +549,7 @@ export function createAliasModal (event) {
|
||||
buttons: dlgButtons,
|
||||
create: function () {
|
||||
$(this).css('maxHeight', $(window).height() - 150);
|
||||
var db = PMA_commonParams.get('db');
|
||||
var db = CommonParams.get('db');
|
||||
if (db) {
|
||||
var option = $('<option></option>');
|
||||
option.text(db);
|
||||
@ -555,7 +558,7 @@ export function createAliasModal (event) {
|
||||
} else {
|
||||
var params = {
|
||||
ajax_request : true,
|
||||
server : PMA_commonParams.get('server'),
|
||||
server : CommonParams.get('server'),
|
||||
type: 'list-databases'
|
||||
};
|
||||
$.post('ajax.php', params, function (response) {
|
||||
|
||||
@ -1,20 +1,30 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
/**
|
||||
* Module import
|
||||
*/
|
||||
import { escapeHtml } from '../utils/Sanitise';
|
||||
|
||||
/**
|
||||
* Returns an HTML IMG tag for a particular image from a theme,
|
||||
* which may be an actual file or an icon from a sprite
|
||||
*
|
||||
* @param string image The name of the file to get
|
||||
* @param string alternate Used to set 'alt' and 'title' attributes of the image
|
||||
* @param object attributes An associative array of other attributes
|
||||
* @access public
|
||||
*
|
||||
* @return Object The requested image, this object has two methods:
|
||||
* @param {string} image The name of the file to get
|
||||
*
|
||||
* @param {string} alternate Used to set 'alt' and 'title' attributes of the image
|
||||
*
|
||||
* @param {object} attributes An associative array of other attributes
|
||||
*
|
||||
* @return {Object} The requested image, this object has two methods:
|
||||
* .toString() - Returns the IMG tag for the requested image
|
||||
* .attr(name) - Returns a particular attribute of the IMG
|
||||
* tag given it's name
|
||||
* .attr(name, value) - Sets a particular attribute of the IMG
|
||||
* tag to the given value
|
||||
*/
|
||||
export function PMA_getImage (image, alternate, attributes) {
|
||||
function PMA_getImage (image, alternate, attributes) {
|
||||
// custom image object, it will eventually be returned by this functions
|
||||
var retval = {
|
||||
data: {
|
||||
@ -76,3 +86,10 @@ export function PMA_getImage (image, alternate, attributes) {
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Module export
|
||||
*/
|
||||
export {
|
||||
PMA_getImage
|
||||
};
|
||||
|
||||
@ -1,20 +1,30 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
/**
|
||||
* Module import
|
||||
*/
|
||||
import { PMA_Messages as messages } from '../variables/export_variables';
|
||||
|
||||
/**
|
||||
* Functions used in the import tab
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Toggles the hiding and showing of each plugin's options
|
||||
* according to the currently selected plugin from the dropdown list
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
export function changePluginOpts () {
|
||||
function changePluginOpts () {
|
||||
$('#format_specific_opts').find('div.format_specific_options').each(function () {
|
||||
$(this).hide();
|
||||
});
|
||||
var selected_plugin_name = $('#plugins').find('option:selected').val();
|
||||
$('#' + selected_plugin_name + '_options').fadeIn('slow');
|
||||
if (selected_plugin_name === 'csv') {
|
||||
$('#import_notification').text(PMA_messages.strImportCSV);
|
||||
var selectedPluginName = $('#plugins').find('option:selected').val();
|
||||
$('#' + selectedPluginName + '_options').fadeIn('slow');
|
||||
if (selectedPluginName === 'csv') {
|
||||
$('#import_notification').text(messages.strImportCSV);
|
||||
} else {
|
||||
$('#import_notification').text('');
|
||||
}
|
||||
@ -23,19 +33,33 @@ export function changePluginOpts () {
|
||||
/**
|
||||
* Toggles the hiding and showing of each plugin's options and sets the selected value
|
||||
* in the plugin dropdown list according to the format of the selected file
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param {string} fname Name of the file
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
export function matchFile (fname) {
|
||||
var fname_array = fname.toLowerCase().split('.');
|
||||
var len = fname_array.length;
|
||||
function matchFile (fname) {
|
||||
var fnameArray = fname.toLowerCase().split('.');
|
||||
var len = fnameArray.length;
|
||||
if (len !== 0) {
|
||||
var extension = fname_array[len - 1];
|
||||
var extension = fnameArray[len - 1];
|
||||
if (extension === 'gz' || extension === 'bz2' || extension === 'zip') {
|
||||
len--;
|
||||
}
|
||||
// Only toggle if the format of the file can be imported
|
||||
if ($('select[name=\'format\'] option').filterByValue(fname_array[len - 1]).length === 1) {
|
||||
$('select[name=\'format\'] option').filterByValue(fname_array[len - 1]).prop('selected', true);
|
||||
if ($('select[name=\'format\'] option').filterByValue(fnameArray[len - 1]).length === 1) {
|
||||
$('select[name=\'format\'] option').filterByValue(fnameArray[len - 1]).prop('selected', true);
|
||||
changePluginOpts();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Module export
|
||||
*/
|
||||
export {
|
||||
changePluginOpts,
|
||||
matchFile
|
||||
};
|
||||
|
||||
@ -3,9 +3,12 @@
|
||||
*
|
||||
* @returns void
|
||||
*/
|
||||
import { PMA_commonParams } from '../variables/common_params';
|
||||
import CommonParams from '../variables/common_params';
|
||||
import { setupRestoreField, setupConfigTabs, setupValidation } from './config';
|
||||
|
||||
import { PMA_ajaxShowMessage, PMA_ajaxRemoveMessage } from '../utils/show_ajax_messages';
|
||||
import { PMA_Messages as PMA_messages } from '../variables/export_variables';
|
||||
import { isStorageSupported } from './config';
|
||||
import { configSet, configGet } from '../utils/config';
|
||||
/**
|
||||
* Traverse the navigation tree backwards to generate all the actual
|
||||
* and virtual paths, as well as the positions in the pagination at
|
||||
@ -69,8 +72,8 @@ export function navTreeStateUpdate () {
|
||||
// content to be stored exceeds storage capacity
|
||||
try {
|
||||
storage.setItem('navTreePaths', JSON.stringify(traverseNavigationForPaths()));
|
||||
storage.setItem('server', PMA_commonParams.get('server'));
|
||||
storage.setItem('token', PMA_commonParams.get('token'));
|
||||
storage.setItem('server', CommonParams.get('server'));
|
||||
storage.setItem('token', CommonParams.get('token'));
|
||||
} catch (error) {
|
||||
// storage capacity exceeded & old navigation tree
|
||||
// state is no more valid, so remove it
|
||||
@ -88,18 +91,17 @@ export function PMA_selectCurrentDb () {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (PMA_commonParams.get('db')) { // db selected
|
||||
if (CommonParams.get('db')) { // db selected
|
||||
$naviDbSelect.show();
|
||||
}
|
||||
|
||||
$naviDbSelect.val(PMA_commonParams.get('db'));
|
||||
return $naviDbSelect.val() === PMA_commonParams.get('db');
|
||||
$naviDbSelect.val(CommonParams.get('db'));
|
||||
return $naviDbSelect.val() === CommonParams.get('db');
|
||||
}
|
||||
|
||||
export function PMA_showCurrentNavigation () {
|
||||
var db = PMA_commonParams.get('db');
|
||||
var table = PMA_commonParams.get('table');
|
||||
|
||||
var db = CommonParams.get('db');
|
||||
var table = CommonParams.get('table');
|
||||
$('#pma_navigation_tree').find('li.selected').removeClass('selected');
|
||||
if (db) {
|
||||
var $dbItem = findLoadedItem($('#pma_navigation_tree').find('> div'), db, 'database', !table);
|
||||
@ -109,7 +111,7 @@ export function PMA_showCurrentNavigation () {
|
||||
}
|
||||
// If loaded database in navigation is not same as current one
|
||||
if ($('#pma_navigation_tree_content').find('span.loaded_db:first').text() !== $('#navi_db_select').val()) {
|
||||
loadChildNodes(false, $('option:selected', $('#navi_db_select')), function (data) {
|
||||
loadChildNodes(false, $('option:selected', $('#navi_db_select')), function () {
|
||||
handleTableOrDb(table, $('#pma_navigation_tree_content'));
|
||||
var $children = $('#pma_navigation_tree_content').children('div.list_container');
|
||||
$children.promise().done(navTreeStateUpdate);
|
||||
@ -325,7 +327,7 @@ export function loadChildNodes (isNode, $expandElem, callback) {
|
||||
if (window.location.href.indexOf('?') === -1) {
|
||||
window.location.href += '?session_expired=1';
|
||||
} else {
|
||||
window.location.href += PMA_commonParams.get('arg_separator') + 'session_expired=1';
|
||||
window.location.href += CommonParams.get('arg_separator') + 'session_expired=1';
|
||||
}
|
||||
window.location.reload();
|
||||
} else {
|
||||
@ -416,7 +418,7 @@ export function PMA_ensureNaviSettings (selflink) {
|
||||
if (!$('#pma_navigation_settings').length) {
|
||||
var params = {
|
||||
getNaviSettings: true,
|
||||
server: PMA_commonParams.get('server'),
|
||||
server: CommonParams.get('server'),
|
||||
};
|
||||
var url = $('#pma_navigation').find('a.navigation_url').attr('href');
|
||||
$.post(url, params, function (data) {
|
||||
@ -691,7 +693,7 @@ export var PMA_fastFilter = {
|
||||
* at the top of this file
|
||||
*/
|
||||
events: {
|
||||
focus: function (event) {
|
||||
focus: function () {
|
||||
var $obj = $(this).closest('div.list_container');
|
||||
if (! $obj.data('fastFilter')) {
|
||||
$obj.data(
|
||||
@ -705,7 +707,7 @@ export var PMA_fastFilter = {
|
||||
$(this).select();
|
||||
}
|
||||
},
|
||||
blur: function (event) {
|
||||
blur: function () {
|
||||
if ($(this).val() === '') {
|
||||
$(this).val(this.defaultValue);
|
||||
}
|
||||
@ -853,7 +855,7 @@ PMA_fastFilter.filter.prototype.request = function () {
|
||||
if (self.$this.find('> ul > li > form.fast_filter:first input[name=searchClause]').length === 0) {
|
||||
var $input = $('#pma_navigation_tree').find('li.fast_filter.db_fast_filter input.searchClause');
|
||||
if ($input.length && $input.val() !== $input[0].defaultValue) {
|
||||
params += PMA_commonParams.get('arg_separator') + 'searchClause=' + encodeURIComponent($input.val());
|
||||
params += CommonParams.get('arg_separator') + 'searchClause=' + encodeURIComponent($input.val());
|
||||
}
|
||||
}
|
||||
self.xhr = $.ajax({
|
||||
@ -1085,7 +1087,7 @@ export var ResizeHandler = function () {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
this.treeResize = function (event) {
|
||||
this.treeResize = function () {
|
||||
var $nav = $('#pma_navigation');
|
||||
var $nav_tree = $('#pma_navigation_tree');
|
||||
var $nav_header = $('#pma_navigation_header');
|
||||
@ -1136,12 +1138,12 @@ export function PMA_reloadNavigation (callback, paths) {
|
||||
var params = {
|
||||
reload: true,
|
||||
no_debug: true,
|
||||
server: PMA_commonParams.get('server'),
|
||||
server: CommonParams.get('server'),
|
||||
};
|
||||
paths = paths || traverseNavigationForPaths();
|
||||
$.extend(params, paths);
|
||||
if ($('#navi_db_select').length) {
|
||||
params.db = PMA_commonParams.get('db');
|
||||
params.db = CommonParams.get('db');
|
||||
requestNaviReload(params);
|
||||
return;
|
||||
}
|
||||
@ -1188,18 +1190,18 @@ export function PMA_navigationTreePagination ($this) {
|
||||
params = 'ajax_request=true';
|
||||
} else { // tagName === 'SELECT'
|
||||
url = 'navigation.php';
|
||||
params = $this.closest('form').serialize() + PMA_commonParams.get('arg_separator') + 'ajax_request=true';
|
||||
params = $this.closest('form').serialize() + CommonParams.get('arg_separator') + 'ajax_request=true';
|
||||
}
|
||||
var searchClause = PMA_fastFilter.getSearchClause();
|
||||
if (searchClause) {
|
||||
params += PMA_commonParams.get('arg_separator') + 'searchClause=' + encodeURIComponent(searchClause);
|
||||
params += CommonParams.get('arg_separator') + 'searchClause=' + encodeURIComponent(searchClause);
|
||||
}
|
||||
if (isDbSelector) {
|
||||
params += PMA_commonParams.get('arg_separator') + 'full=true';
|
||||
params += CommonParams.get('arg_separator') + 'full=true';
|
||||
} else {
|
||||
var searchClause2 = PMA_fastFilter.getSearchClause2($this);
|
||||
if (searchClause2) {
|
||||
params += PMA_commonParams.get('arg_separator') + 'searchClause2=' + encodeURIComponent(searchClause2);
|
||||
params += CommonParams.get('arg_separator') + 'searchClause2=' + encodeURIComponent(searchClause2);
|
||||
}
|
||||
}
|
||||
$.post(url, params, function (data) {
|
||||
|
||||
67
js/src/functions/page_settings.js
Normal file
67
js/src/functions/page_settings.js
Normal file
@ -0,0 +1,67 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
/**
|
||||
* Module import
|
||||
*/
|
||||
import { PMA_Messages as messages } from '../variables/export_variables';
|
||||
|
||||
/**
|
||||
* @param {Element} selector jQuery element for which setting need to be show
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
function showSettings (selector) {
|
||||
var buttons = {};
|
||||
buttons[messages.strApply] = function () {
|
||||
$('.config-form').submit();
|
||||
};
|
||||
|
||||
buttons[messages.strCancel] = function () {
|
||||
$(this).dialog('close');
|
||||
};
|
||||
|
||||
// Keeping a clone to restore in case the user cancels the operation
|
||||
var $clone = $(selector + ' .page_settings').clone(true);
|
||||
$(selector)
|
||||
.dialog({
|
||||
title: messages.strPageSettings,
|
||||
width: 700,
|
||||
minHeight: 250,
|
||||
modal: true,
|
||||
open: function () {
|
||||
$(this).dialog('option', 'maxHeight', $(window).height() - $(this).offset().top);
|
||||
},
|
||||
close: function () {
|
||||
$(selector + ' .page_settings').replaceWith($clone);
|
||||
},
|
||||
buttons: buttons
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @access public
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
function showPageSettings () {
|
||||
showSettings('#page_settings_modal');
|
||||
}
|
||||
|
||||
/**
|
||||
* @access public
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
function showNaviSettings () {
|
||||
showSettings('#pma_navigation_settings');
|
||||
}
|
||||
|
||||
/**
|
||||
* Module export
|
||||
*/
|
||||
export {
|
||||
showNaviSettings,
|
||||
showPageSettings
|
||||
};
|
||||
@ -1,9 +1,22 @@
|
||||
import { AJAX } from './ajax';
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
/**
|
||||
* Module import
|
||||
*/
|
||||
import './variables/import_variables';
|
||||
import './variables/get_config';
|
||||
import { jQuery as $ } from './utils/JqueryExtended';
|
||||
import { AJAX } from './ajax';
|
||||
import './variables/get_config';
|
||||
import files from './consts/files';
|
||||
import Console from './console';
|
||||
import { PMA_sprintf } from './utils/sprintf';
|
||||
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';
|
||||
|
||||
// console.log(PMA_messages);
|
||||
// console.log(PMA_ajaxShowMessage);
|
||||
|
||||
/**
|
||||
* Page load event handler
|
||||
@ -69,6 +82,34 @@ $(function () {
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ajaxError(function (event, request, settings) {
|
||||
if (AJAX._debug) {
|
||||
console.log('AJAX error: status=' + request.status + ', text=' + request.statusText);
|
||||
}
|
||||
// Don't handle aborted requests
|
||||
if (request.status !== 0 || request.statusText !== 'abort') {
|
||||
var details = '';
|
||||
var state = request.state();
|
||||
|
||||
if (request.status !== 0) {
|
||||
details += '<div>' + escapeHtml(PMA_sprintf(PMA_messages.strErrorCode, request.status)) + '</div>';
|
||||
}
|
||||
details += '<div>' + escapeHtml(PMA_sprintf(PMA_messages.strErrorText, request.statusText + ' (' + state + ')')) + '</div>';
|
||||
if (state === 'rejected' || state === 'timeout') {
|
||||
details += '<div>' + escapeHtml(PMA_messages.strErrorConnection) + '</div>';
|
||||
}
|
||||
PMA_ajaxShowMessage(
|
||||
'<div class="error">' +
|
||||
PMA_messages.strErrorProcessingRequest +
|
||||
details +
|
||||
'</div>',
|
||||
false
|
||||
);
|
||||
AJAX.active = false;
|
||||
AJAX.xhr = null;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Adding common files for every page
|
||||
*/
|
||||
@ -92,6 +133,10 @@ if (typeof files[firstPage] !== 'undefined' && firstPage.toLocaleLowerCase() !==
|
||||
for (let i in files[indexPage]) {
|
||||
AJAX.scriptHandler.add(files[indexPage][i], 1);
|
||||
}
|
||||
} else if (typeof files[indexPage] !== 'undefined' && firstPage.toLocaleLowerCase() === 'index') {
|
||||
for (let i in files[indexPage]) {
|
||||
AJAX.scriptHandler.add(files[indexPage][i]);
|
||||
}
|
||||
}
|
||||
|
||||
$(function () {
|
||||
|
||||
@ -9,7 +9,7 @@ import { expandTreeNode,
|
||||
PMA_reloadNavigation,
|
||||
PMA_navigationTreePagination } from './functions/navigation';
|
||||
import { PMA_Messages as PMA_messages } from './variables/export_variables';
|
||||
import { PMA_commonParams } from './variables/common_params';
|
||||
import CommonParams from './variables/common_params';
|
||||
import { PMA_ajaxShowMessage, PMA_ajaxRemoveMessage, PMA_tooltip } from './utils/show_ajax_messages';
|
||||
import { isStorageSupported } from './functions/config';
|
||||
|
||||
@ -74,7 +74,7 @@ $(function () {
|
||||
|
||||
$(document).on('change', '#navi_db_select', function () {
|
||||
if (! $(this).val()) {
|
||||
PMA_commonParams.set('db', '');
|
||||
CommonParams.set('db', '');
|
||||
PMA_reloadNavigation();
|
||||
}
|
||||
$(this).closest('form').trigger('submit');
|
||||
@ -243,7 +243,7 @@ $(function () {
|
||||
event.preventDefault();
|
||||
var url = $(this).attr('href').substr(
|
||||
$(this).attr('href').indexOf('?') + 1
|
||||
) + PMA_commonParams.get('arg_separator') + 'ajax_request=true';
|
||||
) + CommonParams.get('arg_separator') + 'ajax_request=true';
|
||||
var title = PMA_messages.strAddIndex;
|
||||
indexEditorDialog(url, title);
|
||||
});
|
||||
@ -253,7 +253,7 @@ $(function () {
|
||||
event.preventDefault();
|
||||
var url = $(this).attr('href').substr(
|
||||
$(this).attr('href').indexOf('?') + 1
|
||||
) + PMA_commonParams.get('arg_separator') + 'ajax_request=true';
|
||||
) + CommonParams.get('arg_separator') + 'ajax_request=true';
|
||||
var title = PMA_messages.strEditIndex;
|
||||
indexEditorDialog(url, title);
|
||||
});
|
||||
@ -270,9 +270,9 @@ $(function () {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
data: {
|
||||
server: PMA_commonParams.get('server'),
|
||||
server: CommonParams.get('server'),
|
||||
},
|
||||
url: $(this).attr('href') + PMA_commonParams.get('arg_separator') + 'ajax_request=true',
|
||||
url: $(this).attr('href') + CommonParams.get('arg_separator') + 'ajax_request=true',
|
||||
success: function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
PMA_reloadNavigation();
|
||||
@ -287,7 +287,7 @@ $(function () {
|
||||
$(document).on('click', 'a.showUnhide.ajax', function (event) {
|
||||
event.preventDefault();
|
||||
var $msg = PMA_ajaxShowMessage();
|
||||
$.get($(this).attr('href') + PMA_commonParams.get('arg_separator') + 'ajax_request=1', function (data) {
|
||||
$.get($(this).attr('href') + CommonParams.get('arg_separator') + 'ajax_request=1', function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
PMA_ajaxRemoveMessage($msg);
|
||||
var buttonOptions = {};
|
||||
@ -321,9 +321,9 @@ $(function () {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
data: {
|
||||
server: PMA_commonParams.get('server'),
|
||||
server: CommonParams.get('server'),
|
||||
},
|
||||
url: $(this).attr('href') + PMA_commonParams.get('arg_separator') + 'ajax_request=true',
|
||||
url: $(this).attr('href') + CommonParams.get('arg_separator') + 'ajax_request=true',
|
||||
success: function (data) {
|
||||
PMA_ajaxRemoveMessage($msg);
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
@ -356,7 +356,7 @@ $(function () {
|
||||
favorite_tables: (isStorageSupported('localStorage') && typeof window.localStorage.favorite_tables !== 'undefined')
|
||||
? window.localStorage.favorite_tables
|
||||
: '',
|
||||
server: PMA_commonParams.get('server'),
|
||||
server: CommonParams.get('server'),
|
||||
},
|
||||
success: function (data) {
|
||||
if (data.changes) {
|
||||
@ -389,8 +389,8 @@ $(function () {
|
||||
typeof storage.navTreePaths === 'undefined'
|
||||
) {
|
||||
PMA_reloadNavigation();
|
||||
} else if (PMA_commonParams.get('server') === storage.server &&
|
||||
PMA_commonParams.get('token') === storage.token
|
||||
} else if (CommonParams.get('server').toString() === storage.server.toString() &&
|
||||
CommonParams.get('token').toString() === storage.token.toString()
|
||||
) {
|
||||
// Reload the tree to the state before page refresh
|
||||
PMA_reloadNavigation(navFilterStateRestore, JSON.parse(storage.navTreePaths));
|
||||
|
||||
49
js/src/page_settings.js
Normal file
49
js/src/page_settings.js
Normal file
@ -0,0 +1,49 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
/**
|
||||
* @fileoverview function used for page-related settings
|
||||
* @name Page-related settings
|
||||
*
|
||||
* @requires jQuery
|
||||
* @requires jQueryUI
|
||||
* @requires js/functions.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module import
|
||||
*/
|
||||
import {
|
||||
showNaviSettings,
|
||||
showPageSettings
|
||||
} from './functions/page_settings';
|
||||
|
||||
/**
|
||||
* @package PhpMyAdmin
|
||||
*
|
||||
* Page Settings
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unbind all event handlers before tearing down a page.
|
||||
*/
|
||||
function teardownPageSettings () {
|
||||
$('#page_settings_icon').css('display', 'none');
|
||||
$('#page_settings_icon').off('click');
|
||||
$('#pma_navigation_settings_icon').off('click');
|
||||
}
|
||||
|
||||
/**
|
||||
* Binding event handler on page load.
|
||||
*/
|
||||
function onloadPageSettings () {
|
||||
if ($('#page_settings_modal').length) {
|
||||
$('#page_settings_icon').css('display', 'inline');
|
||||
$('#page_settings_icon').on('click', showPageSettings);
|
||||
}
|
||||
$('#pma_navigation_settings_icon').on('click', showNaviSettings);
|
||||
}
|
||||
|
||||
export {
|
||||
teardownPageSettings,
|
||||
onloadPageSettings
|
||||
};
|
||||
@ -7,6 +7,10 @@
|
||||
* @requires jQueryUI
|
||||
* @required js/functions.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Moduele import
|
||||
*/
|
||||
import { PMA_sprintf } from './utils/sprintf';
|
||||
import './variables/import_variables';
|
||||
import { PMA_ajaxShowMessage } from './utils/show_ajax_messages';
|
||||
@ -14,17 +18,26 @@ import { escapeHtml } from './utils/Sanitise';
|
||||
import { PMA_Messages as PMA_messages } from './variables/export_variables';
|
||||
import { jQuery as $ } from './utils/JqueryExtended';
|
||||
import { AJAX } from './ajax';
|
||||
import { PMA_commonParams } from './variables/common_params';
|
||||
import CommonParams from './variables/common_params';
|
||||
|
||||
/**
|
||||
* @package PhpMyAdmin
|
||||
*
|
||||
* Server Databases
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unbind all event handlers before tearing down a page
|
||||
*/
|
||||
export function teardown1 () {
|
||||
function teardownServerDatabases () {
|
||||
$(document).off('submit', '#dbStatsForm');
|
||||
$(document).off('submit', '#create_database_form.ajax');
|
||||
}
|
||||
|
||||
export function onload1 () {
|
||||
/**
|
||||
* Binding event handlers on page load
|
||||
*/
|
||||
function onloadServerDatabases () {
|
||||
/**
|
||||
* Attach Event Handler for 'Drop Databases'
|
||||
*/
|
||||
@ -46,7 +59,7 @@ export function onload1 () {
|
||||
if (! selected_dbs.length) {
|
||||
PMA_ajaxShowMessage(
|
||||
$('<div class="notice" />').text(
|
||||
PMA_messages.strNoDatabasesSelected
|
||||
messages.strNoDatabasesSelected
|
||||
),
|
||||
2000
|
||||
);
|
||||
@ -55,16 +68,16 @@ export function onload1 () {
|
||||
/**
|
||||
* @var question String containing the question to be asked for confirmation
|
||||
*/
|
||||
var question = PMA_messages.strDropDatabaseStrongWarning + ' ' +
|
||||
PMA_sprintf(PMA_messages.strDoYouReally, selected_dbs.join('<br />'));
|
||||
var question = messages.strDropDatabaseStrongWarning + ' ' +
|
||||
PMA_sprintf(messages.strDoYouReally, selected_dbs.join('<br />'));
|
||||
|
||||
var argsep = PMA_commonParams.get('arg_separator');
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
$(this).PMA_confirm(
|
||||
question,
|
||||
$form.prop('action') + '?' + $(this).serialize() +
|
||||
argsep + 'drop_selected_dbs=1' + argsep + 'is_js_confirmed=1' + argsep + 'ajax_request=true',
|
||||
function (url) {
|
||||
PMA_ajaxShowMessage(PMA_messages.strProcessingRequest, false);
|
||||
PMA_ajaxShowMessage(messages.strProcessingRequest, false);
|
||||
|
||||
var params = getJSConfirmCommonParam(this);
|
||||
|
||||
@ -105,12 +118,12 @@ export function onload1 () {
|
||||
var newDbNameInput = $form.find('input[name=new_db]');
|
||||
if (newDbNameInput.val() === '') {
|
||||
newDbNameInput.focus();
|
||||
alert(PMA_messages.strFormEmpty);
|
||||
alert(messages.strFormEmpty);
|
||||
return;
|
||||
}
|
||||
// end remove
|
||||
|
||||
PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
|
||||
PMA_ajaxShowMessage(messages.strProcessingRequest);
|
||||
PMA_prepareForAjaxRequest($form);
|
||||
|
||||
$.post($form.attr('action'), $form.serialize(), function (data) {
|
||||
@ -125,7 +138,7 @@ export function onload1 () {
|
||||
// make ajax request to load db structure page - taken from ajax.js
|
||||
var dbStruct_url = data.url_query;
|
||||
dbStruct_url = dbStruct_url.replace(/amp;/ig, '');
|
||||
var params = 'ajax_request=true' + PMA_commonParams.get('arg_separator') + 'ajax_page_request=true';
|
||||
var params = 'ajax_request=true' + CommonParams.get('arg_separator') + 'ajax_page_request=true';
|
||||
if (! (history && history.pushState)) {
|
||||
params += PMA_MicroHistory.menus.getRequestParam();
|
||||
}
|
||||
@ -143,9 +156,14 @@ export function onload1 () {
|
||||
}
|
||||
|
||||
var tableRows = $('.server_databases');
|
||||
$.each(tableRows, function (index, item) {
|
||||
$.each(tableRows, function (index) {
|
||||
$(this).click(function () {
|
||||
PMA_commonActions.setDb($(this).attr('data'));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export {
|
||||
teardownServerDatabases,
|
||||
onloadServerDatabases
|
||||
};
|
||||
|
||||
@ -6,17 +6,25 @@
|
||||
* @requires jQuery
|
||||
* @requires jQueryUI
|
||||
* @requires js/functions.js
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module import
|
||||
*/
|
||||
import { PMA_sprintf } from './utils/sprintf';
|
||||
import { checkPasswordStrength, displayPasswordGenerateButton } from './utils/password';
|
||||
// import { AJAX } from './ajax';
|
||||
import { PMA_Messages as PMA_messages } from './variables/export_variables';
|
||||
import { PMA_Messages as messages } from './variables/export_variables';
|
||||
import { PMA_ajaxShowMessage, PMA_ajaxRemoveMessage } from './utils/show_ajax_messages';
|
||||
import { PMA_commonParams } from './variables/common_params';
|
||||
import CommonParams from './variables/common_params';
|
||||
import { jQuery as $ } from './utils/JqueryExtended';
|
||||
import { PMA_getSQLEditor } from './utils/sql';
|
||||
|
||||
/**
|
||||
* @package PhpMyAdmin
|
||||
*
|
||||
* Server Privileges
|
||||
*/
|
||||
|
||||
/**
|
||||
* AJAX scripts for server_privileges page.
|
||||
*
|
||||
@ -33,9 +41,9 @@ import { PMA_getSQLEditor } from './utils/sql';
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unbind all event handlers before tearing down a page
|
||||
* Unbind all event handlers before tearing down a page.
|
||||
*/
|
||||
export function teardown1 () {
|
||||
function teardownServerPrivileges () {
|
||||
$('#fieldset_add_user_login').off('change', 'input[name=\'username\']');
|
||||
$(document).off('click', '#fieldset_delete_user_footer #buttonGo.ajax');
|
||||
$(document).off('click', 'a.edit_user_group_anchor.ajax');
|
||||
@ -49,7 +57,10 @@ export function teardown1 () {
|
||||
$(document).off('change', '#select_authentication_plugin');
|
||||
}
|
||||
|
||||
export function onload1 () {
|
||||
/**
|
||||
* Binding event handlers on page load.
|
||||
*/
|
||||
function onloadServerPrivileges () {
|
||||
/**
|
||||
* Display a warning if there is already a user by the name entered as the username.
|
||||
*/
|
||||
@ -60,7 +71,7 @@ export function onload1 () {
|
||||
var href = $('form[name=\'usersForm\']').attr('action');
|
||||
var params = {
|
||||
'ajax_request' : true,
|
||||
'server' : PMA_commonParams.get('server'),
|
||||
'server' : CommonParams.get('server'),
|
||||
'validate_username' : true,
|
||||
'username' : username
|
||||
};
|
||||
@ -79,29 +90,29 @@ export function onload1 () {
|
||||
/**
|
||||
* Indicating password strength
|
||||
*/
|
||||
var meter_obj;
|
||||
var meter_obj_label;
|
||||
var meterObj;
|
||||
var meterObjLabel;
|
||||
var username;
|
||||
$(document).on('keyup', '#text_pma_pw', function () {
|
||||
meter_obj = $('#password_strength_meter');
|
||||
meter_obj_label = $('#password_strength');
|
||||
meterObj = $('#password_strength_meter');
|
||||
meterObjLabel = $('#password_strength');
|
||||
username = $('input[name="username"]');
|
||||
username = username.val();
|
||||
checkPasswordStrength($(this).val(), meter_obj, meter_obj_label, username);
|
||||
checkPasswordStrength($(this).val(), meterObj, meterObjLabel, username);
|
||||
});
|
||||
|
||||
$(document).on('keyup', '#text_pma_change_pw', function () {
|
||||
meter_obj = $('#change_password_strength_meter');
|
||||
meter_obj_label = $('#change_password_strength');
|
||||
checkPasswordStrength($(this).val(), meter_obj, meter_obj_label, PMA_commonParams.get('user'));
|
||||
meterObj = $('#change_password_strength_meter');
|
||||
meterObjLabel = $('#change_password_strength');
|
||||
checkPasswordStrength($(this).val(), meterObj, meterObjLabel, CommonParams.get('user'));
|
||||
});
|
||||
|
||||
/**
|
||||
* Display a notice if sha256_password is selected
|
||||
*/
|
||||
$(document).on('change', '#select_authentication_plugin', function () {
|
||||
var selected_plugin = $(this).val();
|
||||
if (selected_plugin === 'sha256_password') {
|
||||
var selectedPlugin = $(this).val();
|
||||
if (selectedPlugin === 'sha256_password') {
|
||||
$('#ssl_reqd_warning').show();
|
||||
} else {
|
||||
$('#ssl_reqd_warning').hide();
|
||||
@ -121,19 +132,19 @@ export function onload1 () {
|
||||
var $thisButton = $(this);
|
||||
var $form = $('#usersForm');
|
||||
|
||||
$thisButton.PMA_confirm(PMA_messages.strDropUserWarning, $form.attr('action'), function (url) {
|
||||
var $drop_users_db_checkbox = $('#checkbox_drop_users_db');
|
||||
if ($drop_users_db_checkbox.is(':checked')) {
|
||||
var is_confirmed = confirm(PMA_messages.strDropDatabaseStrongWarning + '\n' + PMA_sprintf(PMA_messages.strDoYouReally, 'DROP DATABASE'));
|
||||
if (! is_confirmed) {
|
||||
$thisButton.PMA_confirm(messages.strDropUserWarning, $form.attr('action'), function (url) {
|
||||
var $dropUsersDbCheckbox = $('#checkbox_drop_users_db');
|
||||
if ($dropUsersDbCheckbox.is(':checked')) {
|
||||
var isConfirmed = confirm(messages.strDropDatabaseStrongWarning + '\n' + PMA_sprintf(messages.strDoYouReally, 'DROP DATABASE'));
|
||||
if (! isConfirmed) {
|
||||
// Uncheck the drop users database checkbox
|
||||
$drop_users_db_checkbox.prop('checked', false);
|
||||
$dropUsersDbCheckbox.prop('checked', false);
|
||||
}
|
||||
}
|
||||
|
||||
PMA_ajaxShowMessage(PMA_messages.strRemovingSelectedUsers);
|
||||
PMA_ajaxShowMessage(messages.strRemovingSelectedUsers);
|
||||
|
||||
var argsep = PMA_commonParams.get('arg_separator');
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
$.post(url, $form.serialize() + argsep + 'delete=' + $thisButton.val() + argsep + 'ajax_request=true', function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
PMA_ajaxShowMessage(data.message);
|
||||
@ -144,12 +155,12 @@ export function onload1 () {
|
||||
}
|
||||
// Remove the revoked user from the users list
|
||||
$form.find('input:checkbox:checked').parents('tr').slideUp('medium', function () {
|
||||
var this_user_initial = $(this).find('input:checkbox').val().charAt(0).toUpperCase();
|
||||
var thisUserInitial = $(this).find('input:checkbox').val().charAt(0).toUpperCase();
|
||||
$(this).remove();
|
||||
|
||||
// If this is the last user with this_user_initial, remove the link from #initials_table
|
||||
if ($('#tableuserrights').find('input:checkbox[value^="' + this_user_initial + '"], input:checkbox[value^="' + this_user_initial.toLowerCase() + '"]').length === 0) {
|
||||
$('#initials_table').find('td > a:contains(' + this_user_initial + ')').parent('td').html(this_user_initial);
|
||||
// If this is the last user with thisUserInitial, remove the link from #initials_table
|
||||
if ($('#tableuserrights').find('input:checkbox[value^="' + thisUserInitial + '"], input:checkbox[value^="' + thisUserInitial.toLowerCase() + '"]').length === 0) {
|
||||
$('#initials_table').find('td > a:contains(' + thisUserInitial + ')').parent('td').html(thisUserInitial);
|
||||
}
|
||||
|
||||
// Re-check the classes of each row
|
||||
@ -184,12 +195,12 @@ export function onload1 () {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
PMA_ajaxRemoveMessage($msg);
|
||||
var buttonOptions = {};
|
||||
buttonOptions[PMA_messages.strGo] = function () {
|
||||
buttonOptions[messages.strGo] = function () {
|
||||
var usrGroup = $('#changeUserGroupDialog')
|
||||
.find('select[name="userGroup"]')
|
||||
.val();
|
||||
var $message = PMA_ajaxShowMessage();
|
||||
var argsep = PMA_commonParams.get('arg_separator');
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
$.post(
|
||||
'server_privileges.php',
|
||||
$('#changeUserGroupDialog').find('form').serialize() + argsep + 'ajax_request=1',
|
||||
@ -211,7 +222,7 @@ export function onload1 () {
|
||||
);
|
||||
$(this).dialog('close');
|
||||
};
|
||||
buttonOptions[PMA_messages.strClose] = function () {
|
||||
buttonOptions[messages.strClose] = function () {
|
||||
$(this).dialog('close');
|
||||
};
|
||||
var $dialog = $('<div/>')
|
||||
@ -249,15 +260,15 @@ export function onload1 () {
|
||||
event.preventDefault();
|
||||
// can't export if no users checked
|
||||
if ($(this.form).find('input:checked').length === 0) {
|
||||
PMA_ajaxShowMessage(PMA_messages.strNoAccountSelected, 2000, 'success');
|
||||
PMA_ajaxShowMessage(messages.strNoAccountSelected, 2000, 'success');
|
||||
return;
|
||||
}
|
||||
var $msgbox = PMA_ajaxShowMessage();
|
||||
var button_options = {};
|
||||
button_options[PMA_messages.strClose] = function () {
|
||||
var buttonOptions = {};
|
||||
buttonOptions[messages.strClose] = function () {
|
||||
$(this).dialog('close');
|
||||
};
|
||||
var argsep = PMA_commonParams.get('arg_separator');
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
$.post(
|
||||
$(this.form).prop('action'),
|
||||
$(this.form).serialize() + argsep + 'submit_mult=export' + argsep + 'ajax_request=true',
|
||||
@ -268,7 +279,7 @@ export function onload1 () {
|
||||
.dialog({
|
||||
title: data.title,
|
||||
width: 500,
|
||||
buttons: button_options,
|
||||
buttons: buttonOptions,
|
||||
close: function () {
|
||||
$(this).remove();
|
||||
}
|
||||
@ -289,10 +300,10 @@ export function onload1 () {
|
||||
event.preventDefault();
|
||||
var $msgbox = PMA_ajaxShowMessage();
|
||||
/**
|
||||
* @var button_options Object containing options for jQueryUI dialog buttons
|
||||
* @var buttonOptions Object containing options for jQueryUI dialog buttons
|
||||
*/
|
||||
var button_options = {};
|
||||
button_options[PMA_messages.strClose] = function () {
|
||||
var buttonOptions = {};
|
||||
buttonOptions[messages.strClose] = function () {
|
||||
$(this).dialog('close');
|
||||
};
|
||||
$.get($(this).attr('href'), { 'ajax_request': true }, function (data) {
|
||||
@ -302,7 +313,7 @@ export function onload1 () {
|
||||
.dialog({
|
||||
title: data.title,
|
||||
width: 500,
|
||||
buttons: button_options,
|
||||
buttons: buttonOptions,
|
||||
close: function () {
|
||||
$(this).remove();
|
||||
}
|
||||
@ -346,7 +357,7 @@ export function onload1 () {
|
||||
}); // end $.get
|
||||
}); // end of the paginate users table
|
||||
|
||||
$(document).on('change', 'input[name="ssl_type"]', function (e) {
|
||||
$(document).on('change', 'input[name="ssl_type"]', function () {
|
||||
var $div = $('#specified_div');
|
||||
if ($('#ssl_type_SPECIFIED').is(':checked')) {
|
||||
$div.find('input').prop('disabled', false);
|
||||
@ -355,7 +366,7 @@ export function onload1 () {
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('change', '#checkbox_SSL_priv', function (e) {
|
||||
$(document).on('change', '#checkbox_SSL_priv', function () {
|
||||
var $div = $('#require_ssl_div');
|
||||
if ($(this).is(':checked')) {
|
||||
$div.find('input').prop('disabled', false);
|
||||
@ -372,10 +383,10 @@ export function onload1 () {
|
||||
*/
|
||||
var addOrUpdateSubmenu = function () {
|
||||
var $topmenu2 = $('#topmenu2');
|
||||
var $edit_user_dialog = $('#edit_user_dialog');
|
||||
var submenu_label;
|
||||
var submenu_link;
|
||||
var link_number;
|
||||
var $editUserDialog = $('#edit_user_dialog');
|
||||
var submenuLabel;
|
||||
var submenuLink;
|
||||
var linkNumber;
|
||||
|
||||
// if submenu exists yet, remove it first
|
||||
if ($topmenu2.length > 0) {
|
||||
@ -386,14 +397,14 @@ export function onload1 () {
|
||||
$topmenu2 = $('<ul/>').prop('id', 'topmenu2');
|
||||
|
||||
$('#edit_user_dialog .submenu-item').each(function () {
|
||||
submenu_label = $(this).find('legend[data-submenu-label]').data('submenu-label');
|
||||
submenuLabel = $(this).find('legend[data-submenu-label]').data('submenu-label');
|
||||
|
||||
submenu_link = $('<a/>')
|
||||
submenuLink = $('<a/>')
|
||||
.prop('href', '#')
|
||||
.html(submenu_label);
|
||||
.html(submenuLabel);
|
||||
|
||||
$('<li/>')
|
||||
.append(submenu_link)
|
||||
.append(submenuLink)
|
||||
.appendTo($topmenu2);
|
||||
});
|
||||
|
||||
@ -408,15 +419,15 @@ export function onload1 () {
|
||||
$(this).addClass('tabactive');
|
||||
|
||||
// which section to show now?
|
||||
link_number = $topmenu2.find('a').index($(this));
|
||||
linkNumber = $topmenu2.find('a').index($(this));
|
||||
// hide all sections but the one to show
|
||||
$('#edit_user_dialog .submenu-item').hide().eq(link_number).show();
|
||||
$('#edit_user_dialog .submenu-item').hide().eq(linkNumber).show();
|
||||
});
|
||||
|
||||
// make first menu item active
|
||||
// TODO: support URL hash history
|
||||
$topmenu2.find('> :first-child a').addClass('tabactive');
|
||||
$edit_user_dialog.prepend($topmenu2);
|
||||
$editUserDialog.prepend($topmenu2);
|
||||
|
||||
// hide all sections but the first
|
||||
$('#edit_user_dialog .submenu-item').hide().eq(0).show();
|
||||
@ -435,3 +446,11 @@ export function onload1 () {
|
||||
var windowwidth = $(window).width();
|
||||
$('.jsresponsive').css('max-width', (windowwidth - 35) + 'px');
|
||||
}
|
||||
|
||||
/**
|
||||
* Module export
|
||||
*/
|
||||
export {
|
||||
onloadServerPrivileges,
|
||||
teardownServerPrivileges
|
||||
};
|
||||
|
||||
112
js/src/shortcuts_handler.js
Normal file
112
js/src/shortcuts_handler.js
Normal file
@ -0,0 +1,112 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* @fileoverview Handle shortcuts in various pages
|
||||
* @name Shortcuts handler
|
||||
*
|
||||
* @requires jQuery
|
||||
* @requires jQueryUI
|
||||
*/
|
||||
/**
|
||||
* Module import
|
||||
*/
|
||||
import Console from './console';
|
||||
import CommonParams from './variables/common_params';
|
||||
|
||||
/**
|
||||
* @package PhpMyAdmin
|
||||
*
|
||||
* Shortcuts Handler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Register key events on load
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
var databaseOp = false;
|
||||
var tableOp = false;
|
||||
var keyD = 68;
|
||||
var keyT = 84;
|
||||
var keyK = 75;
|
||||
var keyS = 83;
|
||||
var keyF = 70;
|
||||
var keyE = 69;
|
||||
var keyH = 72;
|
||||
var keyC = 67;
|
||||
var keyBackSpace = 8;
|
||||
$(document).on('keyup', function (e) {
|
||||
if (e.target.nodeName === 'INPUT' || e.target.nodeName === 'TEXTAREA' || e.target.nodeName === 'SELECT') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.keyCode === keyD) {
|
||||
setTimeout(function () {
|
||||
databaseOp = false;
|
||||
}, 2000);
|
||||
} else if (e.keyCode === keyT) {
|
||||
setTimeout(function () {
|
||||
tableOp = false;
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
$(document).on('keydown', function (e) {
|
||||
if (e.ctrlKey && e.altKey && e.keyCode === keyC) {
|
||||
Console.toggle();
|
||||
}
|
||||
|
||||
if (e.ctrlKey && e.keyCode === keyK) {
|
||||
e.preventDefault();
|
||||
Console.toggle();
|
||||
}
|
||||
|
||||
if (e.target.nodeName === 'INPUT' || e.target.nodeName === 'TEXTAREA' || e.target.nodeName === 'SELECT') {
|
||||
return;
|
||||
}
|
||||
|
||||
var isTable;
|
||||
var isDb;
|
||||
if (e.keyCode === keyD) {
|
||||
databaseOp = true;
|
||||
} else if (e.keyCode === keyK) {
|
||||
e.preventDefault();
|
||||
Console.toggle();
|
||||
} else if (e.keyCode === keyS) {
|
||||
if (databaseOp === true) {
|
||||
isTable = CommonParams.get('table');
|
||||
isDb = CommonParams.get('db');
|
||||
if (isDb && ! isTable) {
|
||||
$('.tab .ic_b_props').first().trigger('click');
|
||||
}
|
||||
} else if (tableOp === true) {
|
||||
isTable = CommonParams.get('table');
|
||||
isDb = CommonParams.get('db');
|
||||
if (isDb && isTable) {
|
||||
$('.tab .ic_b_props').first().trigger('click');
|
||||
}
|
||||
} else {
|
||||
$('#pma_navigation_settings_icon').trigger('click');
|
||||
}
|
||||
} else if (e.keyCode === keyF) {
|
||||
if (databaseOp === true) {
|
||||
isTable = CommonParams.get('table');
|
||||
isDb = CommonParams.get('db');
|
||||
if (isDb && ! isTable) {
|
||||
$('.tab .ic_b_search').first().trigger('click');
|
||||
}
|
||||
} else if (tableOp === true) {
|
||||
isTable = CommonParams.get('table');
|
||||
isDb = CommonParams.get('db');
|
||||
if (isDb && isTable) {
|
||||
$('.tab .ic_b_search').first().trigger('click');
|
||||
}
|
||||
}
|
||||
} else if (e.keyCode === keyT) {
|
||||
tableOp = true;
|
||||
} else if (e.keyCode === keyE) {
|
||||
$('.ic_b_export').first().trigger('click');
|
||||
} else if (e.keyCode === keyBackSpace) {
|
||||
window.history.back();
|
||||
} else if (e.keyCode === keyH) {
|
||||
$('.ic_b_home').first().trigger('click');
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -1,8 +1,15 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
/**
|
||||
* @access public
|
||||
*
|
||||
* @param {string} unsafe Unsafe html which needs to be escaped
|
||||
*
|
||||
* @return {string}
|
||||
*
|
||||
* HTML escaping
|
||||
*/
|
||||
|
||||
export function escapeHtml (unsafe) {
|
||||
function escapeHtml (unsafe) {
|
||||
if (typeof(unsafe) !== 'undefined') {
|
||||
return unsafe
|
||||
.toString()
|
||||
@ -16,7 +23,14 @@ export function escapeHtml (unsafe) {
|
||||
}
|
||||
}
|
||||
|
||||
export function escapeJsString (unsafe) {
|
||||
/**
|
||||
* @access public
|
||||
*
|
||||
* @param {string} unsafe Unsafe javascript
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
function escapeJsString (unsafe) {
|
||||
if (typeof(unsafe) !== 'undefined') {
|
||||
return unsafe
|
||||
.toString()
|
||||
@ -33,3 +47,11 @@ export function escapeJsString (unsafe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Module export
|
||||
*/
|
||||
export {
|
||||
escapeHtml,
|
||||
escapeJsString
|
||||
};
|
||||
|
||||
113
js/src/utils/config.js
Normal file
113
js/src/utils/config.js
Normal file
@ -0,0 +1,113 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
/**
|
||||
* Module import
|
||||
*/
|
||||
import CommonParams from '../variables/common_params';
|
||||
import { PMA_ajaxShowMessage } from '../utils/show_ajax_messages';
|
||||
|
||||
/**
|
||||
* Sets a configuration value.
|
||||
*
|
||||
* A configuration value may be set in both browser's local storage and
|
||||
* remotely in server's configuration table.
|
||||
*
|
||||
* If the `only_local` argument is `true`, the value is store is stored only in
|
||||
* browser's local storage and may be lost if the user resets his browser's
|
||||
* settings.
|
||||
*
|
||||
* NOTE: Depending on server's configuration, the configuration table may be or
|
||||
* not persistent.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param {string} key Configuration key.
|
||||
*
|
||||
* @param {object} value Configuration value.
|
||||
*
|
||||
* @param {boolean} onlyLocal Configuration type.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
function configSet (key, value, onlyLocal) {
|
||||
onlyLocal = (typeof onlyLocal !== 'undefined') ? onlyLocal : false;
|
||||
var serialized = JSON.stringify(value);
|
||||
localStorage.setItem(key, serialized);
|
||||
$.ajax({
|
||||
url: 'ajax.php',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
key: key,
|
||||
type: 'config-set',
|
||||
server: CommonParams.get('server'),
|
||||
value: serialized,
|
||||
},
|
||||
success: function (data) {
|
||||
// Updating value in local storage.
|
||||
if (! data.success) {
|
||||
PMA_ajaxShowMessage(data.message);
|
||||
}
|
||||
// Eventually, call callback.
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a configuration value. A configuration value will be searched in
|
||||
* browser's local storage first and if not found, a call to the server will be
|
||||
* made.
|
||||
*
|
||||
* If value should not be cached and the up-to-date configuration value from
|
||||
* right from the server is required, the third parameter should be `false`.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param {string} key Configuration key.
|
||||
*
|
||||
* @param {boolean} cached Configuration type.
|
||||
*
|
||||
* @return {object} Configuration value.
|
||||
*/
|
||||
function configGet (key, cached) {
|
||||
cached = (typeof cached !== 'undefined') ? cached : true;
|
||||
var value = localStorage.getItem(key);
|
||||
if (cached && value !== undefined && value !== null) {
|
||||
return JSON.parse(value);
|
||||
}
|
||||
|
||||
// Result not found in local storage or ignored.
|
||||
// Hitting the server.
|
||||
$.ajax({
|
||||
// TODO: This is ugly, but usually when a configuration is needed,
|
||||
// processing cannot continue until that value is found.
|
||||
// Another solution is to provide a callback as a parameter.
|
||||
async: false,
|
||||
url: 'ajax.php',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
type: 'config-get',
|
||||
server: CommonParams.get('server'),
|
||||
key: key
|
||||
},
|
||||
success: function (data) {
|
||||
// Updating value in local storage.
|
||||
if (data.success) {
|
||||
localStorage.setItem(key, JSON.stringify(data.value));
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.message);
|
||||
}
|
||||
// Eventually, call callback.
|
||||
}
|
||||
});
|
||||
return JSON.parse(localStorage.getItem(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Module export
|
||||
*/
|
||||
export {
|
||||
configGet,
|
||||
configSet
|
||||
};
|
||||
@ -1,20 +1,27 @@
|
||||
import { PMA_Messages as PMA_messages } from '../variables/export_variables';
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
/**
|
||||
* Module import
|
||||
*/
|
||||
import zxcvbn from 'zxcvbn';
|
||||
import { PMA_Messages as messages } from '../variables/export_variables';
|
||||
|
||||
/**
|
||||
* Generate a new password and copy it to the password input areas
|
||||
*
|
||||
* @param passwd_form object the form that holds the password fields
|
||||
* @access private
|
||||
*
|
||||
* @return boolean always true
|
||||
* @param {Object} passwdForm the form that holds the password fields
|
||||
*
|
||||
* @return {boolean} always true
|
||||
*/
|
||||
export function suggestPassword (passwd_form) {
|
||||
function suggestPassword (passwdForm) {
|
||||
// restrict the password to just letters and numbers to avoid problems:
|
||||
// "editors and viewers regard the password as multiple words and
|
||||
// things like double click no longer work"
|
||||
var pwchars = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWYXZ';
|
||||
var passwordlength = 16; // do we want that to be dynamic? no, keep it simple :)
|
||||
var passwd = passwd_form.generated_pw;
|
||||
var passwd = passwdForm.generated_pw;
|
||||
var randomWords = new Int32Array(passwordlength);
|
||||
|
||||
passwd.value = '';
|
||||
@ -36,13 +43,13 @@ export function suggestPassword (passwd_form) {
|
||||
passwd.value += pwchars.charAt(Math.abs(randomWords[i]) % pwchars.length);
|
||||
}
|
||||
|
||||
var $jquery_passwd_form = $(passwd_form);
|
||||
var $jqueryPasswdForm = $(passwdForm);
|
||||
|
||||
passwd_form.elements.pma_pw.value = passwd.value;
|
||||
passwd_form.elements.pma_pw2.value = passwd.value;
|
||||
var meter_obj = $jquery_passwd_form.find('meter[name="pw_meter"]').first();
|
||||
var meter_obj_label = $jquery_passwd_form.find('span[name="pw_strength"]').first();
|
||||
checkPasswordStrength(passwd.value, meter_obj, meter_obj_label);
|
||||
passwdForm.elements.pma_pw.value = passwd.value;
|
||||
passwdForm.elements.pma_pw2.value = passwd.value;
|
||||
var meterObj = $jqueryPasswdForm.find('meter[name="pw_meter"]').first();
|
||||
var meterObjLabel = $jqueryPasswdForm.find('span[name="pw_strength"]').first();
|
||||
checkPasswordStrength(passwd.value, meterObj, meterObjLabel);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -50,13 +57,16 @@ export function suggestPassword (passwd_form) {
|
||||
* for PhpMyAdmin\Display\ChangePassword
|
||||
* libraries/user_password.php
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
export function displayPasswordGenerateButton () {
|
||||
function displayPasswordGenerateButton () {
|
||||
var generatePwdRow = $('<tr />').addClass('vmiddle');
|
||||
$('<td />').html(PMA_messages.strGeneratePassword).appendTo(generatePwdRow);
|
||||
$('<td />').html(messages.strGeneratePassword).appendTo(generatePwdRow);
|
||||
var pwdCell = $('<td />').appendTo(generatePwdRow);
|
||||
var pwdButton = $('<input />')
|
||||
.attr({ type: 'button', id: 'button_generate_password', value: PMA_messages.strGenerate })
|
||||
.attr({ type: 'button', id: 'button_generate_password', value: messages.strGenerate })
|
||||
.addClass('button')
|
||||
.on('click', function () {
|
||||
suggestPassword(this.form);
|
||||
@ -69,7 +79,7 @@ export function displayPasswordGenerateButton () {
|
||||
|
||||
var generatePwdDiv = $('<div />').addClass('item');
|
||||
$('<label />').attr({ for: 'button_generate_password' })
|
||||
.html(PMA_messages.strGeneratePassword + ':')
|
||||
.html(messages.strGeneratePassword + ':')
|
||||
.appendTo(generatePwdDiv);
|
||||
var optionsSpan = $('<span/>').addClass('options')
|
||||
.appendTo(generatePwdDiv);
|
||||
@ -78,38 +88,46 @@ export function displayPasswordGenerateButton () {
|
||||
$('#div_element_before_generate_password').parent().append(generatePwdDiv);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validates the "add a user" form
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @return {boolean} whether the form is validated or not
|
||||
*/
|
||||
export function checkAddUser (the_form) {
|
||||
if (the_form.elements.pred_hostname.value === 'userdefined' && the_form.elements.hostname.value === '') {
|
||||
alert(PMA_messages.strHostEmpty);
|
||||
the_form.elements.hostname.focus();
|
||||
function checkAddUser (theForm) {
|
||||
if (theForm.elements.pred_hostname.value === 'userdefined' && theForm.elements.hostname.value === '') {
|
||||
alert(messages.strHostEmpty);
|
||||
theForm.elements.hostname.focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (the_form.elements.pred_username.value === 'userdefined' && the_form.elements.username.value === '') {
|
||||
alert(PMA_messages.strUserEmpty);
|
||||
the_form.elements.username.focus();
|
||||
if (theForm.elements.pred_username.value === 'userdefined' && theForm.elements.username.value === '') {
|
||||
alert(messages.strUserEmpty);
|
||||
theForm.elements.username.focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
return PMA_checkPassword($(the_form));
|
||||
return checkPassword($(theForm));
|
||||
} // end of the 'checkAddUser()' function
|
||||
|
||||
/**
|
||||
* Function to check the password strength
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param {string} value Passworrd string
|
||||
* @param {object} meter_obj jQuery object to show strength in meter
|
||||
* @param {object} meter_object_label jQuery object to show text of password strnegth
|
||||
*
|
||||
* @param {object} meterObj jQuery object to show strength in meter
|
||||
*
|
||||
* @param {object} meterObjectLabel jQuery object to show text of password strnegth
|
||||
*
|
||||
* @param {string} username Username string
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
export function checkPasswordStrength (value, meter_obj, meter_object_label, username) {
|
||||
function checkPasswordStrength (value, meterObj, meterObjectLabel, username) {
|
||||
// List of words we don't want to appear in the password
|
||||
var customDict = [
|
||||
'phpmyadmin',
|
||||
@ -122,58 +140,72 @@ export function checkPasswordStrength (value, meter_obj, meter_object_label, use
|
||||
if (username !== null) {
|
||||
customDict.push(username);
|
||||
}
|
||||
var zxcvbn_obj = zxcvbn(value, customDict);
|
||||
var strength = zxcvbn_obj.score;
|
||||
var zxcvbnObj = zxcvbn(value, customDict);
|
||||
var strength = zxcvbnObj.score;
|
||||
strength = parseInt(strength);
|
||||
meter_obj.val(strength);
|
||||
meterObj.val(strength);
|
||||
switch (strength) {
|
||||
case 0: meter_object_label.html(PMA_messages.strExtrWeak);
|
||||
case 0: meterObjectLabel.html(messages.strExtrWeak);
|
||||
break;
|
||||
case 1: meter_object_label.html(PMA_messages.strVeryWeak);
|
||||
case 1: meterObjectLabel.html(messages.strVeryWeak);
|
||||
break;
|
||||
case 2: meter_object_label.html(PMA_messages.strWeak);
|
||||
case 2: meterObjectLabel.html(messages.strWeak);
|
||||
break;
|
||||
case 3: meter_object_label.html(PMA_messages.strGood);
|
||||
case 3: meterObjectLabel.html(messages.strGood);
|
||||
break;
|
||||
case 4: meter_object_label.html(PMA_messages.strStrong);
|
||||
case 4: meterObjectLabel.html(messages.strStrong);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the password field in a form
|
||||
*
|
||||
* @see PMA_messages.strPasswordEmpty
|
||||
* @see PMA_messages.strPasswordNotSame
|
||||
* @param object $the_form The form to be validated
|
||||
* @return bool
|
||||
* @access private
|
||||
*
|
||||
* @see PMA_Messages.strPasswordEmpty
|
||||
*
|
||||
* @see PMA_Messages.strPasswordNotSame
|
||||
*
|
||||
* @param {Object} $the_form The form to be validated
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
function PMA_checkPassword ($the_form) {
|
||||
function checkPassword ($theForm) {
|
||||
// Did the user select 'no password'?
|
||||
if ($the_form.find('#nopass_1').is(':checked')) {
|
||||
if ($theForm.find('#nopass_1').is(':checked')) {
|
||||
return true;
|
||||
} else {
|
||||
var $pred = $the_form.find('#select_pred_password');
|
||||
var $pred = $theForm.find('#select_pred_password');
|
||||
if ($pred.length && ($pred.val() === 'none' || $pred.val() === 'keep')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
var $password = $the_form.find('input[name=pma_pw]');
|
||||
var $password_repeat = $the_form.find('input[name=pma_pw2]');
|
||||
var alert_msg = false;
|
||||
var $password = $theForm.find('input[name=pma_pw]');
|
||||
var $passwordRepeat = $theForm.find('input[name=pma_pw2]');
|
||||
var alertMsg = false;
|
||||
|
||||
if ($password.val() === '') {
|
||||
alert_msg = PMA_messages.strPasswordEmpty;
|
||||
} else if ($password.val() !== $password_repeat.val()) {
|
||||
alert_msg = PMA_messages.strPasswordNotSame;
|
||||
alertMsg = messages.strPasswordEmpty;
|
||||
} else if ($password.val() !== $passwordRepeat.val()) {
|
||||
alertMsg = messages.strPasswordNotSame;
|
||||
}
|
||||
|
||||
if (alert_msg) {
|
||||
alert(alert_msg);
|
||||
if (alertMsg) {
|
||||
alert(alertMsg);
|
||||
$password.val('');
|
||||
$password_repeat.val('');
|
||||
$passwordRepeat.val('');
|
||||
$password.focus();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Module export
|
||||
*/
|
||||
export {
|
||||
checkAddUser,
|
||||
checkPasswordStrength,
|
||||
displayPasswordGenerateButton
|
||||
};
|
||||
|
||||
@ -7,25 +7,29 @@
|
||||
/**
|
||||
* Module imports
|
||||
*/
|
||||
import { PMA_Messages as PMA_messages } from '../variables/export_variables';
|
||||
import { PMA_Messages as messages } from '../variables/export_variables';
|
||||
import { PMA_highlightSQL } from './sql';
|
||||
|
||||
/**
|
||||
* @var int ajax_message_count Number of AJAX messages shown since page load
|
||||
* @var {int} ajax_message_count Number of AJAX messages shown since page load
|
||||
*/
|
||||
let ajax_message_count = 0;
|
||||
|
||||
/**
|
||||
* Create a jQuery UI tooltip
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param $elements jQuery object representing the elements
|
||||
*
|
||||
* @param item the item
|
||||
* (see https://api.jqueryui.com/tooltip/#option-items)
|
||||
* @param myContent content of the tooltip
|
||||
*
|
||||
* @param additionalOptions to override the default options
|
||||
*
|
||||
*/
|
||||
export function PMA_tooltip ($elements, item, myContent, additionalOptions) {
|
||||
function PMA_tooltip ($elements, item, myContent, additionalOptions) {
|
||||
if ($('#no_hint').length > 0) {
|
||||
return;
|
||||
}
|
||||
@ -65,6 +69,8 @@ export function PMA_tooltip ($elements, item, myContent, additionalOptions) {
|
||||
* This will show a message that will not disappear automatically, but it
|
||||
* can be dismissed by the user after he has finished reading it.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param string message string containing the message to be shown.
|
||||
* optional, defaults to 'Loading...'
|
||||
* @param mixed timeout number of milliseconds for the message to be visible
|
||||
@ -81,11 +87,11 @@ export function PMA_tooltip ($elements, item, myContent, additionalOptions) {
|
||||
* to remove the notification
|
||||
*/
|
||||
|
||||
export const PMA_ajaxShowMessage = (message, timeout, type) => {
|
||||
const PMA_ajaxShowMessage = (message, timeout, type) => {
|
||||
/**
|
||||
* @var self_closing Whether the notification will automatically disappear
|
||||
*/
|
||||
var self_closing = true;
|
||||
var selfClosing = true;
|
||||
/**
|
||||
* @var dismissable Whether the user will be able to remove
|
||||
* the notification by clicking on it
|
||||
@ -97,19 +103,19 @@ export const PMA_ajaxShowMessage = (message, timeout, type) => {
|
||||
return true;
|
||||
} else if (! message) {
|
||||
// If the message is undefined, show the default
|
||||
message = PMA_messages.strLoading;
|
||||
message = messages.strLoading;
|
||||
dismissable = false;
|
||||
self_closing = false;
|
||||
} else if (message === PMA_messages.strProcessingRequest) {
|
||||
selfClosing = false;
|
||||
} else if (message === messages.strProcessingRequest) {
|
||||
// This is another case where the message should not disappear
|
||||
dismissable = false;
|
||||
self_closing = false;
|
||||
selfClosing = false;
|
||||
}
|
||||
// Figure out whether (or after how long) to remove the notification
|
||||
if (timeout === undefined) {
|
||||
timeout = 5000;
|
||||
} else if (timeout === false) {
|
||||
self_closing = false;
|
||||
selfClosing = false;
|
||||
}
|
||||
// Determine type of message, add styling as required
|
||||
if (type === 'error') {
|
||||
@ -140,7 +146,7 @@ export const PMA_ajaxShowMessage = (message, timeout, type) => {
|
||||
.html(message)
|
||||
.show();
|
||||
// If the notification is self-closing we should create a callback to remove it
|
||||
if (self_closing) {
|
||||
if (selfClosing) {
|
||||
$retval
|
||||
.delay(timeout)
|
||||
.fadeOut('medium', function () {
|
||||
@ -162,7 +168,7 @@ export const PMA_ajaxShowMessage = (message, timeout, type) => {
|
||||
PMA_tooltip(
|
||||
$retval,
|
||||
'span',
|
||||
PMA_messages.strDismiss
|
||||
messages.strDismiss
|
||||
);
|
||||
}
|
||||
PMA_highlightSQL($retval);
|
||||
@ -173,19 +179,30 @@ export const PMA_ajaxShowMessage = (message, timeout, type) => {
|
||||
/**
|
||||
* Removes the message shown for an Ajax operation when it's completed
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param jQuery object jQuery Element that holds the notification
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
export function PMA_ajaxRemoveMessage ($this_msgbox) {
|
||||
if ($this_msgbox !== undefined && $this_msgbox instanceof jQuery) {
|
||||
$this_msgbox
|
||||
function PMA_ajaxRemoveMessage ($thisMsgbox) {
|
||||
if ($thisMsgbox !== undefined && $thisMsgbox instanceof jQuery) {
|
||||
$thisMsgbox
|
||||
.stop(true, true)
|
||||
.fadeOut('medium');
|
||||
if ($this_msgbox.is(':data(tooltip)')) {
|
||||
$this_msgbox.tooltip('destroy');
|
||||
if ($thisMsgbox.is(':data(tooltip)')) {
|
||||
$thisMsgbox.tooltip('destroy');
|
||||
} else {
|
||||
$this_msgbox.remove();
|
||||
$thisMsgbox.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Module export
|
||||
*/
|
||||
export {
|
||||
PMA_ajaxRemoveMessage,
|
||||
PMA_ajaxShowMessage,
|
||||
PMA_tooltip
|
||||
};
|
||||
|
||||
@ -1,3 +1,8 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
/**
|
||||
* Module import
|
||||
*/
|
||||
import sprintf from 'sprintf-js';
|
||||
|
||||
/**
|
||||
@ -6,7 +11,7 @@ import sprintf from 'sprintf-js';
|
||||
* @return string A concated string of aguments passed
|
||||
*/
|
||||
|
||||
export function PMA_sprintf () {
|
||||
function PMA_sprintf () {
|
||||
/**
|
||||
* This package can be implemented in two ways
|
||||
*
|
||||
@ -16,3 +21,10 @@ export function PMA_sprintf () {
|
||||
*/
|
||||
return sprintf.sprintf(...arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Module export
|
||||
*/
|
||||
export {
|
||||
PMA_sprintf
|
||||
};
|
||||
|
||||
@ -211,12 +211,13 @@ class Header
|
||||
$this->_scripts->addFile('navigation.js');
|
||||
$this->_scripts->addFile('indexes.js');
|
||||
$this->_scripts->addFile('common.js');
|
||||
$this->_scripts->addFile('page_settings.js');
|
||||
|
||||
if($GLOBALS['cfg']['enable_drag_drop_import'] === true) {
|
||||
$this->_scripts->addFile('drag_drop_import.js');
|
||||
}
|
||||
$this->_scripts->addFile('page_settings');
|
||||
if (! $GLOBALS['PMA_Config']->get('DisableShortcutKeys')) {
|
||||
$this->_scripts->addFile('shortcuts_handler.js');
|
||||
$this->_scripts->addFile('shortcuts_handler');
|
||||
}
|
||||
$this->_scripts->addCode($this->getJsParamsCode());
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user