4 <meta charset="utf-8" />
5 <meta http-equiv="X-UA-Compatible" content="IE=edge">
6 <% include ../partials/head %>
7 <% include ../partials/header %>
8 <script type="text/javascript" src="/javascripts/admportal.js" async></script>
9 <title>AdminPortal</title>
11 $(document).ready(function() {
12 $('#user_admin').DataTable( {
13 "order": [[ 0, "asc" ]]
22 <div class="well well-sm">
23 <h3>User Administration</h3>
26 <% if ( typeof result != 'undefined' ) {
27 if (result.code.length > 0) {
28 if ( result.code == 'success' ) { %>
29 <div class='alert alert-success' role='alert'><%=result.msg %></div>
31 <div class='alert alert-danger' role='danger'><%=result.msg %></div>
36 <% if( typeof privilege != 'undefined'){
37 var priv = privilege.privilege;
43 <div class="container-fluid">
44 <div class="actions" style="padding:15px 0px;">
45 <% if(priv == 'A') { %>
46 <button class="btn btn-primary" data-toggle="modal" data-target="#new_user">Add User</button>
51 <table id="user_admin" class="table table-hover table-condensed">
57 <% if(priv == 'A'){ %>
64 rows.forEach(function(row) { %>
66 <td><%= row.email %></td>
69 <% if(row.privilege == 'A'){ %>
71 <% } else if (row.privilege == 'R') { %>
77 <% if(priv == 'A') { %>
80 <button type="button" class="btn btn-default btn-xs"
81 onclick="updateRequest('<%=row.email %>', '<%=row.password %>', '<%=row.privilege %>');">Update</button>
82 <button type="button" class="btn btn-default btn-xs"
83 onclick="deleteRequest('<%=row.email %>');">Delete</button>
93 <% include ../partials/newuserform %>
94 <% include ../partials/userform %>
97 <% include ../partials/footer %>
100 <script type="text/javascript">
102 function submitUserAdmin(form)
107 var confirm_password = '';
110 if ( form.name == 'addForm' )
112 email = form.nf_email;
113 password = form.nf_password;
114 confirm_password = form.nf_confirm_password;
115 privilege = form.nf_privilege;
117 if ( (email.value == null) || (email.value == "") || isblank(email.value) )
119 errorMsg += 'Email is required.<br>';
121 if( errorMsg.length > 0 ) {
122 bootbox.alert(errorMsg);
126 if ( password.value != confirm_password.value )
128 bootbox.alert('Passwords do not match.');
134 email = form.uf_email;
135 password = form.uf_password;
136 confirm_password = form.uf_confirm_password;
137 privilege = form.uf_privilege;
139 if ( (email.value == null) || (email.value == "") || isblank(email.value) )
141 errorMsg += 'Email is required.<br>';
143 if ( password.value != confirm_password.value )
145 bootbox.alert('Passwords do not match.');
152 function deleteRequest(email) {
155 message: "Are you sure you want to delete user [" + email + "] ?",
156 callback: function(result) {
159 location.assign("/user/deleteUser?email=" + email);
173 function updateRequest(email,password,privilege) {
175 document.getElementById('uf_email').value = email;
176 document.getElementById('uf_key_email').value = email;
177 document.getElementById('uf_password').value = password;
178 document.getElementById('uf_confirm_password').value = password;
179 if ( privilege == "A" ){
180 document.getElementById('uf_privilege').value = 'admin';
181 }else if (privilege == "R"){
182 document.getElementById('uf_privilege').value = 'readonly';
184 document.getElementById('uf_privilege').value = 'admin';
186 document.getElementById('uf_action').value = "/user/updateUser";
187 $('#myUserModal').modal('show');