-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete a member from a group. I moved around some files for display g…
…roup. Also added Underscore. So please do a bower install when you pull
- Loading branch information
Showing
8 changed files
with
241 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
angular.module("myApp.displayGroups", ["ngRoute", "LocalStorageModule", "myApp.groups.groupsHandler"]) | ||
|
||
.config(["$routeProvider", function($routeProvider) { | ||
$routeProvider.when("/displayGroup", { | ||
templateUrl: "displayGroup/displayGroup.html", | ||
controller: "displaygroupsController" | ||
}); | ||
}]) | ||
|
||
.controller("displaygroupsController", function($scope, $location, localStorageService, groupsHandler) { | ||
var usernameFromStorage, | ||
storageKey = "user", | ||
selected_group = groupsHandler.curr_group; | ||
|
||
$scope.groups = []; | ||
|
||
function getItem(key) { | ||
return localStorageService.get(key); | ||
}; | ||
|
||
if(!getItem(storageKey)){ | ||
//User has not logged in yet so redirect to login | ||
$location.url("/login"); | ||
}else{ | ||
usernameFromStorage = getItem(storageKey); | ||
} | ||
|
||
function getMembers(groupID) { | ||
groupsHandler.getMembers(groupID, function(result){ | ||
var index = 0; | ||
if(result.data.success){ | ||
for(index; index < result.data.results.length; index++){ | ||
$scope.groups.push({"name": result.data.results[index][1], "date": result.data.results[index][0]}); | ||
} | ||
console.log($scope.groups); | ||
}else{ | ||
alert("Error loading group. Please try again."); | ||
} | ||
}) | ||
}; | ||
|
||
if(!selected_group){ | ||
$location.url("/groups"); | ||
}else{ | ||
console.log(selected_group); | ||
$scope.group_name = selected_group.name; | ||
// $scope.groups = []; | ||
getMembers(selected_group.id); | ||
// console.log($scope.groups); | ||
} | ||
|
||
$scope.addMember = function () { | ||
if($scope.addMemberName){ | ||
groupsHandler.addMember(selected_group.id, $scope.addMemberName, function(result){ | ||
if(result.data.success){ | ||
$scope.groups.push({"name": $scope.addMemberName, "date": selected_group.id}); | ||
}else{ | ||
alert("Error adding member. Please try again with a valid username."); | ||
} | ||
}); | ||
}else{ | ||
alert("Please type a valid username to be added"); | ||
} | ||
}; | ||
|
||
$scope.removeMember = function () { | ||
if($scope.removeMemberName){ | ||
groupsHandler.deleteMember(selected_group.id, $scope.removeMemberName, function(result){ | ||
if(result.data.success){ | ||
$scope.groups.splice(_.indexOf($scope.groups, _.findWhere($scope.groups, { "name" : $scope.removeMemberName})), 1); | ||
}else{ | ||
alert("Error deleting member. Please try again with a valid username."); | ||
} | ||
}); | ||
}else{ | ||
alert("Please type a valid username to be added"); | ||
} | ||
}; | ||
|
||
|
||
|
||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters