r
This commit is contained in:
386
public/admin-script.js
Normal file
386
public/admin-script.js
Normal file
@@ -0,0 +1,386 @@
|
||||
let currentUser = null;
|
||||
let users = [];
|
||||
let filteredUsers = [];
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
checkAuth();
|
||||
setupEventListeners();
|
||||
});
|
||||
|
||||
async function checkAuth() {
|
||||
try {
|
||||
const response = await fetch('/api/user');
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
currentUser = data.user;
|
||||
|
||||
if (currentUser.role !== 'admin') {
|
||||
window.location.href = '/';
|
||||
return;
|
||||
}
|
||||
|
||||
showAdminInterface();
|
||||
} else {
|
||||
showLoginInterface();
|
||||
}
|
||||
} catch (error) {
|
||||
showLoginInterface();
|
||||
}
|
||||
}
|
||||
|
||||
function showLoginInterface() {
|
||||
document.getElementById('login-modal').style.display = 'block';
|
||||
document.querySelector('.admin-container').style.display = 'none';
|
||||
}
|
||||
|
||||
function showAdminInterface() {
|
||||
document.getElementById('login-modal').style.display = 'none';
|
||||
document.querySelector('.admin-container').style.display = 'block';
|
||||
|
||||
let userInfo = `Администратор: ${currentUser.name}`;
|
||||
if (currentUser.auth_type === 'ldap') {
|
||||
userInfo += ` (LDAP)`;
|
||||
}
|
||||
|
||||
document.getElementById('current-user').textContent = userInfo;
|
||||
|
||||
loadUsers();
|
||||
loadDashboardStats();
|
||||
}
|
||||
|
||||
function setupEventListeners() {
|
||||
document.getElementById('login-form').addEventListener('submit', login);
|
||||
document.getElementById('edit-user-form').addEventListener('submit', updateUser);
|
||||
}
|
||||
|
||||
async function login(event) {
|
||||
event.preventDefault();
|
||||
|
||||
const login = document.getElementById('login').value;
|
||||
const password = document.getElementById('password').value;
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/login', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ login, password })
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
currentUser = data.user;
|
||||
|
||||
if (currentUser.role !== 'admin') {
|
||||
window.location.href = '/';
|
||||
return;
|
||||
}
|
||||
|
||||
showAdminInterface();
|
||||
} else {
|
||||
const error = await response.json();
|
||||
alert(error.error || 'Ошибка входа');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Ошибка:', error);
|
||||
alert('Ошибка подключения к серверу');
|
||||
}
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
try {
|
||||
await fetch('/api/logout', { method: 'POST' });
|
||||
currentUser = null;
|
||||
showLoginInterface();
|
||||
} catch (error) {
|
||||
console.error('Ошибка выхода:', error);
|
||||
}
|
||||
}
|
||||
|
||||
function showAdminSection(sectionName) {
|
||||
document.querySelectorAll('.admin-tab').forEach(tab => {
|
||||
tab.classList.remove('active');
|
||||
});
|
||||
|
||||
document.querySelectorAll('.admin-section').forEach(section => {
|
||||
section.classList.remove('active');
|
||||
});
|
||||
|
||||
document.querySelector(`.admin-tab[onclick="showAdminSection('${sectionName}')"]`).classList.add('active');
|
||||
document.getElementById(`admin-${sectionName}`).classList.add('active');
|
||||
|
||||
if (sectionName === 'users') {
|
||||
loadUsers();
|
||||
} else if (sectionName === 'dashboard') {
|
||||
loadDashboardStats();
|
||||
}
|
||||
}
|
||||
|
||||
async function loadUsers() {
|
||||
try {
|
||||
const response = await fetch('/admin/users');
|
||||
if (!response.ok) {
|
||||
throw new Error('Ошибка загрузки пользователей');
|
||||
}
|
||||
users = await response.json();
|
||||
filteredUsers = [...users];
|
||||
renderUsersTable();
|
||||
} catch (error) {
|
||||
console.error('Ошибка загрузки пользователей:', error);
|
||||
showError('users-table-body', 'Ошибка загрузки пользователей');
|
||||
}
|
||||
}
|
||||
|
||||
async function loadDashboardStats() {
|
||||
try {
|
||||
const response = await fetch('/admin/stats');
|
||||
if (!response.ok) {
|
||||
throw new Error('Ошибка загрузки статистики');
|
||||
}
|
||||
|
||||
const stats = await response.json();
|
||||
updateStatsUI(stats);
|
||||
} catch (error) {
|
||||
console.error('Ошибка загрузки статистики:', error);
|
||||
}
|
||||
}
|
||||
|
||||
function updateStatsUI(stats) {
|
||||
// Задачи
|
||||
document.getElementById('total-tasks').textContent = stats.totalTasks;
|
||||
document.getElementById('active-tasks').textContent = stats.activeTasks;
|
||||
document.getElementById('closed-tasks').textContent = stats.closedTasks;
|
||||
document.getElementById('deleted-tasks').textContent = stats.deletedTasks;
|
||||
|
||||
// Процент активных задач
|
||||
if (stats.totalTasks > 0) {
|
||||
const activePercentage = Math.round((stats.activeTasks / stats.totalTasks) * 100);
|
||||
document.getElementById('active-tasks-bar').style.width = `${activePercentage}%`;
|
||||
}
|
||||
|
||||
// Назначения
|
||||
document.getElementById('total-assignments').textContent = stats.totalAssignments;
|
||||
document.getElementById('assigned-count').textContent = stats.assignedCount;
|
||||
document.getElementById('in-progress-count').textContent = stats.inProgressCount;
|
||||
document.getElementById('completed-count').textContent = stats.completedCount;
|
||||
document.getElementById('overdue-count').textContent = stats.overdueCount;
|
||||
document.getElementById('rework-count').textContent = stats.reworkCount;
|
||||
|
||||
// Пользователи
|
||||
document.getElementById('total-users').textContent = stats.totalUsers;
|
||||
document.getElementById('admin-users').textContent = stats.adminUsers;
|
||||
document.getElementById('teacher-users').textContent = stats.teacherUsers;
|
||||
document.getElementById('ldap-users').textContent = stats.ldapUsers;
|
||||
document.getElementById('local-users').textContent = stats.localUsers;
|
||||
|
||||
// Файлы
|
||||
document.getElementById('total-files').textContent = stats.totalFiles;
|
||||
const fileSizeMB = (stats.totalFilesSize / 1024 / 1024).toFixed(2);
|
||||
document.getElementById('total-files-size').textContent = `${fileSizeMB} MB`;
|
||||
|
||||
// Последние задачи
|
||||
renderRecentTasks(stats.recentTasks || []);
|
||||
}
|
||||
|
||||
function renderRecentTasks(tasks) {
|
||||
const container = document.getElementById('recent-tasks-list');
|
||||
|
||||
if (!tasks || tasks.length === 0) {
|
||||
container.innerHTML = '<div class="loading">Нет недавних задач</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
container.innerHTML = tasks.map(task => `
|
||||
<div class="task-item">
|
||||
<div class="task-info">
|
||||
<div class="task-title">${task.title}</div>
|
||||
<div class="task-meta">
|
||||
Создал: ${task.creator_name} | ${formatDateTime(task.created_at)}
|
||||
</div>
|
||||
</div>
|
||||
<div class="task-actions">
|
||||
<a href="/#task-${task.id}" class="view-task-btn" onclick="window.location.href = '/#task-${task.id}'">Просмотр</a>
|
||||
</div>
|
||||
</div>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
function searchUsers() {
|
||||
const search = document.getElementById('user-search').value.toLowerCase();
|
||||
filteredUsers = users.filter(user =>
|
||||
user.login.toLowerCase().includes(search) ||
|
||||
user.name.toLowerCase().includes(search) ||
|
||||
user.email.toLowerCase().includes(search) ||
|
||||
user.role.toLowerCase().includes(search) ||
|
||||
user.auth_type.toLowerCase().includes(search)
|
||||
);
|
||||
renderUsersTable();
|
||||
}
|
||||
|
||||
function renderUsersTable() {
|
||||
const tbody = document.getElementById('users-table-body');
|
||||
|
||||
if (!filteredUsers || filteredUsers.length === 0) {
|
||||
tbody.innerHTML = '<tr><td colspan="9" class="loading">Пользователи не найдены</td></tr>';
|
||||
return;
|
||||
}
|
||||
|
||||
tbody.innerHTML = filteredUsers.map(user => `
|
||||
<tr>
|
||||
<td>${user.id}</td>
|
||||
<td>
|
||||
${user.login}
|
||||
${user.auth_type === 'ldap' ? '<span class="ldap-badge">LDAP</span>' : ''}
|
||||
</td>
|
||||
<td>${user.name}</td>
|
||||
<td>${user.email}</td>
|
||||
<td>
|
||||
${user.role === 'admin' ? 'Администратор' : 'Учитель'}
|
||||
${user.role === 'admin' ? '<span class="admin-badge">ADMIN</span>' : ''}
|
||||
</td>
|
||||
<td>${user.auth_type === 'ldap' ? 'LDAP' : 'Локальная'}</td>
|
||||
<td>${formatDate(user.created_at)}</td>
|
||||
<td>${user.last_login ? formatDateTime(user.last_login) : 'Никогда'}</td>
|
||||
<td class="user-actions">
|
||||
<button class="edit-btn" onclick="openEditUserModal(${user.id})" title="Редактировать">✏️</button>
|
||||
<button class="delete-btn" onclick="deleteUser(${user.id})" title="Удалить" ${user.id === currentUser.id ? 'disabled' : ''}>🗑️</button>
|
||||
</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
async function openEditUserModal(userId) {
|
||||
try {
|
||||
const response = await fetch(`/admin/users/${userId}`);
|
||||
if (!response.ok) {
|
||||
throw new Error('Ошибка загрузки пользователя');
|
||||
}
|
||||
|
||||
const user = await response.json();
|
||||
|
||||
document.getElementById('edit-user-id').value = user.id;
|
||||
document.getElementById('edit-login').value = user.login;
|
||||
document.getElementById('edit-name').value = user.name;
|
||||
document.getElementById('edit-email').value = user.email;
|
||||
document.getElementById('edit-role').value = user.role;
|
||||
document.getElementById('edit-auth-type').value = user.auth_type;
|
||||
document.getElementById('edit-groups').value = user.groups || '[]';
|
||||
document.getElementById('edit-description').value = user.description || '';
|
||||
|
||||
document.getElementById('edit-user-modal').style.display = 'block';
|
||||
} catch (error) {
|
||||
console.error('Ошибка:', error);
|
||||
alert('Ошибка загрузки пользователя');
|
||||
}
|
||||
}
|
||||
|
||||
function closeEditUserModal() {
|
||||
document.getElementById('edit-user-modal').style.display = 'none';
|
||||
}
|
||||
|
||||
async function updateUser(event) {
|
||||
event.preventDefault();
|
||||
|
||||
const userId = document.getElementById('edit-user-id').value;
|
||||
const login = document.getElementById('edit-login').value;
|
||||
const name = document.getElementById('edit-name').value;
|
||||
const email = document.getElementById('edit-email').value;
|
||||
const role = document.getElementById('edit-role').value;
|
||||
const auth_type = document.getElementById('edit-auth-type').value;
|
||||
const groups = document.getElementById('edit-groups').value;
|
||||
const description = document.getElementById('edit-description').value;
|
||||
|
||||
if (!login || !name || !email) {
|
||||
alert('Заполните обязательные поля');
|
||||
return;
|
||||
}
|
||||
|
||||
const userData = {
|
||||
login,
|
||||
name,
|
||||
email,
|
||||
role,
|
||||
auth_type,
|
||||
groups: groups || '[]',
|
||||
description
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await fetch(`/admin/users/${userId}`, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(userData)
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
alert('Пользователь успешно обновлен!');
|
||||
closeEditUserModal();
|
||||
loadUsers();
|
||||
loadDashboardStats();
|
||||
} else {
|
||||
const error = await response.json();
|
||||
alert(error.error || 'Ошибка обновления пользователя');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Ошибка:', error);
|
||||
alert('Ошибка обновления пользователя');
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteUser(userId) {
|
||||
if (userId === currentUser.id) {
|
||||
alert('Нельзя удалить самого себя');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm('Вы уверены, что хотите удалить этого пользователя?')) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`/admin/users/${userId}`, {
|
||||
method: 'DELETE'
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
alert('Пользователь успешно удален!');
|
||||
loadUsers();
|
||||
loadDashboardStats();
|
||||
} else {
|
||||
const error = await response.json();
|
||||
alert(error.error || 'Ошибка удаления пользователя');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Ошибка:', error);
|
||||
alert('Ошибка удаления пользователя');
|
||||
}
|
||||
}
|
||||
|
||||
function formatDateTime(dateTimeString) {
|
||||
if (!dateTimeString) return '';
|
||||
const date = new Date(dateTimeString);
|
||||
return date.toLocaleString('ru-RU');
|
||||
}
|
||||
|
||||
function formatDate(dateString) {
|
||||
if (!dateString) return '';
|
||||
const date = new Date(dateString);
|
||||
return date.toLocaleDateString('ru-RU');
|
||||
}
|
||||
|
||||
function showError(elementId, message) {
|
||||
const element = document.getElementById(elementId);
|
||||
if (element) {
|
||||
element.innerHTML = `<tr><td colspan="9" class="error">${message}</td></tr>`;
|
||||
}
|
||||
}
|
||||
|
||||
// Автоматическое обновление статистики каждые 30 секунд
|
||||
setInterval(() => {
|
||||
if (document.getElementById('admin-dashboard').classList.contains('active')) {
|
||||
loadDashboardStats();
|
||||
}
|
||||
}, 30000);
|
||||
472
public/admin.html
Normal file
472
public/admin.html
Normal file
@@ -0,0 +1,472 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>School CRM - Административная панель</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<style>
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
gap: 20px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
|
||||
border-left: 4px solid #3498db;
|
||||
}
|
||||
|
||||
.stat-card.task-stat {
|
||||
border-left-color: #3498db;
|
||||
}
|
||||
|
||||
.stat-card.user-stat {
|
||||
border-left-color: #2ecc71;
|
||||
}
|
||||
|
||||
.stat-card.file-stat {
|
||||
border-left-color: #9b59b6;
|
||||
}
|
||||
|
||||
.stat-card.status-stat {
|
||||
border-left-color: #f39c12;
|
||||
}
|
||||
|
||||
.stat-card h3 {
|
||||
margin: 0 0 15px 0;
|
||||
color: #495057;
|
||||
font-size: 1.1rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 2.5rem;
|
||||
font-weight: 700;
|
||||
color: #2c3e50;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.stat-desc {
|
||||
color: #6c757d;
|
||||
font-size: 0.9rem;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.stat-subitems {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.stat-subitem {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 5px 0;
|
||||
border-bottom: 1px solid #f1f1f1;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.stat-subitem:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.stat-subitem .label {
|
||||
color: #6c757d;
|
||||
}
|
||||
|
||||
.stat-subitem .value {
|
||||
font-weight: 600;
|
||||
color: #2c3e50;
|
||||
}
|
||||
|
||||
.recent-tasks {
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.recent-tasks h3 {
|
||||
margin: 0 0 15px 0;
|
||||
color: #495057;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.task-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 12px;
|
||||
border-bottom: 1px solid #e9ecef;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.task-item:hover {
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
.task-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.task-info {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.task-title {
|
||||
font-weight: 600;
|
||||
color: #2c3e50;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.task-meta {
|
||||
font-size: 0.85rem;
|
||||
color: #6c757d;
|
||||
}
|
||||
|
||||
.task-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.view-task-btn {
|
||||
padding: 6px 12px;
|
||||
background: #3498db;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-size: 0.85rem;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.view-task-btn:hover {
|
||||
background: #2980b9;
|
||||
}
|
||||
|
||||
.percentage-bar {
|
||||
height: 6px;
|
||||
background: #e9ecef;
|
||||
border-radius: 3px;
|
||||
margin-top: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.percentage-fill {
|
||||
height: 100%;
|
||||
background: #3498db;
|
||||
border-radius: 3px;
|
||||
transition: width 0.3s ease;
|
||||
}
|
||||
|
||||
.users-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.users-table th,
|
||||
.users-table td {
|
||||
padding: 12px;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #e9ecef;
|
||||
}
|
||||
|
||||
.users-table th {
|
||||
background: #f8f9fa;
|
||||
font-weight: 600;
|
||||
color: #495057;
|
||||
}
|
||||
|
||||
.users-table tr:hover {
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
.user-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.user-actions button {
|
||||
padding: 6px 12px;
|
||||
font-size: 0.85rem;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.ldap-badge {
|
||||
background: #3498db;
|
||||
color: white;
|
||||
padding: 3px 8px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.75rem;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.admin-badge {
|
||||
background: #e74c3c;
|
||||
color: white;
|
||||
padding: 3px 8px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.75rem;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.form-row {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.form-row .form-group {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.modal-lg {
|
||||
max-width: 800px;
|
||||
}
|
||||
|
||||
.search-container {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.search-container input {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.file-size {
|
||||
font-size: 1.2rem;
|
||||
color: #2c3e50;
|
||||
margin-top: 5px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="login-modal" class="modal">
|
||||
<div class="modal-content">
|
||||
<h2>Вход в School CRM</h2>
|
||||
<form id="login-form">
|
||||
<div class="form-group">
|
||||
<label for="login">Логин:</label>
|
||||
<input type="text" id="login" name="login" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Пароль:</label>
|
||||
<input type="password" id="password" name="password" required>
|
||||
</div>
|
||||
<button type="submit">Войти</button>
|
||||
</form>
|
||||
<div class="test-users">
|
||||
<h3>Тестовые пользователи:</h3>
|
||||
<ul>
|
||||
<li><strong>admin</strong> / admin123 (Администратор)</li>
|
||||
<li><strong>teacher</strong> / teacher123</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-container">
|
||||
<div class="admin-header">
|
||||
<h1>Административная панель</h1>
|
||||
<div class="user-info">
|
||||
<span id="current-user"></span>
|
||||
<button onclick="window.location.href = '/'">Назад к задачам</button>
|
||||
<button onclick="logout()">Выйти</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-tabs">
|
||||
<button class="admin-tab active" onclick="showAdminSection('dashboard')">Дашборд</button>
|
||||
<button class="admin-tab" onclick="showAdminSection('users')">Пользователи</button>
|
||||
</div>
|
||||
|
||||
<div id="admin-dashboard" class="admin-section active">
|
||||
<h2>Статистика системы</h2>
|
||||
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card task-stat">
|
||||
<h3>Задачи</h3>
|
||||
<div class="stat-value" id="total-tasks">0</div>
|
||||
<div class="stat-desc">Всего задач в системе</div>
|
||||
<div class="percentage-bar">
|
||||
<div class="percentage-fill" id="active-tasks-bar" style="width: 0%"></div>
|
||||
</div>
|
||||
<div class="stat-subitems">
|
||||
<div class="stat-subitem">
|
||||
<span class="label">Активные:</span>
|
||||
<span class="value" id="active-tasks">0</span>
|
||||
</div>
|
||||
<div class="stat-subitem">
|
||||
<span class="label">Закрытые:</span>
|
||||
<span class="value" id="closed-tasks">0</span>
|
||||
</div>
|
||||
<div class="stat-subitem">
|
||||
<span class="label">Удаленные:</span>
|
||||
<span class="value" id="deleted-tasks">0</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stat-card status-stat">
|
||||
<h3>Статусы назначений</h3>
|
||||
<div class="stat-value" id="total-assignments">0</div>
|
||||
<div class="stat-desc">Всего назначений</div>
|
||||
<div class="stat-subitems">
|
||||
<div class="stat-subitem">
|
||||
<span class="label">Назначено:</span>
|
||||
<span class="value" id="assigned-count">0</span>
|
||||
</div>
|
||||
<div class="stat-subitem">
|
||||
<span class="label">В работе:</span>
|
||||
<span class="value" id="in-progress-count">0</span>
|
||||
</div>
|
||||
<div class="stat-subitem">
|
||||
<span class="label">Выполнено:</span>
|
||||
<span class="value" id="completed-count">0</span>
|
||||
</div>
|
||||
<div class="stat-subitem">
|
||||
<span class="label">Просрочено:</span>
|
||||
<span class="value" id="overdue-count">0</span>
|
||||
</div>
|
||||
<div class="stat-subitem">
|
||||
<span class="label">На доработке:</span>
|
||||
<span class="value" id="rework-count">0</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stat-card user-stat">
|
||||
<h3>Пользователи</h3>
|
||||
<div class="stat-value" id="total-users">0</div>
|
||||
<div class="stat-desc">Зарегистрировано пользователей</div>
|
||||
<div class="stat-subitems">
|
||||
<div class="stat-subitem">
|
||||
<span class="label">Администраторы:</span>
|
||||
<span class="value" id="admin-users">0</span>
|
||||
</div>
|
||||
<div class="stat-subitem">
|
||||
<span class="label">Учителя:</span>
|
||||
<span class="value" id="teacher-users">0</span>
|
||||
</div>
|
||||
<div class="stat-subitem">
|
||||
<span class="label">LDAP:</span>
|
||||
<span class="value" id="ldap-users">0</span>
|
||||
</div>
|
||||
<div class="stat-subitem">
|
||||
<span class="label">Локальные:</span>
|
||||
<span class="value" id="local-users">0</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stat-card file-stat">
|
||||
<h3>Файлы</h3>
|
||||
<div class="stat-value" id="total-files">0</div>
|
||||
<div class="stat-desc">Всего загружено файлов</div>
|
||||
<div class="file-size" id="total-files-size">0 MB</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="recent-tasks">
|
||||
<h3>Последние созданные задачи</h3>
|
||||
<div id="recent-tasks-list" class="loading">Загрузка...</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="admin-users-section" class="admin-section">
|
||||
<h2>Управление пользователями</h2>
|
||||
|
||||
<div class="search-container">
|
||||
<input type="text" id="user-search" placeholder="Поиск пользователей по логину, имени или email..." oninput="searchUsers()">
|
||||
<button onclick="loadUsers()">Сбросить</button>
|
||||
</div>
|
||||
|
||||
<table class="users-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Логин</th>
|
||||
<th>Имя</th>
|
||||
<th>Email</th>
|
||||
<th>Роль</th>
|
||||
<th>Тип</th>
|
||||
<th>Дата создания</th>
|
||||
<th>Последний вход</th>
|
||||
<th>Действия</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="users-table-body">
|
||||
<tr>
|
||||
<td colspan="9" class="loading">Загрузка пользователей...</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="edit-user-modal" class="modal">
|
||||
<div class="modal-content modal-lg">
|
||||
<span class="close" onclick="closeEditUserModal()">×</span>
|
||||
<h3>Редактировать пользователя</h3>
|
||||
<form id="edit-user-form">
|
||||
<input type="hidden" id="edit-user-id">
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="edit-login">Логин *</label>
|
||||
<input type="text" id="edit-login" name="login" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="edit-name">Имя *</label>
|
||||
<input type="text" id="edit-name" name="name" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="edit-email">Email *</label>
|
||||
<input type="email" id="edit-email" name="email" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="edit-role">Роль</label>
|
||||
<select id="edit-role" name="role">
|
||||
<option value="teacher">Учитель</option>
|
||||
<option value="admin">Администратор</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="edit-auth-type">Тип авторизации</label>
|
||||
<select id="edit-auth-type" name="auth_type">
|
||||
<option value="local">Локальная</option>
|
||||
<option value="ldap">LDAP</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="edit-groups">Группы (JSON)</label>
|
||||
<input type="text" id="edit-groups" name="groups" placeholder='["group1", "group2"]'>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="edit-description">Описание</label>
|
||||
<textarea id="edit-description" name="description" rows="3"></textarea>
|
||||
</div>
|
||||
|
||||
<button type="submit">Сохранить изменения</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="admin-script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -41,6 +41,7 @@
|
||||
<button onclick="showSection('tasks')">Задачи</button>
|
||||
<button onclick="showSection('create-task')">Создать задачу</button>
|
||||
<button onclick="showSection('logs')">Лог активности</button>
|
||||
<button onclick="window.location.href = '/admin'" style="background: linear-gradient(135deg, #e74c3c, #c0392b);">Админ-панель</button>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
|
||||
251
public/style.css
251
public/style.css
@@ -1022,4 +1022,255 @@ button.reopen-btn:hover {
|
||||
/* В существующие стили добавляем */
|
||||
.show-deleted-label[style*="display: none"] {
|
||||
display: none !important;
|
||||
}
|
||||
.deadline-badge {
|
||||
padding: 4px 12px;
|
||||
border-radius: 20px;
|
||||
font-size: 0.8rem;
|
||||
margin-left: 10px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.deadline-48h {
|
||||
background: linear-gradient(135deg, #ffc107, #e0a800);
|
||||
color: #856404;
|
||||
}
|
||||
|
||||
.deadline-24h {
|
||||
background: linear-gradient(135deg, #fd7e14, #e8590c);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.deadline-indicator {
|
||||
padding: 2px 8px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.7rem;
|
||||
margin-left: 8px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.task-title .deadline-badge {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.filter-group select {
|
||||
min-width: 150px;
|
||||
}
|
||||
|
||||
.filters {
|
||||
gap: 15px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.filters {
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.filter-group select {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
/* Админ-стили */
|
||||
.admin-container {
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.admin-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 30px;
|
||||
padding-bottom: 20px;
|
||||
border-bottom: 2px solid #e9ecef;
|
||||
}
|
||||
|
||||
.admin-tabs {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 20px;
|
||||
border-bottom: 2px solid #e9ecef;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.admin-tab {
|
||||
padding: 10px 20px;
|
||||
background: #f8f9fa;
|
||||
border: none;
|
||||
border-radius: 8px 8px 0 0;
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
color: #495057;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.admin-tab:hover {
|
||||
background: #e9ecef;
|
||||
}
|
||||
|
||||
.admin-tab.active {
|
||||
background: #3498db;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.admin-section {
|
||||
display: none;
|
||||
padding: 20px;
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.admin-section.active {
|
||||
display: block;
|
||||
animation: fadeIn 0.3s ease;
|
||||
}
|
||||
|
||||
.users-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.users-table th,
|
||||
.users-table td {
|
||||
padding: 12px;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #e9ecef;
|
||||
}
|
||||
|
||||
.users-table th {
|
||||
background: #f8f9fa;
|
||||
font-weight: 600;
|
||||
color: #495057;
|
||||
}
|
||||
|
||||
.users-table tr:hover {
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
.user-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.user-actions button {
|
||||
padding: 6px 12px;
|
||||
font-size: 0.85rem;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.ldap-badge {
|
||||
background: #3498db;
|
||||
color: white;
|
||||
padding: 3px 8px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.75rem;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.admin-badge {
|
||||
background: #e74c3c;
|
||||
color: white;
|
||||
padding: 3px 8px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.75rem;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.form-row {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.form-row .form-group {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.password-fields {
|
||||
background: #f8f9fa;
|
||||
padding: 15px;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 20px;
|
||||
border-left: 4px solid #3498db;
|
||||
}
|
||||
|
||||
.modal-lg {
|
||||
max-width: 800px;
|
||||
}
|
||||
|
||||
.search-container {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.search-container input {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.stats-cards {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
||||
gap: 20px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
|
||||
border-left: 4px solid #3498db;
|
||||
}
|
||||
|
||||
.stat-card h3 {
|
||||
margin: 0 0 10px 0;
|
||||
color: #495057;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 2rem;
|
||||
font-weight: 700;
|
||||
color: #2c3e50;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.stat-desc {
|
||||
color: #6c757d;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.stat-card.admin-stat {
|
||||
border-left-color: #e74c3c;
|
||||
}
|
||||
|
||||
.stat-card.ldap-stat {
|
||||
border-left-color: #2ecc71;
|
||||
}
|
||||
|
||||
.stat-card.local-stat {
|
||||
border-left-color: #f39c12;
|
||||
}
|
||||
|
||||
/* Анимация появления */
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; transform: translateY(10px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
.error {
|
||||
background: linear-gradient(135deg, #f8d7da, #f5c6cb);
|
||||
color: #721c24;
|
||||
padding: 15px 20px;
|
||||
border-radius: 10px;
|
||||
margin: 15px 0;
|
||||
border: 1px solid #f5c6cb;
|
||||
border-left: 5px solid #e74c3c;
|
||||
text-align: center;
|
||||
}
|
||||
Reference in New Issue
Block a user