2016-07-20 15:11:55 -07:00
|
|
|
<div id="users" class="page">
|
|
|
|
|
<div class="col-sm-12 col-sm-offset-0">
|
2016-10-26 14:48:11 -07:00
|
|
|
|
|
|
|
|
<!-- Main Page Content -->
|
2016-07-20 15:11:55 -07:00
|
|
|
<h1><span class="fa fa-users"></span> Manage Users</h1>
|
|
|
|
|
|
|
|
|
|
<div class="col-sm-6">
|
|
|
|
|
<div class="dt-buttons btn-group">
|
|
|
|
|
<a id="createButton" class="btn btn-default buttons-create" tabindex="0" href="javaScript:void(0);"><span>New</span></a>
|
2016-10-26 14:48:11 -07:00
|
|
|
<a id="changeLoginButton" class="btn btn-default buttons-selected buttons-edit" style="visibility: hidden; display: none;" tabindex="0" href="javaScript:void(0);"><span>Change Login</span></a>
|
|
|
|
|
<a id="resetPasswordButton" class="btn btn-default buttons-selected buttons-edit" style="visibility: hidden; display: none;" tabindex="0" href="javaScript:void(0);"><span>Reset Password</span></a>
|
|
|
|
|
<a id="deleteButton" class="btn btn-default buttons-selected buttons-remove" style="visibility: hidden; display: none;" tabindex="0" href="javaScript:void(0);"><span>Delete</span></a>
|
2016-07-20 15:11:55 -07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2016-10-26 14:48:11 -07:00
|
|
|
<table id="dataTable" class="table table-striped table-hover">
|
2016-07-20 15:11:55 -07:00
|
|
|
<thead>
|
|
|
|
|
<tr>
|
|
|
|
|
<th data-key-name="login">Name</th>
|
|
|
|
|
<th data-key-name="admin">Admin</th>
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
</table>
|
|
|
|
|
|
2016-10-26 14:48:11 -07:00
|
|
|
<!-- Create Dialog -->
|
2016-07-20 15:11:55 -07:00
|
|
|
<div id="createUserDialog" class="modal fade" role="dialog">
|
|
|
|
|
<div class="modal-dialog">
|
2016-10-26 14:48:11 -07:00
|
|
|
<div class="modal-header">
|
|
|
|
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
|
|
|
|
<h4 class="modal-title">Create User</h4>
|
|
|
|
|
</div>
|
|
|
|
|
<form role="form" autocomplete="off">
|
2016-07-20 15:11:55 -07:00
|
|
|
<div class="modal-body">
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label>Login</label>
|
2016-10-26 14:48:11 -07:00
|
|
|
<input name="login" id="DFLogin" type="text" class="form-control" tabindex="0">
|
2016-07-20 15:11:55 -07:00
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label>Password</label>
|
2016-10-26 14:48:11 -07:00
|
|
|
<input name="password" id="DFPassword" type="password" class="form-control" tabindex="0">
|
2016-07-20 15:11:55 -07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="modal-footer">
|
2016-10-26 14:48:11 -07:00
|
|
|
<button id="DFCreateSave" type="button" class="btn btn-default btn-primary btn-md" tabindex="0">Create</button>
|
|
|
|
|
<button id="DFCreateSavePlus" type="button" class="btn btn-primary btn-md" tabindex="0">Create++</button>
|
|
|
|
|
<button id="DFCreateCancel" type="button" class="btn" data-dismiss="modal" tabindex="0">Cancel</button>
|
2016-07-20 15:11:55 -07:00
|
|
|
</div>
|
2016-10-26 14:48:11 -07:00
|
|
|
</form>
|
2016-08-17 17:54:59 -07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2016-10-26 14:48:11 -07:00
|
|
|
<!-- Reset Password Dialog -->
|
2016-08-17 17:54:59 -07:00
|
|
|
<div id="resetPasswordDialog" class="modal fade" role="dialog">
|
|
|
|
|
<div class="modal-dialog">
|
|
|
|
|
<div class="modal-header">
|
|
|
|
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
|
|
|
|
<h4 class="modal-title">Reset Password</h4>
|
|
|
|
|
</div>
|
2016-10-26 14:48:11 -07:00
|
|
|
<form role="form" autocomplete="off">
|
|
|
|
|
<div class="modal-body">
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label>Password</label>
|
|
|
|
|
<input name="password" id="DFResetPassword" type="password" class="form-control" tabindex="0">
|
|
|
|
|
</div>
|
2016-08-17 17:54:59 -07:00
|
|
|
</div>
|
2016-10-26 14:48:11 -07:00
|
|
|
<div class="modal-footer">
|
|
|
|
|
<button id="DFResetPasswordSave" type="button" class="btn btn-warning btn-md" tabindex="0">Save</button>
|
|
|
|
|
<button id="DFResetPasswordCancel" type="button" class="btn btn-default" data-dismiss="modal" tabindex="0">Cancel</button>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
2016-08-17 17:54:59 -07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2016-10-26 14:48:11 -07:00
|
|
|
<!-- Change Login Dialog -->
|
2016-08-17 17:54:59 -07:00
|
|
|
<div id="changeLoginDialog" class="modal fade" role="dialog">
|
|
|
|
|
<div id="changeLoginDialogInner" class="modal-dialog">
|
|
|
|
|
<div class="modal-header">
|
|
|
|
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
|
|
|
|
<h4 class="modal-title">Change Login</h4>
|
|
|
|
|
</div>
|
2016-10-26 14:48:11 -07:00
|
|
|
<form role="form" autocomplete="off">
|
|
|
|
|
<div class="modal-body">
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label>Login</label>
|
|
|
|
|
<input name="login" id="DFChangeLogin" type="text" class="form-control" tabindex="0">
|
|
|
|
|
</div>
|
2016-08-17 17:54:59 -07:00
|
|
|
</div>
|
2016-10-26 14:48:11 -07:00
|
|
|
<div class="modal-footer">
|
|
|
|
|
<button id="DFChangeLoginSave" type="button" class="btn btn-warning btn-md" tabindex="0">Save</button>
|
|
|
|
|
<button id="DFChangeLoginCancel" type="button" class="btn btn-default" data-dismiss="modal" tabindex="0">Cancel</button>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
2016-08-17 17:54:59 -07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2016-10-26 14:48:11 -07:00
|
|
|
<!-- Delete Dialog -->
|
2016-08-17 17:54:59 -07:00
|
|
|
<div id="deleteUserDialog" class="modal fade" role="dialog">
|
|
|
|
|
<div class="modal-dialog">
|
|
|
|
|
<div class="modal-header">
|
|
|
|
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
|
|
|
|
<h4 class="modal-title">Delete User</h4>
|
|
|
|
|
</div>
|
2016-10-26 14:48:11 -07:00
|
|
|
<form role="form" autocomplete="off">
|
|
|
|
|
<div class="modal-body">
|
|
|
|
|
Are you certain you wish to delete the user <span id="deleteUserDialogUserName"></span>?
|
|
|
|
|
</div>
|
|
|
|
|
<div class="modal-footer">
|
|
|
|
|
<button id="DFDeleteSave" type="button" class="btn btn-warning btn-md" tabindex="0">Delete</button>
|
|
|
|
|
<button id="DFDeleteCancel" type="button" class="btn btn-default" data-dismiss="modal" tabindex="1">Cancel</button>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
2016-07-20 15:11:55 -07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2016-10-26 14:48:11 -07:00
|
|
|
<script language="JavaScript" type="text/javascript">//# sourceURL=users.html
|
2016-08-17 17:54:59 -07:00
|
|
|
$(function() {
|
2016-10-26 14:48:11 -07:00
|
|
|
var $page = $('#users');
|
|
|
|
|
var $btnCreate = $page.find("#createButton");
|
|
|
|
|
var $btnChangeLogin = $page.find("#changeLoginButton");
|
|
|
|
|
var $btnResetPassword = $page.find("#resetPasswordButton");
|
|
|
|
|
var $btnDelete = $page.find("#deleteButton");
|
|
|
|
|
var $createUserDialog = $page.find('#createUserDialog');
|
|
|
|
|
var $resetPasswordDialog = $page.find('#resetPasswordDialog');
|
|
|
|
|
var $changeLoginDialog = $page.find('#changeLoginDialog');
|
|
|
|
|
var $deleteUserDialog = $page.find('#deleteUserDialog');
|
|
|
|
|
|
|
|
|
|
var dataTable = new LinkedTable($page.find('#dataTable'), {
|
|
|
|
|
url: "data/User/readAll",
|
2016-08-17 17:54:59 -07:00
|
|
|
attr: "data-key-name",
|
2016-10-26 14:48:11 -07:00
|
|
|
selection: "row",
|
|
|
|
|
selectionChanged: function($tr, model) {
|
|
|
|
|
if($tr && model) {
|
|
|
|
|
$btnChangeLogin.show();
|
|
|
|
|
$btnResetPassword.show();
|
|
|
|
|
$btnDelete.show();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$btnChangeLogin.hide();
|
|
|
|
|
$btnResetPassword.hide();
|
|
|
|
|
$btnDelete.hide();
|
|
|
|
|
}
|
|
|
|
|
},
|
2016-08-17 17:54:59 -07:00
|
|
|
});
|
2016-07-20 15:11:55 -07:00
|
|
|
|
2016-08-17 17:54:59 -07:00
|
|
|
//Call the refresh user table function once initially.
|
2016-10-26 14:48:11 -07:00
|
|
|
dataTable.refresh();
|
2016-07-20 15:11:55 -07:00
|
|
|
|
2016-10-26 14:48:11 -07:00
|
|
|
//----------------------------
|
2016-08-17 17:54:59 -07:00
|
|
|
//---- Create User Dialog ----
|
2016-10-26 14:48:11 -07:00
|
|
|
|
|
|
|
|
$btnCreate.on("click", function(event) {
|
|
|
|
|
$createUserDialog.modal();
|
2016-08-17 17:54:59 -07:00
|
|
|
});
|
2016-10-26 14:48:11 -07:00
|
|
|
$createUserDialog.find("#DFCreateSave").on("click", function(event) {
|
2016-08-17 17:54:59 -07:00
|
|
|
try {
|
2016-10-26 14:48:11 -07:00
|
|
|
$.post("data/User/create", {
|
|
|
|
|
login: $createUserDialog.find("#loginDialogLogin").val(),
|
|
|
|
|
password: $createUserDialog.find("#loginDialogPassword").val()
|
2016-08-17 17:54:59 -07:00
|
|
|
}, function(data) {
|
|
|
|
|
if(data.result == "success") {
|
2016-10-26 14:48:11 -07:00
|
|
|
$createUserDialog.modal("hide");
|
|
|
|
|
dataTable.refresh();
|
2016-08-17 17:54:59 -07:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
alert(data.result);
|
|
|
|
|
}
|
|
|
|
|
}, "json");
|
|
|
|
|
} catch(e) {
|
|
|
|
|
alert(e);
|
|
|
|
|
}
|
|
|
|
|
});
|
2016-10-26 14:48:11 -07:00
|
|
|
$createUserDialog.find("#DFCreateSave").on("click", function(event) {
|
|
|
|
|
$createUserDialog.modal('hide');
|
|
|
|
|
});
|
|
|
|
|
$createUserDialog.on('shown.bs.modal', function() {
|
|
|
|
|
$createUserDialog.find('#DFLogin').focus();
|
2016-08-17 17:54:59 -07:00
|
|
|
});
|
2016-07-20 15:11:55 -07:00
|
|
|
|
2016-10-26 14:48:11 -07:00
|
|
|
//----------------------------
|
2016-08-17 17:54:59 -07:00
|
|
|
//---- Delete User Dialog ----
|
2016-10-26 14:48:11 -07:00
|
|
|
|
|
|
|
|
$btnDelete.on("click", function(event) {
|
2016-08-17 17:54:59 -07:00
|
|
|
//debugger;
|
2016-10-26 14:48:11 -07:00
|
|
|
if(dataTable.getSelectedRow() != null) {
|
2016-08-17 17:54:59 -07:00
|
|
|
//Note: This assumes that the first column is the user login (name).
|
2016-10-03 11:00:49 -07:00
|
|
|
//$("#users #deleteUserDialogUserName").html($("td", userTable.getSelectedRow())[0].innerHTML);
|
2016-10-26 14:48:11 -07:00
|
|
|
$deleteUserDialog.find("#deleteUserDialogUserName").html(dataTable.getSelectedRow().data("model").login);
|
|
|
|
|
$deleteUserDialog.modal();
|
2016-08-17 17:54:59 -07:00
|
|
|
}
|
|
|
|
|
});
|
2016-10-26 14:48:11 -07:00
|
|
|
$deleteUserDialog.find("#DFDelete").on("click", function(event) {
|
|
|
|
|
if(dataTable.getSelectedRow() != null) {
|
|
|
|
|
$.post("data/User/delete", {where: {id: dataTable.getSelectedRow().data("model").id}}, function(data) {
|
2016-08-17 17:54:59 -07:00
|
|
|
if(data.result == "success") {
|
2016-10-26 14:48:11 -07:00
|
|
|
$deleteUserDialog.modal("hide");
|
|
|
|
|
dataTable.refresh();
|
2016-08-17 17:54:59 -07:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
alert(data.result);
|
|
|
|
|
}
|
|
|
|
|
}, "json");
|
2016-07-20 15:11:55 -07:00
|
|
|
}
|
2016-08-17 17:54:59 -07:00
|
|
|
});
|
2016-10-26 14:48:11 -07:00
|
|
|
$deleteUserDialog.find("#DFDeleteCancel").on("click", function(event) {
|
|
|
|
|
$deleteUserDialog.modal('hide');
|
|
|
|
|
});
|
|
|
|
|
$deleteUserDialog.on('shown.bs.modal', function() {
|
|
|
|
|
$deleteUserDialog.find('#DFDeleteCancel').focus();
|
|
|
|
|
});
|
2016-08-17 17:54:59 -07:00
|
|
|
|
2016-10-26 14:48:11 -07:00
|
|
|
//------------------------------
|
2016-08-17 17:54:59 -07:00
|
|
|
//----- Change Login Dialog ----
|
2016-10-26 14:48:11 -07:00
|
|
|
|
|
|
|
|
$btnChangeLogin.on("click", function(event) {
|
|
|
|
|
if(dataTable.getSelectedRow() != null) {
|
|
|
|
|
$changeLoginDialog.find('#changeLoginDialogLogin').val(dataTable.getSelectedRow().data("model").login);
|
|
|
|
|
$changeLoginDialog.modal();
|
2016-07-20 15:11:55 -07:00
|
|
|
}
|
2016-08-17 17:54:59 -07:00
|
|
|
});
|
2016-10-26 14:48:11 -07:00
|
|
|
$changeLoginDialog.find("#DFChangeLoginSave").on("click", function(event) {
|
|
|
|
|
if(dataTable.getSelectedRow() != null) {
|
|
|
|
|
$.post("data/User/update", {
|
|
|
|
|
id: dataTable.getSelectedRow().data("model").id,
|
|
|
|
|
login: $changeLoginDialog("#DFChangeLogin").val()
|
2016-08-17 17:54:59 -07:00
|
|
|
}, function(data) {
|
|
|
|
|
if(data.result == "success") {
|
2016-10-26 14:48:11 -07:00
|
|
|
$changeLoginDialog.modal("hide");
|
|
|
|
|
dataTable.refresh();
|
2016-08-17 17:54:59 -07:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
alert(data.result);
|
|
|
|
|
}
|
|
|
|
|
}, "json");
|
|
|
|
|
}
|
|
|
|
|
});
|
2016-10-26 14:48:11 -07:00
|
|
|
$changeLoginDialog.find("#DFChangeLoginCancel").on("click", function(event) {
|
|
|
|
|
$changeLoginDialog.modal('hide');
|
|
|
|
|
});
|
|
|
|
|
$changeLoginDialog.on('shown.bs.modal', function() {
|
|
|
|
|
$changeLoginDialog.find('#DFChangeLogin').focus().select();
|
2016-08-17 17:54:59 -07:00
|
|
|
});
|
|
|
|
|
|
2016-10-26 14:48:11 -07:00
|
|
|
//-------------------------------
|
2016-08-17 17:54:59 -07:00
|
|
|
//---- Reset Password Dialog ----
|
2016-10-26 14:48:11 -07:00
|
|
|
|
|
|
|
|
$btnResetPassword.on("click", function(event) {
|
|
|
|
|
if(dataTable.getSelectedRow() != null) {
|
|
|
|
|
$resetPasswordDialog.modal();
|
2016-08-17 17:54:59 -07:00
|
|
|
}
|
|
|
|
|
});
|
2016-10-26 14:48:11 -07:00
|
|
|
$resetPasswordDialog.find("#DFResetPasswordSave").on("click", function(event) {
|
|
|
|
|
if(dataTable.getSelectedRow() != null) {
|
|
|
|
|
$.post("data/User/update", {
|
|
|
|
|
id: dataTable.getSelectedRow().data("model").id,
|
|
|
|
|
password: $resetPasswordDialog.find("#DFResetPassword").val()
|
2016-08-17 17:54:59 -07:00
|
|
|
}, function(data) {
|
|
|
|
|
if(data.result == "success") {
|
2016-10-26 14:48:11 -07:00
|
|
|
$resetPasswordDialog.modal("hide");
|
|
|
|
|
dataTable.refresh();
|
2016-08-17 17:54:59 -07:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
alert(data.result);
|
|
|
|
|
}
|
|
|
|
|
}, "json");
|
|
|
|
|
}
|
|
|
|
|
});
|
2016-10-26 14:48:11 -07:00
|
|
|
$resetPasswordDialog.find("#DFResetPasswordCancel").on("click", function(event) {
|
|
|
|
|
$resetPasswordDialog.modal('hide');
|
|
|
|
|
});
|
|
|
|
|
$resetPasswordDialog.on('shown.bs.modal', function() {
|
|
|
|
|
$resetPasswordDialog.find('#DFResetPassword').focus();
|
2016-08-17 17:54:59 -07:00
|
|
|
});
|
|
|
|
|
});
|
2016-07-20 15:11:55 -07:00
|
|
|
</script>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|