speakmore-2.0/templates/admin_panel.html
Olai bc9fcda6aa Updated online detection and fixed bugs
Updated online detection and fixed bugs
2024-06-25 23:27:34 +02:00

100 lines
3.7 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Admin Panel</title>
{% include 'head.html' %}
<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>
<body class="dark:!bg-black bg-white">
<div class="container">
<h1 class="dark:!text-white text-black">Admin Panel</h1>
<table class="table dark:!text-white text-black">
<thead>
<tr>
<th>ID</th>
<th>Username</th>
<th>Change Password</th>
<th>Disable Account</th>
<th>Online?</th>
<th>Admin?</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<td>{{ user.id }}</td>
<td>{{ user.username }}</td>
<td>
<button class="btn btn-warning" onclick="changePassword({{ user.id }})">Change Password</button>
</td>
<td>
<button class="button-admin" onclick="disableAccount({{ user.id }})" {% if user.disabled %}disabled{% endif %}>Disable</button>
<button class="button-admin" onclick="enableAccount({{ user.id }})" {% if not user.disabled %}disabled{% endif %}>Enable</button>
</td>
<td>{{ user.online }}</td>
<td>{{ user.is_admin }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</body>
</html>