diff options
author | Ashutosh Dhundhara <ashutoshdhundhara@yahoo.com> | 2014-05-10 18:53:15 +0400 |
---|---|---|
committer | Ashutosh Dhundhara <ashutoshdhundhara@yahoo.com> | 2014-05-10 18:53:15 +0400 |
commit | 0a5d1ad7570fbd838239d54b79e81853afef7ee3 (patch) | |
tree | d7e237201c1bf5c5a5e7ebceae53bc0fa6c5066d /js/db_structure.js | |
parent | 3084c9f1c81abb7cccac46196afcbfc9a2f1654b (diff) |
RFE: #1448 Allow clicking an approximate row count to get a correct one.
Signed-off-by: Ashutosh Dhundhara <ashutoshdhundhara@yahoo.com>
Diffstat (limited to 'js/db_structure.js')
-rw-r--r-- | js/db_structure.js | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/js/db_structure.js b/js/db_structure.js index 56c4391e7c..0e53d61b43 100644 --- a/js/db_structure.js +++ b/js/db_structure.js @@ -29,6 +29,8 @@ AJAX.registerTeardown('db_structure.js', function () { $('a.drop_tracking_anchor.ajax').die('click'); $('#real_end_input').die('click'); $("a.favorite_table_anchor.ajax").die('click'); + $('a.real_row_count').off('click'); + $('a.row_count_sum').off('click'); }); /** @@ -126,11 +128,50 @@ function PMA_adjustTotals() { // Update summary with new data var $summary = $("#tbl_summary_row"); $summary.find('.tbl_num').text($.sprintf(PMA_messages.strTables, tableSum)); - $summary.find('.tbl_rows').text(strRowSum); + $summary.find('.row_count_sum').text(strRowSum); $summary.find('.tbl_size').text(sizeSum + " " + byteUnits[size_magnitude]); $summary.find('.tbl_overhead').text(overheadSum + " " + byteUnits[overhead_magnitude]); } +/** + * Gets the real row count for a table or DB. + * @param object $target Target for appending the real count value. + */ +function PMA_fetchRealRowCount($target) +{ + $.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. + PMA_adjustTotals(); + } else { + PMA_ajaxShowMessage(PMA_messages.strErrorRealRowCount); + } + }, + error: function () { + PMA_ajaxShowMessage(PMA_messages.strErrorRealRowCount); + } + }); +} + AJAX.registerOnload('db_structure.js', function () { /** * Handler for the print view multisubmit. @@ -396,4 +437,15 @@ AJAX.registerOnload('db_structure.js', function () { $(this).attr("title") ); }); + + // Get real row count via Ajax. + $('a.real_row_count').on('click', function (event) { + event.preventDefault(); + PMA_fetchRealRowCount($(this)); + }); + // Get all real row count. + $('a.row_count_sum').on('click', function (event) { + event.preventDefault(); + PMA_fetchRealRowCount($(this)); + }); }); // end $() |