2024-06-24 08:50:18 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<title>Admin Panel</title>
|
2024-06-24 21:06:46 +00:00
|
|
|
{% include 'head.html' %}
|
2024-06-24 08:50:18 +00:00
|
|
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
|
|
|
|
<script>
|
|
|
|
function changePassword(userId) {
|
|
|
|
const newPassword = prompt('Enter the new password:');
|
|
|
|
if (newPassword) {
|
|
|
|
fetch('/admin/change_password', {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify({ user_id: userId, new_password: newPassword })
|
|
|
|
})
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
if (data.status === 'success') {
|
|
|
|
alert('Password changed successfully.');
|
|
|
|
} else {
|
|
|
|
alert('Failed to change password.');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function disableAccount(userId) {
|
|
|
|
fetch('/admin/disable_account', {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify({ user_id: userId })
|
|
|
|
}).then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
if (data.status === 'success') {
|
|
|
|
alert('Account disabled successfully');
|
|
|
|
location.reload();
|
|
|
|
} else {
|
|
|
|
alert('Failed to disable account');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function enableAccount(userId) {
|
|
|
|
fetch('/admin/enable_account', {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify({ user_id: userId })
|
|
|
|
}).then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
if (data.status === 'success') {
|
|
|
|
alert('Account enabled successfully');
|
|
|
|
location.reload();
|
|
|
|
} else {
|
|
|
|
alert('Failed to enable account');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</head>
|
2024-06-24 21:06:46 +00:00
|
|
|
<body class="dark:!bg-black bg-white">
|
2024-06-24 08:50:18 +00:00
|
|
|
<div class="container">
|
2024-06-24 21:06:46 +00:00
|
|
|
<h1 class="dark:!text-white text-black">Admin Panel</h1>
|
|
|
|
<table class="table dark:!text-white text-black">
|
2024-06-24 08:50:18 +00:00
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Username</th>
|
|
|
|
<th>Actions</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for user in users %}
|
|
|
|
<tr>
|
|
|
|
<td>{{ user.username }}</td>
|
|
|
|
<td>
|
|
|
|
<button class="btn btn-warning" onclick="changePassword({{ user.id }})">Change Password</button>
|
|
|
|
<button onclick="disableAccount({{ user.id }})" {% if user.disabled %}disabled{% endif %}>Disable</button>
|
|
|
|
<button onclick="enableAccount({{ user.id }})" {% if not user.disabled %}disabled{% endif %}>Enable</button>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|