adlerka.space/templates/adminActions.html

88 lines
2.7 KiB
HTML
Raw Normal View History

2024-02-03 16:08:26 +01:00
<script>
2024-02-03 17:55:54 +01:00
async function addActivationCodes() {
2024-02-03 16:08:26 +01:00
const count = document.getElementById("activationCodeCount").value;
const data = new URLSearchParams();
data.append("action", "add_activation_codes");
data.append("count", count);
2024-02-03 17:55:54 +01:00
const result = await doAccountAction(data, "Activation codes added Successfully!", "Activation codes addition failed.");
2024-02-04 09:50:04 +01:00
displayList(result.ActivationCodes, "codeListTable", deleteActivationCode);
2024-02-03 16:08:26 +01:00
}
async function listUsers() {
const data = new URLSearchParams();
data.append("action", "list_users");
2024-02-03 17:01:52 +01:00
const result = await doAccountAction(data, "User list retrieved Successfully!", "User list retrieval failed.");
2024-02-03 16:08:26 +01:00
if (result && result.Status === "Success") {
2024-02-04 09:50:04 +01:00
displayList(result.Users, "userListTable", deleteUser);
2024-02-03 16:08:26 +01:00
}
}
2024-02-03 17:55:54 +01:00
async function listActivationCodes() {
2024-02-03 16:08:26 +01:00
const data = new URLSearchParams();
data.append("action", "list_activation_codes");
2024-02-03 17:55:54 +01:00
const result = await doAccountAction(data, "Activation code list retrieved Successfully!", "Activation code list retrieval failed.");
2024-02-04 09:50:04 +01:00
displayList(result.ActivationCodes, "codeListTable", deleteActivationCode);
2024-02-03 16:08:26 +01:00
}
2024-02-04 09:50:04 +01:00
function deleteUser(userId) {
2024-02-03 16:08:26 +01:00
const data = new URLSearchParams();
data.append("action", "delete_user");
data.append("user_id", userId);
2024-02-03 17:01:52 +01:00
doAccountAction(data, "User deleted Successfully!", "User deletion failed.");
2024-02-04 09:50:04 +01:00
listUsers();
2024-02-03 16:08:26 +01:00
}
2024-02-04 09:50:04 +01:00
function deleteActivationCode(activationCode) {
2024-02-03 16:08:26 +01:00
const data = new URLSearchParams();
data.append("action", "delete_activation_code");
data.append("activation_code", activationCode);
2024-02-03 17:01:52 +01:00
doAccountAction(data, "Activation code deleted Successfully!", "Activation code deletion failed.");
2024-02-04 09:50:04 +01:00
listActivationCodes();
2024-02-03 16:08:26 +01:00
}
2024-02-04 09:54:21 +01:00
function admininit(){
listActivationCodes();
listUsers();
}
window.onload = admininit;
2024-02-03 16:08:26 +01:00
</script>
2024-02-03 17:37:56 +01:00
2024-02-03 16:08:26 +01:00
<div class="form-container" id="addActivationCodesForm">
2024-02-04 09:50:04 +01:00
<h1>Activation Codes</h1>
<h2>List Activation Codes</h2>
2024-02-04 09:53:18 +01:00
<button type="button" onclick="listActivationCodes()">List Activation Codes</button><br>
2024-02-04 09:50:04 +01:00
<h2>Add Activation Codes</h2>
2024-02-03 16:08:26 +01:00
<label for="activationCodeCount">Activation Code Count:</label>
2024-02-03 17:55:54 +01:00
<input type="text" id="activationCodeCount" name="activationCodeCount" required><br>
2024-02-03 16:08:26 +01:00
<button type="button" onclick="addActivationCodes()">Add Activation Codes</button>
2024-02-04 09:53:18 +01:00
<br>
<table id="codeListTable"></table>
2024-02-03 16:08:26 +01:00
</div>
2024-02-04 09:50:04 +01:00
<hr>
2024-02-03 16:08:26 +01:00
<div class="form-container" id="listUsersForm">
<h1>List Users</h1>
2024-02-04 09:50:04 +01:00
<button type="button" onclick="listUsers()">List Users</button><br>
2024-02-04 09:53:18 +01:00
<br>
2024-02-04 09:50:04 +01:00
<table id="userListTable"></table>
2024-02-03 16:08:26 +01:00
</div>
2024-02-04 09:50:04 +01:00
<hr>