fix bug web admin panel and sort list users

This commit is contained in:
vrubelroman 2025-11-13 15:27:10 +03:00
parent e645e57f74
commit 526d36bc03
2 changed files with 136 additions and 54 deletions

View file

@ -259,8 +259,16 @@
Сегодня отправлено: <strong id="total-messages-today">0</strong>
</div>
<div id="message-stats-by-command" style="margin-top: 10px; font-size: 12px; color: #666;">
<div style="margin-bottom: 5px;"><strong>По командам:</strong></div>
<div id="command-stats-list"></div>
<div style="display: flex; gap: 20px;">
<div style="flex: 1;">
<div style="margin-bottom: 8px; font-weight: bold;">За все время:</div>
<div id="command-stats-all-time"></div>
</div>
<div style="flex: 1;">
<div style="margin-bottom: 8px; font-weight: bold;">За сегодня:</div>
<div id="command-stats-today"></div>
</div>
</div>
</div>
</div>
@ -312,36 +320,40 @@
document.getElementById('total-messages-all').textContent = data.message_stats.total_all_time || 0;
document.getElementById('total-messages-today').textContent = data.message_stats.total_today || 0;
// Render command stats
const commandStatsList = document.getElementById('command-stats-list');
// Render command stats in two columns
const commandStatsAllTime = document.getElementById('command-stats-all-time');
const commandStatsToday = document.getElementById('command-stats-today');
if (data.message_stats.by_command && Object.keys(data.message_stats.by_command).length > 0) {
const commandNames = {
'addgamer': 'Add Gamer',
'addtoken': 'Add Token',
'getgamers': 'Get Gamers',
'delgamer': 'Del Gamer',
'today': 'Today',
'yesterday': 'Yesterday',
'week': 'Week',
'setperiod': 'Set Period',
'periodic_notification': 'Periodic Notifications'
};
// Filter out excluded commands
// Filter out excluded commands (already filtered on server, but double-check)
const excludedCommands = ['start', 'lang', 'resetlang'];
const filteredCommands = Object.entries(data.message_stats.by_command)
.filter(([cmd]) => !excludedCommands.includes(cmd));
.filter(([cmd]) => !excludedCommands.includes(cmd))
.sort((a, b) => a[0].localeCompare(b[0])); // Sort alphabetically
commandStatsList.innerHTML = filteredCommands
.sort((a, b) => b[1].total - a[1].total)
.map(([cmd, stats]) => {
const cmdName = commandNames[cmd] || cmd;
return `<div style="margin-bottom: 3px;">
${cmdName}: <strong>${stats.total}</strong> (сегодня: <strong>${stats.today}</strong>)
</div>`;
}).join('');
if (filteredCommands.length > 0) {
// Render "All time" column
commandStatsAllTime.innerHTML = filteredCommands
.map(([cmd, stats]) => {
return `<div style="margin-bottom: 3px;">
• ${cmd}: <strong>${stats.total}</strong>
</div>`;
}).join('');
// Render "Today" column
commandStatsToday.innerHTML = filteredCommands
.map(([cmd, stats]) => {
return `<div style="margin-bottom: 3px;">
• ${cmd}: <strong>${stats.today}</strong>
</div>`;
}).join('');
} else {
commandStatsAllTime.innerHTML = '<div style="color: #999;">Нет данных</div>';
commandStatsToday.innerHTML = '<div style="color: #999;">Нет данных</div>';
}
} else {
commandStatsList.innerHTML = '<div style="color: #999;">Нет данных</div>';
commandStatsAllTime.innerHTML = '<div style="color: #999;">Нет данных</div>';
commandStatsToday.innerHTML = '<div style="color: #999;">Нет данных</div>';
}
}