t00-multiuser/server/views/admin/user.ejs

65 lines
2.3 KiB
Text
Raw Normal View History

2024-09-28 14:31:02 +01:00
<%- include("../base/header", { title: typeof(id) === "undefined" || id.trim().length === 0 ? "Add User" : `Edit ${username}`, userId: session.userId, isAdmin: true }) %>
<div class="row">
<div class="col">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/admin">Admin</a></li>
<li class="breadcrumb-item"><a href="/admin/users">User Management</a></li>
<li class="breadcrumb-item active"><a><%= typeof(id) === "undefined" ? "Add User" : `Edit ${username}` %></a></li>
</ol>
</nav>
</div>
</div>
<div class="row">
<div class="col">
<h1><%= typeof(id) === "undefined" || id.trim().length === 0 ? "Add User" : `Edit ${username}` %></h1>
</div>
</div>
<% if (typeof(message) === "string") { %>
<div class="alert alert-danger text-center mt-5" role="alert"><%= message %></div>
<% } %>
<form method="post" class="needs-validation" novalidate>
<input type="hidden" name="id" value="<%= typeof(id) === "undefined" || id.trim().length === 0 ? "" : id %>" />
<div class="row mt-5 mb-3">
<div class="col">
<label for="username" class="form-label">Username</label>
<input class="form-control" id="username" name="username" value="<%= typeof(username) === "undefined" ? "" : username %>" required maxlength="255" autocomplete="one-time-code" />
</div>
</div>
<div class="row mb-5">
<div class="col">
<label for="name" class="form-label">Permissions</label>
<select class="form-select" name="userLevel" required>
<option value="" disabled <%= userLevel === "0" ? "selected" : "" %>>Please select...</option>
<option value="10" <%= userLevel === "10" ? "selected" : "" %>>User</option>
<option value="999" <%= userLevel === "999" ? "selected" : "" %>>Admin</option>
</select>
</div>
</div>
<div class="row mb-3">
<div class="col text-center">
<button type="submit" class="btn btn-primary">Save</button>
<a type="submit" class="btn btn-danger" href="/admin/users">Cancel</a>
</div>
</div>
</form>
<script>
const imageImg = document.querySelector("#imageImg");
const imageUrl = document.querySelector("#imageUrl");
imageUrl.addEventListener("change", () => {
if (imageUrl.value.trim() === ""){
imageImg.src = "/img/missing.png";
} else {
imageImg.src = imageUrl.value;
}
});
</script>
<%- include("../base/footer") %>