feat: add light/dark theme, RU/EN i18n, instructions page, green/red monitoring

- Light and dark theme toggle with localStorage persistence
- Russian and English language support (full i18n)
- Instructions & cheat sheet modal with install/SSH/API/commands
- Green pulsing dot for online, red for offline servers
- Color-coded metrics: green (ok), yellow (warn >70%), red (crit >90%)
- Top bar on server cards: green=online, red=offline

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Андрей Бобырев
2026-05-20 05:55:16 +03:00
parent 468d0bd028
commit 4846742c60
6 changed files with 563 additions and 91 deletions

169
server/static/js/i18n.js Normal file
View File

@@ -0,0 +1,169 @@
const translations = {
ru: {
title: "VPS Monitoring",
login: "Вход",
username: "Логин",
password: "Пароль",
loginBtn: "Войти",
invalidCreds: "Неверный логин или пароль",
connError: "Ошибка подключения",
total: "Всего",
online: "Online",
offline: "Offline",
addServer: "+ Добавить сервер",
refresh: "Обновить",
settings: "Настройки",
logout: "Выход",
serverName: "Название",
host: "IP / Host",
sshPort: "Порт SSH",
sshLogin: "Логин",
sshPassword: "Пароль",
description: "Описание",
add: "Добавить",
save: "Сохранить",
cancel: "Отмена",
auth: "Авторизация",
newPassword: "Новый пароль",
leaveEmpty: "Оставьте пустым, чтобы не менять",
telegram: "Telegram",
botToken: "Bot Token",
chatId: "Chat ID",
monitoring: "Мониторинг",
pollInterval: "Интервал опроса (сек)",
cpuThreshold: "Порог CPU (%)",
ramThreshold: "Порог RAM (%)",
diskThreshold: "Порог Disk (%)",
settingsSaved: "Настройки сохранены",
rebootConfirm: "Перезагрузить сервер?",
rebootSent: "Команда перезагрузки отправлена",
deleteConfirm: "Удалить сервер из мониторинга?",
noServers: "Нет серверов. Нажмите \"+ Добавить сервер\"",
noData: "Нет данных",
sshTerminal: "SSH Терминал",
instructions: "Инструкции",
quickStart: "Быстрый старт",
cheatSheet: "Шпаргалка",
uptime: "Время работы",
load: "Нагрузка",
network: "Сеть",
networkIn: "Входящий",
networkOut: "Исходящий",
status: "Статус",
theme: "Тема",
language: "Язык",
dark: "Тёмная",
light: "Светлая",
instructions_title: "Инструкции и шпаргалки",
instr_install: "Установка",
instr_install_text: "curl -sSL https://raw.githubusercontent.com/andrey271192/vps_monitoring/main/install.sh | bash",
instr_add_server: "Добавление сервера",
instr_add_server_text: "Нажмите '+ Добавить сервер', введите IP, логин и пароль SSH",
instr_ssh: "SSH подключение",
instr_ssh_text: "Нажмите кнопку 'SSH' на карточке сервера для терминала в браузере",
instr_telegram: "Telegram бот",
instr_telegram_text: "Отправьте /start боту. Получайте алерты при проблемах",
instr_reboot: "Перезагрузка",
instr_reboot_text: "Через панель: кнопка 'Reboot'. Через бот: Управление → Сервер → Перезагрузить",
instr_commands: "Команды управления сервисом",
instr_cmd_status: "systemctl status vps-monitoring",
instr_cmd_restart: "systemctl restart vps-monitoring",
instr_cmd_logs: "journalctl -u vps-monitoring -f",
instr_cmd_update: "cd /opt/vps-monitoring && git pull && systemctl restart vps-monitoring",
instr_api: "API endpoints",
instr_thresholds: "Пороги алертов",
instr_thresholds_text: "Настройки → Мониторинг. По умолчанию: CPU 90%, RAM 90%, Disk 90%",
},
en: {
title: "VPS Monitoring",
login: "Login",
username: "Username",
password: "Password",
loginBtn: "Sign In",
invalidCreds: "Invalid username or password",
connError: "Connection error",
total: "Total",
online: "Online",
offline: "Offline",
addServer: "+ Add Server",
refresh: "Refresh",
settings: "Settings",
logout: "Logout",
serverName: "Name",
host: "IP / Host",
sshPort: "SSH Port",
sshLogin: "Login",
sshPassword: "Password",
description: "Description",
add: "Add",
save: "Save",
cancel: "Cancel",
auth: "Authentication",
newPassword: "New password",
leaveEmpty: "Leave empty to keep current",
telegram: "Telegram",
botToken: "Bot Token",
chatId: "Chat ID",
monitoring: "Monitoring",
pollInterval: "Poll interval (sec)",
cpuThreshold: "CPU threshold (%)",
ramThreshold: "RAM threshold (%)",
diskThreshold: "Disk threshold (%)",
settingsSaved: "Settings saved",
rebootConfirm: "Reboot server?",
rebootSent: "Reboot command sent",
deleteConfirm: "Remove server from monitoring?",
noServers: "No servers. Click \"+ Add Server\"",
noData: "No data",
sshTerminal: "SSH Terminal",
instructions: "Instructions",
quickStart: "Quick Start",
cheatSheet: "Cheat Sheet",
uptime: "Uptime",
load: "Load",
network: "Network",
networkIn: "In",
networkOut: "Out",
status: "Status",
theme: "Theme",
language: "Language",
dark: "Dark",
light: "Light",
instructions_title: "Instructions & Cheat Sheet",
instr_install: "Installation",
instr_install_text: "curl -sSL https://raw.githubusercontent.com/andrey271192/vps_monitoring/main/install.sh | bash",
instr_add_server: "Adding a server",
instr_add_server_text: "Click '+ Add Server', enter IP, SSH login and password",
instr_ssh: "SSH connection",
instr_ssh_text: "Click 'SSH' button on server card for browser terminal",
instr_telegram: "Telegram bot",
instr_telegram_text: "Send /start to the bot. Get alerts when issues arise",
instr_reboot: "Reboot",
instr_reboot_text: "Panel: 'Reboot' button. Bot: Manage → Server → Reboot",
instr_commands: "Service management commands",
instr_cmd_status: "systemctl status vps-monitoring",
instr_cmd_restart: "systemctl restart vps-monitoring",
instr_cmd_logs: "journalctl -u vps-monitoring -f",
instr_cmd_update: "cd /opt/vps-monitoring && git pull && systemctl restart vps-monitoring",
instr_api: "API endpoints",
instr_thresholds: "Alert thresholds",
instr_thresholds_text: "Settings → Monitoring. Default: CPU 90%, RAM 90%, Disk 90%",
}
};
let currentLang = localStorage.getItem('vps_lang') || 'ru';
function t(key) {
return translations[currentLang]?.[key] || translations['en']?.[key] || key;
}
function setLang(lang) {
currentLang = lang;
localStorage.setItem('vps_lang', lang);
document.documentElement.lang = lang;
if (typeof renderPage === 'function') renderPage();
}
function toggleLang() {
setLang(currentLang === 'ru' ? 'en' : 'ru');
}