Files
oldmarketcustomserver/templates/dashboard_settings.html
2025-10-18 10:33:04 +03:00

213 lines
6.9 KiB
HTML

<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Настройки дашборда - OldMarket Admin</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
background: #f5f5f5;
}
.sidebar {
width: 250px;
background: #2c3e50;
color: white;
height: 100vh;
position: fixed;
padding: 20px;
}
.sidebar h2 {
margin-bottom: 30px;
text-align: center;
}
.sidebar .user-info {
background: #34495e;
padding: 10px;
border-radius: 5px;
margin-bottom: 20px;
text-align: center;
}
.sidebar ul {
list-style: none;
}
.sidebar li {
margin: 15px 0;
}
.sidebar a {
color: white;
text-decoration: none;
padding: 10px;
display: block;
border-radius: 5px;
transition: background 0.3s;
}
.sidebar a:hover {
background: #34495e;
}
.content {
margin-left: 250px;
padding: 40px;
}
.settings-section {
background: white;
padding: 25px;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
margin-bottom: 30px;
}
.settings-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
}
.btn {
background: #3498db;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
text-decoration: none;
display: inline-block;
}
.btn:hover {
background: #2980b9;
}
.form-group {
margin-bottom: 15px;
}
label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
input, textarea, select {
width: 100%;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
}
.dashboard-image {
max-width: 100%;
max-height: 400px;
border-radius: 8px;
margin-top: 15px;
}
.current-settings {
background: #f8f9fa;
padding: 15px;
border-radius: 5px;
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class="sidebar">
<h2>OldMarket Admin</h2>
<div class="user-info">
Вы вошли как: <strong>{{ username }}</strong>
</div>
<ul>
<li><a href="/admin">Дашборд</a></li>
<li><a href="/admin/apps">Управление приложениями</a></li>
<li><a href="/admin/reviews">Управление отзывами</a></li>
<li><a href="/admin/dashboard-settings">Настройки дашборда</a></li>
<li><a href="/api/apps" target="_blank">API приложений</a></li>
<li><a href="/admin/logout">Выйти</a></li>
</ul>
</div>
<div class="content">
<h1>Настройки дашборда</h1>
<p>Управление сообщением дня и изображением на главной странице</p>
<!-- Текущие настройки -->
<div class="settings-section">
<h2>Текущие настройки</h2>
<div class="current-settings">
<p><strong>Текущее сообщение дня:</strong></p>
<p>{{ motd }}</p>
<p><strong>Текущее изображение:</strong></p>
<img src="/static/dashboard/{{ dashboard_image }}" alt="Dashboard Image" class="dashboard-image">
</div>
</div>
<!-- Изменение MOTD -->
<div class="settings-section">
<div class="settings-header">
<h2>Изменение сообщения дня (MOTD)</h2>
</div>
<form id="motdForm">
<div class="form-group">
<label>Сообщение дня:</label>
<textarea name="motd" rows="4" required>{{ motd }}</textarea>
</div>
<div class="form-group">
<button type="submit" class="btn">Сохранить MOTD</button>
</div>
</form>
</div>
<!-- Изменение изображения -->
<div class="settings-section">
<div class="settings-header">
<h2>Изменение изображения дашборда</h2>
</div>
<form id="imageForm" enctype="multipart/form-data">
<div class="form-group">
<label>Выберите новое изображение:</label>
<input type="file" name="image" accept="image/*" required>
</div>
<div class="form-group">
<button type="submit" class="btn">Загрузить изображение</button>
</div>
</form>
</div>
</div>
<script>
document.getElementById('motdForm').addEventListener('submit', async function(e) {
e.preventDefault();
const formData = new FormData(this);
try {
const response = await fetch('/api/admin/dashboard/motd', {
method: 'POST',
body: formData
});
const result = await response.json();
alert(result.message);
location.reload();
} catch (error) {
alert('Ошибка при сохранении: ' + error);
}
});
document.getElementById('imageForm').addEventListener('submit', async function(e) {
e.preventDefault();
const formData = new FormData(this);
try {
const response = await fetch('/api/admin/dashboard/image', {
method: 'POST',
body: formData
});
const result = await response.json();
alert(result.message);
location.reload();
} catch (error) {
alert('Ошибка при загрузке изображения: ' + error);
}
});
</script>
</body>
</html>