пользователь
This commit is contained in:
@@ -119,6 +119,8 @@ async function logout() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function showAdminSection(sectionName) {
|
function showAdminSection(sectionName) {
|
||||||
|
console.log('showAdminSection called with:', sectionName);
|
||||||
|
|
||||||
// Убираем активный класс у всех вкладок
|
// Убираем активный класс у всех вкладок
|
||||||
document.querySelectorAll('.admin-tab').forEach(tab => {
|
document.querySelectorAll('.admin-tab').forEach(tab => {
|
||||||
tab.classList.remove('active');
|
tab.classList.remove('active');
|
||||||
@@ -130,48 +132,74 @@ function showAdminSection(sectionName) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Находим и активируем соответствующую вкладку
|
// Находим и активируем соответствующую вкладку
|
||||||
const tab = document.querySelector(`.admin-tab[onclick*="showAdminSection('${sectionName}')"]`);
|
|
||||||
if (tab) {
|
|
||||||
tab.classList.add('active');
|
|
||||||
} else {
|
|
||||||
// Альтернативный поиск если выше не сработал
|
|
||||||
const tabs = document.querySelectorAll('.admin-tab');
|
const tabs = document.querySelectorAll('.admin-tab');
|
||||||
tabs.forEach(t => {
|
let tabFound = false;
|
||||||
if (t.textContent.toLowerCase().includes(sectionName)) {
|
|
||||||
t.classList.add('active');
|
tabs.forEach(tab => {
|
||||||
|
const onclick = tab.getAttribute('onclick');
|
||||||
|
if (onclick && onclick.includes(`showAdminSection('${sectionName}')`)) {
|
||||||
|
tab.classList.add('active');
|
||||||
|
tabFound = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Если не нашли по onclick, ищем по тексту
|
||||||
|
if (!tabFound) {
|
||||||
|
tabs.forEach(tab => {
|
||||||
|
const tabText = tab.textContent.toLowerCase();
|
||||||
|
if (tabText.includes(sectionName.toLowerCase())) {
|
||||||
|
tab.classList.add('active');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Активируем соответствующую секцию
|
// Активируем соответствующую секцию
|
||||||
const section = document.getElementById(`admin-${sectionName}`);
|
const sectionId = `admin-${sectionName}-section`;
|
||||||
if (section) {
|
let section = document.getElementById(sectionId);
|
||||||
section.classList.add('active');
|
|
||||||
|
// Если не нашли по такому ID, пробуем другие варианты
|
||||||
|
if (!section) {
|
||||||
|
if (sectionName === 'users') {
|
||||||
|
section = document.getElementById('admin-users-section');
|
||||||
|
} else if (sectionName === 'dashboard') {
|
||||||
|
section = document.getElementById('admin-dashboard');
|
||||||
|
} else if (sectionName === 'stats') {
|
||||||
|
section = document.getElementById('admin-stats-section');
|
||||||
} else {
|
} else {
|
||||||
// Если секция не найдена по ID, ищем по другому шаблону
|
// Пробуем найти по частичному совпадению
|
||||||
const sections = document.querySelectorAll('.admin-section');
|
const sections = document.querySelectorAll('.admin-section');
|
||||||
sections.forEach(s => {
|
sections.forEach(s => {
|
||||||
if (s.id.includes(sectionName)) {
|
if (s.id.includes(sectionName)) {
|
||||||
s.classList.add('active');
|
section = s;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (section) {
|
||||||
|
section.classList.add('active');
|
||||||
|
console.log('Activated section:', section.id);
|
||||||
|
} else {
|
||||||
|
console.error('Section not found for:', sectionName);
|
||||||
|
}
|
||||||
|
|
||||||
// Загружаем данные для активной секции
|
// Загружаем данные для активной секции
|
||||||
|
setTimeout(() => {
|
||||||
if (sectionName === 'users') {
|
if (sectionName === 'users') {
|
||||||
|
console.log('Loading users...');
|
||||||
loadUsers();
|
loadUsers();
|
||||||
} else if (sectionName === 'dashboard') {
|
} else if (sectionName === 'dashboard') {
|
||||||
|
console.log('Loading dashboard...');
|
||||||
if (typeof renderDashboard === 'function') {
|
if (typeof renderDashboard === 'function') {
|
||||||
renderDashboard();
|
renderDashboard();
|
||||||
}
|
}
|
||||||
} else if (sectionName === 'stats') {
|
} else if (sectionName === 'stats') {
|
||||||
|
console.log('Loading stats...');
|
||||||
if (typeof renderStatsSection === 'function') {
|
if (typeof renderStatsSection === 'function') {
|
||||||
renderStatsSection();
|
renderStatsSection();
|
||||||
} else if (typeof checkAndRenderStats === 'function') {
|
|
||||||
// Альтернативный вызов если функция переименована
|
|
||||||
checkAndRenderStats();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadUsers() {
|
async function loadUsers() {
|
||||||
|
|||||||
Reference in New Issue
Block a user