Files
digiserver/templates/admin.html
2025-06-26 16:57:09 +03:00

233 lines
11 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Panel</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body.dark-mode {
background-color: #121212;
color: #ffffff;
}
.card.dark-mode {
background-color: #1e1e1e;
color: #ffffff;
}
.dark-mode label, .dark-mode th, .dark-mode td {
color: #ffffff;
}
.img-preview {
max-width: 100px;
max-height: 100px;
}
.popup-message {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: rgba(0, 0, 0, 0.8);
color: white;
padding: 20px;
border-radius: 10px;
display: none;
z-index: 1000;
}
.logo {
max-height: 100px;
margin-right: 20px;
}
@media (max-width: 768px) {
.logo {
max-height: 50px;
margin-right: 10px;
}
h1 {
font-size: 1.5rem;
}
.btn {
font-size: 0.9rem;
padding: 0.5rem 1rem;
}
.card {
margin-bottom: 1rem;
}
}
</style>
</head>
<body class="{{ 'dark-mode' if theme == 'dark' else '' }}">
<div class="container py-5">
<div class="d-flex justify-content-start align-items-center mb-4">
{% if logo_exists %}
<img src="{{ url_for('static', filename='resurse/logo.png') }}" alt="Logo" class="logo">
{% endif %}
<h1 class="mb-0">Admin Panel</h1>
</div>
<!-- Manage Users Card -->
<div class="card mb-4 {{ 'dark-mode' if theme == 'dark' else '' }}">
<div class="card-header">
<h2>Manage Users</h2>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-5">
<h3>Manage User Roles</h3>
<table class="table">
<thead>
<tr>
<th>Username</th>
<th>Role</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<td>{{ user.username }}</td>
<td>{{ user.role }}</td>
<td>
<form action="{{ url_for('change_role', user_id=user.id) }}" method="post" class="d-inline">
<select name="role" class="form-select d-inline-block" style="width: auto;">
<option value="user" {% if user.role == 'user' %}selected{% endif %}>User</option>
<option value="admin" {% if user.role == 'admin' %}selected{% endif %}>Admin</option>
</select>
<button type="submit" class="btn btn-sm btn-primary">Change Role</button>
</form>
<form action="{{ url_for('delete_user', user_id=user.id) }}" method="post" class="d-inline">
<button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('Are you sure you want to delete this user?');">Delete</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="col-md-1 d-flex justify-content-center">
<div class="vr"></div>
</div>
<div class="col-md-6">
<h3>Add User</h3>
<form action="{{ url_for('create_user') }}" method="post">
<div class="mb-3">
<label for="username" class="form-label">Username</label>
<input type="text" class="form-control {{ 'dark-mode' if theme == 'dark' else '' }}" id="username" name="username" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control {{ 'dark-mode' if theme == 'dark' else '' }}" id="password" name="password" required>
</div>
<div class="mb-3">
<label for="role" class="form-label">Role</label>
<select class="form-select {{ 'dark-mode' if theme == 'dark' else '' }}" id="role" name="role" required>
<option value="admin">Admin</option>
<option value="user">User</option>
</select>
</div>
<button type="submit" class="btn btn-primary">Add User</button>
</form>
</div>
</div>
</div>
</div>
<!-- Upload Personalization Photos Card -->
<div class="card mb-4 {{ 'dark-mode' if theme == 'dark' else '' }}">
<div class="card-header">
<h2>Upload Personalization Photos</h2>
</div>
<div class="card-body">
<form action="{{ url_for('upload_personalization_pictures') }}" method="post" enctype="multipart/form-data">
<div class="row mb-3">
<div class="col-md-6">
<label for="logo" class="form-label">Current Logo</label>
{% if logo_exists %}
<img src="{{ url_for('static', filename='resurse/logo.png') }}" alt="Current Logo" class="img-thumbnail img-preview mb-3">
{% endif %}
<input type="file" class="form-control {{ 'dark-mode' if theme == 'dark' else '' }}" id="logo" name="logo">
</div>
<div class="col-md-6">
<label for="login_picture" class="form-label">Current Login Page Picture</label>
{% if login_picture_exists %}
<img src="{{ url_for('static', filename='resurse/login_picture.png') }}" alt="Current Login Picture" class="img-thumbnail img-preview mb-3">
{% endif %}
<input type="file" class="form-control {{ 'dark-mode' if theme == 'dark' else '' }}" id="login_picture" name="login_picture">
</div>
</div>
<button type="submit" class="btn btn-primary">Upload Pictures</button>
</form>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-12">
<!-- Change Theme Card -->
<div class="card mb-4 {{ 'dark-mode' if theme == 'dark' else '' }}">
<div class="card-header">
<h2>Change Theme</h2>
</div>
<div class="card-body">
<form action="{{ url_for('change_theme') }}" method="post" onsubmit="showPopupMessage('Theme changed successfully!')">
<div class="mb-3">
<label for="theme" class="form-label">Select Theme</label>
<select class="form-select" id="theme" name="theme" required>
<option value="light" {% if theme == 'light' %}selected{% endif %}>Light</option>
<option value="dark" {% if theme == 'dark' %}selected{% endif %}>Dark</option>
</select>
</div>
<button type="submit" class="btn btn-primary">Change Theme</button>
</form>
</div>
</div>
</div>
<div class="col-lg-6 col-12">
<!-- Clean Unused Files Card -->
<div class="card mb-4 {{ 'dark-mode' if theme == 'dark' else '' }}">
<div class="card-header">
<h2>Clean Unused Files</h2>
</div>
<div class="card-body">
<form action="{{ url_for('clean_unused_files') }}" method="post" onsubmit="showPopupMessage('Clean script executed successfully!')">
<button type="submit" class="btn btn-danger">Run Clean Script</button>
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-12">
<!-- Server Info Card -->
<div class="card mb-4 {{ 'dark-mode' if theme == 'dark' else '' }}">
<div class="card-header">
<h2>Server Info</h2>
</div>
<div class="card-body">
<p><strong>Server Version:</strong> {{ server_version }}</p>
<p><strong>Date of Build:</strong> {{ build_date }}</p>
</div>
</div>
</div>
</div>
<div class="mt-4">
<a href="{{ url_for('dashboard') }}" class="btn btn-secondary">Back to Dashboard</a>
</div>
</div>
<div id="popup-message" class="popup-message"></div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script>
<script>
function showPopupMessage(message) {
const popup = document.getElementById('popup-message');
popup.textContent = message;
popup.style.display = 'block';
setTimeout(() => {
popup.style.display = 'none';
}, 5000);
}
</script>
</body>
</html>