Fix #8276
This commit is contained in:
parent
f82a3f253d
commit
02fda919a5
|
@ -640,8 +640,8 @@ var exchange_types;
|
|||
// Used for access control
|
||||
var user_tags;
|
||||
var user;
|
||||
var ac;
|
||||
var display;
|
||||
var ac = new AccessControl();
|
||||
var display = new DisplayControl();
|
||||
|
||||
var ui_data_model = {
|
||||
vhosts: [],
|
||||
|
@ -651,42 +651,60 @@ var ui_data_model = {
|
|||
|
||||
// Access control
|
||||
|
||||
function AccessControl(user, ui_data_model) {
|
||||
this.user = user;
|
||||
this.user_tags = expand_user_tags(user.tags);
|
||||
this.ui_data_model = ui_data_model;
|
||||
function AccessControl() {
|
||||
|
||||
this.update = function(user, ui_data_model) {
|
||||
this.user = user;
|
||||
this.user_tags = expand_user_tags(user.tags);
|
||||
this.ui_data_model = ui_data_model;
|
||||
};
|
||||
this.isMonitoringUser = function() {
|
||||
return this.user_tags.includes("monitoring");
|
||||
if (this.user_tags)
|
||||
return this.user_tags.includes("monitoring");
|
||||
else return false;
|
||||
};
|
||||
this.isAdministratorUser = function() {
|
||||
return this.user_tags.includes("administrator");
|
||||
if (this.user_tags)
|
||||
return this.user_tags.includes("administrator");
|
||||
else return false;
|
||||
};
|
||||
this.isPolicyMakerUser = function() {
|
||||
return this.user_tags.includes("policymaker");
|
||||
if (this.user_tags)
|
||||
return this.user_tags.includes("policymaker");
|
||||
else return false;
|
||||
};
|
||||
this.canAccessVhosts = function() {
|
||||
return this.ui_data_model.vhosts.length > 0;
|
||||
if (this.ui_data_model)
|
||||
return this.ui_data_model.vhosts.length > 0;
|
||||
else return false;
|
||||
};
|
||||
this.canListNodes = function() {
|
||||
return this.isMonitoringUser() && this.ui_data_model.nodes.length > 1;
|
||||
if (this.ui_data_model)
|
||||
return this.isMonitoringUser() && this.ui_data_model.nodes.length > 1;
|
||||
else return false;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
function DisplayControl(overview, ui_data_model) {
|
||||
this.nodes = ac.canListNodes() && ui_data_model.nodes.length > 1;
|
||||
this.vhosts = ac.canAccessVhosts();
|
||||
this.rabbitmqVersions = false;
|
||||
var v = '';
|
||||
for (var i = 0; i < ui_data_model.nodes.length; i++) {
|
||||
var v1 = fmt_rabbit_version(ui_data_model.nodes[i].applications);
|
||||
if (v1 != 'unknown') {
|
||||
if (v != '' && v != v1) this.rabbitmqVersions = true;
|
||||
v = v1;
|
||||
}
|
||||
function DisplayControl() {
|
||||
this.nodes = false
|
||||
this.vhosts = false
|
||||
this.rabbitmqVersions = false
|
||||
|
||||
this.update = function(overview, ui_data_model) {
|
||||
this.nodes = ac.canListNodes() && ui_data_model.nodes.length > 1
|
||||
this.vhosts = ac.canAccessVhosts()
|
||||
this.rabbitmqVersions = false
|
||||
var v = '';
|
||||
for (var i = 0; i < ui_data_model.nodes.length; i++) {
|
||||
var v1 = fmt_rabbit_version(ui_data_model.nodes[i].applications);
|
||||
if (v1 != 'unknown') {
|
||||
if (v != '' && v != v1) this.rabbitmqVersions = true;
|
||||
v = v1;
|
||||
}
|
||||
}
|
||||
this.data = ui_data_model;
|
||||
}
|
||||
this.data = ui_data_model;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -113,13 +113,13 @@ function check_login () {
|
|||
}
|
||||
|
||||
ui_data_model.vhosts = JSON.parse(sync_get('/vhosts'));
|
||||
ac = new AccessControl(user, ui_data_model)
|
||||
ac.update(user, ui_data_model)
|
||||
if (ac.isMonitoringUser()) {
|
||||
ui_data_model.nodes = JSON.parse(sync_get('/nodes'))
|
||||
}
|
||||
var overview = JSON.parse(sync_get('/overview'))
|
||||
|
||||
display = new DisplayControl(overview, ui_data_model)
|
||||
display.update(overview, ui_data_model)
|
||||
|
||||
setup_global_vars(overview)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<%= group_heading('queues', 'Overview', [vhosts_interesting, nodes_interesting, true]) %>
|
||||
<%= group_heading('queues', 'Overview', [display.vhosts, display.nodes, true]) %>
|
||||
<% if(disable_stats && enable_queue_totals) { %>
|
||||
<%= group_heading('queues', 'Messages', []) %>
|
||||
<% } else { %>
|
||||
|
|
Loading…
Reference in New Issue