diff --git a/js/server_status.js b/js/server_status.js index 6cacabc759..ac4071c3f6 100644 --- a/js/server_status.js +++ b/js/server_status.js @@ -982,7 +982,7 @@ $(function() { } if(msg.length == 0) { - icon = 'ic_s_success'; + icon = 'ic_s_error'; msg = PMA_messages['strBothLogOff']; } @@ -1528,9 +1528,11 @@ $(function() { tableStr += '' + formatValue(cols[j], rows[i][cols[j]]) + ''; tableStr += ''; } - - tableStr+=''; - + + tableStr += ''; + tableStr += 'Sum of grouped rows: '+ data.numRows +'Total:' + data.sum.TOTAL + ''; + tableStr += ''; + $('#logTable').html(tableStr); // Append a tooltip to the count column, if there exist one @@ -1553,6 +1555,8 @@ $(function() { }) } + + $('div#logTable table').tablesorter({ sortList: [[0,1]], widgets: ['zebra'] @@ -1569,6 +1573,64 @@ $(function() { $('#loadingLogsDialog').append(key + ': ' + value + '
'); }); + if(data.numRows > 12) { + $('div#logTable').prepend( + '
' + + ' Filters' + + '
' + + ' ' + + ' ' + + ((data.numRows > 250) ? ' ' : '') + + '
' + + '
' + ); + + if(data.numRows > 250) { + $('div#logTable button#startFilterQueryText').click(filterQueries); + } else { + $('div#logTable input#filterQueryText').keyup(filterQueries); + } + + function filterQueries() { + var odd_row=false, cell, textFilter; + var val = $('div#logTable input#filterQueryText').val(); + + if(val.length == 0) textFilter = null; + else textFilter = new RegExp(val, 'i'); + + var rowSum = 0, totalSum = 0; + + $('div#logTable table tbody tr').each(function() { + // We just assume the sql text is always in the second last column + cell = $(this).children(':nth-child(' + (cols.length - 1) + ')'); + + if(textFilter==null || textFilter.exec(cell.text())) { + // And that total count is right of the sql text + totalSum += parseInt(cell.next().text()); + rowSum ++; + + odd_row = !odd_row; + $(this).css('display',''); + if(odd_row) { + $(this).addClass('odd'); + $(this).removeClass('even'); + } else { + $(this).addClass('even'); + $(this).removeClass('odd'); + } + } else { + $(this).css('display','none'); + } + }); + + + $('div#logTable table tfoot tr') + .html('Sum of grouped rows: '+ rowSum +'Total:' + + totalSum + ''); + }; + } + var dlgBtns = {}; dlgBtns[PMA_messages['strJumpToTable']] = function() { $(this).dialog("close"); diff --git a/server_status.php b/server_status.php index d971169263..b6324b7967 100644 --- a/server_status.php +++ b/server_status.php @@ -210,7 +210,8 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { preg_match('/^(\w+)\s/',$row['argument'],$match); $type = strtolower($match[1]); // Ignore undefined index warning, just increase counter by one - @$return['sum'][$type]++; + @$return['sum'][$type] += $row['#']; + if($type=='insert' || $type=='update') { // Group inserts if selected if($type=='insert' && isset($_REQUEST['groupInserts']) && $_REQUEST['groupInserts'] && preg_match('/^INSERT INTO (`|\'|"|)([^\s\\1]+)\\1/i',$row['argument'],$matches)) { @@ -219,8 +220,8 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { $return['rows'][$insertTablesFirst]['#'] = $insertTables[$matches[2]]; // Add a ... to the end of this query to indicate that there's been other queries - $return['rows'][$insertTablesFirst]['argument'][strlen($return['rows'][$insertTablesFirst]['argument'])-1] != '.'; - $return['rows'][$insertTablesFirst]['argument'] .= '
...'; + if($return['rows'][$insertTablesFirst]['argument'][strlen($return['rows'][$insertTablesFirst]['argument'])-1] != '.') + $return['rows'][$insertTablesFirst]['argument'] .= '
...'; // Group this value, thus do not add to the result list continue; @@ -240,6 +241,7 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { } $return['sum']['TOTAL'] = array_sum($return['sum']); + $return['numRows'] = count($return['rows']); PMA_DBI_free_result($result); @@ -571,7 +573,7 @@ echo __('Runtime Information'); ?>