2023-02-07 09:24:13 +01:00
|
|
|
@page
|
2023-02-13 18:17:38 +01:00
|
|
|
@using AfRApay.Web.Backend.Database
|
2023-02-06 02:23:00 +01:00
|
|
|
@model IndexModel
|
|
|
|
@{
|
|
|
|
ViewData["Title"] = "Index";
|
2023-02-13 18:17:38 +01:00
|
|
|
var db = new DatabaseContext();
|
2023-02-06 02:23:00 +01:00
|
|
|
}
|
|
|
|
|
2023-02-10 18:09:18 +01:00
|
|
|
@section Header {
|
2023-02-06 02:23:00 +01:00
|
|
|
<link rel="stylesheet" href="~/lib/datatables/dataTables.bootstrap5.min.css"/>
|
|
|
|
}
|
|
|
|
|
|
|
|
@section Scripts {
|
|
|
|
<script src="~/lib/datatables/jquery.dataTables.min.js"></script>
|
|
|
|
<script src="~/lib/datatables/dataTables.bootstrap5.min.js"></script>
|
|
|
|
<script>
|
2023-02-14 02:02:19 +01:00
|
|
|
$(document).ready(function () {
|
2023-02-06 02:23:00 +01:00
|
|
|
let search = "";
|
|
|
|
if (window.location.hash.startsWith("#")) {
|
2023-02-14 02:02:19 +01:00
|
|
|
if (window.location.hash === "#add_user")
|
|
|
|
$("#add_user_modal").modal('show');
|
|
|
|
else
|
|
|
|
search = decodeURI(window.location.hash.substring(1));
|
2023-02-06 02:23:00 +01:00
|
|
|
}
|
|
|
|
|
2023-02-14 02:02:19 +01:00
|
|
|
$('#add_user_modal').on('shown.bs.modal', function() {
|
|
|
|
$(this).find('input:first').focus();
|
|
|
|
});
|
|
|
|
|
2023-02-06 02:23:00 +01:00
|
|
|
$('#users').DataTable({
|
2023-02-07 09:24:13 +01:00
|
|
|
// Setting the DOM for dataTables. Using default with adjustments for margin. See here for syntax details https://datatables.net/reference/option/dom
|
|
|
|
dom: "<'row'<'col-sm-12 col-md-6 my-1'l><'col-sm-12 col-md-6 my-1'f>>" +
|
|
|
|
"<'row'<'col-sm-12'tr>>" +
|
2023-02-14 02:02:19 +01:00
|
|
|
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
|
|
|
|
lengthMenu: [10, 25, 50, 100, -1],
|
|
|
|
pageLength: 25,
|
|
|
|
search: {
|
2023-02-06 02:23:00 +01:00
|
|
|
search: search,
|
|
|
|
}
|
2023-02-14 02:02:19 +01:00
|
|
|
});
|
|
|
|
});
|
2023-02-06 02:23:00 +01:00
|
|
|
</script>
|
|
|
|
}
|
|
|
|
|
|
|
|
<div class="text-center">
|
|
|
|
<h1 class="display-5">
|
|
|
|
Users
|
2023-02-14 02:02:19 +01:00
|
|
|
<button type="button" class="btn btn-lg btn-primary" data-bs-toggle="modal" data-bs-target="#add_user_modal">
|
2023-02-13 21:54:31 +01:00
|
|
|
Add
|
|
|
|
</button>
|
2023-02-06 02:23:00 +01:00
|
|
|
</h1>
|
|
|
|
</div>
|
2023-02-13 21:54:31 +01:00
|
|
|
|
|
|
|
<!-- Modal dialog for adding a user -->
|
|
|
|
<div class="modal fade" id="add_user_modal" tabindex="-1" aria-labelledby="add_user_modal_label" aria-hidden="true">
|
|
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<h5 class="modal-title" id="add_user_modal_label">Add User</h5>
|
|
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
|
|
</div>
|
2023-02-14 02:02:19 +01:00
|
|
|
<div class="modal-body">
|
|
|
|
<form method="POST" id="add_user">
|
2023-02-13 21:54:31 +01:00
|
|
|
<label for="nickname" class="form-label">Nickname</label>
|
|
|
|
<input type="text" maxlength="10" class="form-control" id="nickname" name="nickname" placeholder="nick" required autofocus>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
|
|
<button type="button" class="btn btn-lg btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
2023-02-14 02:02:19 +01:00
|
|
|
<button type="submit" form="add_user" class="btn btn-lg btn-primary" name="action" value="add_user">Save</button>
|
2023-02-13 21:54:31 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2023-02-06 02:23:00 +01:00
|
|
|
<div>
|
|
|
|
<table class="table table-striped table-hover" id="users">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
2023-05-16 01:06:12 +02:00
|
|
|
<th scope="col">Nickname</th>
|
2023-02-06 02:23:00 +01:00
|
|
|
<th scope="col">Balance</th>
|
|
|
|
<th scope="col">Cards</th>
|
|
|
|
<th scope="col">Actions</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
@foreach (var user in db.Users.OrderBy(p => p.Nickname.ToLower())) {
|
|
|
|
<tr id="user_@user.Id">
|
|
|
|
<td>
|
|
|
|
<b>@user.Nickname</b>
|
|
|
|
</td>
|
|
|
|
<td>
|
2023-02-10 17:02:20 +01:00
|
|
|
@($"{user.Balance / 100M:C}")
|
2023-02-06 02:23:00 +01:00
|
|
|
</td>
|
|
|
|
<td>
|
2023-02-13 18:17:38 +01:00
|
|
|
<b>@db.Cards.Count(p => p.User.Id == user.Id)</b> cards linked.
|
2023-02-06 02:23:00 +01:00
|
|
|
</td>
|
2023-02-10 17:02:20 +01:00
|
|
|
<td>
|
|
|
|
<!-- Displayed when in big layout -->
|
|
|
|
<form method="POST">
|
|
|
|
<input type="hidden" name="action" value="transaction">
|
|
|
|
<input type="hidden" name="userId" value="@user.Id">
|
|
|
|
<div class="d-none d-md-flex btn-group btn-group-lg" role="group">
|
|
|
|
<!-- Make sure these buttons match the small/mobile layout ones below -->
|
|
|
|
<button type="submit" class="btn px-3 btn-danger" name="amount" value="-150">-1.50€</button>
|
2023-05-18 22:19:56 +02:00
|
|
|
<button type="submit" class="btn px-3 btn-danger" name="amount" value="-200">-2€</button>
|
2023-02-10 17:02:20 +01:00
|
|
|
<button type="submit" class="btn px-3 btn-success" name="amount" value="500">+5€</button>
|
|
|
|
<button type="submit" class="btn px-3 btn-success" name="amount" value="1000">+10€</button>
|
|
|
|
<a class="btn px-2 btn-primary" href="/EditUser/@user.Id">Edit</a>
|
|
|
|
</div>
|
|
|
|
<!-- Displayed when in compact/phone layout -->
|
|
|
|
<div class="dropdown d-md-none">
|
|
|
|
<a class="btn btn-lg px-1 btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false">
|
|
|
|
Actions
|
|
|
|
</a>
|
2023-02-11 02:21:25 +01:00
|
|
|
<div class="dropdown-menu p-1 mw-max-content" aria-labelledby="dropdownMenuLink">
|
2023-02-10 17:02:20 +01:00
|
|
|
<!-- Inline CSS, sets minimum width of drop down to maxium size of content -->
|
|
|
|
<div class="d-grid gap-1">
|
|
|
|
<!-- Make sure these buttons match the big layout ones above-->
|
|
|
|
<button type="submit" class="btn btn-lg btn-danger" name="amount" value="-150">-1.50€</button>
|
2023-05-18 22:19:56 +02:00
|
|
|
<button type="submit" class="btn btn-lg btn-danger" name="amount" value="-200">-2€</button>
|
2023-02-10 17:02:20 +01:00
|
|
|
<button type="submit" class="btn btn-lg btn-success" name="amount" value="500">+5€</button>
|
|
|
|
<button type="submit" class="btn btn-lg btn-success" name="amount" value="1000">+10€</button>
|
|
|
|
<a class="btn btn-lg btn-primary" href="/EditUser/@user.Id">Edit</a>
|
|
|
|
</div>
|
2023-02-06 20:14:11 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-02-10 17:02:20 +01:00
|
|
|
</form>
|
2023-02-06 02:23:00 +01:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|