Skip to content

Commit 58db672

Browse files
Merge pull request #8302 from rabbitmq/mergify/bp/v3.11.x/pr-8300
Fix #8276 (backport #8289) (backport #8300)
2 parents a2f2ef6 + cb9105e commit 58db672

File tree

3 files changed

+91
-1
lines changed

3 files changed

+91
-1
lines changed

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

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,76 @@ var exchange_types;
638638
// Used for access control
639639
var user_tags;
640640
var user;
641+
<<<<<<< HEAD
642+
=======
643+
var ac = new AccessControl();
644+
var display = new DisplayControl();
645+
646+
var ui_data_model = {
647+
vhosts: [],
648+
nodes: [],
649+
650+
};
651+
652+
// Access control
653+
654+
function AccessControl() {
655+
656+
this.update = function(user, ui_data_model) {
657+
this.user = user;
658+
this.user_tags = expand_user_tags(user.tags);
659+
this.ui_data_model = ui_data_model;
660+
};
661+
this.isMonitoringUser = function() {
662+
if (this.user_tags)
663+
return this.user_tags.includes("monitoring");
664+
else return false;
665+
};
666+
this.isAdministratorUser = function() {
667+
if (this.user_tags)
668+
return this.user_tags.includes("administrator");
669+
else return false;
670+
};
671+
this.isPolicyMakerUser = function() {
672+
if (this.user_tags)
673+
return this.user_tags.includes("policymaker");
674+
else return false;
675+
};
676+
this.canAccessVhosts = function() {
677+
if (this.ui_data_model)
678+
return this.ui_data_model.vhosts.length > 0;
679+
else return false;
680+
};
681+
this.canListNodes = function() {
682+
if (this.ui_data_model)
683+
return this.isMonitoringUser() && this.ui_data_model.nodes.length > 1;
684+
else return false;
685+
};
686+
687+
};
688+
689+
function DisplayControl() {
690+
this.nodes = false
691+
this.vhosts = false
692+
this.rabbitmqVersions = false
693+
694+
this.update = function(overview, ui_data_model) {
695+
this.nodes = ac.canListNodes() && ui_data_model.nodes.length > 1
696+
this.vhosts = ac.canAccessVhosts()
697+
this.rabbitmqVersions = false
698+
var v = '';
699+
for (var i = 0; i < ui_data_model.nodes.length; i++) {
700+
var v1 = fmt_rabbit_version(ui_data_model.nodes[i].applications);
701+
if (v1 != 'unknown') {
702+
if (v != '' && v != v1) this.rabbitmqVersions = true;
703+
v = v1;
704+
}
705+
}
706+
this.data = ui_data_model;
707+
}
708+
709+
}
710+
>>>>>>> cc4fc57d0b (Fix #8276)
641711

642712
// Set up the above vars
643713
function setup_global_vars() {

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,22 @@ function check_login () {
111111
if (!isNaN(user_login_session_timeout)) {
112112
update_login_session_timeout(user_login_session_timeout)
113113
}
114+
<<<<<<< HEAD
114115
setup_global_vars()
116+
=======
117+
118+
ui_data_model.vhosts = JSON.parse(sync_get('/vhosts'));
119+
ac.update(user, ui_data_model)
120+
if (ac.isMonitoringUser()) {
121+
ui_data_model.nodes = JSON.parse(sync_get('/nodes'))
122+
}
123+
var overview = JSON.parse(sync_get('/overview'))
124+
125+
display.update(overview, ui_data_model)
126+
127+
setup_global_vars(overview)
128+
129+
>>>>>>> cc4fc57d0b (Fix #8276)
115130
setup_constant_events()
116131
update_vhosts()
117132
update_interval()

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

Lines changed: 6 additions & 1 deletion
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 { %>
@@ -284,8 +284,13 @@
284284
</tr>
285285
<% } %>
286286
<%
287+
<<<<<<< HEAD
287288
if (nodes_interesting) {
288289
var nodes = JSON.parse(sync_get('/nodes'));
290+
=======
291+
if (ac.canListNodes()) {
292+
var nodes = display.data.nodes
293+
>>>>>>> 30184053c9 (Fix member variable for datamodel in Display)
289294
%>
290295
<tr>
291296
<th><label>Node:</label></th>

0 commit comments

Comments
 (0)