Hi, Please find the attached patch to fix the RM #1165 - Too many request to update dashboard graphs when server is disconnected.
Thanks, Khushboo
diff --git a/web/pgadmin/dashboard/templates/dashboard/js/dashboard.js b/web/pgadmin/dashboard/templates/dashboard/js/dashboard.js index 34a1ab7..e858faa 100644 --- a/web/pgadmin/dashboard/templates/dashboard/js/dashboard.js +++ b/web/pgadmin/dashboard/templates/dashboard/js/dashboard.js @@ -89,28 +89,35 @@ function(r, $, pgAdmin, _, Backbone, gettext) { ); if (div) { - // Avoid unnecessary reloads - if (url != $(dashboardPanel).data('dashboard_url')) { - // Clear out everything so any existing timers die off + if (itemData.connected || _.isUndefined(itemData.connected)) { + // Avoid unnecessary reloads + if (url != $(dashboardPanel).data('dashboard_url')) { + // Clear out everything so any existing timers die off + $(div).empty(); + + $.ajax({ + url: url, + type: "GET", + dataType: "html", + success: function (data) { + $(div).html(data); + }, + error: function (xhr, status) { + $(div).html( + '<div class="alert alert-danger pg-panel-message" role="alert">' + gettext('An error occurred whilst loading the dashboard.') + '</div>' + ); + } + }); + } + } + else { $(div).empty(); - - $.ajax({ - url: url, - type: "GET", - dataType: "html", - success: function (data) { - $(div).html(data); - }, - error: function (xhr, status) { - $(div).html( - '<div class="alert alert-danger pg-panel-message" role="alert">' + gettext('An error occurred whilst loading the dashboard.') + '</div>' - ); - } - }); - - // Cache the current IDs for next time - $(dashboardPanel).data('dashboard_url', url); + $(div).html( + '<div class="alert alert-info pg-panel-message" role="alert">' + gettext('Please connect to the selected server to view the dashboard.') + '</div>' + ); } + // Cache the current IDs for next time + $(dashboardPanel).data('dashboard_url', url); } } }