Large set of changes - building the GUI for the data tracking app.
This commit is contained in:
@@ -5,8 +5,9 @@
|
||||
<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>
|
||||
<a class="btn btn-default buttons-selected buttons-edit" tabindex="0" href="javaScript:void(0);"><span>Edit</span></a>
|
||||
<a class="btn btn-default buttons-selected buttons-remove" tabindex="0" href="javaScript:void(0);"><span>Delete</span></a>
|
||||
<a id="changeLoginButton" class="btn btn-default buttons-selected buttons-edit" tabindex="0" href="javaScript:void(0);"><span>Change Login</span></a>
|
||||
<a id="resetPasswordButton" class="btn btn-default buttons-selected buttons-edit" tabindex="0" href="javaScript:void(0);"><span>Reset Password</span></a>
|
||||
<a id="deleteButton" class="btn btn-default buttons-selected buttons-remove" tabindex="0" href="javaScript:void(0);"><span>Delete</span></a>
|
||||
</div>
|
||||
</div>
|
||||
<table id="user-table" class="table table-striped table-hover">
|
||||
@@ -20,7 +21,6 @@
|
||||
|
||||
<div id="createUserDialog" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<!--<form action="/admin/createUser" method="post">-->
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
<h4 class="modal-title">Create User</h4>
|
||||
@@ -28,40 +28,193 @@
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label>Login</label>
|
||||
<input type="text" class="form-control" name="login" id="loginDialogLogin">
|
||||
<input type="text" class="form-control" name="login" id="loginDialogLogin" tabindex="0">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Password</label>
|
||||
<input type="password" class="form-control" name="password" id="loginDialogPassword">
|
||||
<input type="password" class="form-control" name="password" id="loginDialogPassword" tabindex="0">
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-warning btn-md" id="createUserDialogButton">Create</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-warning btn-md" id="createUserDialogButton" tabindex="0">Create</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal" tabindex="0">Close</button>
|
||||
</div>
|
||||
<!--</form>-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label>Password</label>
|
||||
<input type="password" class="form-control" name="password" id="resetPasswordDialogPassword" tabindex="0">
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-warning btn-md" id="resetPasswordDialogSaveButton" tabindex="0">Save</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal" tabindex="0">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label>Login</label>
|
||||
<input type="text" class="form-control" name="password" id="changeLoginDialogLogin" tabindex="0">
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-warning btn-md" id="changeLoginDialogSaveButton" tabindex="0">Save</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal" tabindex="0">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
<div class="modal-body">
|
||||
Are you certain you wish to delete the user <span id="deleteUserDialogUserName"></span>?
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-warning btn-md" id="deleteUserDialogDeleteButton" tabindex="0">Delete</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal" tabindex="1">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
var userTable = new LinkedTable($('#user-table'), {url: "user-data", attr: "data-key-name", selection: "row"});
|
||||
$(function() {
|
||||
//# sourceURL=users.html
|
||||
var userTable = new LinkedTable($('#user-table'), {
|
||||
url: "user/list",
|
||||
attr: "data-key-name",
|
||||
selection: "row"
|
||||
});
|
||||
|
||||
//Call the refresh user table function once initially.
|
||||
userTable.refresh();
|
||||
$("#createButton").on("click", function(event) {
|
||||
$("#createUserDialog").modal();
|
||||
//Call the refresh user table function once initially.
|
||||
userTable.refresh();
|
||||
|
||||
//---- Create User Dialog ----
|
||||
$("#createButton").on("click", function(event) {
|
||||
$("#createUserDialog").modal();
|
||||
});
|
||||
$("#createUserDialogButton").on("click", function(event) {
|
||||
try {
|
||||
$.post("/admin/user/create", {
|
||||
login: $("#loginDialogLogin").val(),
|
||||
password: $("#loginDialogPassword").val()
|
||||
}, function(data) {
|
||||
if(data.result == "success") {
|
||||
$("#createUserDialog").modal("hide");
|
||||
userTable.refresh();
|
||||
}
|
||||
else {
|
||||
alert(data.result);
|
||||
}
|
||||
}, "json");
|
||||
} catch(e) {
|
||||
alert(e);
|
||||
}
|
||||
});
|
||||
$("#createUserDialog").on('shown.bs.modal', function() {
|
||||
$('#createUserDialogLogin').focus();
|
||||
});
|
||||
//----------------------------
|
||||
|
||||
//---- Delete User Dialog ----
|
||||
$("#deleteButton").on("click", function(event) {
|
||||
//debugger;
|
||||
if(userTable.getSelectedRow() != null) {
|
||||
//Note: This assumes that the first column is the user login (name).
|
||||
//$("#deleteUserDialogUserName").html($("td", userTable.getSelectedRow())[0].innerHTML);
|
||||
$("#deleteUserDialogUserName").html(userTable.getSelectedRow().data("model").login);
|
||||
$("#deleteUserDialog").modal();
|
||||
}
|
||||
});
|
||||
$("#deleteUserDialogDeleteButton").on("click", function(event) {
|
||||
if(userTable.getSelectedRow() != null) {
|
||||
$.post("/admin/user/delete", {id: userTable.getSelectedRow().data("model").id}, function(data) {
|
||||
if(data.result == "success") {
|
||||
$("#deleteUserDialog").modal("hide");
|
||||
userTable.refresh();
|
||||
}
|
||||
else {
|
||||
alert(data.result);
|
||||
}
|
||||
}, "json");
|
||||
}
|
||||
});
|
||||
//-----------------------------
|
||||
|
||||
//----- Change Login Dialog ----
|
||||
$("#changeLoginButton").on("click", function(event) {
|
||||
if(userTable.getSelectedRow() != null) {
|
||||
$('#changeLoginDialogLogin').val(userTable.getSelectedRow().data("model").login);
|
||||
$("#changeLoginDialog").modal();
|
||||
}
|
||||
});
|
||||
$("#changeLoginDialogSaveButton").on("click", function(event) {
|
||||
if(userTable.getSelectedRow() != null) {
|
||||
$.post("/admin/user/changeLogin", {
|
||||
id: userTable.getSelectedRow().data("model").id,
|
||||
login: $("#changeLoginDialogLogin").val()
|
||||
}, function(data) {
|
||||
if(data.result == "success") {
|
||||
$("#changeLoginDialog").modal("hide");
|
||||
userTable.refresh();
|
||||
}
|
||||
else {
|
||||
alert(data.result);
|
||||
}
|
||||
}, "json");
|
||||
}
|
||||
});
|
||||
$("#changeLoginDialog").on('shown.bs.modal', function() {
|
||||
$('#changeLoginDialogLogin').focus().select();
|
||||
});
|
||||
//---------------------
|
||||
|
||||
//---- Reset Password Dialog ----
|
||||
$("#resetPasswordButton").on("click", function(event) {
|
||||
if(userTable.getSelectedRow() != null) {
|
||||
$("#resetPasswordDialog").modal();
|
||||
}
|
||||
});
|
||||
$("#resetPasswordDialogSaveButton").on("click", function(event) {
|
||||
if(userTable.getSelectedRow() != null) {
|
||||
$.post("/admin/user/resetPassword", {
|
||||
id: userTable.getSelectedRow().data("model").id,
|
||||
password: $("#resetPasswordDialogPassword").val()
|
||||
}, function(data) {
|
||||
if(data.result == "success") {
|
||||
$("#resetPasswordDialog").modal("hide");
|
||||
userTable.refresh();
|
||||
}
|
||||
else {
|
||||
alert(data.result);
|
||||
}
|
||||
}, "json");
|
||||
}
|
||||
});
|
||||
$("#resetPasswordDialog").on('shown.bs.modal', function() {
|
||||
$('#resetPasswordDialogPassword').focus();
|
||||
});
|
||||
//----------------------------------
|
||||
});
|
||||
|
||||
$("#createUserDialogButton").on("click", function(event) {
|
||||
$.post("createUser", {login: $("#loginDialogLogin"), password: $("#loginDialogPassword")}, function(data) {
|
||||
if(data.result == "success") {
|
||||
|
||||
}
|
||||
else {
|
||||
alert(data.result);
|
||||
}
|
||||
}, "json");
|
||||
})
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user