Skip to content

Commit 8d26319

Browse files
committed
Full page reload in some situations
1. If the Management UI lost connection and established it again, there's a good chance it's now connected to a diffrent RabbitMQ node, potentially running a different version. 2. If the overview endpoints returns a different version, fully reload the page. This only works on the home page, but that's better than nothing
1 parent a1bb14c commit 8d26319

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

deps/rabbitmq_management/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ prepare-dist::
4848
mv $(EZ_DIR)/priv/www/css/main.css $(EZ_DIR)/priv/www/css/main-$(PROJECT_VERSION).css
4949
$(verbose) sed "s#css/main.css#css/main-$(PROJECT_VERSION).css#" priv/www/index.html \
5050
> $(EZ_DIR)/priv/www/index.html
51+
echo "management_version = \"$(PROJECT_VERSION)\";" >> $(EZ_DIR)/priv/www/js/global.js

deps/rabbitmq_management/priv/www/js/global.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,9 @@ var timer_interval;
872872
// When did we last connect successfully (for the "could not connect" error)
873873
var last_successful_connect;
874874

875+
// we want a full page refresh after we were disconnected or if the RabbitMQ version changed
876+
var needs_full_refresh = false;
877+
875878
// Every 200 updates without user interaction we do a full refresh, to
876879
// work around memory leaks in browser DOM implementations.
877880
// TODO: maybe we don't need this any more?
@@ -886,3 +889,6 @@ var chart_data = {};
886889
var last_page_out_of_range_error = 0;
887890

888891
var oauth;
892+
893+
// version of RabbitMQ we connected to; used to detect version changes
894+
var management_version = "";

deps/rabbitmq_management/priv/www/js/main.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,11 @@ function maybe_format_extra_queue_content(queue, extraContent) {
13061306

13071307
function update_status(status) {
13081308
var text;
1309-
if (status == 'ok')
1309+
if (status == 'ok' && needs_full_refresh) {
1310+
// connection was restored, get the latest CSS/JS
1311+
needs_full_refresh = false;
1312+
full_refresh();
1313+
} else if (status == 'ok')
13101314
text = "Refreshed " + fmt_date(new Date());
13111315
else if (status == 'error') {
13121316
var next_try = new Date(new Date().getTime() + timer_interval);
@@ -1496,6 +1500,7 @@ function check_bad_response(req, full_page_404) {
14961500
clearInterval(timer);
14971501
}
14981502

1503+
needs_full_refresh = true;
14991504
return false;
15001505
}
15011506

deps/rabbitmq_management/priv/www/js/tmpl/overview.ejs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
<%
2+
if(management_version != overview.management_version) {
3+
// RabbitMQ was upgraded
4+
// full reload to get the latest CSS and JavaScript files
5+
needs_full_refresh = true;
6+
}
7+
%>
18
<% if(disable_stats) { %>
29
<h1>Overview: Management only mode</h1>
310
<% } else { %>

0 commit comments

Comments
 (0)