summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimur Sufiev <tsufiev@mirantis.com>2015-04-30 12:54:29 +0300
committerDoug Fish <drfish@us.ibm.com>2015-04-30 22:14:14 +0000
commit78b6f5ed6145dcb2e9ce2caed0c87d159c12697b (patch)
treeb2dae65dbc44d61ddac636923ecbe3fb9aff3ebd
parent8a966fe67037922ae991783a9ce4a811f0153e42 (diff)
downloadhorizon-78b6f5ed6145dcb2e9ce2caed0c87d159c12697b.tar.gz
Fix exponentially growing AJAX updates for table rows
Schedule next table rows update only when the last row was updated. Since unit-test for this fix relies on a blueprint replace-qunit-tests-with-jasmine it is moved to a separate commit to speed up this fix merge, see https://review.openstack.org/#/c/179013/ Closes-Bug: #1263665 (cherry picked from commit ca090378b4875afebdebd67bdb457eebad6b2b7d) Conflict Resolution Notes: cherry-pick needed to have the old body of the complete: function manually removed - it wasn't sure if it still belonged (resulting in nearly duplicate code) or should be removed. I'm a bit surprised the cherry-pick didn't auto-resolve. Conflicts: horizon/static/horizon/js/horizon.tables.js Change-Id: Id603a4fde5713d8f2b85b1dcf72c82c93a87c755
-rw-r--r--horizon/static/horizon/js/horizon.tables.js32
1 files changed, 18 insertions, 14 deletions
diff --git a/horizon/static/horizon/js/horizon.tables.js b/horizon/static/horizon/js/horizon.tables.js
index 2788119ca..f927d7c14 100644
--- a/horizon/static/horizon/js/horizon.tables.js
+++ b/horizon/static/horizon/js/horizon.tables.js
@@ -1,8 +1,9 @@
/* Namespace for core functionality related to DataTables. */
horizon.datatables = {
update: function () {
- var $rows_to_update = $('tr.status_unknown.ajax-update');
- if ($rows_to_update.length) {
+ var $rows_to_update = $('tr.status_unknown.ajax-update'),
+ rows_to_update = $rows_to_update.length;
+ if ( rows_to_update > 0 ) {
var interval = $rows_to_update.attr('data-update-interval'),
$table = $rows_to_update.closest('table'),
decay_constant = $table.attr('decay_constant');
@@ -93,19 +94,22 @@ horizon.datatables = {
complete: function (jqXHR, textStatus) {
// Revalidate the button check for the updated table
horizon.datatables.validate_button();
-
- // Set interval decay to this table, and increase if it already exist
- if(decay_constant === undefined) {
- decay_constant = 1;
- } else {
- decay_constant++;
+ rows_to_update--;
+ // Schedule next poll when all the rows are updated
+ if ( rows_to_update === 0 ) {
+ // Set interval decay to this table, and increase if it already exist
+ if(decay_constant === undefined) {
+ decay_constant = 1;
+ } else {
+ decay_constant++;
+ }
+ $table.attr('decay_constant', decay_constant);
+ // Poll until there are no rows in an "unknown" state on the page.
+ var next_poll = interval * decay_constant;
+ // Limit the interval to 30 secs
+ if(next_poll > 30 * 1000) { next_poll = 30 * 1000; }
+ setTimeout(horizon.datatables.update, next_poll);
}
- $table.attr('decay_constant', decay_constant);
- // Poll until there are no rows in an "unknown" state on the page.
- next_poll = interval * decay_constant;
- // Limit the interval to 30 secs
- if(next_poll > 30 * 1000) { next_poll = 30 * 1000; }
- setTimeout(horizon.datatables.update, next_poll);
}
});
});