diff options
Diffstat (limited to 'app/common')
-rw-r--r-- | app/common/directives/ldap-user-roles.html | 2 | ||||
-rw-r--r-- | app/common/directives/ldap-user-roles.js | 98 |
2 files changed, 37 insertions, 63 deletions
diff --git a/app/common/directives/ldap-user-roles.html b/app/common/directives/ldap-user-roles.html index e250772..22a9ffb 100644 --- a/app/common/directives/ldap-user-roles.html +++ b/app/common/directives/ldap-user-roles.html @@ -84,7 +84,7 @@ <!-- LDAP Disabled Role Groups Table Row --> <div class="empty__logs" ng-if="roleGroups.length < 1 || !enabled"> <p - ng-if="roleGroups.length < 1 && roleGroupType === 'ad' || roleGroupType === 'ldap'" + ng-if="!roleGroups.length && roleGroupType" > No role groups have been created yet. </p> diff --git a/app/common/directives/ldap-user-roles.js b/app/common/directives/ldap-user-roles.js index afe30c5..0074170 100644 --- a/app/common/directives/ldap-user-roles.js +++ b/app/common/directives/ldap-user-roles.js @@ -41,22 +41,19 @@ window.angular && (function(angular) { }; $scope.addRoleGroup = () => { + $scope.loading = true; + const newGroup = {}; newGroup.RemoteGroup = $scope.newGroup.RemoteGroup; newGroup.LocalRole = $scope.newGroup.LocalRole; - $scope.loading = true; const data = {}; - - if ($scope.roleGroupType == 'ldap') { - data.LDAP = {}; - data.LDAP.RemoteRoleMapping = $scope.roleGroups; - data.LDAP.RemoteRoleMapping.push(newGroup); - } else { - data.ActiveDirectory = {}; - data.ActiveDirectory.RemoteRoleMapping = $scope.roleGroups; - data.ActiveDirectory.RemoteRoleMapping.push(newGroup); - } + const roleGroups = $scope.roleGroups; + const roleGroupType = $scope.roleGroupType; + data[roleGroupType] = {}; + data[roleGroupType]['RemoteRoleMapping'] = roleGroups; + data[roleGroupType]['RemoteRoleMapping'][roleGroups.length] = + newGroup; APIUtils.saveLdapProperties(data) .then( @@ -82,19 +79,14 @@ window.angular && (function(angular) { $scope.editRoleGroup = () => { $scope.loading = true; const data = {}; - - if ($scope.roleGroupType == 'ldap') { - data.LDAP = {}; - data.LDAP.RemoteRoleMapping = $scope.roleGroups; - data.LDAP.RemoteRoleMapping[$scope.selectedGroupIndex] - .LocalRole = $scope.newGroup.LocalRole; - } else { - data.ActiveDirectory = {}; - data.ActiveDirectory.RemoteRoleMapping = $scope.roleGroups; - data.ActiveDirectory - .RemoteRoleMapping[$scope.selectedGroupIndex] - .LocalRole = $scope.newGroup.LocalRole; - } + const roleGroupType = $scope.roleGroupType; + const roleGroups = $scope.roleGroups; + const localRole = $scope.newGroup.LocalRole; + const selectedIndex = $scope.selectedGroupIndex; + data[roleGroupType] = {}; + data[roleGroupType]['RemoteRoleMapping'] = roleGroups; + data[roleGroupType]['RemoteRoleMapping'][selectedIndex]['LocalRole'] = + localRole; APIUtils.saveLdapProperties(data) .then( @@ -111,29 +103,21 @@ window.angular && (function(angular) { $scope.editGroup = false; }; - $scope.removeGroupFn = (index) => { + $scope.removeGroupFn = index => { $scope.removeGroup = true; $scope.selectedGroupIndex = index; }; $scope.removeRoleGroup = () => { $scope.loading = true; + const roleGroupType = $scope.roleGroupType; + const roleGroups = $scope.roleGroups; + const selectedGroupIndex = $scope.selectedGroupIndex; const data = {}; - - if ($scope.roleGroupType == 'ldap') { - data.LDAP = {}; - data.LDAP.RemoteRoleMapping = $scope.roleGroups; - data.LDAP.RemoteRoleMapping[$scope.selectedGroupIndex] = - $scope.newGroup; - } else { - data.ActiveDirectory = {}; - data.ActiveDirectory.RemoteRoleMapping = $scope.roleGroups; - data.ActiveDirectory - .RemoteRoleMapping[$scope.selectedGroupIndex] = - $scope.newGroup; - } - - $scope.roleGroups[$scope.selectedGroupIndex] = null; + data[roleGroupType] = {}; + data[roleGroupType]['RemoteRoleMapping'] = roleGroups; + data[roleGroupType]['RemoteRoleMapping'][selectedGroupIndex] = + null; APIUtils.saveLdapProperties(data) .then( @@ -158,7 +142,7 @@ window.angular && (function(angular) { $scope.roleGroupIsSelectedChanged = () => { let groupSelected = false; $scope.roleGroups.forEach(group => { - if (group['isSelected']) { + if (group && group['isSelected']) { groupSelected = true; } }); @@ -167,28 +151,18 @@ window.angular && (function(angular) { $scope.removeMultipleRoleGroups = () => { $scope.loading = true; + const roleGroupType = $scope.roleGroupType; + const roleGroups = $scope.roleGroups; const data = {}; - - if ($scope.roleGroupType == 'ldap') { - data.LDAP = {}; - data.LDAP.RemoteRoleMapping = $scope.roleGroups.map((group) => { - if (group['isSelected']) { - return null; - } else { - return group; - } - }); - } else { - data.ActiveDirectory = {}; - data.ActiveDirectory.RemoteRoleMapping = - $scope.roleGroups.map((group) => { - if (group['isSelected']) { - return null; - } else { - return group; - } - }); - } + data[roleGroupType] = {}; + data[roleGroupType]['RemoteRoleMapping'] = + roleGroups.map((group) => { + if (group['isSelected']) { + return null; + } else { + return group; + } + }); APIUtils.saveLdapProperties(data) .then( |