Skip to content

Commit

Permalink
otp-datastore: added user management functionality. related to #1169
Browse files Browse the repository at this point in the history
  • Loading branch information
David Emory committed Apr 18, 2014
1 parent 13eae92 commit 09683f4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
7 changes: 7 additions & 0 deletions otp-datastore/app/controllers/Admin.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,11 @@ public static void deleteUser(long id) {
getUsers();
}

public static void changeUserRole(long id, String role) {
TrinetUser user = TrinetUser.findById(id);
user.role = role;
user.save();
getUsers();
}

}
41 changes: 35 additions & 6 deletions otp-datastore/app/views/Admin/getUsers.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,35 @@
<a href="@{Secure.logout()}">Log out</a>

<p><b>All users:</b>
<ul>
<table border=0 cellpadding=4 cellspacing=6>
<tr>
<td style='background-color: #444; color: white'>TriNet Username</td>
<td style='background-color: #444; color: white'>User Role</td>
<td style='background-color: #444; color: white'>Other Actions</td>
</tr>
#{list users, as:'user'}
<li>
${user.username} (${user.role}) [<a href="/admin/deleteUser?id=${user.id}">Delete</a>]

</li>
<tr>
<td style='background-color: #ddd;'>${user.username}</td>
<td style='background-color: #ddd;'>
<b>${user.role}</b>&nbsp;&nbsp;
[ Reassign:
#{if user.role != "calltaker"}
(<a href="/admin/changeUserRole?id=${user.id}&role=calltaker">calltaker</a>)
#{/if}
#{if user.role != "fieldtrip"}
(<a href="/admin/changeUserRole?id=${user.id}&role=fieldtrip">fieldtrip</a>)
#{/if}
#{if user.role != "all"}
(<a href="/admin/changeUserRole?id=${user.id}&role=all">all</a>)
#{/if}
]
</td>
<td style='background-color: #ddd;'>
[<a href="javascript:deleteUser(${user.id}, '${user.username}')">Delete</a>]
</td>
</tr>
#{/list}
</ul>
</table>

#{form @Admin.addUser(), id:'addUserForm'}

Expand Down Expand Up @@ -58,4 +79,12 @@
}
}

function deleteUser(id, name) {
var response = confirm('Are you sure you want to delete user ' + name + '?');
if(response === true) {
console.log('delete '+id);
window.location = "/admin/deleteUser?id=" + id;
}
}

</script>

0 comments on commit 09683f4

Please sign in to comment.