Add Filter to Process List | Feature #1606

Signed-off-by: Deven Bansod <devenbansod.bits@gmail.com>
This commit is contained in:
Deven Bansod 2015-02-21 20:34:19 +05:30
parent 127ba15547
commit 42d5a90f2f
3 changed files with 79 additions and 20 deletions

View File

@ -86,20 +86,20 @@ var processList = {
// if auto refresh is enabled
if (processList.autoRefresh) {
var interval = parseInt(processList.refreshInterval, 10) * 1000;
processList.refreshRequest = $.get(processList.refreshUrl, {
'ajax_request': true,
'refresh': true
}, function(data) {
if (data.hasOwnProperty('success') && data.success) {
$newTable = $(data.message);
$('#tableprocesslist').html($newTable.html());
PMA_highlightSQL($('#tableprocesslist'));
}
processList.refreshTimeout = setTimeout(
processList.refresh,
interval
);
});
var urlParams = processList.getUrlParams();
processList.refreshRequest = $.get(processList.refreshUrl,
urlParams,
function(data) {
if (data.hasOwnProperty('success') && data.success) {
$newTable = $(data.message);
$('#tableprocesslist').html($newTable.html());
PMA_highlightSQL($('#tableprocesslist'));
}
processList.refreshTimeout = setTimeout(
processList.refresh,
interval
);
});
}
},
@ -131,6 +131,22 @@ var processList = {
processList.refresh();
}
$('a#toggleRefresh').html(PMA_getImage(img) + escapeHtml(label));
},
/**
* Return the Url Parameters
* for autorefresh request,
* includes showExecuting if the filter is checked
*
* @return urlParams - url parameters with autoRefresh request
*/
getUrlParams: function() {
var urlParams = { 'ajax_request': true, 'refresh': true };
if ($('#showExecuting').is(":checked")) {
urlParams['showExecuting'] = true;
return urlParams;
}
return urlParams;
}
};

View File

@ -126,12 +126,18 @@ function PMA_getHtmlForServerProcesslist()
$sql_query = $show_full_sql
? 'SHOW FULL PROCESSLIST'
: 'SHOW PROCESSLIST';
if (! empty($_REQUEST['order_by_field'])
&& ! empty($_REQUEST['sort_order'])
if ( (! empty($_REQUEST['order_by_field'])
&& ! empty($_REQUEST['sort_order']) )
|| (! empty($_REQUEST['showExecuting']) )
) {
$sql_query = 'SELECT * FROM `INFORMATION_SCHEMA`.`PROCESSLIST` '
. 'ORDER BY `'
. $_REQUEST['order_by_field'] . '` ' . $_REQUEST['sort_order'];
$sql_query = 'SELECT * FROM `INFORMATION_SCHEMA`.`PROCESSLIST` ';
}
if (! empty($_REQUEST['showExecuting'])) {
$sql_query = $sql_query . ' WHERE state = "executing" ';
}
if (! empty($_REQUEST['order_by_field']) && ! empty($_REQUEST['sort_order']) ) {
$sql_query = $sql_query . ' ORDER BY `' . $_REQUEST['order_by_field'] . '` '
. $_REQUEST['sort_order'];
}
}
@ -218,6 +224,40 @@ function PMA_getHtmlForServerProcesslist()
return $retval;
}
/**
* Returns the html for the list filter
*
* @return string
*/
function PMA_getHtmlForProcessListFilter()
{
$showExecuting = '';
if (! empty($_REQUEST['showExecuting'])) {
$showExecuting = ' checked="checked"';
}
$url_params = array(
'showExecuting' => 1,
'ajax_request' => true
);
$retval = '';
$retval .= '<fieldset id="tableFilter">';
$retval .= '<legend>' . __('Filters') . '</legend>';
$retval .= '<form action="server_status_processes.php?' . PMA_URL_getCommon($url_params) . '">';
$retval .= '<input type="submit" value="' . __('Refresh') . '" />';
$retval .= '<div class="formelement">';
$retval .= '<input' . $showExecuting . ' type="checkbox" name="showExecuting" id="showExecuting" />';
$retval .= '<label for="showExecuting">';
$retval .= __('Show only active');
$retval .= '</label>';
$retval .= '</div>';
$retval .= '</form>';
$retval .= '</fieldset>';
return $retval;
}
/**
* Prints Every Item of Server Process
*
@ -231,7 +271,9 @@ function PMA_getHtmlForServerProcessItem($process, $odd_row, $show_full_sql)
{
// Array keys need to modify due to the way it has used
// to display column values
if (! empty($_REQUEST['order_by_field']) && ! empty($_REQUEST['sort_order']) ) {
if ( (! empty($_REQUEST['order_by_field']) && ! empty($_REQUEST['sort_order']) )
|| (! empty($_REQUEST['showExecuting']))
) {
foreach (array_keys($process) as $key) {
$new_key = ucfirst(/*overload*/mb_strtolower($key));
if ($new_key !== $key) {

View File

@ -57,6 +57,7 @@ if ($response->isAjax() && !empty($_REQUEST['kill'])) {
$response->addHTML('<div>');
$response->addHTML($ServerStatusData->getMenuHtml());
$response->addHTML(PMA_getHtmlForServerProcesses());
$response->addHTML(PMA_getHtmlForProcessListFilter());
$response->addHTML('</div>');
}
exit;