-
Notifications
You must be signed in to change notification settings - Fork 95
Added delete a user service ,Added remove icon and refresh the user list #13
base: master
Are you sure you want to change the base?
Changes from 1 commit
f71a024
a6bd633
75b9f3c
272d73c
4721493
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,7 @@ class SQLUserDAO(val database: SQLDatabase) extends UserDAO with SQLUserSchema { | |
| } | ||
|
|
||
| def findById(userId: ObjectId) = findOneWhere(_.id === userId) | ||
|
|
||
| def findByEmail(email: String) = findOneWhere(_.emailLowerCase === email.toLowerCase) | ||
|
|
||
| def findByLowerCasedLogin(login: String) = db.withTransaction { implicit session => | ||
|
|
@@ -124,7 +124,7 @@ class SQLUserDAO(val database: SQLDatabase) extends UserDAO with SQLUserSchema { | |
| } yield (u, a, s, l) | ||
| userQuery.firstOption.map(queryUserAliases).map(untuple) | ||
| } | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove this empty line |
||
| private def queryUserAliases(tuple: (UserTuple, SQLAuth, SQLSettings, SQLLastNotif))(implicit session: Session) = { | ||
| val userId = tuple._1._1 | ||
| val aliases = userAliases.where(_.userId === userId).list() | ||
|
|
@@ -135,4 +135,11 @@ class SQLUserDAO(val database: SQLDatabase) extends UserDAO with SQLUserSchema { | |
| val aliases = userAliases.where(_.userId === tuple._1).list() | ||
| (tuple._1, tuple._2, tuple._3, tuple._4, UserAliases(aliases.map(_.toUserAlias))) | ||
| } | ||
| } | ||
|
|
||
| def delete(userId: ObjectId) { | ||
| db.withTransaction { implicit session => | ||
| users.filter(_.id === userId).delete | ||
| } | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,4 +40,7 @@ trait UserDAO { | |
| def countAll(): Long | ||
|
|
||
| def countAllActive(): Long | ||
|
|
||
| def delete(userId: ObjectId) | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,4 +51,8 @@ class ModifyUserDetailsUseCase(protected val userDao: UserDAO) extends Logging { | |
| validate(checkUserActive, changeOwnFlagsCheck) | ||
| } | ||
|
|
||
| def delete(userId: ObjectId) = { | ||
| userDao.delete(userId) | ||
| } | ||
|
||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,17 +26,37 @@ angular.module('codebrag.userMgmt') | |
| }); | ||
| }; | ||
|
|
||
| $scope.deleteUser = function(userId) { | ||
| $scope.flash.clear(); | ||
| var userData = { userId: userId }; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this is not used |
||
| userMgmtService.deleteUser(userId).then(deleteSuccess, deleteFailed('active', userId)) | ||
| userMgmtService.loadUsers().then(function(users) { | ||
| $scope.users = users; | ||
| }); | ||
| }; | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please unident the whole section |
||
| $scope.askForNewPassword = function(user) { | ||
| $scope.flash.clear(); | ||
| var modal = popupsService.openSetUserPasswordPopup(user); | ||
| modal.result.then(function() { | ||
| $scope.flash.add('info', 'User password changed'); | ||
| }); | ||
| }; | ||
| function deleteSuccess() { | ||
| $scope.flash.add('error', 'User is removed'); | ||
| } | ||
|
|
||
| function modifySuccess() { | ||
| $scope.flash.add('info', 'User details changed'); | ||
| } | ||
| function deleteFailed(flag, userId) { | ||
| return function(errorsMap) { | ||
| $scope.flash.add('error', 'Could not change user details'); | ||
| flattenErrorsMap(errorsMap).forEach(function(error) { | ||
| $scope.flash.add('error', error); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| function modifyFailed(flag, user) { | ||
| return function(errorsMap) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,11 @@ angular.module('codebrag.userMgmt') | |
| return $http.put(modifyUserUrl, userData).then(null, modifyUserFailed); | ||
| }; | ||
|
|
||
| this.deleteUser = function(userId) { | ||
| var modifyUserUrl = [usersApiUrl, '/', userId].join(''); | ||
| return $http.delete(modifyUserUrl).then(null, modifyUserFailed); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please un-indent both lines |
||
| }; | ||
|
|
||
| function modifyUserFailed(response) { | ||
| return $q.reject(response.data); | ||
| } | ||
|
|
@@ -34,4 +39,4 @@ angular.module('codebrag.userMgmt') | |
| $modal.open(config) | ||
| } | ||
|
|
||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,17 +21,21 @@ <h1>Manage team members | |
| </th> | ||
| <th class="cell-centered"> | ||
| <div class="thead">Admin?</div> | ||
| </th> | ||
| </th> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ??? |
||
| <th> | ||
| <div class="thead"> </div> | ||
| </th> | ||
| <th class="cell-centered"> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add proper indent here |
||
| <div class="thead"> </div> | ||
| </th> | ||
| </thead> | ||
| <tbody> | ||
| <tr ng-repeat="user in users"> | ||
| <td class="user-email">{{ user.email}}</td> | ||
| <td class="cell-centered"><input type="checkbox" ng-model="user.active" ng-click="modifyUser(user, 'active')" ng-disabled="user.locked"/></td> | ||
| <td class="cell-centered"><input type="checkbox" ng-model="user.admin" ng-click="modifyUser(user, 'admin')" ng-disabled="user.locked"/></td> | ||
| <td><button class="link" ng-disabled="!user.active" ng-click="askForNewPassword(user)">Set password</button></td> | ||
| <td><i class="icon-remove" ng-hide="user.admin" ng-disabled="user.locked" ng-click="deleteUser(user.userId)"></i></td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
|
|
@@ -45,4 +49,4 @@ <h1>Manage team members | |
| <span class="close-btn" ng-click="$close()"> | ||
| <i class="icon-remove"></i> | ||
| </span> | ||
| </div> | ||
| </div> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this empty line