Edit APIs

This commit is contained in:
2024-02-03 17:55:54 +01:00
parent 8b7e465796
commit 1e037cd6a2
3 changed files with 59 additions and 34 deletions

View File

@@ -1,12 +1,14 @@
<script>
function addActivationCodes() {
async function addActivationCodes() {
const count = document.getElementById("activationCodeCount").value;
const data = new URLSearchParams();
data.append("action", "add_activation_codes");
data.append("count", count);
doAccountAction(data, "Activation codes added Successfully!", "Activation codes addition failed.");
const result = await doAccountAction(data, "Activation codes added Successfully!", "Activation codes addition failed.");
displayUserList(result.ActivationCodes);
}
async function listUsers() {
@@ -48,11 +50,13 @@
tableContainer.appendChild(table);
}
function listActivationCodes() {
async function listActivationCodes() {
const data = new URLSearchParams();
data.append("action", "list_activation_codes");
doAccountAction(data, "Activation code list retrieved Successfully!", "Activation code list retrieval failed.");
const result = await doAccountAction(data, "Activation code list retrieved Successfully!", "Activation code list retrieval failed.");
displayUserList(result.ActivationCodes);
}
function deleteUser() {
@@ -82,7 +86,7 @@
<h1>Add Activation Codes</h1>
<form>
<label for="activationCodeCount">Activation Code Count:</label>
<input type="text" id="activationCodeCount" name="activationCodeCount" required>
<input type="text" id="activationCodeCount" name="activationCodeCount" required><br>
<button type="button" onclick="addActivationCodes()">Add Activation Codes</button>
</form>
@@ -106,7 +110,7 @@
<h1>Delete User</h1>
<form>
<label for="userId">User ID:</label>
<input type="text" id="userId" name="userId" required>
<input type="text" id="userId" name="userId" required><br>
<button type="button" onclick="deleteUser()">Delete User</button>
</form>
@@ -116,7 +120,7 @@
<h1>Delete Activation Code</h1>
<form>
<label for="activationCode">Activation Code:</label>
<input type="text" id="activationCode" name="activationCode" required>
<input type="text" id="activationCode" name="activationCode" required><br>
<button type="button" onclick="deleteActivationCode()">Delete Activation Code</button>
</form>

View File

@@ -1,11 +1,11 @@
<script>
function changePassword() {
const userId = document.getElementById("changeUserId").value;
const oldPassword = document.getElementById("changeoldPassword").value;
const newPassword = document.getElementById("changeNewPassword").value;
const data = new URLSearchParams();
data.append("action", "change_password");
data.append("user_id", userId);
data.append("old_password", oldPassword);
data.append("new_password", newPassword);
doChangePassword(data, "Password change Successful!", "Password change failed.");
@@ -87,56 +87,53 @@
<div class="form-container" id="changePasswordForm">
<h1>Change Password</h1>
<form>
<label for="changeUserId">User ID:</label>
<input type="text" id="changeUserId" name="changeUserId" required>
<label for="changeOldPassword">Old Password:</label>
<input type="password" id="changeOldPassword" name="changeOldPassword" required>
<input type="password" id="changeOldPassword" name="changeOldPassword" required><br>
<label for="changeNewPassword">New Password:</label>
<input type="password" id="changeNewPassword" name="changeNewPassword" required>
<input type="password" id="changeNewPassword" name="changeNewPassword" required><br>
<button type="button" onclick="changePassword()">Change Password</button>
</form>
</form><br>
</div>
<div class="form-container" id="updateUserProfileForm">
<h1>Update User Profile</h1>
<form>
<label for="updateUserIdProfile">User ID:</label>
<input type="text" id="updateUserIdProfile" name="updateUserIdProfile" required>
<input type="text" id="updateUserIdProfile" name="updateUserIdProfile" required><br>
<label for="updateFirstName">First Name:</label>
<input type="text" id="updateFirstName" name="updateFirstName" required>
<input type="text" id="updateFirstName" name="updateFirstName" required><br>
<label for="updateLastName">Last Name:</label>
<input type="text" id="updateLastName" name="updateLastName" required>
<input type="text" id="updateLastName" name="updateLastName" required><br>
<label for="updateNickname">Nickname:</label>
<input type="text" id="updateNickname" name="updateNickname" required>
<input type="text" id="updateNickname" name="updateNickname" required><br>
<label for="updateMinecraftNick">Minecraft Nick:</label>
<input type="text" id="updateMinecraftNick" name="updateMinecraftNick" required>
<input type="text" id="updateMinecraftNick" name="updateMinecraftNick" required><br>
<button type="button" onclick="updateUserProfile()">Update Profile</button>
</form>
</form><br>
</div>
<div class="form-container" id="getUserInfoForm">
<h1>Get User Info</h1>
<form>
<button type="button" onclick="getUserInfo()">Get User Info</button>
</form>
</form><br>
</div>
<div class="form-container" id="updateUserEmailForm">
<h1>Update User Email</h1>
<form>
<label for="updateNewEmail">New Email:</label>
<input type="email" id="updateNewEmail" name="updateNewEmail" required>
<input type="email" id="updateNewEmail" name="updateNewEmail" required><br>
<button type="button" onclick="updateEmail()">Update Email</button>
</form>
</form><br>
</div>
<button type="button" onclick="logout()">Logout</button>
<button type="button" onclick="logout()">Logout</button><br>