summaryrefslogtreecommitdiffstats
path: root/app/common
diff options
context:
space:
mode:
authorDerick Montague <derick.montague@ibm.com>2019-09-24 12:09:30 -0500
committerGunnar Mills <gmills@us.ibm.com>2019-10-09 20:42:21 +0000
commit7bdb91d4c4cd456ada08fc1dc684ff7aefa1ffa8 (patch)
tree419ad09d6d821f0c6d1e357e8e08d01565824e7e /app/common
parent86c0b94b6d4e3876b9a43b01faa8ee78269415eb (diff)
downloadphosphor-webui-7bdb91d4c4cd456ada08fc1dc684ff7aefa1ffa8.tar.gz
phosphor-webui-7bdb91d4c4cd456ada08fc1dc684ff7aefa1ffa8.zip
Fix LDAP service update error
When a service is enabled, it must be disabled prior to changing the service type, e.g change from OpenLDAP to ActiveDirectory. - Add check to determine if a service is already enabled - Make two calls if service is already enabled. First to disable existing service. Second to enable updated service - Remove toast message for ssl check and replace with error message which also keeps submit button disabled if the regex pattern is not met Tested: - Edge - Safari - Firefox - Chrome - IE 11 Signed-off-by: Derick Montague <derick.montague@ibm.com> Change-Id: I195eeb7d1cd3621681c18f4dd9aa4414eb079c09
Diffstat (limited to 'app/common')
-rw-r--r--app/common/directives/ldap-user-roles.html2
-rw-r--r--app/common/directives/ldap-user-roles.js98
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(
OpenPOWER on IntegriCloud