diff --git a/src/main/java/org/openhmis/manager/UserManager.java b/src/main/java/org/openhmis/manager/UserManager.java index 8c6d789..18a4b11 100644 --- a/src/main/java/org/openhmis/manager/UserManager.java +++ b/src/main/java/org/openhmis/manager/UserManager.java @@ -65,6 +65,8 @@ public static UserDTO updateUser(UserDTO inputDTO) { TmpUser tmpUser = UserManager.generateTmpUser(inputDTO); tmpUser.setUserId(Integer.parseInt(inputDTO.getUserId())); tmpUser.setDateUpdated(new Date()); + tmpUser.setOrganization(inputDTO.getOrganization()); + tmpUser.setCoC(inputDTO.getCoC()); // Update the object tmpUserDAO.update(tmpUser); @@ -88,6 +90,8 @@ public static UserDTO generateUserDTO(TmpUser tmpUser) { userDTO.setCanRead(tmpUser.getCanRead()); userDTO.setCanWrite(tmpUser.getCanWrite()); userDTO.setCanAdmin(tmpUser.getCanAdmin()); + userDTO.setOrganization(tmpUser.getOrganization()); + userDTO.setCoC(tmpUser.getCoC()); // Export Standard Fields (TBD: what are "Standard Fields"?) userDTO.setDateCreated(tmpUser.getDateCreated()); @@ -103,6 +107,8 @@ public static TmpUser generateTmpUser(UserDTO inputDTO) { tmpUser.setCanRead(inputDTO.getCanRead()); tmpUser.setCanWrite(inputDTO.getCanWrite()); tmpUser.setCanAdmin(inputDTO.getCanAdmin()); + tmpUser.setOrganization(inputDTO.getOrganization()); + tmpUser.setCoC(inputDTO.getCoC()); // Export Standard Fields (TBD: what are "Standard Fields"?) tmpUser.setDateCreated(inputDTO.getDateCreated()); diff --git a/src/main/java/org/openhmis/webservice/UserService.java b/src/main/java/org/openhmis/webservice/UserService.java index ab16e56..111d9e7 100644 --- a/src/main/java/org/openhmis/webservice/UserService.java +++ b/src/main/java/org/openhmis/webservice/UserService.java @@ -42,8 +42,9 @@ public UserService() {} public List getUsers(@HeaderParam("Authorization") String authorization) throws JsonProcessingException { if(!Authentication.googleAuthenticate(authorization, Authentication.ADMIN)) throw new AccessDeniedException(); - + List userDTOs = UserManager.getUsers(); + log.info("GET /users (" + userDTOs.size() + " results)"); return userDTOs; } @@ -55,6 +56,7 @@ public UserDTO createUser(@HeaderParam("Authorization") String authorization, Us if(!Authentication.googleAuthenticate(authorization, Authentication.ADMIN)) throw new AccessDeniedException(); UserDTO outputDTO = UserManager.addUser(inputDTO); + log.info("POST /users (" + outputDTO.getId() + ")"); return outputDTO; } @@ -65,6 +67,7 @@ public UserDTO getUser(@HeaderParam("Authorization") String authorization, @Path if(!Authentication.googleAuthenticate(authorization, Authentication.ADMIN)) throw new AccessDeniedException(); UserDTO outputDTO = UserManager.getUserById(userId); + log.info("GET /users/" + userId); return outputDTO; } @@ -78,6 +81,7 @@ public UserDTO updateUser(@HeaderParam("Authorization") String authorization, @P inputDTO.setUserId(userId); UserDTO outputDTO = UserManager.updateUser(inputDTO); + log.info("PUT /users/" + userId); return outputDTO; } @@ -88,6 +92,7 @@ public String deleteUser(@HeaderParam("Authorization") String authorization, @Pa if(!Authentication.googleAuthenticate(authorization, Authentication.ADMIN)) throw new AccessDeniedException(); UserManager.deleteUser(userId); + log.info("DELETE /users/" + userId); return "true"; } } diff --git a/src/main/webapp/admin/index.html b/src/main/webapp/admin/index.html index d16b25e..84eedc0 100644 --- a/src/main/webapp/admin/index.html +++ b/src/main/webapp/admin/index.html @@ -45,6 +45,14 @@

OpenHMIS Admin

+
+ + +
+
+ + +
@@ -75,4 +83,4 @@

OpenHMIS Admin

- \ No newline at end of file + diff --git a/src/main/webapp/admin/js/admin.js b/src/main/webapp/admin/js/admin.js index c5b0652..381266d 100644 --- a/src/main/webapp/admin/js/admin.js +++ b/src/main/webapp/admin/js/admin.js @@ -27,12 +27,16 @@ $(function() { $("#saveUser").click(function() { var internalId = $("#internalId").val(); var externalId = $("#externalId").val(); + var organization = $("#organization").val(); + var coC = $("#coC").val(); var canAdmin = $("#canAdmin").prop("checked")?1:0; var canRead = $("#canRead").prop("checked")?1:0; var canWrite = $("#canWrite").prop("checked")?1:0; var data = { - externalId: externalId, + externalId: externalId, + organization: organization, + coC: coC, canRead: canRead, canWrite: canWrite, canAdmin: canAdmin @@ -49,8 +53,8 @@ $(function() { }); function saveUser(data, internalId) { - // Does the internal ID exist? - if(internalId) { + // Does the internal ID exist? + if(internalId) { $.ajax({ "type": "PUT", "url": "../api/v3/users/" + internalId, @@ -61,7 +65,7 @@ function saveUser(data, internalId) { "dataType": "json", "contentType": "application/json" }).success(function() { - reloadAdmin(); + reloadAdmin(); }) } else { $.ajax({ @@ -74,7 +78,7 @@ function saveUser(data, internalId) { "dataType": "json", "contentType": "application/json" }).success(function() { - reloadAdmin(); + reloadAdmin(); }) } @@ -157,18 +161,20 @@ function renderAdmin() { // Loads the latest user data and refreshes the view function reloadAdmin() { - $("#loader").show(); + $("#loader").show(); $.ajax({ "type": "GET", "url": "../api/v3/users", - beforeSend: function (request) { - request.setRequestHeader("Authorization", idToken); - }, + beforeSend: function (request) { + request.setRequestHeader("Authorization", idToken); + }, "dataType": "json" }).success(function(data) { - var users = data.data.items; + var users = data.data.items; var columns = [ { title: "Email" }, + { title: "Organization" }, + { title: "Continuum of Care" }, { title: "Read" }, { title: "Write" }, { title: "Admin" }, @@ -179,7 +185,9 @@ function reloadAdmin() { for(var x in users) { var user = users[x]; var row = [ - user.externalId, + user.externalId, + user.organization, + user.coC, user.canRead, user.canWrite, user.canAdmin, @@ -222,13 +230,17 @@ function renderInput(user) { $("#canAdmin").prop("checked", user.canAdmin); $("#canRead").prop("checked", user.canRead); $("#canWrite").prop("checked", user.canWrite); - $("#deleteUser").show(); + $("#organization").val(user.organization); + $("#coC").val(user.coC); + $("#deleteUser").show(); } else { $("#internalId").val("") $("#externalId").val(""); $("#canAdmin").prop("checked", false); $("#canRead").prop("checked", false); $("#canWrite").prop("checked", false); - $("#deleteUser").hide(); + $("#organization").val(""); + $("#coC").val(""); + $("#deleteUser").hide(); } }