From 8fe271e8f0e45503e5ffb6eb55b17cb50540bef8 Mon Sep 17 00:00:00 2001
From: juanf <juanf>
Date: Tue, 1 Nov 2016 12:15:43 +0000
Subject: [PATCH] SSDM-4309 : User manager hidden for non admins

SVN: 37229
---
 .../1/as/webapps/eln-lims/html/js/config/Profile.js | 13 ++++++++++++-
 .../html/js/views/SideMenu/SideMenuWidgetView.js    |  2 +-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/Profile.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/Profile.js
index 43b5362d009..2421b7fb60c 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/Profile.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/Profile.js
@@ -96,6 +96,7 @@ $.extend(DefaultProfile.prototype, {
 				}
 		}
 		
+		this.isAdmin = false;
 		this.searchDomains = [ { "@id" : -1, "@type" : "GobalSearch", label : "Global", name : "global"}];
 		this.inventorySpaces = ["MATERIALS", "METHODS"]; //"STOCK_CATALOG"
 		this.inventorySpacesReadOnly = []; //"STOCK_ORDERS"
@@ -722,6 +723,14 @@ $.extend(DefaultProfile.prototype, {
 			});
 		}
 		
+		this.initIsAdmin = function(callback) {
+			var _this = this;
+			this.serverFacade.listPersons(function(data) {
+				_this.isAdmin = !(data.error);
+				callback();
+			});
+		}
+		
 		//
 		// Initializes
 		//
@@ -732,7 +741,9 @@ $.extend(DefaultProfile.prototype, {
 				_this.initVocabulariesForSampleTypes(function() {
 					_this.initSearchDomains(function() {
 						_this.initDirectLinkURL(function() {
-							callbackWhenDone();
+							_this.initIsAdmin(function() {
+								callbackWhenDone();
+							});
 						});
 					});
 				});
diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js
index 35caa3b38ea..9767c6acf03 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js
@@ -253,7 +253,7 @@ function SideMenuWidgetView(sideMenuWidgetController, sideMenuWidgetModel) {
         	treeModelUtils.push({ title : "Storage Manager", entityType: "STORAGE_MANAGER", key : "STORAGE_MANAGER", folder : false, lazy : false, view : "showStorageManager" });
         }
         
-        if(profile.mainMenu.showUserManager) {
+        if(profile.mainMenu.showUserManager && profile.isAdmin) {
         	treeModelUtils.push({ title : "User Manager", entityType: "USER_MANAGER", key : "USER_MANAGER", folder : false, lazy : false, view : "showUserManagerPage", icon : "fa fa-users" });
         }
         
-- 
GitLab