additional things
This commit is contained in:
@@ -26,6 +26,13 @@
|
||||
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;
|
||||
}
|
||||
@@ -52,6 +59,7 @@
|
||||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
||||
gap: 20px;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.card {
|
||||
background: white;
|
||||
@@ -69,13 +77,90 @@
|
||||
font-weight: bold;
|
||||
color: #3498db;
|
||||
}
|
||||
.sidebar .user-info {
|
||||
background: #34495e;
|
||||
padding: 10px;
|
||||
.motd-section {
|
||||
background: white;
|
||||
padding: 25px;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.motd-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.motd-content {
|
||||
font-size: 1.1em;
|
||||
line-height: 1.5;
|
||||
color: #2c3e50;
|
||||
}
|
||||
.dashboard-image-section {
|
||||
background: white;
|
||||
padding: 25px;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.dashboard-image {
|
||||
max-width: 100%;
|
||||
max-height: 400px;
|
||||
border-radius: 8px;
|
||||
margin-top: 15px;
|
||||
}
|
||||
.btn {
|
||||
background: #3498db;
|
||||
color: white;
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
margin-bottom: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
}
|
||||
.btn:hover {
|
||||
background: #2980b9;
|
||||
}
|
||||
.btn-success {
|
||||
background: #27ae60;
|
||||
}
|
||||
.btn-success:hover {
|
||||
background: #219a52;
|
||||
}
|
||||
.modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0,0,0,0.5);
|
||||
z-index: 1000;
|
||||
}
|
||||
.modal-content {
|
||||
background: white;
|
||||
margin: 50px auto;
|
||||
padding: 30px;
|
||||
width: 80%;
|
||||
max-width: 600px;
|
||||
border-radius: 10px;
|
||||
max-height: 80vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.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;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -88,6 +173,7 @@
|
||||
<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>
|
||||
@@ -97,52 +183,133 @@
|
||||
<h1>Дашборд админ-панели</h1>
|
||||
<p>Добро пожаловать в панель управления OldMarket</p>
|
||||
|
||||
<!-- MOTD Section -->
|
||||
<div class="motd-section">
|
||||
<div class="motd-header">
|
||||
<h2>Сообщение дня (MOTD)</h2>
|
||||
<button class="btn" onclick="showMotdModal()">Изменить MOTD</button>
|
||||
</div>
|
||||
<div class="motd-content">
|
||||
{{ motd }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Dashboard Image Section -->
|
||||
<div class="dashboard-image-section">
|
||||
<div class="motd-header">
|
||||
<h2>Изображение дашборда</h2>
|
||||
<button class="btn" onclick="showImageModal()">Изменить изображение</button>
|
||||
</div>
|
||||
<img src="/static/dashboard/{{ dashboard_image }}" alt="Dashboard Image" class="dashboard-image">
|
||||
</div>
|
||||
|
||||
<div class="dashboard-cards">
|
||||
<div class="card">
|
||||
<h3>Приложения</h3>
|
||||
<div class="number" id="apps-count">0</div>
|
||||
<div class="number" id="apps-count">{{ apps_count }}</div>
|
||||
<p>всего в каталоге</p>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h3>Отзывы</h3>
|
||||
<div class="number" id="reviews-count">0</div>
|
||||
<div class="number" id="reviews-count">{{ reviews_count }}</div>
|
||||
<p>всего отзывов</p>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h3>Загрузки</h3>
|
||||
<div class="number" id="downloads-count">0</div>
|
||||
<div class="number" id="downloads-count">{{ total_downloads }}</div>
|
||||
<p>всего скачиваний</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Модальное окно для изменения MOTD -->
|
||||
<div id="motdModal" class="modal">
|
||||
<div class="modal-content">
|
||||
<h2>Изменить сообщение дня (MOTD)</h2>
|
||||
<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">Сохранить</button>
|
||||
<button type="button" class="btn" onclick="hideMotdModal()">Отмена</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Модальное окно для изменения изображения -->
|
||||
<div id="imageModal" class="modal">
|
||||
<div class="modal-content">
|
||||
<h2>Изменить изображение дашборда</h2>
|
||||
<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>
|
||||
<button type="button" class="btn" onclick="hideImageModal()">Отмена</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Загружаем статистику
|
||||
async function loadStats() {
|
||||
try {
|
||||
const appsResponse = await fetch('/api/admin/apps');
|
||||
const apps = await appsResponse.json();
|
||||
|
||||
document.getElementById('apps-count').textContent = apps.length;
|
||||
|
||||
let totalDownloads = 0;
|
||||
let totalReviews = 0;
|
||||
|
||||
apps.forEach(app => {
|
||||
totalDownloads += app.downloads || 0;
|
||||
// Для отзывов нужно сделать отдельный запрос, упростим
|
||||
totalReviews += app.review_count || 0;
|
||||
});
|
||||
|
||||
document.getElementById('downloads-count').textContent = totalDownloads;
|
||||
document.getElementById('reviews-count').textContent = totalReviews;
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading stats:', error);
|
||||
}
|
||||
function showMotdModal() {
|
||||
document.getElementById('motdModal').style.display = 'block';
|
||||
}
|
||||
|
||||
loadStats();
|
||||
function hideMotdModal() {
|
||||
document.getElementById('motdModal').style.display = 'none';
|
||||
}
|
||||
|
||||
function showImageModal() {
|
||||
document.getElementById('imageModal').style.display = 'block';
|
||||
}
|
||||
|
||||
function hideImageModal() {
|
||||
document.getElementById('imageModal').style.display = 'none';
|
||||
}
|
||||
|
||||
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);
|
||||
hideMotdModal();
|
||||
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);
|
||||
hideImageModal();
|
||||
location.reload();
|
||||
} catch (error) {
|
||||
alert('Ошибка при загрузке изображения: ' + error);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user