Update website
This commit is contained in:
parent
41ce1aa076
commit
ea0eb1c6e0
4222 changed files with 721797 additions and 14 deletions
231
admin/phpMyAdmin/js/dist/database/central_columns.js
vendored
Normal file
231
admin/phpMyAdmin/js/dist/database/central_columns.js
vendored
Normal file
|
@ -0,0 +1,231 @@
|
|||
/**
|
||||
* @fileoverview events handling from central columns page
|
||||
* @name Central columns
|
||||
*
|
||||
* @requires jQuery
|
||||
*/
|
||||
|
||||
/**
|
||||
* AJAX scripts for /database/central-columns
|
||||
*
|
||||
* Actions ajaxified here:
|
||||
* Inline Edit and save of a result row
|
||||
* Delete a row
|
||||
* Multiple edit and delete option
|
||||
*
|
||||
*/
|
||||
|
||||
AJAX.registerTeardown('database/central_columns.js', function () {
|
||||
$('.edit').off('click');
|
||||
$('.edit_save_form').off('click');
|
||||
$('.edit_cancel_form').off('click');
|
||||
$('.del_row').off('click');
|
||||
$(document).off('keyup', '.filter_rows');
|
||||
$('.edit_cancel_form').off('click');
|
||||
$('#table-select').off('change');
|
||||
$('#column-select').off('change');
|
||||
$('#add_col_div').find('>a').off('click');
|
||||
$('#add_new').off('submit');
|
||||
$('#multi_edit_central_columns').off('submit');
|
||||
$('select.default_type').off('change');
|
||||
$('button[name=\'delete_central_columns\']').off('click');
|
||||
$('button[name=\'edit_central_columns\']').off('click');
|
||||
});
|
||||
AJAX.registerOnload('database/central_columns.js', function () {
|
||||
$('#tableslistcontainer input,#tableslistcontainer select,#tableslistcontainer .default_value,#tableslistcontainer .open_enum_editor').hide();
|
||||
$('#tableslistcontainer').find('.checkall').show();
|
||||
$('#tableslistcontainer').find('.checkall_box').show();
|
||||
if ($('#table_columns').find('tbody tr').length > 0) {
|
||||
$('#table_columns').tablesorter({
|
||||
headers: {
|
||||
0: {
|
||||
sorter: false
|
||||
},
|
||||
1: {
|
||||
sorter: false
|
||||
},
|
||||
// hidden column
|
||||
4: {
|
||||
sorter: 'integer'
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
$('#tableslistcontainer').find('button[name="delete_central_columns"]').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
var multiDeleteColumns = $('.checkall:checkbox:checked').serialize();
|
||||
if (multiDeleteColumns === '') {
|
||||
Functions.ajaxShowMessage(Messages.strRadioUnchecked);
|
||||
return false;
|
||||
}
|
||||
Functions.ajaxShowMessage();
|
||||
$('#del_col_name').val(multiDeleteColumns);
|
||||
$('#del_form').trigger('submit');
|
||||
});
|
||||
$('#tableslistcontainer').find('button[name="edit_central_columns"]').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
var editColumnList = $('.checkall:checkbox:checked').serialize();
|
||||
if (editColumnList === '') {
|
||||
Functions.ajaxShowMessage(Messages.strRadioUnchecked);
|
||||
return false;
|
||||
}
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
var editColumnData = editColumnList + '' + argsep + 'edit_central_columns_page=true' + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true' + argsep + 'db=' + encodeURIComponent(CommonParams.get('db')) + argsep + 'server=' + CommonParams.get('server');
|
||||
Functions.ajaxShowMessage();
|
||||
AJAX.source = $(this);
|
||||
$.post('index.php?route=/database/central-columns', editColumnData, AJAX.responseHandler);
|
||||
});
|
||||
$('#multi_edit_central_columns').on('submit', function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
var multiColumnEditData = $('#multi_edit_central_columns').serialize() + argsep + 'multi_edit_central_column_save=true' + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true' + argsep + 'db=' + encodeURIComponent(CommonParams.get('db')) + argsep + 'server=' + CommonParams.get('server');
|
||||
Functions.ajaxShowMessage();
|
||||
AJAX.source = $(this);
|
||||
$.post('index.php?route=/database/central-columns', multiColumnEditData, AJAX.responseHandler);
|
||||
});
|
||||
$('#add_new').find('td').each(function () {
|
||||
if ($(this).attr('name') !== 'undefined') {
|
||||
$(this).find('input,select').first().attr('name', $(this).attr('name'));
|
||||
}
|
||||
});
|
||||
$('#field_0_0').attr('required', 'required');
|
||||
$('#add_new input[type="text"], #add_new input[type="number"], #add_new select').css({
|
||||
'width': '10em',
|
||||
'box-sizing': 'border-box'
|
||||
});
|
||||
window.scrollTo(0, 0);
|
||||
$(document).on('keyup', '.filter_rows', function () {
|
||||
// get the column names
|
||||
var cols = $('th.column_heading').map(function () {
|
||||
return $(this).text().trim();
|
||||
}).get();
|
||||
$.uiTableFilter($('#table_columns'), $(this).val(), cols, null, 'td span');
|
||||
});
|
||||
$('.edit').on('click', function () {
|
||||
var rownum = $(this).parent().data('rownum');
|
||||
$('#save_' + rownum).show();
|
||||
$(this).hide();
|
||||
$('#f_' + rownum + ' td span').hide();
|
||||
$('#f_' + rownum + ' input, #f_' + rownum + ' select, #f_' + rownum + ' .open_enum_editor').show();
|
||||
var attributeVal = $('#f_' + rownum + ' td[name=col_attribute] span').html();
|
||||
$('#f_' + rownum + ' select[name=field_attribute\\[' + rownum + '\\] ] option[value="' + attributeVal + '"]').attr('selected', 'selected');
|
||||
if ($('#f_' + rownum + ' .default_type').val() === 'USER_DEFINED') {
|
||||
$('#f_' + rownum + ' .default_type').siblings('.default_value').show();
|
||||
} else {
|
||||
$('#f_' + rownum + ' .default_type').siblings('.default_value').hide();
|
||||
}
|
||||
});
|
||||
$('.del_row').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
var $td = $(this);
|
||||
var question = Messages.strDeleteCentralColumnWarning;
|
||||
$td.confirm(question, null, function () {
|
||||
var rownum = $td.data('rownum');
|
||||
$('#del_col_name').val('selected_fld%5B%5D=' + $('#checkbox_row_' + rownum).val());
|
||||
$('#del_form').trigger('submit');
|
||||
});
|
||||
});
|
||||
$('.edit_cancel_form').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
var rownum = $(this).data('rownum');
|
||||
$('#save_' + rownum).hide();
|
||||
$('#edit_' + rownum).show();
|
||||
$('#f_' + rownum + ' td span').show();
|
||||
$('#f_' + rownum + ' input, #f_' + rownum + ' select,#f_' + rownum + ' .default_value, #f_' + rownum + ' .open_enum_editor').hide();
|
||||
$('#tableslistcontainer').find('.checkall').show();
|
||||
});
|
||||
$('.edit_save_form').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
var rownum = $(this).data('rownum');
|
||||
$('#f_' + rownum + ' td').each(function () {
|
||||
if ($(this).attr('name') !== 'undefined') {
|
||||
$(this).find(':input[type!="hidden"],select').first().attr('name', $(this).attr('name'));
|
||||
}
|
||||
});
|
||||
if ($('#f_' + rownum + ' .default_type').val() === 'USER_DEFINED') {
|
||||
$('#f_' + rownum + ' .default_type').attr('name', 'col_default_sel');
|
||||
} else {
|
||||
$('#f_' + rownum + ' .default_value').attr('name', 'col_default_val');
|
||||
}
|
||||
var datastring = $('#f_' + rownum + ' :input').serialize();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'index.php?route=/database/central-columns',
|
||||
data: datastring + CommonParams.get('arg_separator') + 'ajax_request=true',
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
if (data.message !== '1') {
|
||||
Functions.ajaxShowMessage('<div class="alert alert-danger" role="alert">' + data.message + '</div>', false);
|
||||
} else {
|
||||
$('#f_' + rownum + ' td input[id=checkbox_row_' + rownum + ']').val($('#f_' + rownum + ' input[name=col_name]').val()).html();
|
||||
$('#f_' + rownum + ' td[name=col_name] span').text($('#f_' + rownum + ' input[name=col_name]').val()).html();
|
||||
$('#f_' + rownum + ' td[name=col_type] span').text($('#f_' + rownum + ' select[name=col_type]').val()).html();
|
||||
$('#f_' + rownum + ' td[name=col_length] span').text($('#f_' + rownum + ' input[name=col_length]').val()).html();
|
||||
$('#f_' + rownum + ' td[name=collation] span').text($('#f_' + rownum + ' select[name=collation]').val()).html();
|
||||
$('#f_' + rownum + ' td[name=col_attribute] span').text($('#f_' + rownum + ' select[name=col_attribute]').val()).html();
|
||||
$('#f_' + rownum + ' td[name=col_isNull] span').text($('#f_' + rownum + ' input[name=col_isNull]').is(':checked') ? 'Yes' : 'No').html();
|
||||
$('#f_' + rownum + ' td[name=col_extra] span').text($('#f_' + rownum + ' input[name=col_extra]').is(':checked') ? 'auto_increment' : '').html();
|
||||
$('#f_' + rownum + ' td[name=col_default] span').text($('#f_' + rownum + ' :input[name=col_default]').val()).html();
|
||||
}
|
||||
$('#save_' + rownum).hide();
|
||||
$('#edit_' + rownum).show();
|
||||
$('#f_' + rownum + ' td span').show();
|
||||
$('#f_' + rownum + ' input, #f_' + rownum + ' select,#f_' + rownum + ' .default_value, #f_' + rownum + ' .open_enum_editor').hide();
|
||||
$('#tableslistcontainer').find('.checkall').show();
|
||||
},
|
||||
error: function () {
|
||||
Functions.ajaxShowMessage('<div class="alert alert-danger" role="alert">' + Messages.strErrorProcessingRequest + '</div>', false);
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#table-select').on('change', function () {
|
||||
var selectValue = $(this).val();
|
||||
var defaultColumnSelect = $('#column-select').find('option').first();
|
||||
var href = 'index.php?route=/database/central-columns/populate';
|
||||
var params = {
|
||||
'ajax_request': true,
|
||||
'server': CommonParams.get('server'),
|
||||
'db': CommonParams.get('db'),
|
||||
'selectedTable': selectValue
|
||||
};
|
||||
$('#column-select').html('<option value="">' + Messages.strLoading + '</option>');
|
||||
if (selectValue !== '') {
|
||||
$.post(href, params, function (data) {
|
||||
$('#column-select').empty().append(defaultColumnSelect);
|
||||
$('#column-select').append(data.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
$('#add_column').on('submit', function (e) {
|
||||
var selectvalue = $('#column-select').val();
|
||||
if (selectvalue === '') {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
});
|
||||
$('#add_col_div').find('>a').on('click', function () {
|
||||
$('#add_new').slideToggle('slow');
|
||||
var $addColDivLinkSpan = $('#add_col_div').find('>a span');
|
||||
if ($addColDivLinkSpan.html() === '+') {
|
||||
$addColDivLinkSpan.html('-');
|
||||
} else {
|
||||
$addColDivLinkSpan.html('+');
|
||||
}
|
||||
});
|
||||
$('#add_new').on('submit', function () {
|
||||
$('#add_new').toggle();
|
||||
});
|
||||
$('#tableslistcontainer').find('select.default_type').on('change', function () {
|
||||
if ($(this).val() === 'USER_DEFINED') {
|
||||
$(this).siblings('.default_value').attr('name', 'col_default');
|
||||
$(this).attr('name', 'col_default_sel');
|
||||
} else {
|
||||
$(this).attr('name', 'col_default');
|
||||
$(this).siblings('.default_value').attr('name', 'col_default_val');
|
||||
}
|
||||
});
|
||||
});
|
570
admin/phpMyAdmin/js/dist/database/events.js
vendored
Normal file
570
admin/phpMyAdmin/js/dist/database/events.js
vendored
Normal file
|
@ -0,0 +1,570 @@
|
|||
AJAX.registerTeardown('database/events.js', function () {
|
||||
$(document).off('click', 'a.ajax.add_anchor, a.ajax.edit_anchor');
|
||||
$(document).off('click', 'a.ajax.export_anchor');
|
||||
$(document).off('click', '#bulkActionExportButton');
|
||||
$(document).off('click', 'a.ajax.drop_anchor');
|
||||
$(document).off('click', '#bulkActionDropButton');
|
||||
$(document).off('change', 'select[name=item_type]');
|
||||
});
|
||||
const DatabaseEvents = {
|
||||
/**
|
||||
* @var $ajaxDialog Query object containing the reference to the
|
||||
* dialog that contains the editor
|
||||
*/
|
||||
$ajaxDialog: null,
|
||||
/**
|
||||
* @var syntaxHiglighter Reference to the codemirror editor
|
||||
*/
|
||||
syntaxHiglighter: null,
|
||||
/**
|
||||
* Validate editor form fields.
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
validate: function () {
|
||||
/**
|
||||
* @var $elm a jQuery object containing the reference
|
||||
* to an element that is being validated
|
||||
*/
|
||||
var $elm = null;
|
||||
// Common validation. At the very least the name
|
||||
// and the definition must be provided for an item
|
||||
$elm = $('table.rte_table').last().find('input[name=item_name]');
|
||||
if ($elm.val() === '') {
|
||||
$elm.trigger('focus');
|
||||
alert(Messages.strFormEmpty);
|
||||
return false;
|
||||
}
|
||||
$elm = $('table.rte_table').find('textarea[name=item_definition]');
|
||||
if ($elm.val() === '') {
|
||||
if (this.syntaxHiglighter !== null) {
|
||||
this.syntaxHiglighter.focus();
|
||||
} else {
|
||||
$('textarea[name=item_definition]').last().trigger('focus');
|
||||
}
|
||||
alert(Messages.strFormEmpty);
|
||||
return false;
|
||||
}
|
||||
// The validation has so far passed, so now
|
||||
// we can validate item-specific fields.
|
||||
return this.validateCustom();
|
||||
},
|
||||
exportDialog: function ($this) {
|
||||
var $msg = Functions.ajaxShowMessage();
|
||||
if ($this.attr('id') === 'bulkActionExportButton') {
|
||||
var combined = {
|
||||
success: true,
|
||||
title: Messages.strExport,
|
||||
message: '',
|
||||
error: ''
|
||||
};
|
||||
// export anchors of all selected rows
|
||||
var exportAnchors = $('input.checkall:checked').parents('tr').find('.export_anchor');
|
||||
var count = exportAnchors.length;
|
||||
var returnCount = 0;
|
||||
var p = $.when();
|
||||
exportAnchors.each(function () {
|
||||
var h = $(this).attr('href');
|
||||
p = p.then(function () {
|
||||
return $.get(h, {
|
||||
'ajax_request': true
|
||||
}, function (data) {
|
||||
returnCount++;
|
||||
if (data.success === true) {
|
||||
combined.message += '\n' + data.message + '\n';
|
||||
if (returnCount === count) {
|
||||
showExport(combined);
|
||||
}
|
||||
} else {
|
||||
// complain even if one export is failing
|
||||
combined.success = false;
|
||||
combined.error += '\n' + data.error + '\n';
|
||||
if (returnCount === count) {
|
||||
showExport(combined);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
$.get($this.attr('href'), {
|
||||
'ajax_request': true
|
||||
}, showExport);
|
||||
}
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
function showExport(data) {
|
||||
if (data.success === true) {
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
/**
|
||||
* @var buttonOptions Object containing options
|
||||
* for jQueryUI dialog buttons
|
||||
*/
|
||||
var buttonOptions = {
|
||||
[Messages.strClose]: {
|
||||
text: Messages.strClose,
|
||||
class: 'btn btn-primary',
|
||||
click: function () {
|
||||
$(this).dialog('close').remove();
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Display the dialog to the user
|
||||
*/
|
||||
data.message = '<textarea cols="40" rows="15" class="w-100">' + data.message + '</textarea>';
|
||||
var $ajaxDialog = $('<div>' + data.message + '</div>').dialog({
|
||||
classes: {
|
||||
'ui-dialog-titlebar-close': 'btn-close'
|
||||
},
|
||||
width: 500,
|
||||
buttons: buttonOptions,
|
||||
title: data.title
|
||||
});
|
||||
// Attach syntax highlighted editor to export dialog
|
||||
/**
|
||||
* @var $elm jQuery object containing the reference
|
||||
* to the Export textarea.
|
||||
*/
|
||||
var $elm = $ajaxDialog.find('textarea');
|
||||
Functions.getSqlEditor($elm);
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
} // end showExport()
|
||||
},
|
||||
|
||||
// end exportDialog()
|
||||
editorDialog: function (isNew, $this) {
|
||||
var that = this;
|
||||
/**
|
||||
* @var $edit_row jQuery object containing the reference to
|
||||
* the row of the the item being edited
|
||||
* from the list of items
|
||||
*/
|
||||
var $editRow = null;
|
||||
if ($this.hasClass('edit_anchor')) {
|
||||
// Remember the row of the item being edited for later,
|
||||
// so that if the edit is successful, we can replace the
|
||||
// row with info about the modified item.
|
||||
$editRow = $this.parents('tr');
|
||||
}
|
||||
/**
|
||||
* @var $msg jQuery object containing the reference to
|
||||
* the AJAX message shown to the user
|
||||
*/
|
||||
var $msg = Functions.ajaxShowMessage();
|
||||
$.get($this.attr('href'), {
|
||||
'ajax_request': true
|
||||
}, function (data) {
|
||||
if (data.success === true) {
|
||||
// We have successfully fetched the editor form
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
/**
|
||||
* @var buttonOptions Object containing options
|
||||
* for jQueryUI dialog buttons
|
||||
*/
|
||||
var buttonOptions = {
|
||||
[Messages.strGo]: {
|
||||
text: Messages.strGo,
|
||||
class: 'btn btn-primary'
|
||||
},
|
||||
[Messages.strClose]: {
|
||||
text: Messages.strClose,
|
||||
class: 'btn btn-secondary'
|
||||
}
|
||||
};
|
||||
// Now define the function that is called when
|
||||
// the user presses the "Go" button
|
||||
buttonOptions[Messages.strGo].click = function () {
|
||||
// Move the data from the codemirror editor back to the
|
||||
// textarea, where it can be used in the form submission.
|
||||
if (typeof CodeMirror !== 'undefined') {
|
||||
that.syntaxHiglighter.save();
|
||||
}
|
||||
// Validate editor and submit request, if passed.
|
||||
if (that.validate()) {
|
||||
/**
|
||||
* @var data Form data to be sent in the AJAX request
|
||||
*/
|
||||
var data = $('form.rte_form').last().serialize();
|
||||
$msg = Functions.ajaxShowMessage(Messages.strProcessingRequest);
|
||||
var url = $('form.rte_form').last().attr('action');
|
||||
$.post(url, data, function (data) {
|
||||
if (data.success === true) {
|
||||
// Item created successfully
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
Functions.slidingMessage(data.message);
|
||||
that.$ajaxDialog.dialog('close');
|
||||
// If we are in 'edit' mode, we must
|
||||
// remove the reference to the old row.
|
||||
if (mode === 'edit' && $editRow !== null) {
|
||||
$editRow.remove();
|
||||
}
|
||||
// Sometimes, like when moving a trigger from
|
||||
// a table to another one, the new row should
|
||||
// not be inserted into the list. In this case
|
||||
// "data.insert" will be set to false.
|
||||
if (data.insert) {
|
||||
// Insert the new row at the correct
|
||||
// location in the list of items
|
||||
/**
|
||||
* @var text Contains the name of an item from
|
||||
* the list that is used in comparisons
|
||||
* to find the correct location where
|
||||
* to insert a new row.
|
||||
*/
|
||||
var text = '';
|
||||
/**
|
||||
* @var inserted Whether a new item has been
|
||||
* inserted in the list or not
|
||||
*/
|
||||
var inserted = false;
|
||||
$('table.data').find('tr').each(function () {
|
||||
text = $(this).children('td').eq(0).find('strong').text().toUpperCase().trim();
|
||||
if (text !== '' && text > data.name) {
|
||||
$(this).before(data.new_row);
|
||||
inserted = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (!inserted) {
|
||||
// If we didn't manage to insert the row yet,
|
||||
// it must belong at the end of the list,
|
||||
// so we insert it there.
|
||||
$('table.data').append(data.new_row);
|
||||
}
|
||||
// Fade-in the new row
|
||||
$('tr.ajaxInsert').show('slow').removeClass('ajaxInsert');
|
||||
} else if ($('table.data').find('tr').has('td').length === 0) {
|
||||
// If we are not supposed to insert the new row,
|
||||
// we will now check if the table is empty and
|
||||
// needs to be hidden. This will be the case if
|
||||
// we were editing the only item in the list,
|
||||
// which we removed and will not be inserting
|
||||
// something else in its place.
|
||||
$('table.data').hide('slow', function () {
|
||||
$('#nothing2display').show('slow');
|
||||
});
|
||||
}
|
||||
// Now we have inserted the row at the correct
|
||||
// position, but surely at least some row classes
|
||||
// are wrong now. So we will iterate through
|
||||
// all rows and assign correct classes to them
|
||||
/**
|
||||
* @var ct Count of processed rows
|
||||
*/
|
||||
var ct = 0;
|
||||
/**
|
||||
* @var rowclass Class to be attached to the row
|
||||
* that is being processed
|
||||
*/
|
||||
var rowclass = '';
|
||||
$('table.data').find('tr').has('td').each(function () {
|
||||
rowclass = ct % 2 === 0 ? 'odd' : 'even';
|
||||
$(this).removeClass().addClass(rowclass);
|
||||
ct++;
|
||||
});
|
||||
// If this is the first item being added, remove
|
||||
// the "No items" message and show the list.
|
||||
if ($('table.data').find('tr').has('td').length > 0 && $('#nothing2display').is(':visible')) {
|
||||
$('#nothing2display').hide('slow', function () {
|
||||
$('table.data').show('slow');
|
||||
});
|
||||
}
|
||||
Navigation.reload();
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
} // end "if (that.validate())"
|
||||
}; // end of function that handles the submission of the Editor
|
||||
buttonOptions[Messages.strClose].click = function () {
|
||||
$(this).dialog('close');
|
||||
};
|
||||
/**
|
||||
* Display the dialog to the user
|
||||
*/
|
||||
that.$ajaxDialog = $('<div id="rteDialog">' + data.message + '</div>').dialog({
|
||||
classes: {
|
||||
'ui-dialog-titlebar-close': 'btn-close'
|
||||
},
|
||||
width: 700,
|
||||
minWidth: 500,
|
||||
buttons: buttonOptions,
|
||||
// Issue #15810 - use button titles for modals (eg: new procedure)
|
||||
// Respect the order: title on href tag, href content, title sent in response
|
||||
title: $this.attr('title') || $this.text() || $(data.title).text(),
|
||||
modal: true,
|
||||
open: function () {
|
||||
$('#rteDialog').dialog('option', 'max-height', $(window).height());
|
||||
if ($('#rteDialog').parents('.ui-dialog').height() > $(window).height()) {
|
||||
$('#rteDialog').dialog('option', 'height', $(window).height());
|
||||
}
|
||||
$(this).find('input[name=item_name]').trigger('focus');
|
||||
$(this).find('input.datefield').each(function () {
|
||||
Functions.addDatepicker($(this).css('width', '95%'), 'date');
|
||||
});
|
||||
$(this).find('input.datetimefield').each(function () {
|
||||
Functions.addDatepicker($(this).css('width', '95%'), 'datetime');
|
||||
});
|
||||
$.datepicker.initialized = false;
|
||||
},
|
||||
close: function () {
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
/**
|
||||
* @var mode Used to remember whether the editor is in
|
||||
* "Edit" or "Add" mode
|
||||
*/
|
||||
var mode = 'add';
|
||||
if ($('input[name=editor_process_edit]').length > 0) {
|
||||
mode = 'edit';
|
||||
}
|
||||
// Attach syntax highlighted editor to the definition
|
||||
/**
|
||||
* @var elm jQuery object containing the reference to
|
||||
* the Definition textarea.
|
||||
*/
|
||||
var $elm = $('textarea[name=item_definition]').last();
|
||||
var linterOptions = {};
|
||||
linterOptions.eventEditor = true;
|
||||
that.syntaxHiglighter = Functions.getSqlEditor($elm, {}, 'both', linterOptions);
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.get()
|
||||
},
|
||||
|
||||
dropDialog: function ($this) {
|
||||
/**
|
||||
* @var $curr_row Object containing reference to the current row
|
||||
*/
|
||||
var $currRow = $this.parents('tr');
|
||||
/**
|
||||
* @var question String containing the question to be asked for confirmation
|
||||
*/
|
||||
var question = $('<div></div>').text($currRow.children('td').children('.drop_sql').html());
|
||||
// We ask for confirmation first here, before submitting the ajax request
|
||||
$this.confirm(question, $this.attr('href'), function (url) {
|
||||
/**
|
||||
* @var msg jQuery object containing the reference to
|
||||
* the AJAX message shown to the user
|
||||
*/
|
||||
var $msg = Functions.ajaxShowMessage(Messages.strProcessingRequest);
|
||||
var params = Functions.getJsConfirmCommonParam(this, $this.getPostData());
|
||||
$.post(url, params, function (data) {
|
||||
if (data.success === true) {
|
||||
/**
|
||||
* @var $table Object containing reference
|
||||
* to the main list of elements
|
||||
*/
|
||||
var $table = $currRow.parent();
|
||||
// Check how many rows will be left after we remove
|
||||
// the one that the user has requested us to remove
|
||||
if ($table.find('tr').length === 3) {
|
||||
// If there are two rows left, it means that they are
|
||||
// the header of the table and the rows that we are
|
||||
// about to remove, so after the removal there will be
|
||||
// nothing to show in the table, so we hide it.
|
||||
$table.hide('slow', function () {
|
||||
$(this).find('tr.even, tr.odd').remove();
|
||||
$('.withSelected').remove();
|
||||
$('#nothing2display').show('slow');
|
||||
});
|
||||
} else {
|
||||
$currRow.hide('slow', function () {
|
||||
$(this).remove();
|
||||
// Now we have removed the row from the list, but maybe
|
||||
// some row classes are wrong now. So we will iterate
|
||||
// through all rows and assign correct classes to them.
|
||||
/**
|
||||
* @var ct Count of processed rows
|
||||
*/
|
||||
var ct = 0;
|
||||
/**
|
||||
* @var rowclass Class to be attached to the row
|
||||
* that is being processed
|
||||
*/
|
||||
var rowclass = '';
|
||||
$table.find('tr').has('td').each(function () {
|
||||
rowclass = ct % 2 === 1 ? 'odd' : 'even';
|
||||
$(this).removeClass().addClass(rowclass);
|
||||
ct++;
|
||||
});
|
||||
});
|
||||
}
|
||||
// Get rid of the "Loading" message
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
// Show the query that we just executed
|
||||
Functions.slidingMessage(data.sql_query);
|
||||
Navigation.reload();
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
});
|
||||
},
|
||||
|
||||
dropMultipleDialog: function ($this) {
|
||||
// We ask for confirmation here
|
||||
$this.confirm(Messages.strDropRTEitems, '', function () {
|
||||
/**
|
||||
* @var msg jQuery object containing the reference to
|
||||
* the AJAX message shown to the user
|
||||
*/
|
||||
var $msg = Functions.ajaxShowMessage(Messages.strProcessingRequest);
|
||||
|
||||
// drop anchors of all selected rows
|
||||
var dropAnchors = $('input.checkall:checked').parents('tr').find('.drop_anchor');
|
||||
var success = true;
|
||||
var count = dropAnchors.length;
|
||||
var returnCount = 0;
|
||||
dropAnchors.each(function () {
|
||||
var $anchor = $(this);
|
||||
/**
|
||||
* @var $curr_row Object containing reference to the current row
|
||||
*/
|
||||
var $currRow = $anchor.parents('tr');
|
||||
var params = Functions.getJsConfirmCommonParam(this, $anchor.getPostData());
|
||||
$.post($anchor.attr('href'), params, function (data) {
|
||||
returnCount++;
|
||||
if (data.success === true) {
|
||||
/**
|
||||
* @var $table Object containing reference
|
||||
* to the main list of elements
|
||||
*/
|
||||
var $table = $currRow.parent();
|
||||
// Check how many rows will be left after we remove
|
||||
// the one that the user has requested us to remove
|
||||
if ($table.find('tr').length === 3) {
|
||||
// If there are two rows left, it means that they are
|
||||
// the header of the table and the rows that we are
|
||||
// about to remove, so after the removal there will be
|
||||
// nothing to show in the table, so we hide it.
|
||||
$table.hide('slow', function () {
|
||||
$(this).find('tr.even, tr.odd').remove();
|
||||
$('.withSelected').remove();
|
||||
$('#nothing2display').show('slow');
|
||||
});
|
||||
} else {
|
||||
$currRow.hide('fast', function () {
|
||||
// we will iterate
|
||||
// through all rows and assign correct classes to them.
|
||||
/**
|
||||
* @var ct Count of processed rows
|
||||
*/
|
||||
var ct = 0;
|
||||
/**
|
||||
* @var rowclass Class to be attached to the row
|
||||
* that is being processed
|
||||
*/
|
||||
var rowclass = '';
|
||||
$table.find('tr').has('td').each(function () {
|
||||
rowclass = ct % 2 === 1 ? 'odd' : 'even';
|
||||
$(this).removeClass().addClass(rowclass);
|
||||
ct++;
|
||||
});
|
||||
});
|
||||
$currRow.remove();
|
||||
}
|
||||
if (returnCount === count) {
|
||||
if (success) {
|
||||
// Get rid of the "Loading" message
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
$('#rteListForm_checkall').prop({
|
||||
checked: false,
|
||||
indeterminate: false
|
||||
});
|
||||
}
|
||||
Navigation.reload();
|
||||
}
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
success = false;
|
||||
if (returnCount === count) {
|
||||
Navigation.reload();
|
||||
}
|
||||
}
|
||||
}); // end $.post()
|
||||
}); // end drop_anchors.each()
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Validate custom editor form fields.
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
validateCustom: function () {
|
||||
/**
|
||||
* @var elm a jQuery object containing the reference
|
||||
* to an element that is being validated
|
||||
*/
|
||||
var $elm = null;
|
||||
if (this.$ajaxDialog.find('select[name=item_type]').find(':selected').val() === 'RECURRING') {
|
||||
// The interval field must not be empty for recurring events
|
||||
$elm = this.$ajaxDialog.find('input[name=item_interval_value]');
|
||||
if ($elm.val() === '') {
|
||||
$elm.trigger('focus');
|
||||
alert(Messages.strFormEmpty);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// The execute_at field must not be empty for "once off" events
|
||||
$elm = this.$ajaxDialog.find('input[name=item_execute_at]');
|
||||
if ($elm.val() === '') {
|
||||
$elm.trigger('focus');
|
||||
alert(Messages.strFormEmpty);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
AJAX.registerOnload('database/events.js', function () {
|
||||
/**
|
||||
* Attach Ajax event handlers for the Add/Edit functionality.
|
||||
*/
|
||||
$(document).on('click', 'a.ajax.add_anchor, a.ajax.edit_anchor', function (event) {
|
||||
event.preventDefault();
|
||||
if ($(this).hasClass('add_anchor')) {
|
||||
$.datepicker.initialized = false;
|
||||
}
|
||||
DatabaseEvents.editorDialog($(this).hasClass('add_anchor'), $(this));
|
||||
});
|
||||
|
||||
/**
|
||||
* Attach Ajax event handlers for Export
|
||||
*/
|
||||
$(document).on('click', 'a.ajax.export_anchor', function (event) {
|
||||
event.preventDefault();
|
||||
DatabaseEvents.exportDialog($(this));
|
||||
}); // end $(document).on()
|
||||
|
||||
$(document).on('click', '#bulkActionExportButton', function (event) {
|
||||
event.preventDefault();
|
||||
DatabaseEvents.exportDialog($(this));
|
||||
}); // end $(document).on()
|
||||
|
||||
/**
|
||||
* Attach Ajax event handlers for Drop functionality
|
||||
*/
|
||||
$(document).on('click', 'a.ajax.drop_anchor', function (event) {
|
||||
event.preventDefault();
|
||||
DatabaseEvents.dropDialog($(this));
|
||||
}); // end $(document).on()
|
||||
|
||||
$(document).on('click', '#bulkActionDropButton', function (event) {
|
||||
event.preventDefault();
|
||||
DatabaseEvents.dropMultipleDialog($(this));
|
||||
}); // end $(document).on()
|
||||
|
||||
/**
|
||||
* Attach Ajax event handlers for the "Change event type" functionality, so that the correct
|
||||
* rows are shown in the editor when changing the event type
|
||||
*/
|
||||
$(document).on('change', 'select[name=item_type]', function () {
|
||||
$(this).closest('table').find('tr.recurring_event_row, tr.onetime_event_row').toggle();
|
||||
});
|
||||
});
|
207
admin/phpMyAdmin/js/dist/database/multi_table_query.js
vendored
Normal file
207
admin/phpMyAdmin/js/dist/database/multi_table_query.js
vendored
Normal file
|
@ -0,0 +1,207 @@
|
|||
/**
|
||||
* @fileoverview function used in QBE for DB
|
||||
* @name Database Operations
|
||||
*
|
||||
* @requires jQuery
|
||||
* @requires jQueryUI
|
||||
* @requires js/functions.js
|
||||
* @requires js/database/query_generator.js
|
||||
*
|
||||
*/
|
||||
|
||||
/* global generateFromBlock, generateWhereBlock */ // js/database/query_generator.js
|
||||
|
||||
/**
|
||||
* js file for handling AJAX and other events in /database/multi-table-query
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unbind all event handlers before tearing down a page
|
||||
*/
|
||||
AJAX.registerTeardown('database/multi_table_query.js', function () {
|
||||
$('.tableNameSelect').each(function () {
|
||||
$(this).off('change');
|
||||
});
|
||||
$('#update_query_button').off('click');
|
||||
$('#add_column_button').off('click');
|
||||
});
|
||||
AJAX.registerOnload('database/multi_table_query.js', function () {
|
||||
var editor = Functions.getSqlEditor($('#MultiSqlquery'), {}, 'both');
|
||||
$('.CodeMirror-line').css('text-align', 'left');
|
||||
editor.setSize(-1, 50);
|
||||
var columnCount = 3;
|
||||
addNewColumnCallbacks();
|
||||
$('#update_query_button').on('click', function () {
|
||||
var columns = [];
|
||||
var tableAliases = {};
|
||||
$('.tableNameSelect').each(function () {
|
||||
var $show = $(this).siblings('.show_col').first();
|
||||
if ($(this).val() !== '' && $show.prop('checked')) {
|
||||
var tableAlias = $(this).siblings('.table_alias').first().val();
|
||||
var columnAlias = $(this).siblings('.col_alias').first().val();
|
||||
if (tableAlias !== '') {
|
||||
columns.push([tableAlias, $(this).siblings('.columnNameSelect').first().val()]);
|
||||
} else {
|
||||
columns.push([$(this).val(), $(this).siblings('.columnNameSelect').first().val()]);
|
||||
}
|
||||
columns[columns.length - 1].push(columnAlias);
|
||||
if ($(this).val() in tableAliases) {
|
||||
if (!tableAliases[$(this).val()].includes(tableAlias)) {
|
||||
tableAliases[$(this).val()].push(tableAlias);
|
||||
}
|
||||
} else {
|
||||
tableAliases[$(this).val()] = [tableAlias];
|
||||
}
|
||||
}
|
||||
});
|
||||
if (Object.keys(tableAliases).length === 0) {
|
||||
Functions.ajaxShowMessage('Nothing selected', false, 'error');
|
||||
return;
|
||||
}
|
||||
var foreignKeys;
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
async: false,
|
||||
url: 'index.php?route=/database/multi-table-query/tables',
|
||||
data: {
|
||||
'server': sessionStorage.server,
|
||||
'db': $('#db_name').val(),
|
||||
'tables': Object.keys(tableAliases),
|
||||
'ajax_request': '1',
|
||||
'token': CommonParams.get('token')
|
||||
},
|
||||
success: function (response) {
|
||||
foreignKeys = response.foreignKeyConstrains;
|
||||
}
|
||||
});
|
||||
var query = 'SELECT ' + '`' + Functions.escapeBacktick(columns[0][0]) + '`.';
|
||||
if (columns[0][1] === '*') {
|
||||
query += '*';
|
||||
} else {
|
||||
query += '`' + Functions.escapeBacktick(columns[0][1]) + '`';
|
||||
}
|
||||
if (columns[0][2] !== '') {
|
||||
query += ' AS `' + Functions.escapeBacktick(columns[0][2]) + '`';
|
||||
}
|
||||
for (var i = 1; i < columns.length; i++) {
|
||||
query += ', `' + Functions.escapeBacktick(columns[i][0]) + '`.';
|
||||
if (columns[i][1] === '*') {
|
||||
query += '*';
|
||||
} else {
|
||||
query += '`' + Functions.escapeBacktick(columns[i][1]) + '`';
|
||||
}
|
||||
if (columns[i][2] !== '') {
|
||||
query += ' AS `' + Functions.escapeBacktick(columns[i][2]) + '`';
|
||||
}
|
||||
}
|
||||
query += '\nFROM ';
|
||||
query += generateFromBlock(tableAliases, foreignKeys);
|
||||
var $criteriaColCount = $('.criteria_col:checked').length;
|
||||
if ($criteriaColCount > 0) {
|
||||
query += '\nWHERE ';
|
||||
query += generateWhereBlock();
|
||||
}
|
||||
query += ';';
|
||||
editor.getDoc().setValue(query);
|
||||
});
|
||||
$('#submit_query').on('click', function () {
|
||||
var query = editor.getDoc().getValue();
|
||||
// Verifying that the query is not empty
|
||||
if (query === '') {
|
||||
Functions.ajaxShowMessage(Messages.strEmptyQuery, false, 'error');
|
||||
return;
|
||||
}
|
||||
var data = {
|
||||
'db': $('#db_name').val(),
|
||||
'sql_query': query,
|
||||
'ajax_request': '1',
|
||||
'server': CommonParams.get('server'),
|
||||
'token': CommonParams.get('token')
|
||||
};
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'index.php?route=/database/multi-table-query/query',
|
||||
data: data,
|
||||
success: function (data) {
|
||||
var $resultsDom = $(data.message);
|
||||
$resultsDom.find('.ajax:not(.pageselector)').each(function () {
|
||||
$(this).on('click', function (event) {
|
||||
event.preventDefault();
|
||||
});
|
||||
});
|
||||
$resultsDom.find('.autosubmit, .pageselector, .showAllRows, .filter_rows').each(function () {
|
||||
$(this).on('change click select focus', function (event) {
|
||||
event.preventDefault();
|
||||
});
|
||||
});
|
||||
$('#sql_results').html($resultsDom);
|
||||
$('#slide-handle').trigger('click'); // Collapse search criteria area
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#add_column_button').on('click', function () {
|
||||
columnCount++;
|
||||
var $newColumnDom = $($('#new_column_layout').html()).clone();
|
||||
$newColumnDom.find('.jsCriteriaButton').first().attr('data-bs-target', '#criteriaOptionsExtra' + columnCount.toString());
|
||||
$newColumnDom.find('.jsCriteriaButton').first().attr('aria-controls', 'criteriaOptionsExtra' + columnCount.toString());
|
||||
$newColumnDom.find('.jsCriteriaOptions').first().attr('id', 'criteriaOptionsExtra' + columnCount.toString());
|
||||
$('#add_column_button').parent().before($newColumnDom);
|
||||
addNewColumnCallbacks();
|
||||
});
|
||||
function addNewColumnCallbacks() {
|
||||
$('.tableNameSelect').each(function () {
|
||||
$(this).on('change', function () {
|
||||
var $sibs = $(this).siblings('.columnNameSelect');
|
||||
if ($sibs.length === 0) {
|
||||
$sibs = $(this).parent().parent().find('.columnNameSelect');
|
||||
}
|
||||
$sibs.first().html($('#' + $(this).find(':selected').data('hash')).html());
|
||||
});
|
||||
});
|
||||
$('.jsRemoveColumn').each(function () {
|
||||
$(this).on('click', function () {
|
||||
$(this).parent().remove();
|
||||
});
|
||||
});
|
||||
$('.jsCriteriaButton').each(function () {
|
||||
$(this).on('click', function (event, from) {
|
||||
if (from === null) {
|
||||
var $checkbox = $(this).siblings('.criteria_col').first();
|
||||
$checkbox.prop('checked', !$checkbox.prop('checked'));
|
||||
}
|
||||
var $criteriaColCount = $('.criteria_col:checked').length;
|
||||
if ($criteriaColCount > 1) {
|
||||
$(this).siblings('.jsCriteriaOptions').first().find('.logical_operator').first().css('display', 'table-row');
|
||||
}
|
||||
});
|
||||
});
|
||||
$('.criteria_col').each(function () {
|
||||
$(this).on('change', function () {
|
||||
var $anchor = $(this).siblings('.jsCriteriaButton').first();
|
||||
if ($(this).is(':checked') && !$anchor.hasClass('collapsed')) {
|
||||
// Do not collapse on checkbox tick as it does not make sense
|
||||
// The user has it open and wants to tick the box
|
||||
return;
|
||||
}
|
||||
$anchor.trigger('click', ['Trigger']);
|
||||
});
|
||||
});
|
||||
$('.criteria_rhs').each(function () {
|
||||
$(this).on('change', function () {
|
||||
var $rhsCol = $(this).parent().parent().siblings('.rhs_table').first();
|
||||
var $rhsText = $(this).parent().parent().siblings('.rhs_text').first();
|
||||
if ($(this).val() === 'text') {
|
||||
$rhsCol.css('display', 'none');
|
||||
$rhsText.css('display', 'table-row');
|
||||
} else if ($(this).val() === 'anotherColumn') {
|
||||
$rhsText.css('display', 'none');
|
||||
$rhsCol.css('display', 'table-row');
|
||||
} else {
|
||||
$rhsText.css('display', 'none');
|
||||
$rhsCol.css('display', 'none');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
157
admin/phpMyAdmin/js/dist/database/operations.js
vendored
Normal file
157
admin/phpMyAdmin/js/dist/database/operations.js
vendored
Normal file
|
@ -0,0 +1,157 @@
|
|||
/**
|
||||
* @fileoverview function used in server privilege pages
|
||||
* @name Database Operations
|
||||
*
|
||||
* @requires jQuery
|
||||
* @requires jQueryUI
|
||||
* @requires js/functions.js
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ajax event handlers here for /database/operations
|
||||
*
|
||||
* Actions Ajaxified here:
|
||||
* Rename Database
|
||||
* Copy Database
|
||||
* Change Charset
|
||||
* Drop Database
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unbind all event handlers before tearing down a page
|
||||
*/
|
||||
AJAX.registerTeardown('database/operations.js', function () {
|
||||
$(document).off('submit', '#rename_db_form.ajax');
|
||||
$(document).off('submit', '#copy_db_form.ajax');
|
||||
$(document).off('submit', '#change_db_charset_form.ajax');
|
||||
$(document).off('click', '#drop_db_anchor.ajax');
|
||||
});
|
||||
AJAX.registerOnload('database/operations.js', function () {
|
||||
/**
|
||||
* Ajax event handlers for 'Rename Database'
|
||||
*/
|
||||
$(document).on('submit', '#rename_db_form.ajax', function (event) {
|
||||
event.preventDefault();
|
||||
if (Functions.emptyCheckTheField(this, 'newname')) {
|
||||
Functions.ajaxShowMessage(Messages.strFormEmpty, false, 'error');
|
||||
return false;
|
||||
}
|
||||
var oldDbName = CommonParams.get('db');
|
||||
var newDbName = $('#new_db_name').val();
|
||||
if (newDbName === oldDbName) {
|
||||
Functions.ajaxShowMessage(Messages.strDatabaseRenameToSameName, false, 'error');
|
||||
return false;
|
||||
}
|
||||
var $form = $(this);
|
||||
var question = Functions.escapeHtml('CREATE DATABASE ' + newDbName + ' / DROP DATABASE ' + oldDbName);
|
||||
Functions.prepareForAjaxRequest($form);
|
||||
$form.confirm(question, $form.attr('action'), function (url) {
|
||||
Functions.ajaxShowMessage(Messages.strRenamingDatabases, false);
|
||||
$.post(url, $('#rename_db_form').serialize() + CommonParams.get('arg_separator') + 'is_js_confirmed=1', function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
Functions.ajaxShowMessage(data.message);
|
||||
CommonParams.set('db', data.newname);
|
||||
Navigation.reload(function () {
|
||||
$('#pma_navigation_tree').find('a:not(\'.expander\')').each(function () {
|
||||
var $thisAnchor = $(this);
|
||||
if ($thisAnchor.text() === data.newname) {
|
||||
// simulate a click on the new db name
|
||||
// in navigation
|
||||
$thisAnchor.trigger('click');
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
});
|
||||
}); // end Rename Database
|
||||
|
||||
/**
|
||||
* Ajax Event Handler for 'Copy Database'
|
||||
*/
|
||||
$(document).on('submit', '#copy_db_form.ajax', function (event) {
|
||||
event.preventDefault();
|
||||
if (Functions.emptyCheckTheField(this, 'newname')) {
|
||||
Functions.ajaxShowMessage(Messages.strFormEmpty, false, 'error');
|
||||
return false;
|
||||
}
|
||||
Functions.ajaxShowMessage(Messages.strCopyingDatabase, false);
|
||||
var $form = $(this);
|
||||
Functions.prepareForAjaxRequest($form);
|
||||
$.post($form.attr('action'), $form.serialize(), function (data) {
|
||||
// use messages that stay on screen
|
||||
$('.alert-success, .alert-danger').fadeOut();
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
if ($('#checkbox_switch').is(':checked')) {
|
||||
CommonParams.set('db', data.newname);
|
||||
CommonActions.refreshMain(false, function () {
|
||||
Functions.ajaxShowMessage(data.message);
|
||||
});
|
||||
} else {
|
||||
CommonParams.set('db', data.db);
|
||||
Functions.ajaxShowMessage(data.message);
|
||||
}
|
||||
Navigation.reload();
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
}); // end copy database
|
||||
|
||||
/**
|
||||
* Change tables columns visible only if change tables is checked
|
||||
*/
|
||||
$('#span_change_all_tables_columns_collations').hide();
|
||||
$('#checkbox_change_all_tables_collations').on('click', function () {
|
||||
$('#span_change_all_tables_columns_collations').toggle();
|
||||
});
|
||||
|
||||
/**
|
||||
* Ajax Event handler for 'Change Charset' of the database
|
||||
*/
|
||||
$(document).on('submit', '#change_db_charset_form.ajax', function (event) {
|
||||
event.preventDefault();
|
||||
var $form = $(this);
|
||||
Functions.prepareForAjaxRequest($form);
|
||||
Functions.ajaxShowMessage(Messages.strChangingCharset);
|
||||
$.post($form.attr('action'), $form.serialize(), function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
Functions.ajaxShowMessage(data.message);
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
}); // end change charset
|
||||
|
||||
/**
|
||||
* Ajax event handlers for Drop Database
|
||||
*/
|
||||
$(document).on('click', '#drop_db_anchor.ajax', function (event) {
|
||||
event.preventDefault();
|
||||
var $link = $(this);
|
||||
/**
|
||||
* @var {String} question String containing the question to be asked for confirmation
|
||||
*/
|
||||
var question = Messages.strDropDatabaseStrongWarning + ' ';
|
||||
question += Functions.sprintf(Messages.strDoYouReally, 'DROP DATABASE `' + Functions.escapeHtml(CommonParams.get('db') + '`'));
|
||||
var params = Functions.getJsConfirmCommonParam(this, $link.getPostData());
|
||||
$(this).confirm(question, $(this).attr('href'), function (url) {
|
||||
Functions.ajaxShowMessage(Messages.strProcessingRequest);
|
||||
$.post(url, params, function (data) {
|
||||
if (typeof data !== 'undefined' && data.success) {
|
||||
// Database deleted successfully, refresh both the frames
|
||||
Navigation.reload();
|
||||
CommonParams.set('db', '');
|
||||
CommonActions.refreshMain('index.php?route=/server/databases', function () {
|
||||
Functions.ajaxShowMessage(data.message);
|
||||
});
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
82
admin/phpMyAdmin/js/dist/database/qbe.js
vendored
Normal file
82
admin/phpMyAdmin/js/dist/database/qbe.js
vendored
Normal file
|
@ -0,0 +1,82 @@
|
|||
/**
|
||||
* @fileoverview function used in QBE for DB
|
||||
* @name Database Operations
|
||||
*
|
||||
* @requires jQuery
|
||||
* @requires jQueryUI
|
||||
* @requires js/functions.js
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ajax event handlers here for /database/qbe
|
||||
*
|
||||
* Actions Ajaxified here:
|
||||
* Select saved search
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unbind all event handlers before tearing down a page
|
||||
*/
|
||||
AJAX.registerTeardown('database/qbe.js', function () {
|
||||
$(document).off('change', 'select[name^=criteriaColumn]');
|
||||
$(document).off('change', '#searchId');
|
||||
$(document).off('click', '#saveSearch');
|
||||
$(document).off('click', '#updateSearch');
|
||||
$(document).off('click', '#deleteSearch');
|
||||
});
|
||||
AJAX.registerOnload('database/qbe.js', function () {
|
||||
Functions.getSqlEditor($('#textSqlquery'), {}, 'none');
|
||||
$('#tblQbe').width($('#tblQbe').parent().width());
|
||||
$('#tblQbeFooters').width($('#tblQbeFooters').parent().width());
|
||||
$('#tblQbe').on('resize', function () {
|
||||
var newWidthTblQbe = $('#textSqlquery').next().width();
|
||||
$('#tblQbe').width(newWidthTblQbe);
|
||||
$('#tblQbeFooters').width(newWidthTblQbe);
|
||||
});
|
||||
|
||||
/**
|
||||
* Ajax handler to check the corresponding 'show' checkbox when column is selected
|
||||
*/
|
||||
$(document).on('change', 'select[name^=criteriaColumn]', function () {
|
||||
if ($(this).val()) {
|
||||
var index = /\d+/.exec($(this).attr('name'));
|
||||
$('input[name=criteriaShow\\[' + index + '\\]]').prop('checked', true);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Ajax event handlers for 'Select saved search'
|
||||
*/
|
||||
$(document).on('change', '#searchId', function () {
|
||||
$('#action').val('load');
|
||||
$('#formQBE').trigger('submit');
|
||||
});
|
||||
|
||||
/**
|
||||
* Ajax event handlers for 'Create bookmark'
|
||||
*/
|
||||
$(document).on('click', '#saveSearch', function () {
|
||||
$('#action').val('create');
|
||||
});
|
||||
|
||||
/**
|
||||
* Ajax event handlers for 'Update bookmark'
|
||||
*/
|
||||
$(document).on('click', '#updateSearch', function () {
|
||||
$('#action').val('update');
|
||||
});
|
||||
|
||||
/**
|
||||
* Ajax event handlers for 'Delete bookmark'
|
||||
*/
|
||||
$(document).on('click', '#deleteSearch', function () {
|
||||
var question = Functions.sprintf(Messages.strConfirmDeleteQBESearch, $('#searchId').find('option:selected').text());
|
||||
if (!confirm(question)) {
|
||||
return false;
|
||||
}
|
||||
$('#action').val('delete');
|
||||
});
|
||||
var windowwidth = $(window).width();
|
||||
$('.jsresponsive').css('max-width', windowwidth - 35 + 'px');
|
||||
});
|
126
admin/phpMyAdmin/js/dist/database/query_generator.js
vendored
Normal file
126
admin/phpMyAdmin/js/dist/database/query_generator.js
vendored
Normal file
|
@ -0,0 +1,126 @@
|
|||
/**
|
||||
* @fileoverview function used in QBE for DB
|
||||
* @name Database Operations
|
||||
*
|
||||
* @requires jQuery
|
||||
* @requires jQueryUI
|
||||
* @requires js/functions.js
|
||||
*
|
||||
*/
|
||||
|
||||
/* global sprintf */ // js/vendor/sprintf.js
|
||||
|
||||
function getFormatsText() {
|
||||
return {
|
||||
'=': ' = \'%s\'',
|
||||
'>': ' > \'%s\'',
|
||||
'>=': ' >= \'%s\'',
|
||||
'<': ' < \'%s\'',
|
||||
'<=': ' <= \'%s\'',
|
||||
'!=': ' != \'%s\'',
|
||||
'LIKE': ' LIKE \'%s\'',
|
||||
'LIKE %...%': ' LIKE \'%%%s%%\'',
|
||||
'NOT LIKE': ' NOT LIKE \'%s\'',
|
||||
'NOT LIKE %...%': ' NOT LIKE \'%%%s%%\'',
|
||||
'BETWEEN': ' BETWEEN \'%s\'',
|
||||
'NOT BETWEEN': ' NOT BETWEEN \'%s\'',
|
||||
'IS NULL': ' \'%s\' IS NULL',
|
||||
'IS NOT NULL': ' \'%s\' IS NOT NULL',
|
||||
'REGEXP': ' REGEXP \'%s\'',
|
||||
'REGEXP ^...$': ' REGEXP \'^%s$\'',
|
||||
'NOT REGEXP': ' NOT REGEXP \'%s\''
|
||||
};
|
||||
}
|
||||
function generateCondition(criteriaDiv, table) {
|
||||
var query = '`' + Functions.escapeBacktick(table.val()) + '`.';
|
||||
query += '`' + Functions.escapeBacktick(table.siblings('.columnNameSelect').first().val()) + '`';
|
||||
if (criteriaDiv.find('.criteria_rhs').first().val() === 'text') {
|
||||
var formatsText = getFormatsText();
|
||||
query += sprintf(formatsText[criteriaDiv.find('.criteria_op').first().val()], Functions.escapeSingleQuote(criteriaDiv.find('.rhs_text_val').first().val()));
|
||||
} else {
|
||||
query += ' ' + criteriaDiv.find('.criteria_op').first().val();
|
||||
query += ' `' + Functions.escapeBacktick(criteriaDiv.find('.tableNameSelect').first().val()) + '`.';
|
||||
query += '`' + Functions.escapeBacktick(criteriaDiv.find('.columnNameSelect').first().val()) + '`';
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function generateWhereBlock() {
|
||||
var count = 0;
|
||||
var query = '';
|
||||
$('.tableNameSelect').each(function () {
|
||||
var criteriaDiv = $(this).siblings('.jsCriteriaOptions').first();
|
||||
var useCriteria = $(this).siblings('.criteria_col').first();
|
||||
if ($(this).val() !== '' && useCriteria.prop('checked')) {
|
||||
if (count > 0) {
|
||||
criteriaDiv.find('input.logical_op').each(function () {
|
||||
if ($(this).prop('checked')) {
|
||||
query += ' ' + $(this).val() + ' ';
|
||||
}
|
||||
});
|
||||
}
|
||||
query += generateCondition(criteriaDiv, $(this));
|
||||
count++;
|
||||
}
|
||||
});
|
||||
return query;
|
||||
}
|
||||
function generateJoin(newTable, tableAliases, fk) {
|
||||
var query = '';
|
||||
query += ' \n\tLEFT JOIN ' + '`' + Functions.escapeBacktick(newTable) + '`';
|
||||
if (tableAliases[fk.TABLE_NAME][0] !== '') {
|
||||
query += ' AS `' + Functions.escapeBacktick(tableAliases[newTable][0]) + '`';
|
||||
query += ' ON `' + Functions.escapeBacktick(tableAliases[fk.TABLE_NAME][0]) + '`';
|
||||
} else {
|
||||
query += ' ON `' + Functions.escapeBacktick(fk.TABLE_NAME) + '`';
|
||||
}
|
||||
query += '.`' + fk.COLUMN_NAME + '`';
|
||||
if (tableAliases[fk.REFERENCED_TABLE_NAME][0] !== '') {
|
||||
query += ' = `' + Functions.escapeBacktick(tableAliases[fk.REFERENCED_TABLE_NAME][0]) + '`';
|
||||
} else {
|
||||
query += ' = `' + Functions.escapeBacktick(fk.REFERENCED_TABLE_NAME) + '`';
|
||||
}
|
||||
query += '.`' + fk.REFERENCED_COLUMN_NAME + '`';
|
||||
return query;
|
||||
}
|
||||
function existReference(table, fk, usedTables) {
|
||||
var isReferredBy = fk.TABLE_NAME === table && usedTables.includes(fk.REFERENCED_TABLE_NAME);
|
||||
var isReferencedBy = fk.REFERENCED_TABLE_NAME === table && usedTables.includes(fk.TABLE_NAME);
|
||||
return isReferredBy || isReferencedBy;
|
||||
}
|
||||
function tryJoinTable(table, tableAliases, usedTables, foreignKeys) {
|
||||
for (var i = 0; i < foreignKeys.length; i++) {
|
||||
var fk = foreignKeys[i];
|
||||
if (existReference(table, fk, usedTables)) {
|
||||
return generateJoin(table, tableAliases, fk);
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
function appendTable(table, tableAliases, usedTables, foreignKeys) {
|
||||
var query = tryJoinTable(table, tableAliases, usedTables, foreignKeys);
|
||||
if (query === '') {
|
||||
if (usedTables.length > 0) {
|
||||
query += '\n\t, ';
|
||||
}
|
||||
query += '`' + Functions.escapeBacktick(table) + '`';
|
||||
if (tableAliases[table][0] !== '') {
|
||||
query += ' AS `' + Functions.escapeBacktick(tableAliases[table][0]) + '`';
|
||||
}
|
||||
}
|
||||
usedTables.push(table);
|
||||
return query;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function generateFromBlock(tableAliases, foreignKeys) {
|
||||
var usedTables = [];
|
||||
var query = '';
|
||||
for (var table in tableAliases) {
|
||||
if (tableAliases.hasOwnProperty(table)) {
|
||||
query += appendTable(table, tableAliases, usedTables, foreignKeys);
|
||||
}
|
||||
}
|
||||
return query;
|
||||
}
|
914
admin/phpMyAdmin/js/dist/database/routines.js
vendored
Normal file
914
admin/phpMyAdmin/js/dist/database/routines.js
vendored
Normal file
|
@ -0,0 +1,914 @@
|
|||
AJAX.registerTeardown('database/routines.js', function () {
|
||||
$(document).off('click', 'a.ajax.add_anchor');
|
||||
$(document).off('click', 'a.ajax.edit_anchor');
|
||||
$(document).off('click', 'a.ajax.exec_anchor');
|
||||
$(document).off('click', 'a.ajax.export_anchor');
|
||||
$(document).off('click', '#bulkActionExportButton');
|
||||
$(document).off('click', 'a.ajax.drop_anchor');
|
||||
$(document).off('click', '#bulkActionDropButton');
|
||||
$(document).off('change', 'select[name=item_type]');
|
||||
$(document).off('change', 'select[name^=item_param_type]');
|
||||
$(document).off('change', 'select[name=item_returntype]');
|
||||
$(document).off('click', '#addRoutineParameterButton');
|
||||
$(document).off('click', 'a.routine_param_remove_anchor');
|
||||
});
|
||||
const DatabaseRoutines = {
|
||||
/**
|
||||
* @var {string} paramTemplate Template for a row in the routine editor
|
||||
*/
|
||||
paramTemplate: '',
|
||||
/**
|
||||
* @var $ajaxDialog Query object containing the reference to the
|
||||
* dialog that contains the editor
|
||||
*/
|
||||
$ajaxDialog: null,
|
||||
/**
|
||||
* @var syntaxHiglighter Reference to the codemirror editor
|
||||
*/
|
||||
syntaxHiglighter: null,
|
||||
/**
|
||||
* Validate editor form fields.
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
validate: function () {
|
||||
/**
|
||||
* @var $elm a jQuery object containing the reference
|
||||
* to an element that is being validated
|
||||
*/
|
||||
var $elm = null;
|
||||
// Common validation. At the very least the name
|
||||
// and the definition must be provided for an item
|
||||
$elm = $('table.rte_table').last().find('input[name=item_name]');
|
||||
if ($elm.val() === '') {
|
||||
$elm.trigger('focus');
|
||||
alert(Messages.strFormEmpty);
|
||||
return false;
|
||||
}
|
||||
$elm = $('table.rte_table').find('textarea[name=item_definition]');
|
||||
if ($elm.val() === '') {
|
||||
if (this.syntaxHiglighter !== null) {
|
||||
this.syntaxHiglighter.focus();
|
||||
} else {
|
||||
$('textarea[name=item_definition]').last().trigger('focus');
|
||||
}
|
||||
alert(Messages.strFormEmpty);
|
||||
return false;
|
||||
}
|
||||
// The validation has so far passed, so now
|
||||
// we can validate item-specific fields.
|
||||
return this.validateCustom();
|
||||
},
|
||||
exportDialog: function ($this) {
|
||||
var $msg = Functions.ajaxShowMessage();
|
||||
if ($this.attr('id') === 'bulkActionExportButton') {
|
||||
var combined = {
|
||||
success: true,
|
||||
title: Messages.strExport,
|
||||
message: '',
|
||||
error: ''
|
||||
};
|
||||
// export anchors of all selected rows
|
||||
var exportAnchors = $('input.checkall:checked').parents('tr').find('.export_anchor');
|
||||
var count = exportAnchors.length;
|
||||
var returnCount = 0;
|
||||
|
||||
// No routine is exportable (due to privilege issues)
|
||||
if (count === 0) {
|
||||
Functions.ajaxShowMessage(Messages.NoExportable);
|
||||
}
|
||||
var p = $.when();
|
||||
exportAnchors.each(function () {
|
||||
var h = $(this).attr('href');
|
||||
p = p.then(function () {
|
||||
return $.get(h, {
|
||||
'ajax_request': true
|
||||
}, function (data) {
|
||||
returnCount++;
|
||||
if (data.success === true) {
|
||||
combined.message += '\n' + data.message + '\n';
|
||||
if (returnCount === count) {
|
||||
showExport(combined);
|
||||
}
|
||||
} else {
|
||||
// complain even if one export is failing
|
||||
combined.success = false;
|
||||
combined.error += '\n' + data.error + '\n';
|
||||
if (returnCount === count) {
|
||||
showExport(combined);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
$.get($this.attr('href'), {
|
||||
'ajax_request': true
|
||||
}, showExport);
|
||||
}
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
function showExport(data) {
|
||||
if (data.success === true) {
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
/**
|
||||
* @var buttonOptions Object containing options
|
||||
* for jQueryUI dialog buttons
|
||||
*/
|
||||
var buttonOptions = {
|
||||
[Messages.strClose]: {
|
||||
text: Messages.strClose,
|
||||
class: 'btn btn-primary',
|
||||
click: function () {
|
||||
$(this).dialog('close').remove();
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Display the dialog to the user
|
||||
*/
|
||||
data.message = '<textarea cols="40" rows="15" class="w-100">' + data.message + '</textarea>';
|
||||
var $ajaxDialog = $('<div>' + data.message + '</div>').dialog({
|
||||
classes: {
|
||||
'ui-dialog-titlebar-close': 'btn-close'
|
||||
},
|
||||
width: 500,
|
||||
buttons: buttonOptions,
|
||||
title: data.title
|
||||
});
|
||||
// Attach syntax highlighted editor to export dialog
|
||||
/**
|
||||
* @var $elm jQuery object containing the reference
|
||||
* to the Export textarea.
|
||||
*/
|
||||
var $elm = $ajaxDialog.find('textarea');
|
||||
Functions.getSqlEditor($elm);
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
} // end showExport()
|
||||
},
|
||||
|
||||
// end exportDialog()
|
||||
editorDialog: function (isNew, $this) {
|
||||
var that = this;
|
||||
/**
|
||||
* @var $edit_row jQuery object containing the reference to
|
||||
* the row of the the item being edited
|
||||
* from the list of items
|
||||
*/
|
||||
var $editRow = null;
|
||||
if ($this.hasClass('edit_anchor')) {
|
||||
// Remember the row of the item being edited for later,
|
||||
// so that if the edit is successful, we can replace the
|
||||
// row with info about the modified item.
|
||||
$editRow = $this.parents('tr');
|
||||
}
|
||||
/**
|
||||
* @var $msg jQuery object containing the reference to
|
||||
* the AJAX message shown to the user
|
||||
*/
|
||||
var $msg = Functions.ajaxShowMessage();
|
||||
$.get($this.attr('href'), {
|
||||
'ajax_request': true
|
||||
}, function (data) {
|
||||
if (data.success === true) {
|
||||
var buttonOptions = {
|
||||
[Messages.strGo]: {
|
||||
text: Messages.strGo,
|
||||
class: 'btn btn-primary'
|
||||
},
|
||||
[Messages.strClose]: {
|
||||
text: Messages.strClose,
|
||||
class: 'btn btn-secondary'
|
||||
}
|
||||
};
|
||||
// We have successfully fetched the editor form
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
// Now define the function that is called when
|
||||
// the user presses the "Go" button
|
||||
buttonOptions[Messages.strGo].click = function () {
|
||||
// Move the data from the codemirror editor back to the
|
||||
// textarea, where it can be used in the form submission.
|
||||
if (typeof CodeMirror !== 'undefined') {
|
||||
that.syntaxHiglighter.save();
|
||||
}
|
||||
// Validate editor and submit request, if passed.
|
||||
if (that.validate()) {
|
||||
/**
|
||||
* @var data Form data to be sent in the AJAX request
|
||||
*/
|
||||
var data = $('form.rte_form').last().serialize();
|
||||
$msg = Functions.ajaxShowMessage(Messages.strProcessingRequest);
|
||||
var url = $('form.rte_form').last().attr('action');
|
||||
$.post(url, data, function (data) {
|
||||
if (data.success === true) {
|
||||
// Item created successfully
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
Functions.slidingMessage(data.message);
|
||||
that.$ajaxDialog.dialog('close');
|
||||
var tableId = '#' + data.tableType + 'Table';
|
||||
// If we are in 'edit' mode, we must
|
||||
// remove the reference to the old row.
|
||||
if (mode === 'edit' && $editRow !== null) {
|
||||
$editRow.remove();
|
||||
}
|
||||
// Sometimes, like when moving a trigger from
|
||||
// a table to another one, the new row should
|
||||
// not be inserted into the list. In this case
|
||||
// "data.insert" will be set to false.
|
||||
if (data.insert) {
|
||||
// Insert the new row at the correct
|
||||
// location in the list of items
|
||||
/**
|
||||
* @var text Contains the name of an item from
|
||||
* the list that is used in comparisons
|
||||
* to find the correct location where
|
||||
* to insert a new row.
|
||||
*/
|
||||
var text = '';
|
||||
/**
|
||||
* @var inserted Whether a new item has been
|
||||
* inserted in the list or not
|
||||
*/
|
||||
var inserted = false;
|
||||
$(tableId + '.data').find('tr').each(function () {
|
||||
text = $(this).children('td').eq(0).find('strong').text().toUpperCase().trim();
|
||||
if (text !== '' && text > data.name) {
|
||||
$(this).before(data.new_row);
|
||||
inserted = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (!inserted) {
|
||||
// If we didn't manage to insert the row yet,
|
||||
// it must belong at the end of the list,
|
||||
// so we insert it there.
|
||||
$(tableId + '.data').append(data.new_row);
|
||||
}
|
||||
// Fade-in the new row
|
||||
$('tr.ajaxInsert').show('slow').removeClass('ajaxInsert');
|
||||
} else if ($(tableId + '.data').find('tr').has('td').length === 0) {
|
||||
// If we are not supposed to insert the new row,
|
||||
// we will now check if the table is empty and
|
||||
// needs to be hidden. This will be the case if
|
||||
// we were editing the only item in the list,
|
||||
// which we removed and will not be inserting
|
||||
// something else in its place.
|
||||
$(tableId + '.data').hide('slow', function () {
|
||||
$('#nothing2display').show('slow');
|
||||
});
|
||||
}
|
||||
// Now we have inserted the row at the correct
|
||||
// position, but surely at least some row classes
|
||||
// are wrong now. So we will iterate through
|
||||
// all rows and assign correct classes to them
|
||||
/**
|
||||
* @var ct Count of processed rows
|
||||
*/
|
||||
var ct = 0;
|
||||
/**
|
||||
* @var rowclass Class to be attached to the row
|
||||
* that is being processed
|
||||
*/
|
||||
var rowclass = '';
|
||||
$(tableId + '.data').find('tr').has('td').each(function () {
|
||||
rowclass = ct % 2 === 0 ? 'odd' : 'even';
|
||||
$(this).removeClass('odd even').addClass(rowclass);
|
||||
ct++;
|
||||
});
|
||||
// If this is the first item being added, remove
|
||||
// the "No items" message and show the list.
|
||||
if ($(tableId + '.data').find('tr').has('td').length > 0 && $('#nothing2display').is(':visible')) {
|
||||
$('#nothing2display').hide('slow', function () {
|
||||
$(tableId + '.data').show('slow');
|
||||
});
|
||||
}
|
||||
Navigation.reload();
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
} // end "if (that.validate())"
|
||||
}; // end of function that handles the submission of the Editor
|
||||
buttonOptions[Messages.strClose].click = function () {
|
||||
$(this).dialog('close');
|
||||
};
|
||||
/**
|
||||
* Display the dialog to the user
|
||||
*/
|
||||
that.$ajaxDialog = $('<div id="rteDialog">' + data.message + '</div>').dialog({
|
||||
classes: {
|
||||
'ui-dialog-titlebar-close': 'btn-close'
|
||||
},
|
||||
height: 400,
|
||||
width: 700,
|
||||
minWidth: 500,
|
||||
buttons: buttonOptions,
|
||||
// Issue #15810 - use button titles for modals (eg: new procedure)
|
||||
// Respect the order: title on href tag, href content, title sent in response
|
||||
title: $this.attr('title') || $this.text() || $(data.title).text(),
|
||||
modal: true,
|
||||
open: function () {
|
||||
$('#rteDialog').dialog('option', 'max-height', $(window).height());
|
||||
if ($('#rteDialog').parents('.ui-dialog').height() > $(window).height()) {
|
||||
$('#rteDialog').dialog('option', 'height', $(window).height());
|
||||
}
|
||||
$(this).find('input[name=item_name]').trigger('focus');
|
||||
$(this).find('input.datefield').each(function () {
|
||||
Functions.addDatepicker($(this).css('width', '95%'), 'date');
|
||||
});
|
||||
$(this).find('input.datetimefield').each(function () {
|
||||
Functions.addDatepicker($(this).css('width', '95%'), 'datetime');
|
||||
});
|
||||
$.datepicker.initialized = false;
|
||||
},
|
||||
close: function () {
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
/**
|
||||
* @var mode Used to remember whether the editor is in
|
||||
* "Edit" or "Add" mode
|
||||
*/
|
||||
var mode = 'add';
|
||||
if ($('input[name=editor_process_edit]').length > 0) {
|
||||
mode = 'edit';
|
||||
}
|
||||
// Attach syntax highlighted editor to the definition
|
||||
/**
|
||||
* @var elm jQuery object containing the reference to
|
||||
* the Definition textarea.
|
||||
*/
|
||||
var $elm = $('textarea[name=item_definition]').last();
|
||||
var linterOptions = {};
|
||||
linterOptions.routineEditor = true;
|
||||
that.syntaxHiglighter = Functions.getSqlEditor($elm, {}, 'both', linterOptions);
|
||||
|
||||
// Execute item-specific code
|
||||
that.postDialogShow(data);
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.get()
|
||||
},
|
||||
|
||||
dropDialog: function ($this) {
|
||||
/**
|
||||
* @var $curr_row Object containing reference to the current row
|
||||
*/
|
||||
var $currRow = $this.parents('tr');
|
||||
/**
|
||||
* @var question String containing the question to be asked for confirmation
|
||||
*/
|
||||
var question = $('<div></div>').text($currRow.children('td').children('.drop_sql').html());
|
||||
// We ask for confirmation first here, before submitting the ajax request
|
||||
$this.confirm(question, $this.attr('href'), function (url) {
|
||||
/**
|
||||
* @var msg jQuery object containing the reference to
|
||||
* the AJAX message shown to the user
|
||||
*/
|
||||
var $msg = Functions.ajaxShowMessage(Messages.strProcessingRequest);
|
||||
var params = Functions.getJsConfirmCommonParam(this, $this.getPostData());
|
||||
$.post(url, params, function (data) {
|
||||
if (data.success === true) {
|
||||
/**
|
||||
* @var $table Object containing reference
|
||||
* to the main list of elements
|
||||
*/
|
||||
var $table = $currRow.parent().parent();
|
||||
// Check how many rows will be left after we remove
|
||||
// the one that the user has requested us to remove
|
||||
if ($table.find('tr').length === 3) {
|
||||
// If there are two rows left, it means that they are
|
||||
// the header of the table and the rows that we are
|
||||
// about to remove, so after the removal there will be
|
||||
// nothing to show in the table, so we hide it.
|
||||
$table.hide('slow', function () {
|
||||
$(this).find('tr.even, tr.odd').remove();
|
||||
$('.withSelected').remove();
|
||||
$('#nothing2display').show('slow');
|
||||
});
|
||||
} else {
|
||||
$currRow.hide('slow', function () {
|
||||
$(this).remove();
|
||||
// Now we have removed the row from the list, but maybe
|
||||
// some row classes are wrong now. So we will iterate
|
||||
// through all rows and assign correct classes to them.
|
||||
/**
|
||||
* @var ct Count of processed rows
|
||||
*/
|
||||
var ct = 0;
|
||||
/**
|
||||
* @var rowclass Class to be attached to the row
|
||||
* that is being processed
|
||||
*/
|
||||
var rowclass = '';
|
||||
$table.find('tr').has('td').each(function () {
|
||||
rowclass = ct % 2 === 1 ? 'odd' : 'even';
|
||||
$(this).removeClass('odd even').addClass(rowclass);
|
||||
ct++;
|
||||
});
|
||||
});
|
||||
}
|
||||
// Get rid of the "Loading" message
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
// Show the query that we just executed
|
||||
Functions.slidingMessage(data.sql_query);
|
||||
Navigation.reload();
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
});
|
||||
},
|
||||
|
||||
dropMultipleDialog: function ($this) {
|
||||
// We ask for confirmation here
|
||||
$this.confirm(Messages.strDropRTEitems, '', function () {
|
||||
/**
|
||||
* @var msg jQuery object containing the reference to
|
||||
* the AJAX message shown to the user
|
||||
*/
|
||||
var $msg = Functions.ajaxShowMessage(Messages.strProcessingRequest);
|
||||
|
||||
// drop anchors of all selected rows
|
||||
var dropAnchors = $('input.checkall:checked').parents('tr').find('.drop_anchor');
|
||||
var success = true;
|
||||
var count = dropAnchors.length;
|
||||
var returnCount = 0;
|
||||
dropAnchors.each(function () {
|
||||
var $anchor = $(this);
|
||||
/**
|
||||
* @var $curr_row Object containing reference to the current row
|
||||
*/
|
||||
var $currRow = $anchor.parents('tr');
|
||||
var params = Functions.getJsConfirmCommonParam(this, $anchor.getPostData());
|
||||
$.post($anchor.attr('href'), params, function (data) {
|
||||
returnCount++;
|
||||
if (data.success === true) {
|
||||
/**
|
||||
* @var $table Object containing reference
|
||||
* to the main list of elements
|
||||
*/
|
||||
var $table = $currRow.parent().parent();
|
||||
// Check how many rows will be left after we remove
|
||||
// the one that the user has requested us to remove
|
||||
if ($table.find('tr').length === 3) {
|
||||
// If there are two rows left, it means that they are
|
||||
// the header of the table and the rows that we are
|
||||
// about to remove, so after the removal there will be
|
||||
// nothing to show in the table, so we hide it.
|
||||
$table.hide('slow', function () {
|
||||
$(this).find('tr.even, tr.odd').remove();
|
||||
$('.withSelected').remove();
|
||||
$('#nothing2display').show('slow');
|
||||
});
|
||||
} else {
|
||||
$currRow.hide('fast', function () {
|
||||
// we will iterate
|
||||
// through all rows and assign correct classes to them.
|
||||
/**
|
||||
* @var ct Count of processed rows
|
||||
*/
|
||||
var ct = 0;
|
||||
/**
|
||||
* @var rowclass Class to be attached to the row
|
||||
* that is being processed
|
||||
*/
|
||||
var rowclass = '';
|
||||
$table.find('tr').has('td').each(function () {
|
||||
rowclass = ct % 2 === 1 ? 'odd' : 'even';
|
||||
$(this).removeClass('odd even').addClass(rowclass);
|
||||
ct++;
|
||||
});
|
||||
});
|
||||
$currRow.remove();
|
||||
}
|
||||
if (returnCount === count) {
|
||||
if (success) {
|
||||
// Get rid of the "Loading" message
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
$('#rteListForm_checkall').prop({
|
||||
checked: false,
|
||||
indeterminate: false
|
||||
});
|
||||
}
|
||||
Navigation.reload();
|
||||
}
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
success = false;
|
||||
if (returnCount === count) {
|
||||
Navigation.reload();
|
||||
}
|
||||
}
|
||||
}); // end $.post()
|
||||
}); // end drop_anchors.each()
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Execute some code after the ajax dialog for the editor is shown.
|
||||
*
|
||||
* @param data JSON-encoded data from the ajax request
|
||||
*/
|
||||
postDialogShow: function (data) {
|
||||
// Cache the template for a parameter table row
|
||||
DatabaseRoutines.paramTemplate = data.paramTemplate;
|
||||
var that = this;
|
||||
// Make adjustments in the dialog to make it AJAX compatible
|
||||
$('td.routine_param_remove').show();
|
||||
// Enable/disable the 'options' dropdowns for parameters as necessary
|
||||
$('table.routine_params_table').last().find('th[colspan=2]').attr('colspan', '1');
|
||||
$('table.routine_params_table').last().find('tr').has('td').each(function () {
|
||||
that.setOptionsForParameter($(this).find('select[name^=item_param_type]'), $(this).find('input[name^=item_param_length]'), $(this).find('select[name^=item_param_opts_text]'), $(this).find('select[name^=item_param_opts_num]'));
|
||||
});
|
||||
// Enable/disable the 'options' dropdowns for
|
||||
// function return value as necessary
|
||||
this.setOptionsForParameter($('table.rte_table').last().find('select[name=item_returntype]'), $('table.rte_table').last().find('input[name=item_returnlength]'), $('table.rte_table').last().find('select[name=item_returnopts_text]'), $('table.rte_table').last().find('select[name=item_returnopts_num]'));
|
||||
// Allow changing parameter order
|
||||
$('.routine_params_table tbody').sortable({
|
||||
containment: '.routine_params_table tbody',
|
||||
handle: '.dragHandle',
|
||||
stop: function () {
|
||||
that.reindexParameters();
|
||||
}
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Reindexes the parameters after dropping a parameter or reordering parameters
|
||||
*/
|
||||
reindexParameters: function () {
|
||||
/**
|
||||
* @var index Counter used for reindexing the input
|
||||
* fields in the routine parameters table
|
||||
*/
|
||||
var index = 0;
|
||||
$('table.routine_params_table tbody').find('tr').each(function () {
|
||||
$(this).find(':input').each(function () {
|
||||
/**
|
||||
* @var inputname The value of the name attribute of
|
||||
* the input field being reindexed
|
||||
*/
|
||||
var inputname = $(this).attr('name');
|
||||
if (inputname.substr(0, 14) === 'item_param_dir') {
|
||||
$(this).attr('name', inputname.substr(0, 14) + '[' + index + ']');
|
||||
} else if (inputname.substr(0, 15) === 'item_param_name') {
|
||||
$(this).attr('name', inputname.substr(0, 15) + '[' + index + ']');
|
||||
} else if (inputname.substr(0, 15) === 'item_param_type') {
|
||||
$(this).attr('name', inputname.substr(0, 15) + '[' + index + ']');
|
||||
} else if (inputname.substr(0, 17) === 'item_param_length') {
|
||||
$(this).attr('name', inputname.substr(0, 17) + '[' + index + ']');
|
||||
$(this).attr('id', 'item_param_length_' + index);
|
||||
} else if (inputname.substr(0, 20) === 'item_param_opts_text') {
|
||||
$(this).attr('name', inputname.substr(0, 20) + '[' + index + ']');
|
||||
} else if (inputname.substr(0, 19) === 'item_param_opts_num') {
|
||||
$(this).attr('name', inputname.substr(0, 19) + '[' + index + ']');
|
||||
}
|
||||
});
|
||||
index++;
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Validate custom editor form fields.
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
validateCustom: function () {
|
||||
/**
|
||||
* @var isSuccess Stores the outcome of the validation
|
||||
*/
|
||||
var isSuccess = true;
|
||||
/**
|
||||
* @var inputname The value of the "name" attribute for
|
||||
* the field that is being processed
|
||||
*/
|
||||
var inputname = '';
|
||||
this.$ajaxDialog.find('table.routine_params_table').last().find('tr').each(function () {
|
||||
// Every parameter of a routine must have
|
||||
// a non-empty direction, name and type
|
||||
if (isSuccess) {
|
||||
$(this).find(':input').each(function () {
|
||||
inputname = $(this).attr('name');
|
||||
if (inputname.substr(0, 14) === 'item_param_dir' || inputname.substr(0, 15) === 'item_param_name' || inputname.substr(0, 15) === 'item_param_type') {
|
||||
if ($(this).val() === '') {
|
||||
$(this).trigger('focus');
|
||||
isSuccess = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (!isSuccess) {
|
||||
alert(Messages.strFormEmpty);
|
||||
return false;
|
||||
}
|
||||
this.$ajaxDialog.find('table.routine_params_table').last().find('tr').each(function () {
|
||||
// SET, ENUM, VARCHAR and VARBINARY fields must have length/values
|
||||
var $inputtyp = $(this).find('select[name^=item_param_type]');
|
||||
var $inputlen = $(this).find('input[name^=item_param_length]');
|
||||
if ($inputtyp.length && $inputlen.length) {
|
||||
if (($inputtyp.val() === 'ENUM' || $inputtyp.val() === 'SET' || $inputtyp.val().substr(0, 3) === 'VAR') && $inputlen.val() === '') {
|
||||
$inputlen.trigger('focus');
|
||||
isSuccess = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!isSuccess) {
|
||||
alert(Messages.strFormEmpty);
|
||||
return false;
|
||||
}
|
||||
if (this.$ajaxDialog.find('select[name=item_type]').find(':selected').val() === 'FUNCTION') {
|
||||
// The length/values of return variable for functions must
|
||||
// be set, if the type is SET, ENUM, VARCHAR or VARBINARY.
|
||||
var $returntyp = this.$ajaxDialog.find('select[name=item_returntype]');
|
||||
var $returnlen = this.$ajaxDialog.find('input[name=item_returnlength]');
|
||||
if (($returntyp.val() === 'ENUM' || $returntyp.val() === 'SET' || $returntyp.val().substr(0, 3) === 'VAR') && $returnlen.val() === '') {
|
||||
$returnlen.trigger('focus');
|
||||
alert(Messages.strFormEmpty);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($('select[name=item_type]').find(':selected').val() === 'FUNCTION') {
|
||||
// A function must contain a RETURN statement in its definition
|
||||
if (this.$ajaxDialog.find('table.rte_table').find('textarea[name=item_definition]').val().toUpperCase().indexOf('RETURN') < 0) {
|
||||
this.syntaxHiglighter.focus();
|
||||
alert(Messages.MissingReturn);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
/**
|
||||
* Enable/disable the "options" dropdown and "length" input for
|
||||
* parameters and the return variable in the routine editor
|
||||
* as necessary.
|
||||
*
|
||||
* @param $type a jQuery object containing the reference
|
||||
* to the "Type" dropdown box
|
||||
* @param $len a jQuery object containing the reference
|
||||
* to the "Length" input box
|
||||
* @param $text a jQuery object containing the reference
|
||||
* to the dropdown box with options for
|
||||
* parameters of text type
|
||||
* @param $num a jQuery object containing the reference
|
||||
* to the dropdown box with options for
|
||||
* parameters of numeric type
|
||||
*/
|
||||
setOptionsForParameter: function ($type, $len, $text, $num) {
|
||||
/**
|
||||
* @var no_opts a jQuery object containing the reference
|
||||
* to an element to be displayed when no
|
||||
* options are available
|
||||
*/
|
||||
var $noOpts = $text.parent().parent().find('.no_opts');
|
||||
/**
|
||||
* @var no_len a jQuery object containing the reference
|
||||
* to an element to be displayed when no
|
||||
* "length/values" field is available
|
||||
*/
|
||||
var $noLen = $len.parent().parent().find('.no_len');
|
||||
|
||||
// Process for parameter options
|
||||
switch ($type.val()) {
|
||||
case 'TINYINT':
|
||||
case 'SMALLINT':
|
||||
case 'MEDIUMINT':
|
||||
case 'INT':
|
||||
case 'BIGINT':
|
||||
case 'DECIMAL':
|
||||
case 'FLOAT':
|
||||
case 'DOUBLE':
|
||||
case 'REAL':
|
||||
$text.parent().hide();
|
||||
$num.parent().show();
|
||||
$noOpts.hide();
|
||||
break;
|
||||
case 'TINYTEXT':
|
||||
case 'TEXT':
|
||||
case 'MEDIUMTEXT':
|
||||
case 'LONGTEXT':
|
||||
case 'CHAR':
|
||||
case 'VARCHAR':
|
||||
case 'SET':
|
||||
case 'ENUM':
|
||||
$text.parent().show();
|
||||
$num.parent().hide();
|
||||
$noOpts.hide();
|
||||
break;
|
||||
default:
|
||||
$text.parent().hide();
|
||||
$num.parent().hide();
|
||||
$noOpts.show();
|
||||
break;
|
||||
}
|
||||
// Process for parameter length
|
||||
switch ($type.val()) {
|
||||
case 'DATE':
|
||||
case 'TINYBLOB':
|
||||
case 'TINYTEXT':
|
||||
case 'BLOB':
|
||||
case 'TEXT':
|
||||
case 'MEDIUMBLOB':
|
||||
case 'MEDIUMTEXT':
|
||||
case 'LONGBLOB':
|
||||
case 'LONGTEXT':
|
||||
$text.closest('tr').find('a').first().hide();
|
||||
$len.parent().hide();
|
||||
$noLen.show();
|
||||
break;
|
||||
default:
|
||||
if ($type.val() === 'ENUM' || $type.val() === 'SET') {
|
||||
$text.closest('tr').find('a').first().show();
|
||||
} else {
|
||||
$text.closest('tr').find('a').first().hide();
|
||||
}
|
||||
$len.parent().show();
|
||||
$noLen.hide();
|
||||
break;
|
||||
}
|
||||
},
|
||||
executeDialog: function ($this) {
|
||||
/**
|
||||
* @var msg jQuery object containing the reference to
|
||||
* the AJAX message shown to the user
|
||||
*/
|
||||
var $msg = Functions.ajaxShowMessage();
|
||||
var params = Functions.getJsConfirmCommonParam($this[0], $this.getPostData());
|
||||
$.post($this.attr('href'), params, function (data) {
|
||||
if (data.success === true) {
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
// If 'data.dialog' is true we show a dialog with a form
|
||||
// to get the input parameters for routine, otherwise
|
||||
// we just show the results of the query
|
||||
if (data.dialog) {
|
||||
var buttonOptions = {
|
||||
[Messages.strGo]: {
|
||||
text: Messages.strGo,
|
||||
class: 'btn btn-primary'
|
||||
},
|
||||
[Messages.strClose]: {
|
||||
text: Messages.strClose,
|
||||
class: 'btn btn-secondary'
|
||||
}
|
||||
};
|
||||
// Define the function that is called when
|
||||
// the user presses the "Go" button
|
||||
buttonOptions[Messages.strGo].click = function () {
|
||||
/**
|
||||
* @var data Form data to be sent in the AJAX request
|
||||
*/
|
||||
var data = $('form.rte_form').last().serialize();
|
||||
$msg = Functions.ajaxShowMessage(Messages.strProcessingRequest);
|
||||
$.post('index.php?route=/database/routines', data, function (data) {
|
||||
if (data.success === true) {
|
||||
// Routine executed successfully
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
Functions.slidingMessage(data.message);
|
||||
$ajaxDialog.dialog('close');
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
});
|
||||
};
|
||||
buttonOptions[Messages.strClose].click = function () {
|
||||
$(this).dialog('close');
|
||||
};
|
||||
/**
|
||||
* Display the dialog to the user
|
||||
*/
|
||||
var $ajaxDialog = $('<div>' + data.message + '</div>').dialog({
|
||||
classes: {
|
||||
'ui-dialog-titlebar-close': 'btn-close'
|
||||
},
|
||||
width: 650,
|
||||
buttons: buttonOptions,
|
||||
title: data.title,
|
||||
modal: true,
|
||||
close: function () {
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
$ajaxDialog.find('input[name^=params]').first().trigger('focus');
|
||||
/**
|
||||
* Attach the datepickers to the relevant form fields
|
||||
*/
|
||||
$ajaxDialog.find('input.datefield, input.datetimefield').each(function () {
|
||||
Functions.addDatepicker($(this).css('width', '95%'));
|
||||
});
|
||||
/*
|
||||
* Define the function if the user presses enter
|
||||
*/
|
||||
$('form.rte_form').on('keyup', function (event) {
|
||||
event.preventDefault();
|
||||
if (event.keyCode === 13) {
|
||||
/**
|
||||
* @var data Form data to be sent in the AJAX request
|
||||
*/
|
||||
var data = $(this).serialize();
|
||||
$msg = Functions.ajaxShowMessage(Messages.strProcessingRequest);
|
||||
var url = $(this).attr('action');
|
||||
$.post(url, data, function (data) {
|
||||
if (data.success === true) {
|
||||
// Routine executed successfully
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
Functions.slidingMessage(data.message);
|
||||
$('form.rte_form').off('keyup');
|
||||
$ajaxDialog.remove();
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Routine executed successfully
|
||||
Functions.slidingMessage(data.message);
|
||||
}
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
}
|
||||
};
|
||||
|
||||
AJAX.registerOnload('database/routines.js', function () {
|
||||
$(document).on('click', 'a.ajax.add_anchor', function (event) {
|
||||
event.preventDefault();
|
||||
$.datepicker.initialized = false;
|
||||
DatabaseRoutines.editorDialog(true, $(this));
|
||||
});
|
||||
$(document).on('click', 'a.ajax.edit_anchor', function (event) {
|
||||
event.preventDefault();
|
||||
DatabaseRoutines.editorDialog(false, $(this));
|
||||
});
|
||||
$(document).on('click', 'a.ajax.exec_anchor', function (event) {
|
||||
event.preventDefault();
|
||||
DatabaseRoutines.executeDialog($(this));
|
||||
});
|
||||
$(document).on('click', 'a.ajax.export_anchor', function (event) {
|
||||
event.preventDefault();
|
||||
DatabaseRoutines.exportDialog($(this));
|
||||
});
|
||||
$(document).on('click', '#bulkActionExportButton', function (event) {
|
||||
event.preventDefault();
|
||||
DatabaseRoutines.exportDialog($(this));
|
||||
});
|
||||
$(document).on('click', 'a.ajax.drop_anchor', function (event) {
|
||||
event.preventDefault();
|
||||
DatabaseRoutines.dropDialog($(this));
|
||||
});
|
||||
$(document).on('click', '#bulkActionDropButton', function (event) {
|
||||
event.preventDefault();
|
||||
DatabaseRoutines.dropMultipleDialog($(this));
|
||||
});
|
||||
$(document).on('change', 'select[name=item_type]', function () {
|
||||
$(this).closest('table').find('tr.routine_return_row, .routine_direction_cell').toggle();
|
||||
});
|
||||
$(document).on('change', 'select[name^=item_param_type]', function () {
|
||||
const $row = $(this).parents('tr').first();
|
||||
DatabaseRoutines.setOptionsForParameter($row.find('select[name^=item_param_type]'), $row.find('input[name^=item_param_length]'), $row.find('select[name^=item_param_opts_text]'), $row.find('select[name^=item_param_opts_num]'));
|
||||
});
|
||||
$(document).on('change', 'select[name=item_returntype]', function () {
|
||||
const $table = $(this).closest('table.rte_table');
|
||||
DatabaseRoutines.setOptionsForParameter($table.find('select[name=item_returntype]'), $table.find('input[name=item_returnlength]'), $table.find('select[name=item_returnopts_text]'), $table.find('select[name=item_returnopts_num]'));
|
||||
});
|
||||
$(document).on('click', '#addRoutineParameterButton', function (event) {
|
||||
event.preventDefault();
|
||||
/**
|
||||
* @var routine_params_table jQuery object containing the reference
|
||||
* to the routine parameters table
|
||||
*/
|
||||
const $routineParamsTable = $(this).closest('div.ui-dialog').find('.routine_params_table');
|
||||
/**
|
||||
* @var new_param_row A string containing the HTML code for the
|
||||
* new row for the routine parameters table
|
||||
*/
|
||||
const newParamRow = DatabaseRoutines.paramTemplate.replace(/%s/g, $routineParamsTable.find('tr').length - 1);
|
||||
// Append the new row to the parameters table
|
||||
$routineParamsTable.append(newParamRow);
|
||||
// Make sure that the row is correctly shown according to the type of routine
|
||||
if ($(this).closest('div.ui-dialog').find('table.rte_table select[name=item_type]').val() === 'FUNCTION') {
|
||||
$('tr.routine_return_row').show();
|
||||
$('td.routine_direction_cell').hide();
|
||||
}
|
||||
/**
|
||||
* @var newrow jQuery object containing the reference to the newly
|
||||
* inserted row in the routine parameters table
|
||||
*/
|
||||
const $newrow = $(this).closest('div.ui-dialog').find('table.routine_params_table').find('tr').has('td').last();
|
||||
// Enable/disable the 'options' dropdowns for parameters as necessary
|
||||
DatabaseRoutines.setOptionsForParameter($newrow.find('select[name^=item_param_type]'), $newrow.find('input[name^=item_param_length]'), $newrow.find('select[name^=item_param_opts_text]'), $newrow.find('select[name^=item_param_opts_num]'));
|
||||
});
|
||||
$(document).on('click', 'a.routine_param_remove_anchor', function (event) {
|
||||
event.preventDefault();
|
||||
$(this).parent().parent().remove();
|
||||
// After removing a parameter, the indices of the name attributes in
|
||||
// the input fields lose the correct order and need to be reordered.
|
||||
DatabaseRoutines.reindexParameters();
|
||||
});
|
||||
});
|
240
admin/phpMyAdmin/js/dist/database/search.js
vendored
Normal file
240
admin/phpMyAdmin/js/dist/database/search.js
vendored
Normal file
|
@ -0,0 +1,240 @@
|
|||
/**
|
||||
* JavaScript functions used on Database Search page
|
||||
*
|
||||
* @requires jQuery
|
||||
* @requires js/functions.js
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
|
||||
/* global makeGrid */ // js/makegrid.js
|
||||
|
||||
/**
|
||||
* AJAX script for the Database Search page.
|
||||
*
|
||||
* Actions ajaxified here:
|
||||
* Retrieve result of SQL query
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unbind all event handlers before tearing down a page
|
||||
*/
|
||||
AJAX.registerTeardown('database/search.js', function () {
|
||||
$('a.browse_results').off('click');
|
||||
$('a.delete_results').off('click');
|
||||
$('#buttonGo').off('click');
|
||||
$('#togglesearchresultlink').off('click');
|
||||
$('#togglequerybox').off('click');
|
||||
$('#togglesearchformlink').off('click');
|
||||
$('#select_all').off('click');
|
||||
$('#unselect_all').off('click');
|
||||
$(document).off('submit', '#db_search_form.ajax');
|
||||
});
|
||||
AJAX.registerOnload('database/search.js', function () {
|
||||
/** Hide the table link in the initial search result */
|
||||
var icon = Functions.getImage('s_tbl', '', {
|
||||
'id': 'table-image'
|
||||
}).toString();
|
||||
$('#table-info').prepend(icon).hide();
|
||||
|
||||
/** Hide the browse and deleted results in the new search criteria */
|
||||
$('#buttonGo').on('click', function () {
|
||||
$('#table-info').hide();
|
||||
$('#browse-results').hide();
|
||||
$('#sqlqueryform').hide();
|
||||
$('#togglequerybox').hide();
|
||||
});
|
||||
/**
|
||||
* Prepare a div containing a link for toggle the search results
|
||||
*/
|
||||
$('#togglesearchresultsdiv')
|
||||
/** don't show it until we have results on-screen */.hide();
|
||||
|
||||
/**
|
||||
* Changing the displayed text according to
|
||||
* the hide/show criteria in search result forms
|
||||
*/
|
||||
$('#togglesearchresultlink').html(Messages.strHideSearchResults).on('click', function () {
|
||||
var $link = $(this);
|
||||
$('#searchresults').slideToggle();
|
||||
if ($link.text() === Messages.strHideSearchResults) {
|
||||
$link.text(Messages.strShowSearchResults);
|
||||
} else {
|
||||
$link.text(Messages.strHideSearchResults);
|
||||
}
|
||||
/** avoid default click action */
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* Prepare a div containing a link for toggle the search form,
|
||||
* otherwise it's incorrectly displayed after a couple of clicks
|
||||
*/
|
||||
$('#togglesearchformdiv').hide(); // don't show it until we have results on-screen
|
||||
|
||||
/**
|
||||
* Changing the displayed text according to
|
||||
* the hide/show criteria in search form
|
||||
*/
|
||||
$('#togglequerybox').hide().on('click', function () {
|
||||
var $link = $(this);
|
||||
$('#sqlqueryform').slideToggle('medium');
|
||||
if ($link.text() === Messages.strHideQueryBox) {
|
||||
$link.text(Messages.strShowQueryBox);
|
||||
} else {
|
||||
$link.text(Messages.strHideQueryBox);
|
||||
}
|
||||
/** avoid default click action */
|
||||
return false;
|
||||
});
|
||||
|
||||
/** don't show it until we have results on-screen */
|
||||
|
||||
/**
|
||||
* Changing the displayed text according to
|
||||
* the hide/show criteria in search criteria form
|
||||
*/
|
||||
$('#togglesearchformlink').html(Messages.strShowSearchCriteria).on('click', function () {
|
||||
var $link = $(this);
|
||||
$('#db_search_form').slideToggle();
|
||||
if ($link.text() === Messages.strHideSearchCriteria) {
|
||||
$link.text(Messages.strShowSearchCriteria);
|
||||
} else {
|
||||
$link.text(Messages.strHideSearchCriteria);
|
||||
}
|
||||
/** avoid default click action */
|
||||
return false;
|
||||
});
|
||||
|
||||
/*
|
||||
* Ajax Event handler for retrieving the results from a table
|
||||
*/
|
||||
$(document).on('click', 'a.browse_results', function (e) {
|
||||
e.preventDefault();
|
||||
/** Hides the results shown by the delete criteria */
|
||||
var $msg = Functions.ajaxShowMessage(Messages.strBrowsing, false);
|
||||
$('#sqlqueryform').hide();
|
||||
$('#togglequerybox').hide();
|
||||
/** Load the browse results to the page */
|
||||
$('#table-info').show();
|
||||
var tableName = $(this).data('table-name');
|
||||
$('#table-link').attr({
|
||||
'href': $(this).attr('href')
|
||||
}).text(tableName);
|
||||
var url = $(this).attr('href') + '#searchresults';
|
||||
var browseSql = $(this).data('browse-sql');
|
||||
var params = {
|
||||
'ajax_request': true,
|
||||
'is_js_confirmed': true,
|
||||
'sql_query': browseSql
|
||||
};
|
||||
$.post(url, params, function (data) {
|
||||
if (typeof data !== 'undefined' && data.success) {
|
||||
$('#browse-results').html(data.message);
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
$('.table_results').each(function () {
|
||||
makeGrid(this, true, true, true, true);
|
||||
});
|
||||
$('#browse-results').show();
|
||||
Functions.highlightSql($('#browse-results'));
|
||||
$('html, body').animate({
|
||||
scrollTop: $('#browse-results').offset().top
|
||||
}, 1000);
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
* Ajax Event handler for deleting the results from a table
|
||||
*/
|
||||
$(document).on('click', 'a.delete_results', function (e) {
|
||||
e.preventDefault();
|
||||
/** Hides the results shown by the browse criteria */
|
||||
$('#table-info').hide();
|
||||
$('#sqlqueryform').hide();
|
||||
$('#togglequerybox').hide();
|
||||
/** Conformation message for deletion */
|
||||
var msg = Functions.sprintf(Messages.strConfirmDeleteResults, $(this).data('table-name'));
|
||||
if (confirm(msg)) {
|
||||
var $msg = Functions.ajaxShowMessage(Messages.strDeleting, false);
|
||||
/** Load the deleted option to the page*/
|
||||
$('#sqlqueryform').html('');
|
||||
var params = {
|
||||
'ajax_request': true,
|
||||
'is_js_confirmed': true,
|
||||
'sql_query': $(this).data('delete-sql')
|
||||
};
|
||||
var url = $(this).attr('href');
|
||||
$.post(url, params, function (data) {
|
||||
if (typeof data === 'undefined' || !data.success) {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
return;
|
||||
}
|
||||
$('#sqlqueryform').html(data.sql_query);
|
||||
/** Refresh the search results after the deletion */
|
||||
$('#buttonGo').trigger('click');
|
||||
$('#togglequerybox').html(Messages.strHideQueryBox);
|
||||
/** Show the results of the deletion option */
|
||||
$('#browse-results').hide();
|
||||
$('#sqlqueryform').show();
|
||||
$('#togglequerybox').show();
|
||||
$('html, body').animate({
|
||||
scrollTop: $('#browse-results').offset().top
|
||||
}, 1000);
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Ajax Event handler for retrieving the result of an SQL Query
|
||||
*/
|
||||
$(document).on('submit', '#db_search_form.ajax', function (event) {
|
||||
event.preventDefault();
|
||||
if ($('#criteriaTables :selected').length === 0) {
|
||||
Functions.ajaxShowMessage(Messages.strNoTableSelected);
|
||||
return;
|
||||
}
|
||||
var $msgbox = Functions.ajaxShowMessage(Messages.strSearching, false);
|
||||
// jQuery object to reuse
|
||||
var $form = $(this);
|
||||
Functions.prepareForAjaxRequest($form);
|
||||
var url = $form.serialize() + CommonParams.get('arg_separator') + 'submit_search=' + $('#buttonGo').val();
|
||||
$.post($form.attr('action'), url, function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
// found results
|
||||
$('#searchresults').html(data.message);
|
||||
$('#togglesearchresultlink')
|
||||
// always start with the Show message
|
||||
.text(Messages.strHideSearchResults);
|
||||
$('#togglesearchresultsdiv')
|
||||
// now it's time to show the div containing the link
|
||||
.show();
|
||||
$('#searchresults').show();
|
||||
$('#db_search_form')
|
||||
// workaround for Chrome problem (bug #3168569)
|
||||
.slideToggle().hide();
|
||||
$('#togglesearchformlink')
|
||||
// always start with the Show message
|
||||
.text(Messages.strShowSearchCriteria);
|
||||
$('#togglesearchformdiv')
|
||||
// now it's time to show the div containing the link
|
||||
.show();
|
||||
} else {
|
||||
// error message (zero rows)
|
||||
$('#searchresults').html(data.error).show();
|
||||
}
|
||||
Functions.ajaxRemoveMessage($msgbox);
|
||||
});
|
||||
});
|
||||
$('#select_all').on('click', function () {
|
||||
Functions.setSelectOptions('db_search', 'criteriaTables[]', true);
|
||||
return false;
|
||||
});
|
||||
$('#unselect_all').on('click', function () {
|
||||
Functions.setSelectOptions('db_search', 'criteriaTables[]', false);
|
||||
return false;
|
||||
});
|
||||
}); // end $()
|
387
admin/phpMyAdmin/js/dist/database/structure.js
vendored
Normal file
387
admin/phpMyAdmin/js/dist/database/structure.js
vendored
Normal file
|
@ -0,0 +1,387 @@
|
|||
/**
|
||||
* @fileoverview functions used on the database structure page
|
||||
* @name Database Structure
|
||||
*
|
||||
* @requires jQuery
|
||||
* @requires jQueryUI
|
||||
* @required js/functions.js
|
||||
*/
|
||||
|
||||
var DatabaseStructure = {};
|
||||
|
||||
/**
|
||||
* AJAX scripts for /database/structure
|
||||
*
|
||||
* Actions ajaxified here:
|
||||
* Drop Database
|
||||
* Truncate Table
|
||||
* Drop Table
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unbind all event handlers before tearing down a page
|
||||
*/
|
||||
AJAX.registerTeardown('database/structure.js', function () {
|
||||
$(document).off('click', 'a.truncate_table_anchor.ajax');
|
||||
$(document).off('click', 'a.drop_table_anchor.ajax');
|
||||
$(document).off('click', '#real_end_input');
|
||||
$(document).off('click', 'a.favorite_table_anchor.ajax');
|
||||
$('a.real_row_count').off('click');
|
||||
$('a.row_count_sum').off('click');
|
||||
$('select[name=submit_mult]').off('change');
|
||||
});
|
||||
|
||||
/**
|
||||
* Adjust number of rows and total size in the summary
|
||||
* when truncating, creating, dropping or inserting into a table
|
||||
*/
|
||||
DatabaseStructure.adjustTotals = function () {
|
||||
var byteUnits = [Messages.strB, Messages.strKiB, Messages.strMiB, Messages.strGiB, Messages.strTiB, Messages.strPiB, Messages.strEiB];
|
||||
/**
|
||||
* @var $allTr jQuery object that references all the rows in the list of tables
|
||||
*/
|
||||
var $allTr = $('#tablesForm').find('table.data tbody').first().find('tr');
|
||||
// New summary values for the table
|
||||
var tableSum = $allTr.length;
|
||||
var rowsSum = 0;
|
||||
var sizeSum = 0;
|
||||
var overheadSum = 0;
|
||||
var rowSumApproximated = false;
|
||||
$allTr.each(function () {
|
||||
var $this = $(this);
|
||||
var i;
|
||||
var tmpVal;
|
||||
// Get the number of rows for this SQL table
|
||||
var strRows = $this.find('.tbl_rows').text();
|
||||
// If the value is approximated
|
||||
if (strRows.indexOf('~') === 0) {
|
||||
rowSumApproximated = true;
|
||||
// The approximated value contains a preceding ~ (Eg 100 --> ~100)
|
||||
strRows = strRows.substring(1, strRows.length);
|
||||
}
|
||||
strRows = strRows.replace(/[,.\s]/g, '');
|
||||
var intRow = parseInt(strRows, 10);
|
||||
if (!isNaN(intRow)) {
|
||||
rowsSum += intRow;
|
||||
}
|
||||
// Extract the size and overhead
|
||||
var valSize = 0;
|
||||
var valOverhead = 0;
|
||||
var strSize = $this.find('.tbl_size span:not(.unit)').text().trim();
|
||||
var strSizeUnit = $this.find('.tbl_size span.unit').text().trim();
|
||||
var strOverhead = $this.find('.tbl_overhead span:not(.unit)').text().trim();
|
||||
var strOverheadUnit = $this.find('.tbl_overhead span.unit').text().trim();
|
||||
// Given a value and a unit, such as 100 and KiB, for the table size
|
||||
// and overhead calculate their numeric values in bytes, such as 102400
|
||||
for (i = 0; i < byteUnits.length; i++) {
|
||||
if (strSizeUnit === byteUnits[i]) {
|
||||
tmpVal = parseFloat(strSize);
|
||||
valSize = tmpVal * Math.pow(1024, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < byteUnits.length; i++) {
|
||||
if (strOverheadUnit === byteUnits[i]) {
|
||||
tmpVal = parseFloat(strOverhead);
|
||||
valOverhead = tmpVal * Math.pow(1024, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
sizeSum += valSize;
|
||||
overheadSum += valOverhead;
|
||||
});
|
||||
// Add some commas for readability:
|
||||
// 1000000 becomes 1,000,000
|
||||
var strRowSum = rowsSum + '';
|
||||
var regex = /(\d+)(\d{3})/;
|
||||
while (regex.test(strRowSum)) {
|
||||
strRowSum = strRowSum.replace(regex, '$1' + ',' + '$2');
|
||||
}
|
||||
// If approximated total value add ~ in front
|
||||
if (rowSumApproximated) {
|
||||
strRowSum = '~' + strRowSum;
|
||||
}
|
||||
// Calculate the magnitude for the size and overhead values
|
||||
var sizeMagnitude = 0;
|
||||
var overheadMagnitude = 0;
|
||||
while (sizeSum >= 1024) {
|
||||
sizeSum /= 1024;
|
||||
sizeMagnitude++;
|
||||
}
|
||||
while (overheadSum >= 1024) {
|
||||
overheadSum /= 1024;
|
||||
overheadMagnitude++;
|
||||
}
|
||||
sizeSum = Math.round(sizeSum * 10) / 10;
|
||||
overheadSum = Math.round(overheadSum * 10) / 10;
|
||||
|
||||
// Update summary with new data
|
||||
var $summary = $('#tbl_summary_row');
|
||||
$summary.find('.tbl_num').text(Functions.sprintf(Messages.strNTables, tableSum));
|
||||
if (rowSumApproximated) {
|
||||
$summary.find('.row_count_sum').text(strRowSum);
|
||||
} else {
|
||||
$summary.find('.tbl_rows').text(strRowSum);
|
||||
}
|
||||
$summary.find('.tbl_size').text(sizeSum + ' ' + byteUnits[sizeMagnitude]);
|
||||
$summary.find('.tbl_overhead').text(overheadSum + ' ' + byteUnits[overheadMagnitude]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the real row count for a table or DB.
|
||||
* @param {object} $target Target for appending the real count value.
|
||||
*/
|
||||
DatabaseStructure.fetchRealRowCount = function ($target) {
|
||||
var $throbber = $('#pma_navigation').find('.throbber').first().clone().css({
|
||||
visibility: 'visible',
|
||||
display: 'inline-block'
|
||||
}).on('click', false);
|
||||
$target.html($throbber);
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: $target.attr('href'),
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
success: function (response) {
|
||||
if (response.success) {
|
||||
// If to update all row counts for a DB.
|
||||
if (response.real_row_count_all) {
|
||||
$.each(JSON.parse(response.real_row_count_all), function (index, table) {
|
||||
// Update each table row count.
|
||||
$('table.data td[data-table*="' + table.table + '"]').text(table.row_count);
|
||||
});
|
||||
}
|
||||
// If to update a particular table's row count.
|
||||
if (response.real_row_count) {
|
||||
// Append the parent cell with real row count.
|
||||
$target.parent().text(response.real_row_count);
|
||||
}
|
||||
// Adjust the 'Sum' displayed at the bottom.
|
||||
DatabaseStructure.adjustTotals();
|
||||
} else {
|
||||
Functions.ajaxShowMessage(Messages.strErrorRealRowCount);
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
Functions.ajaxShowMessage(Messages.strErrorRealRowCount);
|
||||
}
|
||||
});
|
||||
};
|
||||
AJAX.registerOnload('database/structure.js', function () {
|
||||
/**
|
||||
* Event handler on select of "Make consistent with central list"
|
||||
*/
|
||||
$('select[name=submit_mult]').on('change', function (event) {
|
||||
var url = 'index.php?route=/database/structure';
|
||||
var action = $(this).val();
|
||||
if (action === 'make_consistent_with_central_list') {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
$('#makeConsistentWithCentralListModal').modal('show').on('shown.bs.modal', function () {
|
||||
$('#makeConsistentWithCentralListContinue').on('click', function () {
|
||||
const $form = $('#tablesForm');
|
||||
const argSep = CommonParams.get('arg_separator');
|
||||
const data = $form.serialize() + argSep + 'ajax_request=true' + argSep + 'ajax_page_request=true';
|
||||
Functions.ajaxShowMessage();
|
||||
AJAX.source = $form;
|
||||
$.post('index.php?route=/database/structure/central-columns/make-consistent', data, AJAX.responseHandler);
|
||||
$('#makeConsistentWithCentralListModal').modal('hide');
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (action === 'copy_tbl' || action === 'add_prefix_tbl' || action === 'replace_prefix_tbl' || action === 'copy_tbl_change_prefix') {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if ($('input[name="selected_tbl[]"]:checked').length === 0) {
|
||||
return false;
|
||||
}
|
||||
var formData = $('#tablesForm').serialize();
|
||||
var modalTitle = '';
|
||||
if (action === 'copy_tbl') {
|
||||
url = 'index.php?route=/database/structure/copy-form';
|
||||
modalTitle = Messages.strCopyTablesTo;
|
||||
} else if (action === 'add_prefix_tbl') {
|
||||
url = 'index.php?route=/database/structure/add-prefix';
|
||||
modalTitle = Messages.strAddPrefix;
|
||||
} else if (action === 'replace_prefix_tbl') {
|
||||
url = 'index.php?route=/database/structure/change-prefix-form';
|
||||
modalTitle = Messages.strReplacePrefix;
|
||||
} else if (action === 'copy_tbl_change_prefix') {
|
||||
url = 'index.php?route=/database/structure/change-prefix-form';
|
||||
modalTitle = Messages.strCopyPrefix;
|
||||
}
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: url,
|
||||
dataType: 'html',
|
||||
data: formData
|
||||
}).done(function (modalBody) {
|
||||
const bulkActionModal = $('#bulkActionModal');
|
||||
bulkActionModal.on('show.bs.modal', function () {
|
||||
this.querySelector('.modal-title').innerText = modalTitle;
|
||||
this.querySelector('.modal-body').innerHTML = modalBody;
|
||||
});
|
||||
bulkActionModal.modal('show').on('shown.bs.modal', function () {
|
||||
$('#bulkActionContinue').on('click', function () {
|
||||
$('#ajax_form').trigger('submit');
|
||||
$('#bulkActionModal').modal('hide');
|
||||
});
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (action === 'analyze_tbl') {
|
||||
url = 'index.php?route=/table/maintenance/analyze';
|
||||
} else if (action === 'sync_unique_columns_central_list') {
|
||||
url = 'index.php?route=/database/structure/central-columns/add';
|
||||
} else if (action === 'delete_unique_columns_central_list') {
|
||||
url = 'index.php?route=/database/structure/central-columns/remove';
|
||||
} else if (action === 'check_tbl') {
|
||||
url = 'index.php?route=/table/maintenance/check';
|
||||
} else if (action === 'checksum_tbl') {
|
||||
url = 'index.php?route=/table/maintenance/checksum';
|
||||
} else if (action === 'drop_tbl') {
|
||||
url = 'index.php?route=/database/structure/drop-form';
|
||||
} else if (action === 'empty_tbl') {
|
||||
url = 'index.php?route=/database/structure/empty-form';
|
||||
} else if (action === 'export') {
|
||||
url = 'index.php?route=/export/tables';
|
||||
} else if (action === 'optimize_tbl') {
|
||||
url = 'index.php?route=/table/maintenance/optimize';
|
||||
} else if (action === 'repair_tbl') {
|
||||
url = 'index.php?route=/table/maintenance/repair';
|
||||
} else if (action === 'show_create') {
|
||||
url = 'index.php?route=/database/structure/show-create';
|
||||
} else {
|
||||
$('#tablesForm').trigger('submit');
|
||||
return;
|
||||
}
|
||||
var $form = $(this).parents('form');
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
var data = $form.serialize() + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true';
|
||||
Functions.ajaxShowMessage();
|
||||
AJAX.source = $form;
|
||||
$.post(url, data, AJAX.responseHandler);
|
||||
});
|
||||
|
||||
/**
|
||||
* Ajax Event handler for 'Truncate Table'
|
||||
*/
|
||||
$(document).on('click', 'a.truncate_table_anchor.ajax', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
/**
|
||||
* @var $this_anchor Object referring to the anchor clicked
|
||||
*/
|
||||
var $thisAnchor = $(this);
|
||||
|
||||
// extract current table name and build the question string
|
||||
/**
|
||||
* @var curr_table_name String containing the name of the table to be truncated
|
||||
*/
|
||||
var currTableName = $thisAnchor.parents('tr').children('th').children('a').text();
|
||||
/**
|
||||
* @var question String containing the question to be asked for confirmation
|
||||
*/
|
||||
var question = Messages.strTruncateTableStrongWarning + ' ' + Functions.sprintf(Messages.strDoYouReally, 'TRUNCATE `' + Functions.escapeHtml(currTableName) + '`') + Functions.getForeignKeyCheckboxLoader();
|
||||
$thisAnchor.confirm(question, $thisAnchor.attr('href'), function (url) {
|
||||
Functions.ajaxShowMessage(Messages.strProcessingRequest);
|
||||
var params = Functions.getJsConfirmCommonParam(this, $thisAnchor.getPostData());
|
||||
$.post(url, params, function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
Functions.ajaxShowMessage(data.message);
|
||||
// Adjust table statistics
|
||||
var $tr = $thisAnchor.closest('tr');
|
||||
$tr.find('.tbl_rows').text('0');
|
||||
$tr.find('.tbl_size, .tbl_overhead').text('-');
|
||||
DatabaseStructure.adjustTotals();
|
||||
} else {
|
||||
Functions.ajaxShowMessage(Messages.strErrorProcessingRequest + ' : ' + data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
}, Functions.loadForeignKeyCheckbox);
|
||||
}); // end of Truncate Table Ajax action
|
||||
|
||||
/**
|
||||
* Ajax Event handler for 'Drop Table' or 'Drop View'
|
||||
*/
|
||||
$(document).on('click', 'a.drop_table_anchor.ajax', function (event) {
|
||||
event.preventDefault();
|
||||
var $thisAnchor = $(this);
|
||||
|
||||
// extract current table name and build the question string
|
||||
/**
|
||||
* @var $curr_row Object containing reference to the current row
|
||||
*/
|
||||
var $currRow = $thisAnchor.parents('tr');
|
||||
/**
|
||||
* @var curr_table_name String containing the name of the table to be truncated
|
||||
*/
|
||||
var currTableName = $currRow.children('th').children('a').text();
|
||||
/**
|
||||
* @var is_view Boolean telling if we have a view
|
||||
*/
|
||||
var isView = $currRow.hasClass('is_view') || $thisAnchor.hasClass('view');
|
||||
/**
|
||||
* @var question String containing the question to be asked for confirmation
|
||||
*/
|
||||
var question;
|
||||
if (!isView) {
|
||||
question = Messages.strDropTableStrongWarning + ' ' + Functions.sprintf(Messages.strDoYouReally, 'DROP TABLE `' + Functions.escapeHtml(currTableName) + '`');
|
||||
} else {
|
||||
question = Functions.sprintf(Messages.strDoYouReally, 'DROP VIEW `' + Functions.escapeHtml(currTableName) + '`');
|
||||
}
|
||||
question += Functions.getForeignKeyCheckboxLoader();
|
||||
$thisAnchor.confirm(question, $thisAnchor.attr('href'), function (url) {
|
||||
var $msg = Functions.ajaxShowMessage(Messages.strProcessingRequest);
|
||||
var params = Functions.getJsConfirmCommonParam(this, $thisAnchor.getPostData());
|
||||
$.post(url, params, function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
Functions.ajaxShowMessage(data.message);
|
||||
$currRow.hide('medium').remove();
|
||||
DatabaseStructure.adjustTotals();
|
||||
Navigation.reload();
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
} else {
|
||||
Functions.ajaxShowMessage(Messages.strErrorProcessingRequest + ' : ' + data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
}, Functions.loadForeignKeyCheckbox);
|
||||
}); // end of Drop Table Ajax action
|
||||
|
||||
// Calculate Real End for InnoDB
|
||||
/**
|
||||
* Ajax Event handler for calculating the real end for a InnoDB table
|
||||
*
|
||||
*/
|
||||
$(document).on('click', '#real_end_input', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
/**
|
||||
* @var question String containing the question to be asked for confirmation
|
||||
*/
|
||||
var question = Messages.strOperationTakesLongTime;
|
||||
$(this).confirm(question, '', function () {
|
||||
return true;
|
||||
});
|
||||
return false;
|
||||
}); // end Calculate Real End for InnoDB
|
||||
|
||||
// Add tooltip to favorite icons.
|
||||
$('.favorite_table_anchor').each(function () {
|
||||
Functions.tooltip($(this), 'a', $(this).attr('title'));
|
||||
});
|
||||
|
||||
// Get real row count via Ajax.
|
||||
$('a.real_row_count').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
DatabaseStructure.fetchRealRowCount($(this));
|
||||
});
|
||||
// Get all real row count.
|
||||
$('a.row_count_sum').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
DatabaseStructure.fetchRealRowCount($(this));
|
||||
});
|
||||
});
|
104
admin/phpMyAdmin/js/dist/database/tracking.js
vendored
Normal file
104
admin/phpMyAdmin/js/dist/database/tracking.js
vendored
Normal file
|
@ -0,0 +1,104 @@
|
|||
/**
|
||||
* Unbind all event handlers before tearing down the page
|
||||
*/
|
||||
AJAX.registerTeardown('database/tracking.js', function () {
|
||||
$('body').off('click', '#trackedForm.ajax button[name="submit_mult"], #trackedForm.ajax input[name="submit_mult"]');
|
||||
$('body').off('click', '#untrackedForm.ajax button[name="submit_mult"], #untrackedForm.ajax input[name="submit_mult"]');
|
||||
$('body').off('click', 'a.delete_tracking_anchor.ajax');
|
||||
});
|
||||
|
||||
/**
|
||||
* Bind event handlers
|
||||
*/
|
||||
AJAX.registerOnload('database/tracking.js', function () {
|
||||
var $versions = $('#versions');
|
||||
$versions.find('tr').first().find('th').append($('<div class="sorticon"></div>'));
|
||||
$versions.tablesorter({
|
||||
sortList: [[1, 0]],
|
||||
headers: {
|
||||
0: {
|
||||
sorter: false
|
||||
},
|
||||
2: {
|
||||
sorter: 'integer'
|
||||
},
|
||||
5: {
|
||||
sorter: false
|
||||
},
|
||||
6: {
|
||||
sorter: false
|
||||
},
|
||||
7: {
|
||||
sorter: false
|
||||
}
|
||||
}
|
||||
});
|
||||
var $noVersions = $('#noversions');
|
||||
$noVersions.find('tr').first().find('th').append($('<div class="sorticon"></div>'));
|
||||
$noVersions.tablesorter({
|
||||
sortList: [[1, 0]],
|
||||
headers: {
|
||||
0: {
|
||||
sorter: false
|
||||
},
|
||||
2: {
|
||||
sorter: false
|
||||
}
|
||||
}
|
||||
});
|
||||
var $body = $('body');
|
||||
|
||||
/**
|
||||
* Handles multi submit for tracked tables
|
||||
*/
|
||||
$body.on('click', '#trackedForm.ajax button[name="submit_mult"], #trackedForm.ajax input[name="submit_mult"]', function (e) {
|
||||
e.preventDefault();
|
||||
var $button = $(this);
|
||||
var $form = $button.parent('form');
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
var submitData = $form.serialize() + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true' + argsep + 'submit_mult=' + $button.val();
|
||||
if ($button.val() === 'delete_tracking') {
|
||||
var question = Messages.strDeleteTrackingDataMultiple;
|
||||
$button.confirm(question, $form.attr('action'), function (url) {
|
||||
Functions.ajaxShowMessage(Messages.strDeletingTrackingData);
|
||||
AJAX.source = $form;
|
||||
$.post(url, submitData, AJAX.responseHandler);
|
||||
});
|
||||
} else {
|
||||
Functions.ajaxShowMessage();
|
||||
AJAX.source = $form;
|
||||
$.post($form.attr('action'), submitData, AJAX.responseHandler);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Handles multi submit for untracked tables
|
||||
*/
|
||||
$body.on('click', '#untrackedForm.ajax button[name="submit_mult"], #untrackedForm.ajax input[name="submit_mult"]', function (e) {
|
||||
e.preventDefault();
|
||||
var $button = $(this);
|
||||
var $form = $button.parent('form');
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
var submitData = $form.serialize() + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true' + argsep + 'submit_mult=' + $button.val();
|
||||
Functions.ajaxShowMessage();
|
||||
AJAX.source = $form;
|
||||
$.post($form.attr('action'), submitData, AJAX.responseHandler);
|
||||
});
|
||||
|
||||
/**
|
||||
* Ajax Event handler for 'Delete tracking'
|
||||
*/
|
||||
$body.on('click', 'a.delete_tracking_anchor.ajax', function (e) {
|
||||
e.preventDefault();
|
||||
var $anchor = $(this);
|
||||
var question = Messages.strDeleteTrackingData;
|
||||
$anchor.confirm(question, $anchor.attr('href'), function (url) {
|
||||
Functions.ajaxShowMessage(Messages.strDeletingTrackingData);
|
||||
AJAX.source = $anchor;
|
||||
var argSep = CommonParams.get('arg_separator');
|
||||
var params = Functions.getJsConfirmCommonParam(this, $anchor.getPostData());
|
||||
params += argSep + 'ajax_page_request=1';
|
||||
$.post(url, params, AJAX.responseHandler);
|
||||
});
|
||||
});
|
||||
});
|
538
admin/phpMyAdmin/js/dist/database/triggers.js
vendored
Normal file
538
admin/phpMyAdmin/js/dist/database/triggers.js
vendored
Normal file
|
@ -0,0 +1,538 @@
|
|||
AJAX.registerTeardown('database/triggers.js', function () {
|
||||
$(document).off('click', 'a.ajax.add_anchor, a.ajax.edit_anchor');
|
||||
$(document).off('click', 'a.ajax.export_anchor');
|
||||
$(document).off('click', '#bulkActionExportButton');
|
||||
$(document).off('click', 'a.ajax.drop_anchor');
|
||||
$(document).off('click', '#bulkActionDropButton');
|
||||
});
|
||||
const DatabaseTriggers = {
|
||||
/**
|
||||
* @var $ajaxDialog Query object containing the reference to the
|
||||
* dialog that contains the editor
|
||||
*/
|
||||
$ajaxDialog: null,
|
||||
/**
|
||||
* @var syntaxHiglighter Reference to the codemirror editor
|
||||
*/
|
||||
syntaxHiglighter: null,
|
||||
/**
|
||||
* Validate editor form fields.
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
validate: function () {
|
||||
/**
|
||||
* @var $elm a jQuery object containing the reference
|
||||
* to an element that is being validated
|
||||
*/
|
||||
var $elm = null;
|
||||
// Common validation. At the very least the name
|
||||
// and the definition must be provided for an item
|
||||
$elm = $('table.rte_table').last().find('input[name=item_name]');
|
||||
if ($elm.val() === '') {
|
||||
$elm.trigger('focus');
|
||||
alert(Messages.strFormEmpty);
|
||||
return false;
|
||||
}
|
||||
$elm = $('table.rte_table').find('textarea[name=item_definition]');
|
||||
if ($elm.val() === '') {
|
||||
if (this.syntaxHiglighter !== null) {
|
||||
this.syntaxHiglighter.focus();
|
||||
} else {
|
||||
$('textarea[name=item_definition]').last().trigger('focus');
|
||||
}
|
||||
alert(Messages.strFormEmpty);
|
||||
return false;
|
||||
}
|
||||
// The validation has so far passed, so now
|
||||
// we can validate item-specific fields.
|
||||
return this.validateCustom();
|
||||
},
|
||||
// end validate()
|
||||
/**
|
||||
* Validate custom editor form fields.
|
||||
* This function can be overridden by
|
||||
* other files in this folder
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
validateCustom: function () {
|
||||
return true;
|
||||
},
|
||||
// end validateCustom()
|
||||
|
||||
exportDialog: function ($this) {
|
||||
var $msg = Functions.ajaxShowMessage();
|
||||
if ($this.attr('id') === 'bulkActionExportButton') {
|
||||
var combined = {
|
||||
success: true,
|
||||
title: Messages.strExport,
|
||||
message: '',
|
||||
error: ''
|
||||
};
|
||||
// export anchors of all selected rows
|
||||
var exportAnchors = $('input.checkall:checked').parents('tr').find('.export_anchor');
|
||||
var count = exportAnchors.length;
|
||||
var returnCount = 0;
|
||||
var p = $.when();
|
||||
exportAnchors.each(function () {
|
||||
var h = $(this).attr('href');
|
||||
p = p.then(function () {
|
||||
return $.get(h, {
|
||||
'ajax_request': true
|
||||
}, function (data) {
|
||||
returnCount++;
|
||||
if (data.success === true) {
|
||||
combined.message += '\n' + data.message + '\n';
|
||||
if (returnCount === count) {
|
||||
showExport(combined);
|
||||
}
|
||||
} else {
|
||||
// complain even if one export is failing
|
||||
combined.success = false;
|
||||
combined.error += '\n' + data.error + '\n';
|
||||
if (returnCount === count) {
|
||||
showExport(combined);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
$.get($this.attr('href'), {
|
||||
'ajax_request': true
|
||||
}, showExport);
|
||||
}
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
function showExport(data) {
|
||||
if (data.success === true) {
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
/**
|
||||
* @var buttonOptions Object containing options
|
||||
* for jQueryUI dialog buttons
|
||||
*/
|
||||
var buttonOptions = {
|
||||
[Messages.strClose]: {
|
||||
text: Messages.strClose,
|
||||
class: 'btn btn-primary'
|
||||
}
|
||||
};
|
||||
buttonOptions[Messages.strClose].click = function () {
|
||||
$(this).dialog('close').remove();
|
||||
};
|
||||
/**
|
||||
* Display the dialog to the user
|
||||
*/
|
||||
data.message = '<textarea cols="40" rows="15" class="w-100">' + data.message + '</textarea>';
|
||||
var $ajaxDialog = $('<div>' + data.message + '</div>').dialog({
|
||||
classes: {
|
||||
'ui-dialog-titlebar-close': 'btn-close'
|
||||
},
|
||||
width: 500,
|
||||
buttons: buttonOptions,
|
||||
title: data.title
|
||||
});
|
||||
// Attach syntax highlighted editor to export dialog
|
||||
/**
|
||||
* @var $elm jQuery object containing the reference
|
||||
* to the Export textarea.
|
||||
*/
|
||||
var $elm = $ajaxDialog.find('textarea');
|
||||
Functions.getSqlEditor($elm);
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
} // end showExport()
|
||||
},
|
||||
|
||||
// end exportDialog()
|
||||
editorDialog: function (isNew, $this) {
|
||||
var that = this;
|
||||
/**
|
||||
* @var $edit_row jQuery object containing the reference to
|
||||
* the row of the the item being edited
|
||||
* from the list of items
|
||||
*/
|
||||
var $editRow = null;
|
||||
if ($this.hasClass('edit_anchor')) {
|
||||
// Remember the row of the item being edited for later,
|
||||
// so that if the edit is successful, we can replace the
|
||||
// row with info about the modified item.
|
||||
$editRow = $this.parents('tr');
|
||||
}
|
||||
/**
|
||||
* @var $msg jQuery object containing the reference to
|
||||
* the AJAX message shown to the user
|
||||
*/
|
||||
var $msg = Functions.ajaxShowMessage();
|
||||
$.get($this.attr('href'), {
|
||||
'ajax_request': true
|
||||
}, function (data) {
|
||||
if (data.success === true) {
|
||||
var buttonOptions = {
|
||||
[Messages.strGo]: {
|
||||
text: Messages.strGo,
|
||||
class: 'btn btn-primary'
|
||||
},
|
||||
[Messages.strClose]: {
|
||||
text: Messages.strClose,
|
||||
class: 'btn btn-secondary'
|
||||
}
|
||||
};
|
||||
// We have successfully fetched the editor form
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
// Now define the function that is called when
|
||||
// the user presses the "Go" button
|
||||
buttonOptions[Messages.strGo].click = function () {
|
||||
// Move the data from the codemirror editor back to the
|
||||
// textarea, where it can be used in the form submission.
|
||||
if (typeof CodeMirror !== 'undefined') {
|
||||
that.syntaxHiglighter.save();
|
||||
}
|
||||
// Validate editor and submit request, if passed.
|
||||
if (that.validate()) {
|
||||
/**
|
||||
* @var data Form data to be sent in the AJAX request
|
||||
*/
|
||||
var data = $('form.rte_form').last().serialize();
|
||||
$msg = Functions.ajaxShowMessage(Messages.strProcessingRequest);
|
||||
var url = $('form.rte_form').last().attr('action');
|
||||
$.post(url, data, function (data) {
|
||||
if (data.success === true) {
|
||||
// Item created successfully
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
Functions.slidingMessage(data.message);
|
||||
that.$ajaxDialog.dialog('close');
|
||||
// If we are in 'edit' mode, we must
|
||||
// remove the reference to the old row.
|
||||
if (mode === 'edit' && $editRow !== null) {
|
||||
$editRow.remove();
|
||||
}
|
||||
// Sometimes, like when moving a trigger from
|
||||
// a table to another one, the new row should
|
||||
// not be inserted into the list. In this case
|
||||
// "data.insert" will be set to false.
|
||||
if (data.insert) {
|
||||
// Insert the new row at the correct
|
||||
// location in the list of items
|
||||
/**
|
||||
* @var text Contains the name of an item from
|
||||
* the list that is used in comparisons
|
||||
* to find the correct location where
|
||||
* to insert a new row.
|
||||
*/
|
||||
var text = '';
|
||||
/**
|
||||
* @var inserted Whether a new item has been
|
||||
* inserted in the list or not
|
||||
*/
|
||||
var inserted = false;
|
||||
$('table.data').find('tr').each(function () {
|
||||
text = $(this).children('td').eq(0).find('strong').text().toUpperCase().trim();
|
||||
if (text !== '' && text > data.name) {
|
||||
$(this).before(data.new_row);
|
||||
inserted = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (!inserted) {
|
||||
// If we didn't manage to insert the row yet,
|
||||
// it must belong at the end of the list,
|
||||
// so we insert it there.
|
||||
$('table.data').append(data.new_row);
|
||||
}
|
||||
// Fade-in the new row
|
||||
$('tr.ajaxInsert').show('slow').removeClass('ajaxInsert');
|
||||
} else if ($('table.data').find('tr').has('td').length === 0) {
|
||||
// If we are not supposed to insert the new row,
|
||||
// we will now check if the table is empty and
|
||||
// needs to be hidden. This will be the case if
|
||||
// we were editing the only item in the list,
|
||||
// which we removed and will not be inserting
|
||||
// something else in its place.
|
||||
$('table.data').hide('slow', function () {
|
||||
$('#nothing2display').show('slow');
|
||||
});
|
||||
}
|
||||
// Now we have inserted the row at the correct
|
||||
// position, but surely at least some row classes
|
||||
// are wrong now. So we will iterate through
|
||||
// all rows and assign correct classes to them
|
||||
/**
|
||||
* @var ct Count of processed rows
|
||||
*/
|
||||
var ct = 0;
|
||||
/**
|
||||
* @var rowclass Class to be attached to the row
|
||||
* that is being processed
|
||||
*/
|
||||
var rowclass = '';
|
||||
$('table.data').find('tr').has('td').each(function () {
|
||||
rowclass = ct % 2 === 0 ? 'odd' : 'even';
|
||||
$(this).removeClass().addClass(rowclass);
|
||||
ct++;
|
||||
});
|
||||
// If this is the first item being added, remove
|
||||
// the "No items" message and show the list.
|
||||
if ($('table.data').find('tr').has('td').length > 0 && $('#nothing2display').is(':visible')) {
|
||||
$('#nothing2display').hide('slow', function () {
|
||||
$('table.data').show('slow');
|
||||
});
|
||||
}
|
||||
Navigation.reload();
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
} // end "if (that.validate())"
|
||||
}; // end of function that handles the submission of the Editor
|
||||
buttonOptions[Messages.strClose].click = function () {
|
||||
$(this).dialog('close');
|
||||
};
|
||||
/**
|
||||
* Display the dialog to the user
|
||||
*/
|
||||
that.$ajaxDialog = $('<div id="rteDialog">' + data.message + '</div>').dialog({
|
||||
classes: {
|
||||
'ui-dialog-titlebar-close': 'btn-close'
|
||||
},
|
||||
width: 700,
|
||||
minWidth: 500,
|
||||
buttons: buttonOptions,
|
||||
// Issue #15810 - use button titles for modals (eg: new procedure)
|
||||
// Respect the order: title on href tag, href content, title sent in response
|
||||
title: $this.attr('title') || $this.text() || $(data.title).text(),
|
||||
modal: true,
|
||||
open: function () {
|
||||
$('#rteDialog').dialog('option', 'max-height', $(window).height());
|
||||
if ($('#rteDialog').parents('.ui-dialog').height() > $(window).height()) {
|
||||
$('#rteDialog').dialog('option', 'height', $(window).height());
|
||||
}
|
||||
$(this).find('input[name=item_name]').trigger('focus');
|
||||
$(this).find('input.datefield').each(function () {
|
||||
Functions.addDatepicker($(this).css('width', '95%'), 'date');
|
||||
});
|
||||
$(this).find('input.datetimefield').each(function () {
|
||||
Functions.addDatepicker($(this).css('width', '95%'), 'datetime');
|
||||
});
|
||||
$.datepicker.initialized = false;
|
||||
},
|
||||
close: function () {
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
/**
|
||||
* @var mode Used to remember whether the editor is in
|
||||
* "Edit" or "Add" mode
|
||||
*/
|
||||
var mode = 'add';
|
||||
if ($('input[name=editor_process_edit]').length > 0) {
|
||||
mode = 'edit';
|
||||
}
|
||||
// Attach syntax highlighted editor to the definition
|
||||
/**
|
||||
* @var elm jQuery object containing the reference to
|
||||
* the Definition textarea.
|
||||
*/
|
||||
var $elm = $('textarea[name=item_definition]').last();
|
||||
var linterOptions = {};
|
||||
linterOptions.triggerEditor = true;
|
||||
that.syntaxHiglighter = Functions.getSqlEditor($elm, {}, 'both', linterOptions);
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.get()
|
||||
},
|
||||
|
||||
dropDialog: function ($this) {
|
||||
/**
|
||||
* @var $curr_row Object containing reference to the current row
|
||||
*/
|
||||
var $currRow = $this.parents('tr');
|
||||
/**
|
||||
* @var question String containing the question to be asked for confirmation
|
||||
*/
|
||||
var question = $('<div></div>').text($currRow.children('td').children('.drop_sql').html());
|
||||
// We ask for confirmation first here, before submitting the ajax request
|
||||
$this.confirm(question, $this.attr('href'), function (url) {
|
||||
/**
|
||||
* @var msg jQuery object containing the reference to
|
||||
* the AJAX message shown to the user
|
||||
*/
|
||||
var $msg = Functions.ajaxShowMessage(Messages.strProcessingRequest);
|
||||
var params = Functions.getJsConfirmCommonParam(this, $this.getPostData());
|
||||
$.post(url, params, function (data) {
|
||||
if (data.success === true) {
|
||||
/**
|
||||
* @var $table Object containing reference
|
||||
* to the main list of elements
|
||||
*/
|
||||
var $table = $currRow.parent();
|
||||
// Check how many rows will be left after we remove
|
||||
// the one that the user has requested us to remove
|
||||
if ($table.find('tr').length === 3) {
|
||||
// If there are two rows left, it means that they are
|
||||
// the header of the table and the rows that we are
|
||||
// about to remove, so after the removal there will be
|
||||
// nothing to show in the table, so we hide it.
|
||||
$table.hide('slow', function () {
|
||||
$(this).find('tr.even, tr.odd').remove();
|
||||
$('.withSelected').remove();
|
||||
$('#nothing2display').show('slow');
|
||||
});
|
||||
} else {
|
||||
$currRow.hide('slow', function () {
|
||||
$(this).remove();
|
||||
// Now we have removed the row from the list, but maybe
|
||||
// some row classes are wrong now. So we will iterate
|
||||
// through all rows and assign correct classes to them.
|
||||
/**
|
||||
* @var ct Count of processed rows
|
||||
*/
|
||||
var ct = 0;
|
||||
/**
|
||||
* @var rowclass Class to be attached to the row
|
||||
* that is being processed
|
||||
*/
|
||||
var rowclass = '';
|
||||
$table.find('tr').has('td').each(function () {
|
||||
rowclass = ct % 2 === 1 ? 'odd' : 'even';
|
||||
$(this).removeClass().addClass(rowclass);
|
||||
ct++;
|
||||
});
|
||||
});
|
||||
}
|
||||
// Get rid of the "Loading" message
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
// Show the query that we just executed
|
||||
Functions.slidingMessage(data.sql_query);
|
||||
Navigation.reload();
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
});
|
||||
},
|
||||
|
||||
dropMultipleDialog: function ($this) {
|
||||
// We ask for confirmation here
|
||||
$this.confirm(Messages.strDropRTEitems, '', function () {
|
||||
/**
|
||||
* @var msg jQuery object containing the reference to
|
||||
* the AJAX message shown to the user
|
||||
*/
|
||||
var $msg = Functions.ajaxShowMessage(Messages.strProcessingRequest);
|
||||
|
||||
// drop anchors of all selected rows
|
||||
var dropAnchors = $('input.checkall:checked').parents('tr').find('.drop_anchor');
|
||||
var success = true;
|
||||
var count = dropAnchors.length;
|
||||
var returnCount = 0;
|
||||
dropAnchors.each(function () {
|
||||
var $anchor = $(this);
|
||||
/**
|
||||
* @var $curr_row Object containing reference to the current row
|
||||
*/
|
||||
var $currRow = $anchor.parents('tr');
|
||||
var params = Functions.getJsConfirmCommonParam(this, $anchor.getPostData());
|
||||
$.post($anchor.attr('href'), params, function (data) {
|
||||
returnCount++;
|
||||
if (data.success === true) {
|
||||
/**
|
||||
* @var $table Object containing reference
|
||||
* to the main list of elements
|
||||
*/
|
||||
var $table = $currRow.parent();
|
||||
// Check how many rows will be left after we remove
|
||||
// the one that the user has requested us to remove
|
||||
if ($table.find('tr').length === 3) {
|
||||
// If there are two rows left, it means that they are
|
||||
// the header of the table and the rows that we are
|
||||
// about to remove, so after the removal there will be
|
||||
// nothing to show in the table, so we hide it.
|
||||
$table.hide('slow', function () {
|
||||
$(this).find('tr.even, tr.odd').remove();
|
||||
$('.withSelected').remove();
|
||||
$('#nothing2display').show('slow');
|
||||
});
|
||||
} else {
|
||||
$currRow.hide('fast', function () {
|
||||
// we will iterate
|
||||
// through all rows and assign correct classes to them.
|
||||
/**
|
||||
* @var ct Count of processed rows
|
||||
*/
|
||||
var ct = 0;
|
||||
/**
|
||||
* @var rowclass Class to be attached to the row
|
||||
* that is being processed
|
||||
*/
|
||||
var rowclass = '';
|
||||
$table.find('tr').has('td').each(function () {
|
||||
rowclass = ct % 2 === 1 ? 'odd' : 'even';
|
||||
$(this).removeClass().addClass(rowclass);
|
||||
ct++;
|
||||
});
|
||||
});
|
||||
$currRow.remove();
|
||||
}
|
||||
if (returnCount === count) {
|
||||
if (success) {
|
||||
// Get rid of the "Loading" message
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
$('#rteListForm_checkall').prop({
|
||||
checked: false,
|
||||
indeterminate: false
|
||||
});
|
||||
}
|
||||
Navigation.reload();
|
||||
}
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
success = false;
|
||||
if (returnCount === count) {
|
||||
Navigation.reload();
|
||||
}
|
||||
}
|
||||
}); // end $.post()
|
||||
}); // end drop_anchors.each()
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
AJAX.registerOnload('database/triggers.js', function () {
|
||||
/**
|
||||
* Attach Ajax event handlers for the Add/Edit functionality.
|
||||
*/
|
||||
$(document).on('click', 'a.ajax.add_anchor, a.ajax.edit_anchor', function (event) {
|
||||
event.preventDefault();
|
||||
if ($(this).hasClass('add_anchor')) {
|
||||
$.datepicker.initialized = false;
|
||||
}
|
||||
DatabaseTriggers.editorDialog($(this).hasClass('add_anchor'), $(this));
|
||||
});
|
||||
|
||||
/**
|
||||
* Attach Ajax event handlers for Export
|
||||
*/
|
||||
$(document).on('click', 'a.ajax.export_anchor', function (event) {
|
||||
event.preventDefault();
|
||||
DatabaseTriggers.exportDialog($(this));
|
||||
});
|
||||
$(document).on('click', '#bulkActionExportButton', function (event) {
|
||||
event.preventDefault();
|
||||
DatabaseTriggers.exportDialog($(this));
|
||||
});
|
||||
|
||||
/**
|
||||
* Attach Ajax event handlers for Drop functionality
|
||||
*/
|
||||
$(document).on('click', 'a.ajax.drop_anchor', function (event) {
|
||||
event.preventDefault();
|
||||
DatabaseTriggers.dropDialog($(this));
|
||||
});
|
||||
$(document).on('click', '#bulkActionDropButton', function (event) {
|
||||
event.preventDefault();
|
||||
DatabaseTriggers.dropMultipleDialog($(this));
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue