diff options
author | Endi S. Dewata <edewata@redhat.com> | 2016-11-22 18:30:01 +0100 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2016-11-22 18:33:15 +0100 |
commit | 3d3772025d0b6cf527dac6e40102bb5d6f4ce317 (patch) | |
tree | a936baf0f980f31b688db4967e81ee3828eb08ee /base/tps/shared/webapps | |
parent | 6d5d15edebeb1ba113e4f3d5b2bb1ba93a92ce1d (diff) | |
download | pki-3d3772025d0b6cf527dac6e40102bb5d6f4ce317.tar.gz pki-3d3772025d0b6cf527dac6e40102bb5d6f4ce317.tar.xz pki-3d3772025d0b6cf527dac6e40102bb5d6f4ce317.zip |
Fixed TPS UI system menu.
The TPS UI has been modified to adjust the system menu based
on the list of accessible components obtained during login.
The TPSApplication has been modified to use TPSAccountService
which returns the list of accessible components based on the
following properties in the CS.cfg:
* admin: target.configure.list
* agent: target.agent_approve.list
https://fedorahosted.org/pki/ticket/2523
Diffstat (limited to 'base/tps/shared/webapps')
-rw-r--r-- | base/tps/shared/webapps/tps/ui/index.html | 56 |
1 files changed, 50 insertions, 6 deletions
diff --git a/base/tps/shared/webapps/tps/ui/index.html b/base/tps/shared/webapps/tps/ui/index.html index 63baf3e27..93d3af0b0 100644 --- a/base/tps/shared/webapps/tps/ui/index.html +++ b/base/tps/shared/webapps/tps/ui/index.html @@ -46,6 +46,40 @@ <script> $(function() { + function getAttribute(attributes, name) { + for (var i=0; i<attributes.length; i++) { + var attribute = attributes[i]; + if (name != attribute.name) continue; + return attribute.value; + } + return null; + } + + function getElementName(component) { + + if (component == "Generals") { + return "config"; + + } else if (component == "Authentication_Sources") { + return "authenticators"; + + } else if (component == "Subsystem_Connections") { + return "connectors"; + + } else if (component == "Profiles") { + return "profiles"; + + } else if (component == "Profile_Mappings") { + return "profile-mappings"; + + } else if (component == "Audit_Logging") { + return "audit"; + + } else { + return null; + } + } + var account = new Account(); account.login({ success: function(data, textStatus, jqXHR) { @@ -64,14 +98,24 @@ $(function() { accounts_menu.hide(); } - if (_.contains(roles, "Administrators")) { - system_menu.show(); - $("li", system_menu).show(); + var attributes = tps.user.Attributes.Attribute; + var values = getAttribute(attributes, "components"); + + var components; + if (values) { + components = values.split(","); + } else { + components = []; + } - } else if (_.contains(roles, "TPS Agents")) { + if (components.length > 0) { + // display menu items for accessible components system_menu.show(); - $("li", system_menu).hide(); - $("[name=profiles]", system_menu).show(); + for (var i=0; i<components.length; i++) { + var name = getElementName(components[i]); + if (!name) continue; + $("[name=" + name + "]", system_menu).show(); + } } else { system_menu.hide(); |