Skip to content

Commit 259343a

Browse files
Merge branch 'v3.11.x' into mergify/bp/v3.11.x/pr-8256
2 parents c9bd34a + 58db672 commit 259343a

File tree

3 files changed

+46
-27
lines changed

3 files changed

+46
-27
lines changed

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

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,9 @@ var exchange_types;
640640
// Used for access control
641641
var user_tags;
642642
var user;
643-
var ac;
644-
var display;
643+
644+
var ac = new AccessControl();
645+
var display = new DisplayControl();
645646

646647
var ui_data_model = {
647648
vhosts: [],
@@ -651,42 +652,60 @@ var ui_data_model = {
651652

652653
// Access control
653654

654-
function AccessControl(user, ui_data_model) {
655-
this.user = user;
656-
this.user_tags = expand_user_tags(user.tags);
657-
this.ui_data_model = ui_data_model;
655+
function AccessControl() {
658656

657+
this.update = function(user, ui_data_model) {
658+
this.user = user;
659+
this.user_tags = expand_user_tags(user.tags);
660+
this.ui_data_model = ui_data_model;
661+
};
659662
this.isMonitoringUser = function() {
660-
return this.user_tags.includes("monitoring");
663+
if (this.user_tags)
664+
return this.user_tags.includes("monitoring");
665+
else return false;
661666
};
662667
this.isAdministratorUser = function() {
663-
return this.user_tags.includes("administrator");
668+
if (this.user_tags)
669+
return this.user_tags.includes("administrator");
670+
else return false;
664671
};
665672
this.isPolicyMakerUser = function() {
666-
return this.user_tags.includes("policymaker");
673+
if (this.user_tags)
674+
return this.user_tags.includes("policymaker");
675+
else return false;
667676
};
668677
this.canAccessVhosts = function() {
669-
return this.ui_data_model.vhosts.length > 0;
678+
if (this.ui_data_model)
679+
return this.ui_data_model.vhosts.length > 0;
680+
else return false;
670681
};
671682
this.canListNodes = function() {
672-
return this.isMonitoringUser() && this.ui_data_model.nodes.length > 1;
683+
if (this.ui_data_model)
684+
return this.isMonitoringUser() && this.ui_data_model.nodes.length > 1;
685+
else return false;
673686
};
674687

675688
};
676689

677-
function DisplayControl(overview, ui_data_model) {
678-
this.nodes = ac.canListNodes() && ui_data_model.nodes.length > 1;
679-
this.vhosts = ac.canAccessVhosts();
680-
this.rabbitmqVersions = false;
681-
var v = '';
682-
for (var i = 0; i < ui_data_model.nodes.length; i++) {
683-
var v1 = fmt_rabbit_version(ui_data_model.nodes[i].applications);
684-
if (v1 != 'unknown') {
685-
if (v != '' && v != v1) this.rabbitmqVersions = true;
686-
v = v1;
687-
}
690+
function DisplayControl() {
691+
this.nodes = false
692+
this.vhosts = false
693+
this.rabbitmqVersions = false
694+
695+
this.update = function(overview, ui_data_model) {
696+
this.nodes = ac.canListNodes() && ui_data_model.nodes.length > 1
697+
this.vhosts = ac.canAccessVhosts()
698+
this.rabbitmqVersions = false
699+
var v = '';
700+
for (var i = 0; i < ui_data_model.nodes.length; i++) {
701+
var v1 = fmt_rabbit_version(ui_data_model.nodes[i].applications);
702+
if (v1 != 'unknown') {
703+
if (v != '' && v != v1) this.rabbitmqVersions = true;
704+
v = v1;
705+
}
706+
}
707+
this.data = ui_data_model;
688708
}
689-
this.data = ui_data_model;
690709

691710
}
692711

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ function check_login () {
113113
}
114114

115115
ui_data_model.vhosts = JSON.parse(sync_get('/vhosts'));
116-
ac = new AccessControl(user, ui_data_model)
116+
ac.update(user, ui_data_model)
117117
if (ac.isMonitoringUser()) {
118118
ui_data_model.nodes = JSON.parse(sync_get('/nodes'))
119119
}
120120
var overview = JSON.parse(sync_get('/overview'))
121121

122-
display = new DisplayControl(overview, ui_data_model)
122+
display.update(overview, ui_data_model)
123123

124124
setup_global_vars(overview)
125125

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<table class="list">
99
<thead>
1010
<tr>
11-
<%= group_heading('queues', 'Overview', [vhosts_interesting, nodes_interesting, true]) %>
11+
<%= group_heading('queues', 'Overview', [display.vhosts, display.nodes, true]) %>
1212
<% if(disable_stats && enable_queue_totals) { %>
1313
<%= group_heading('queues', 'Messages', []) %>
1414
<% } else { %>
@@ -286,7 +286,7 @@
286286
<% } %>
287287
<%
288288
if (ac.canListNodes()) {
289-
var nodes = display.data_model.nodes
289+
var nodes = display.data.nodes
290290
%>
291291
<tr>
292292
<th><label>Node:</label></th>

0 commit comments

Comments
 (0)