From 04fe7da6509d036797403724f4d21f57de5e9f6a Mon Sep 17 00:00:00 2001 From: Eric Feldmann Date: Thu, 1 May 2014 20:07:13 -0500 Subject: [PATCH] Fixed User Group Dashboard --- app/scripts/controllers/user_group_detail.js | 51 +------------------- app/scripts/services/user_groups.js | 30 +----------- app/views/user_group_detail.html | 45 ++++++----------- 3 files changed, 20 insertions(+), 106 deletions(-) diff --git a/app/scripts/controllers/user_group_detail.js b/app/scripts/controllers/user_group_detail.js index afe497b..50b0ee5 100644 --- a/app/scripts/controllers/user_group_detail.js +++ b/app/scripts/controllers/user_group_detail.js @@ -7,20 +7,13 @@ angular.module('vinzApp') $scope.userGroup = userGroups.getUserGroup(userGroupId); $scope.access = {has:true, message: "Revoke"}; - $scope.maintain = {title: "Servers", inGroupYesLabel: "In Group", inGroupNoLabel: "Not In Group"}; + $scope.maintain = {title: "Users", inGroupYesLabel: "In Group", inGroupNoLabel: "Not In Group"}; $scope.action = {buttonClass: "danger", message: "Remove"}; $scope.inGroupYes = true; // caseId = 0 => users in group // caseId = 1 => users not in group - // caseId = 2 => servers with access to group - // caseId = 3 => servers without access to group - // caseId = 4 => servergroups with access to group - // caseId = 5 => servergroups without access to group $scope.shownInTable = function(caseId) { - if (!$scope.inGroupYes && caseId % 2 == 0) { - caseId++; - } $scope.caseId = caseId; @@ -31,17 +24,9 @@ angular.module('vinzApp') } if (caseId == 0 || caseId == 1) { - $scope.maintain.title = "Servers"; + $scope.maintain.title = "Users"; $scope.maintain.inGroupNoLabel = "Not In Group"; $scope.maintain.inGroupYesLabel = "In Group"; - } else if (caseId == 2 || caseId == 3) { - $scope.maintain.title = "Users"; - $scope.maintain.inGroupNoLabel = "No Access"; - $scope.maintain.inGroupYesLabel = "Has Access"; - } else { - $scope.maintain.title = "User Groups"; - $scope.maintain.inGroupNoLabel = "No Access"; - $scope.maintain.inGroupYesLabel = "Has Access"; } switch(caseId) @@ -54,22 +39,6 @@ angular.module('vinzApp') $scope.myUsers = userGroups.getNonGroupUsers(userGroupId); $scope.action.message = "Add"; break; - case 2: - $scope.myServers = userGroups.getUserGroupServers(userGroupId); - $scope.action.message = "Revoke"; - break; - case 3: - $scope.myServers = userGroups.getNonUserGroupServers(userGroupId); - $scope.action.message = "Grant"; - break; - case 4: - $scope.myServerGroups = userGroups.getUserGroupServerGroups(userGroupId); - $scope.action.message = "Revoke"; - break; - case 5: - $scope.myServerGroups = userGroups.getNonUserGroupServerGroups(userGroupId); - $scope.action.message = "Grant"; - break; } } @@ -99,22 +68,6 @@ angular.module('vinzApp') removeFromArray($scope.myUsers, id, 'id'); userGroups.addUserToGroup(userGroupId, id); break; - case 2: - removeFromArray($scope.myServers, id, 'id'); - userGroups.revokeServerAccessToGroup(userGroupId, id); - break; - case 3: - removeFromArray($scope.myServers, id, 'id'); - userGroups.grantServerAccessToGroup(userGroupId, id); - break; - case 4: - removeFromArray($scope.myServerGroups, id, 'id'); - userGroups.revokeServerGroupAccessToGroup(userGroupId, id); - break; - case 5: - removeFromArray($scope.myServerGroups, id, 'id'); - userGroups.grantServerGroupAccessToGroup(userGroupId, id); - break; } } diff --git a/app/scripts/services/user_groups.js b/app/scripts/services/user_groups.js index 2457a2d..47536b5 100644 --- a/app/scripts/services/user_groups.js +++ b/app/scripts/services/user_groups.js @@ -28,8 +28,8 @@ angular.module('vinzApp') createUserGroup: function(newUserGroup) { $http.post(userGroupsURL, newUserGroup); }, - getUserServers: function(userGroupId) { - return UserServer.query({id: userGroupId}); + getGroupUsers: function(userGroupId) { + return GroupUser.query({id: userGroupId}); }, getNonGroupUsers: function(userGroupId) { return GroupUser.query({id: userGroupId, not_in_group: true}); @@ -40,32 +40,6 @@ angular.module('vinzApp') addUserToGroup: function(userGroupId, userId) { var groupUsersAPI = userGroupsURL + userGroupId + '/users/'; $http.post(groupUsersAPI, {user_id: userId}); - }, - getUserGroupServer: function(userGroupId) { - return GroupServer.query({id: userGroupId}); - }, - getNonUserGroupServers: function(userGroupId) { - return GroupServer.query({id: userGroupId, no_access: true}); - }, - revokeServerAccessToGroup: function(userGroupId, serverId) { - GroupServer.remove({id: userGroupId, server_id: serverId}); - }, - grantServerAccessToGroup: function(userGroupId, serverId) { - var groupServersAPI = userGroupsURL + userGroupId + '/servers/'; - $http.post(groupServersAPI, {server_id: serverId}); - }, - getUserGroupServerGroups: function(userGroupId) { - return GroupServerGroup.query({id: userGroupId}); - }, - getNonUserGroupServerGroups: function(userGroupId) { - return GroupServerGroup.query({id: userGroupId, no_access: true}); - }, - revokeServerGroupAccessToGroup: function(userGroupId, serverGroupId) { - GroupServerGroup.remove({id: userGroupId, server_group_id: serverGroupId}); - }, - grantServerGroupAccessToGroup: function(userGroupId, serverGroupId) { - var groupServerGroupsAPI = userGroupsURL + userGroupId + '/servergroups/'; - $http.post(groupServerGroupsAPI, {server_group_id: serverGroupId}); } }; }); diff --git a/app/views/user_group_detail.html b/app/views/user_group_detail.html index e03ce63..bf09149 100644 --- a/app/views/user_group_detail.html +++ b/app/views/user_group_detail.html @@ -4,7 +4,7 @@
User Group Dashboard
- + All Groups @@ -19,49 +19,41 @@ - +
-
-
- - -
+
+ Users
- +
- - + +
- - + + - - - - + + + +
NameHostnameAccessEmailGroup
{{server.name}}{{server.hostname}}
{{access.message}}
{{user.first_name}} {{user.last_name}}{{user.email}}
@@ -70,7 +62,6 @@