up frontend

This commit is contained in:
2026-04-21 03:57:59 +03:00
parent b9d1afad42
commit 82a932dd2b
14 changed files with 492 additions and 172 deletions

View File

@@ -102,7 +102,7 @@
</div>
<div class="flex-1 min-w-0">
<p class="text-sm font-medium text-gray-900 truncate">{{ userName }}</p>
<p class="text-xs text-gray-500 truncate">{{ userStore.role === 'admin' ? 'Administrator' : 'User' }}</p>
<p class="text-xs text-gray-500 truncate">{{ userStore.role === 'admin' ? t('app.administrator') : t('app.user') }}</p>
</div>
</div>
</div>
@@ -124,7 +124,7 @@
<div class="relative">
<input
type="text"
placeholder="Search..."
:placeholder="t('app.search')"
class="w-64 px-4 py-2 pl-10 text-sm border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500"
/>
<svg class="absolute left-3 top-2.5 w-4 h-4 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
@@ -133,7 +133,7 @@
</div>
<!-- Notifications -->
<button class="relative p-2 text-gray-400 hover:text-gray-600 rounded-lg hover:bg-gray-100 transition-colors">
<button class="relative p-2 text-gray-400 hover:text-gray-600 rounded-lg hover:bg-gray-100 transition-colors" :title="t('app.notifications')">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9" />
</svg>
@@ -186,15 +186,12 @@ const { t, locale } = useI18n()
const userName = computed(() => userStore.login || 'User')
const userInitials = computed(() => (userName.value[0] || 'U').toUpperCase())
// Sidebar collapsed state with localStorage
const SIDEBAR_STORAGE_KEY = 'admin_sidebar_collapsed'
const sidebarCollapsed = ref(false)
onMounted(() => {
const saved = localStorage.getItem(SIDEBAR_STORAGE_KEY)
if (saved !== null) {
sidebarCollapsed.value = saved === 'true'
}
if (saved !== null) sidebarCollapsed.value = saved === 'true'
})
function toggleSidebar() {
@@ -210,11 +207,20 @@ async function logout() {
async function toggleLanguage() {
const newLang = locale.value === 'en' ? 'ru' : 'en'
if (userStore.id) {
const ok = await userStore.updateProfile({ language: newLang })
if (ok) {
locale.value = newLang
localStorage.setItem('locale', newLang)
} else {
// В случае ошибки всё равно меняем локаль, но не сохраняем в БД
locale.value = newLang
localStorage.setItem('locale', newLang)
}
} else {
// Для неавторизованных просто сохраняем в localStorage
locale.value = newLang
localStorage.setItem('locale', newLang)
}
}
</script>

View File

@@ -7,29 +7,163 @@
"settings": "Settings",
"profile": "Profile",
"logout": "Logout",
"language": "Language"
"language": "Language",
"search": "Search...",
"notifications": "Notifications",
"administrator": "Administrator",
"user": "User",
"yes": "Yes",
"no": "No",
"cancel": "Cancel",
"save": "Save",
"delete": "Delete",
"edit": "Edit",
"add": "Add",
"reset": "Reset",
"loading": "Loading..."
},
"user": {
"common": {
"id": "ID",
"name": "Name",
"email": "Email",
"password": "Password",
"login": "Login",
"username": "Username",
"role": "Role",
"status": "Status",
"ip": "IP",
"created": "Created",
"actions": "Actions",
"active": "Active",
"inactive": "Inactive",
"yes": "Yes",
"no": "No",
"passwordRequired": "Password is required",
"saveChanges": "Save Changes",
"confirmDelete": "Confirm Delete",
"leavePasswordBlank": "Leave blank to keep current password",
"deleteConfirmation": "Are you sure you want to delete this item? This action cannot be undone.",
"operationSuccess": "Operation completed successfully",
"operationFailed": "Operation failed"
},
"dashboard": {
"totalUsers": "Total Users",
"activeSessions": "Active Sessions",
"systemHealth": "System Health",
"uptime": "Uptime",
"vsLastMonth": "vs last month",
"fromLastHour": "from last hour",
"operational": "Operational",
"down": "Down",
"userActivity": "User Activity (Last 7 days)",
"week": "Week",
"month": "Month",
"systemServices": "System Services",
"recentUsers": "Recent Users",
"recentRestaurants": "Recent Restaurants",
"viewAll": "View all",
"noUsers": "No users yet",
"noRestaurants": "No restaurants yet",
"new": "New",
"today": "Today",
"yesterday": "Yesterday",
"daysAgo": "{count} days ago"
},
"users": {
"pageName": "Users Management",
"add": "Add User",
"edit": "Edit User"
"edit": "Edit User",
"delete": "Delete User",
"you": "(You)",
"cannotChangeOwnRole": "You cannot change your own role",
"confirmDelete": "Delete User",
"deleteConfirmation": "Are you sure you want to delete this user? This action cannot be undone."
},
"restaurants": {
"pageName": "Restaurants",
"add": "Add Restaurant",
"edit": "Edit Restaurant",
"delete": "Delete Restaurant",
"host": "Host",
"https": "HTTPS",
"useHttps": "Use HTTPS",
"confirmDelete": "Delete Restaurant",
"noRestaurants": "No restaurants found. Click \"Add Restaurant\" to create one.",
"deleteConfirmation": "Are you sure you want to delete this restaurant? This action cannot be undone."
},
"settings": {
"title": "Application Settings",
"save": "Save Changes",
"reset": "Reset",
"saved": "Settings saved successfully",
"saveFailed": "Failed to save settings",
"loadFailed": "Failed to load settings metadata",
"enabled": "Enabled"
},
"profile": {
"title": "My Profile",
"subtitle": "Manage your account settings",
"username": "Username",
"email": "Email Address",
"newPassword": "New Password",
"confirmPassword": "Confirm New Password",
"language": "Language",
"save": "Save Changes",
"reset": "Reset",
"role": "Role",
"passwordMismatch": "Passwords do not match",
"updateSuccess": "Profile updated successfully",
"updateFailed": "Failed to update profile"
},
"login": {
"title": "Welcome Back",
"subtitle": "Sign in to your account",
"username": "Username or Email",
"password": "Password",
"remember": "Remember me",
"signin": "Sign In",
"createAccount": "Create account"
"createAccount": "Create account",
"invalidCredentials": "Invalid username or password",
"networkError": "Network error. Please try again."
},
"profile": {
"title": "My Profile",
"register": {
"title": "Create Account",
"subtitle": "Register and wait for admin approval",
"username": "Username",
"email": "Email",
"password": "Password",
"newPassword": "New Password",
"language": "Language",
"save": "Save Changes",
"role": "Role"
"register": "Register",
"success": "Account created! Wait for admin activation.",
"failed": "Registration failed",
"alreadyHaveAccount": "Already have an account?",
"networkError": "Network error"
},
"setup": {
"title": "Setup Admin Account",
"subtitle": "Create your administrator account",
"step1": "Account Details",
"step2": "Complete",
"createAccount": "Create Account",
"passwordStrength": "Password strength",
"veryWeak": "Very Weak",
"weak": "Weak",
"fair": "Fair",
"good": "Good",
"strong": "Strong",
"validationUsernameMin": "Username must be at least 3 characters",
"validationEmailInvalid": "Please enter a valid email address",
"validationPasswordMin": "Password must be at least 6 characters",
"createFailed": "Failed to create account"
},
"notFound": {
"title": "Oops! Page not found",
"message": "The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.",
"goToDashboard": "Go to Dashboard",
"signIn": "Sign In"
},
"validation": {
"required": "This field is required",
"minLength": "Must be at least {min} characters",
"email": "Please enter a valid email address",
"passwordMismatch": "Passwords do not match"
}
}

View File

@@ -7,29 +7,163 @@
"settings": "Настройки",
"profile": "Профиль",
"logout": "Выйти",
"language": "Язык"
"language": "Язык",
"search": "Поиск...",
"notifications": "Уведомления",
"administrator": "Администратор",
"user": "Пользователь",
"yes": "Да",
"no": "Нет",
"cancel": "Отмена",
"save": "Сохранить",
"delete": "Удалить",
"edit": "Редактировать",
"add": "Добавить",
"reset": "Сбросить",
"loading": "Загрузка..."
},
"user": {
"common": {
"id": "ID",
"name": "Название",
"email": "Email",
"password": "Пароль",
"login": "Логин",
"username": "Имя пользователя",
"role": "Роль",
"status": "Статус",
"ip": "IP",
"created": "Создан",
"actions": "Действия",
"active": "Активен",
"inactive": "Неактивен",
"yes": "Да",
"no": "Нет",
"passwordRequired": "Пароль обязателен",
"saveChanges": "Сохранить изменения",
"confirmDelete": "Подтверждение удаления",
"leavePasswordBlank": "Оставьте пустым, чтобы оставить текущий пароль",
"deleteConfirmation": "Вы уверены, что хотите удалить этот элемент? Это действие необратимо.",
"operationSuccess": "Операция выполнена успешно",
"operationFailed": "Операция не удалась"
},
"dashboard": {
"totalUsers": "Всего пользователей",
"activeSessions": "Активных сессий",
"systemHealth": "Здоровье системы",
"uptime": "Время работы",
"vsLastMonth": "по сравнению с прошлым месяцем",
"fromLastHour": "за последний час",
"operational": "Работает",
"down": "Недоступен",
"userActivity": "Активность пользователей (последние 7 дней)",
"week": "Неделя",
"month": "Месяц",
"systemServices": "Системные сервисы",
"recentUsers": "Недавние пользователи",
"recentRestaurants": "Недавние рестораны",
"viewAll": "Все",
"noUsers": "Пока нет пользователей",
"noRestaurants": "Пока нет ресторанов",
"new": "Новый",
"today": "Сегодня",
"yesterday": "Вчера",
"daysAgo": "дн. назад"
},
"users": {
"pageName": "Управление пользователями",
"add": "Добавить пользователя",
"edit": "Редактировать пользователя"
"edit": "Редактировать пользователя",
"delete": "Удалить пользователя",
"you": "(Вы)",
"cannotChangeOwnRole": "Вы не можете изменить свою собственную роль",
"confirmDelete": "Удалить пользователя",
"deleteConfirmation": "Вы уверены, что хотите удалить этого пользователя? Это действие необратимо."
},
"restaurants": {
"pageName": "Рестораны",
"add": "Добавить ресторан",
"edit": "Редактировать ресторан",
"delete": "Удалить ресторан",
"host": "Хост",
"https": "HTTPS",
"useHttps": "Использовать HTTPS",
"confirmDelete": "Удалить ресторан",
"noRestaurants": "Ресторанов не найдено. Нажмите \"Добавить ресторан\", чтобы создать его.",
"deleteConfirmation": "Вы уверены, что хотите удалить этот ресторан? Это действие необратимо."
},
"settings": {
"title": "Настройки приложения",
"save": "Сохранить изменения",
"reset": "Сбросить",
"saved": "Настройки успешно сохранены",
"saveFailed": "Не удалось сохранить настройки",
"loadFailed": "Не удалось загрузить метаданные настроек",
"enabled": "Включено"
},
"profile": {
"title": "Мой профиль",
"subtitle": "Управление настройками аккаунта",
"username": "Имя пользователя",
"email": "Email",
"newPassword": "Новый пароль",
"confirmPassword": "Подтверждение нового пароля",
"language": "Язык",
"save": "Сохранить изменения",
"reset": "Сбросить",
"role": "Роль",
"passwordMismatch": "Пароли не совпадают",
"updateSuccess": "Профиль успешно обновлен",
"updateFailed": "Не удалось обновить профиль"
},
"login": {
"title": "С возвращением",
"subtitle": "Войдите в свой аккаунт",
"username": "Имя пользователя или Email",
"password": "Пароль",
"remember": "Запомнить меня",
"signin": "Войти",
"createAccount": "Создать аккаунт"
"createAccount": "Создать аккаунт",
"invalidCredentials": "Неверное имя пользователя или пароль",
"networkError": "Ошибка сети. Попробуйте еще раз."
},
"profile": {
"title": "Мой профиль",
"register": {
"title": "Создать аккаунт",
"subtitle": "Зарегистрируйтесь и ожидайте одобрения администратора",
"username": "Имя пользователя",
"email": "Email",
"password": "Пароль",
"newPassword": "Новый пароль",
"language": "Язык",
"save": "Сохранить",
"role": "Роль"
"register": "Зарегистрироваться",
"success": "Аккаунт создан! Ожидайте активации администратором.",
"failed": "Ошибка регистрации",
"alreadyHaveAccount": "Уже есть аккаунт?",
"networkError": "Ошибка сети"
},
"setup": {
"title": "Настройка учетной записи администратора",
"subtitle": "Создайте учетную запись администратора",
"step1": "Данные аккаунта",
"step2": "Завершение",
"createAccount": "Создать аккаунт",
"passwordStrength": "Сложность пароля",
"veryWeak": "Очень слабый",
"weak": "Слабый",
"fair": "Средний",
"good": "Хороший",
"strong": "Сильный",
"validationUsernameMin": "Имя пользователя должно содержать не менее 3 символов",
"validationEmailInvalid": "Введите корректный email адрес",
"validationPasswordMin": "Пароль должен содержать не менее 6 символов",
"createFailed": "Не удалось создать аккаунт"
},
"notFound": {
"title": "Упс! Страница не найдена",
"message": "Возможно, страница была удалена, переименована или временно недоступна.",
"goToDashboard": "На главную",
"signIn": "Войти"
},
"validation": {
"required": "Это поле обязательно",
"minLength": "Должно быть не менее {min} символов",
"email": "Введите корректный email адрес",
"passwordMismatch": "Пароли не совпадают"
}
}

View File

@@ -1,3 +1,4 @@
// src/main.ts
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
@@ -9,9 +10,19 @@ import { createI18n } from 'vue-i18n'
import en from './locales/en.json'
import ru from './locales/ru.json'
// Функция определения языка браузера
function getBrowserLocale(): string {
const browserLang = navigator.language.split('-')[0]
return browserLang === 'ru' ? 'ru' : 'en'
}
// Получаем сохраненный язык из localStorage (для неавторизованных)
const storedLocale = localStorage.getItem('locale')
const initialLocale = storedLocale || getBrowserLocale()
const i18n = createI18n({
legacy: false,
locale: 'en',
locale: initialLocale,
fallbackLocale: 'en',
messages: { en, ru }
})
@@ -30,9 +41,14 @@ Promise.all([
settingsStore.loadSettings(),
userStore.fetchProfile().catch(() => {})
]).then(() => {
// Устанавливаем язык из профиля, если есть
if (userStore.language) {
// Если пользователь авторизован используем язык из профиля
if (userStore.id && userStore.language) {
i18n.global.locale.value = userStore.language
// Сохраняем в localStorage для синхронизации (опционально)
localStorage.setItem('locale', userStore.language)
} else {
// Для неавторизованных сохраняем текущий язык в localStorage
localStorage.setItem('locale', i18n.global.locale.value)
}
app.mount('#app')
})

View File

@@ -1,7 +1,7 @@
<template>
<AppLayout>
<div class="card">
<h1 class="text-2xl font-bold mb-6">Application Settings</h1>
<h1 class="text-2xl font-bold mb-6">{{ t('settings.title') }}</h1>
<form @submit.prevent="saveSettings" class="space-y-6 max-w-2xl">
<div v-for="field in meta" :key="field.key" class="border-b border-gray-200 pb-4">
<label class="block text-sm font-medium text-gray-700 mb-1">
@@ -54,8 +54,8 @@
</div>
<div class="flex justify-end space-x-3 pt-4">
<button type="button" @click="loadData" class="btn-secondary">Reset</button>
<button type="submit" class="btn-primary">Save Changes</button>
<button type="button" @click="loadData" class="btn-secondary">{{ t('settings.reset') }}</button>
<button type="submit" class="btn-primary">{{ t('settings.save') }}</button>
</div>
</form>
@@ -69,7 +69,9 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import AppLayout from '../components/Layout/AppLayout.vue';
import { useI18n } from 'vue-i18n'
const { t, locale } = useI18n()
interface FieldMeta {
key: string;
label: string;

View File

@@ -5,7 +5,7 @@
<div class="card hover:shadow-md transition-shadow">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-gray-600">Total Users</p>
<p class="text-sm font-medium text-gray-600">{{ t('dashboard.totalUsers') }}</p>
<p class="text-3xl font-bold text-gray-900 mt-2">{{ stats.totalUsers }}</p>
</div>
<div class="w-12 h-12 bg-primary-100 rounded-xl flex items-center justify-center">
@@ -16,14 +16,14 @@
</div>
<div class="mt-4 flex items-center text-sm">
<span class="text-green-600 font-medium"> {{ userGrowth }}%</span>
<span class="text-gray-500 ml-2">vs last month</span>
<span class="text-gray-500 ml-2">{{ t('dashboard.vsLastMonth') }}</span>
</div>
</div>
<div class="card hover:shadow-md transition-shadow">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-gray-600">Active Sessions</p>
<p class="text-sm font-medium text-gray-600">{{ t('dashboard.activeSessions') }}</p>
<p class="text-3xl font-bold text-gray-900 mt-2">{{ stats.activeSessions }}</p>
</div>
<div class="w-12 h-12 bg-green-100 rounded-xl flex items-center justify-center">
@@ -34,14 +34,14 @@
</div>
<div class="mt-4 flex items-center text-sm">
<span class="text-green-600 font-medium"> {{ sessionGrowth }}%</span>
<span class="text-gray-500 ml-2">from last hour</span>
<span class="text-gray-500 ml-2">{{ t('dashboard.fromLastHour') }}</span>
</div>
</div>
<div class="card hover:shadow-md transition-shadow">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-gray-600">System Health</p>
<p class="text-sm font-medium text-gray-600">{{ t('dashboard.systemHealth') }}</p>
<p class="text-3xl font-bold text-gray-900 mt-2">{{ stats.systemHealth }}%</p>
</div>
<div class="w-12 h-12 bg-blue-100 rounded-xl flex items-center justify-center">
@@ -63,7 +63,7 @@
<div class="card hover:shadow-md transition-shadow">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-gray-600">Uptime</p>
<p class="text-sm font-medium text-gray-600">{{ t('dashboard.uptime') }}</p>
<p class="text-3xl font-bold text-gray-900 mt-2">{{ stats.uptime }}</p>
</div>
<div class="w-12 h-12 bg-purple-100 rounded-xl flex items-center justify-center">
@@ -75,7 +75,7 @@
<div class="mt-4 flex items-center text-sm">
<div class="flex items-center text-green-600">
<div class="w-2 h-2 bg-green-600 rounded-full mr-2"></div>
Operational
{{ t('dashboard.operational') }}
</div>
</div>
</div>
@@ -86,10 +86,10 @@
<!-- User Activity Chart -->
<div class="card">
<div class="flex justify-between items-center mb-4">
<h3 class="text-lg font-semibold text-gray-900">User Activity (Last 7 days)</h3>
<h3 class="text-lg font-semibold text-gray-900">{{ t('dashboard.userActivity') }}</h3>
<div class="flex items-center space-x-2">
<button @click="activityPeriod = 'week'" class="text-xs px-2 py-1 rounded" :class="activityPeriod === 'week' ? 'bg-primary-100 text-primary-700' : 'text-gray-500'">Week</button>
<button @click="activityPeriod = 'month'" class="text-xs px-2 py-1 rounded" :class="activityPeriod === 'month' ? 'bg-primary-100 text-primary-700' : 'text-gray-500'">Month</button>
<button @click="activityPeriod = 'week'" class="text-xs px-2 py-1 rounded" :class="activityPeriod === 'week' ? 'bg-primary-100 text-primary-700' : 'text-gray-500'">{{ t('dashboard.week') }}</button>
<button @click="activityPeriod = 'month'" class="text-xs px-2 py-1 rounded" :class="activityPeriod === 'month' ? 'bg-primary-100 text-primary-700' : 'text-gray-500'">{{ t('dashboard.month') }}</button>
</div>
</div>
<div class="flex items-end space-x-2 h-48">
@@ -102,7 +102,7 @@
<!-- System Services Status -->
<div class="card">
<h3 class="text-lg font-semibold text-gray-900 mb-4">System Services</h3>
<h3 class="text-lg font-semibold text-gray-900 mb-4">{{ t('dashboard.systemServices') }}</h3>
<div class="space-y-4">
<div v-for="service in systemServices" :key="service.name" class="flex items-center justify-between p-3 bg-gray-50 rounded-lg">
<div class="flex items-center space-x-3">
@@ -112,7 +112,7 @@
<div class="flex items-center space-x-4">
<span class="text-sm text-gray-500">{{ service.latency }}ms</span>
<span class="text-xs px-2 py-1 rounded-full" :class="service.status === 'up' ? 'bg-green-100 text-green-700' : 'bg-red-100 text-red-700'">
{{ service.status === 'up' ? 'Operational' : 'Down' }}
{{ service.status === 'up' ? t('dashboard.operational') : t('dashboard.down') }}
</span>
</div>
</div>
@@ -124,8 +124,8 @@
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<div class="card">
<div class="flex justify-between items-center mb-4">
<h3 class="text-lg font-semibold text-gray-900">Recent Users</h3>
<router-link to="/users" class="text-sm text-primary-600 hover:text-primary-700">View all </router-link>
<h3 class="text-lg font-semibold text-gray-900">{{ t('dashboard.recentUsers') }}</h3>
<router-link to="/users" class="text-sm text-primary-600 hover:text-primary-700">{{ t('dashboard.viewAll') }} </router-link>
</div>
<div class="space-y-3">
<div v-for="user in recentUsers" :key="user.id" class="flex items-center justify-between p-3 hover:bg-gray-50 rounded-lg transition-colors">
@@ -138,16 +138,16 @@
<p class="text-sm text-gray-500">{{ formatDate(user.created) }}</p>
</div>
</div>
<span class="px-2 py-1 text-xs font-medium bg-green-100 text-green-700 rounded-full">New</span>
<span class="px-2 py-1 text-xs font-medium bg-green-100 text-green-700 rounded-full">{{ t('dashboard.new') }}</span>
</div>
<div v-if="recentUsers.length === 0" class="text-center text-gray-500 py-8">No users yet</div>
<div v-if="recentUsers.length === 0" class="text-center text-gray-500 py-8">{{ t('dashboard.noUsers') }}</div>
</div>
</div>
<div class="card">
<div class="flex justify-between items-center mb-4">
<h3 class="text-lg font-semibold text-gray-900">Recent Restaurants</h3>
<router-link to="/restaurants" class="text-sm text-primary-600 hover:text-primary-700">View all </router-link>
<h3 class="text-lg font-semibold text-gray-900">{{ t('dashboard.recentRestaurants') }}</h3>
<router-link to="/restaurants" class="text-sm text-primary-600 hover:text-primary-700">{{ t('dashboard.viewAll') }} </router-link>
</div>
<div class="space-y-3">
<div v-for="rest in recentRestaurants" :key="rest.id" class="flex items-center justify-between p-3 hover:bg-gray-50 rounded-lg transition-colors">
@@ -166,7 +166,7 @@
<span class="text-xs text-gray-500">{{ formatDate(rest.created) }}</span>
</div>
</div>
<div v-if="recentRestaurants.length === 0" class="text-center text-gray-500 py-8">No restaurants yet</div>
<div v-if="recentRestaurants.length === 0" class="text-center text-gray-500 py-8">{{ t('dashboard.noRestaurants') }}</div>
</div>
</div>
</div>
@@ -176,6 +176,8 @@
<script setup lang="ts">
import { ref, onMounted, onUnmounted } from 'vue';
import AppLayout from '../components/Layout/AppLayout.vue';
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
const stats = ref({ totalUsers: 0, activeSessions: 0, systemHealth: 100, uptime: '99.9%' });
const userGrowth = ref(12);
@@ -229,9 +231,9 @@ function formatDate(dateStr: string) {
const date = new Date(dateStr);
const now = new Date();
const diffDays = Math.floor((now.getTime() - date.getTime()) / (1000 * 60 * 60 * 24));
if (diffDays === 0) return 'Today';
if (diffDays === 1) return 'Yesterday';
if (diffDays < 7) return `${diffDays} days ago`;
if (diffDays === 0) return t('dashboard.today');
if (diffDays === 1) return t('dashboard.yesterday');
if (diffDays < 7) return `${diffDays} ${t('dashboard.daysAgo')}`;
return date.toLocaleDateString();
}

View File

@@ -9,20 +9,20 @@
</div>
</div>
<h1 class="text-6xl font-bold text-gray-900 mb-4">404</h1>
<p class="text-xl text-gray-600 mb-8">Oops! Page not found</p>
<p class="text-gray-500 mb-8">The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.</p>
<p class="text-xl text-gray-600 mb-8">{{ t('notFound.title') }}</p>
<p class="text-gray-500 mb-8">{{ t('notFound.message') }}</p>
<div class="flex flex-col sm:flex-row gap-4 justify-center">
<router-link
to="/dashboard"
class="px-6 py-3 bg-primary-600 text-white rounded-lg hover:bg-primary-700 transition-colors"
>
Go to Dashboard
{{ t('notFound.goToDashboard') }}
</router-link>
<router-link
to="/login"
class="px-6 py-3 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 transition-colors"
>
Sign In
{{ t('notFound.signIn') }}
</router-link>
</div>
</div>
@@ -30,5 +30,7 @@
</template>
<script setup lang="ts">
// No additional logic needed
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
</script>

View File

@@ -7,29 +7,29 @@
<div class="w-20 h-20 bg-gradient-to-br from-primary-500 to-primary-700 rounded-full flex items-center justify-center text-white text-2xl font-bold">
{{ userInitials }}
</div>
<button class="absolute bottom-0 right-0 p-1 bg-white rounded-full shadow-md hover:shadow-lg transition-shadow">
<!-- <button class="absolute bottom-0 right-0 p-1 bg-white rounded-full shadow-md hover:shadow-lg transition-shadow">
<svg class="w-4 h-4 text-gray-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 9a2 2 0 012-2h.93a2 2 0 001.664-.89l.812-1.22A2 2 0 0110.07 4h3.86a2 2 0 011.664.89l.812 1.22A2 2 0 0018.07 7H19a2 2 0 012 2v9a2 2 0 01-2 2H5a2 2 0 01-2-2V9z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 13a3 3 0 11-6 0 3 3 0 016 0z" />
</svg>
</button>
</button> -->
</div>
<div>
<h1 class="text-2xl font-bold text-gray-900">My Profile</h1>
<p class="text-gray-500">Manage your account settings</p>
<h1 class="text-2xl font-bold text-gray-900">{{ t('profile.title') }}</h1>
<p class="text-gray-500">{{ t('profile.subtitle') }}</p>
</div>
</div>
<form @submit.prevent="saveProfile" class="space-y-6">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Username</label>
<label class="block text-sm font-medium text-gray-700 mb-1">{{ t('common.username') }}</label>
<input v-model="userStore.login" type="text" disabled class="input-field bg-gray-100" />
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Role</label>
<label class="block text-sm font-medium text-gray-700 mb-1">{{ t('common.role') }}</label>
<div class="relative">
<input :value="userStore.role === 'admin' ? 'Administrator' : 'User'" type="text" disabled class="input-field bg-gray-100" />
<input :value="userStore.role === 'admin' ? t('app.administrator') : t('app.user')" type="text" disabled class="input-field bg-gray-100" />
<div class="absolute right-3 top-2.5">
<span class="px-2 py-0.5 text-xs rounded-full" :class="userStore.role === 'admin' ? 'bg-purple-100 text-purple-700' : 'bg-gray-100 text-gray-600'">
{{ userStore.role === 'admin' ? 'Admin' : 'User' }}
@@ -40,24 +40,24 @@
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Email Address</label>
<label class="block text-sm font-medium text-gray-700 mb-1">{{ t('common.email') }}</label>
<input v-model="form.email" type="email" required class="input-field" />
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">New Password</label>
<label class="block text-sm font-medium text-gray-700 mb-1">{{ t('profile.newPassword') }}</label>
<input v-model="form.password" type="password" class="input-field" autocomplete="new-password" />
<p class="text-xs text-gray-500 mt-1">Leave blank to keep current password</p>
<p class="text-xs text-gray-500 mt-1">{{ t('common.leavePasswordBlank') }}</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Confirm New Password</label>
<label class="block text-sm font-medium text-gray-700 mb-1">{{ t('profile.confirmPassword') }}</label>
<input v-model="form.confirmPassword" type="password" class="input-field" :class="{ 'border-red-300': passwordMismatch }" />
<p v-if="passwordMismatch" class="text-xs text-red-600 mt-1">Passwords do not match</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Language</label>
<label class="block text-sm font-medium text-gray-700 mb-1">{{ t('app.language') }}</label>
<select v-model="form.language" class="input-field">
<option value="en">English</option>
<option value="ru">Русский</option>
@@ -66,13 +66,13 @@
<div class="pt-4 border-t">
<div class="flex justify-end space-x-3">
<button type="button" @click="resetForm" class="btn-secondary">Reset</button>
<button type="button" @click="resetForm" class="btn-secondary">{{ t('settings.reset') }}</button>
<button type="submit" :disabled="loading" class="btn-primary flex items-center gap-2">
<svg v-if="loading" class="animate-spin h-4 w-4 text-white" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
Save Changes
{{ t('settings.save') }}
</button>
</div>
</div>
@@ -102,7 +102,7 @@ import { useI18n } from 'vue-i18n';
import AppLayout from '../components/Layout/AppLayout.vue';
const userStore = useUserStore();
const { locale } = useI18n();
const { t, locale } = useI18n();
const form = reactive({
email: '',

View File

@@ -1,12 +1,12 @@
<template>
<AppLayout>
<div class="flex justify-between items-center mb-6">
<h1 class="text-2xl font-bold text-gray-900">Restaurants</h1>
<h1 class="text-2xl font-bold text-gray-900">{{ t('restaurants.pageName') }}</h1>
<button @click="openModal('create')" class="btn-primary flex items-center gap-2">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
</svg>
Add Restaurant
{{ t('restaurants.add') }}
</button>
</div>
@@ -15,13 +15,13 @@
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Host</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">HTTPS</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Login</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Created</th>
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.id') }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.name') }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('restaurants.host') }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('restaurants.https') }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.login') }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.created') }}</th>
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.actions') }}</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200 bg-white">
@@ -57,7 +57,7 @@
</td>
</tr>
<tr v-if="restaurants.length === 0">
<td colspan="7" class="px-6 py-12 text-center text-gray-500">No restaurants found. Click "Add Restaurant" to create one.</td>
<td colspan="7" class="px-6 py-12 text-center text-gray-500">{{ t('restaurants.noRestaurants') }}</td>
</tr>
</tbody>
</table>
@@ -80,23 +80,23 @@
</div>
<form @submit.prevent="submitRestaurant" class="p-6 space-y-5">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Name *</label>
<label class="block text-sm font-medium text-gray-700 mb-1">{{ t('common.name') }} *</label>
<input v-model="form.name" type="text" required class="input-field" />
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Host *</label>
<label class="block text-sm font-medium text-gray-700 mb-1">{{ t('restaurants.host') }} *</label>
<input v-model="form.host" type="text" required class="input-field" placeholder="e.g., api.example.com" />
</div>
<div class="flex items-center">
<input type="checkbox" v-model="form.https" class="rounded border-gray-300 text-primary-600 focus:ring-primary-500 w-4 h-4 mr-2" />
<label class="text-sm font-medium text-gray-700">Use HTTPS</label>
<label class="text-sm font-medium text-gray-700">{{ t('restaurants.useHttps') }}</label>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Login *</label>
<label class="block text-sm font-medium text-gray-700 mb-1">{{ t('common.login') }} *</label>
<input v-model="form.login" type="text" required class="input-field" />
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Password</label>
<label class="block text-sm font-medium text-gray-700 mb-1">{{ t('common.password') }}</label>
<input
v-model="form.password"
:required="modalMode === 'create'"
@@ -104,11 +104,11 @@
class="input-field"
autocomplete="new-password"
/>
<p v-if="modalMode === 'edit'" class="text-xs text-gray-500 mt-1">Leave blank to keep current password</p>
<p v-if="modalMode === 'edit'" class="text-xs text-gray-500 mt-1">{{ t('common.leavePasswordBlank') }}</p>
</div>
<div class="flex justify-end space-x-3 pt-2">
<button type="button" @click="closeModal" class="btn-secondary">Cancel</button>
<button type="submit" class="btn-primary">Save</button>
<button type="button" @click="closeModal" class="btn-secondary">{{ t('app.cancel') }}</button>
<button type="submit" class="btn-primary">{{ t('app.save') }}</button>
</div>
</form>
</div>
@@ -128,11 +128,11 @@
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
</svg>
</div>
<h3 class="text-lg font-medium text-gray-900 mb-2">Delete Restaurant</h3>
<p class="text-sm text-gray-500 mb-6">Are you sure you want to delete this restaurant? This action cannot be undone.</p>
<h3 class="text-lg font-medium text-gray-900 mb-2">{{ t('restaurants.delete') }}</h3>
<p class="text-sm text-gray-500 mb-6">{{ t('restaurants.deleteConfirmation') }}</p>
<div class="flex justify-center space-x-3">
<button @click="deleteConfirm.show = false" class="btn-secondary">Cancel</button>
<button @click="deleteRestaurant(deleteConfirm.id)" class="bg-red-600 text-white px-4 py-2 rounded-lg hover:bg-red-700 transition-colors">Delete</button>
<button @click="deleteConfirm.show = false" class="btn-secondary">{{ t('app.cancel') }}</button>
<button @click="deleteUser(deleteConfirm.id)" class="bg-red-600 text-white px-4 py-2 rounded-lg hover:bg-red-700 transition-colors">{{ t('app.delete') }}</button>
</div>
</div>
</div>
@@ -145,7 +145,9 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import AppLayout from '../components/Layout/AppLayout.vue';
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
const restaurants = ref([]);
const modalOpen = ref(false);
const modalMode = ref<'create' | 'edit'>('create');
@@ -167,7 +169,7 @@ function openModal(mode: 'create' | 'edit', rest: any = null) {
modalMode.value = mode;
if (mode === 'create') {
form.value = { id: null, name: '', login: '', password: '', host: '', https: false };
modalTitle.value = 'Create Restaurant';
modalTitle.value = t('restaurants.add');
} else {
form.value = {
id: rest.id,
@@ -177,7 +179,7 @@ function openModal(mode: 'create' | 'edit', rest: any = null) {
host: rest.host,
https: rest.https || false
};
modalTitle.value = 'Edit Restaurant';
modalTitle.value = t('restaurants.edit');
}
modalOpen.value = true;
}

View File

@@ -1,12 +1,12 @@
<template>
<AppLayout>
<div class="flex justify-between items-center mb-6">
<h1 class="text-2xl font-bold text-gray-900">{{ t('user.pageName') }}</h1>
<h1 class="text-2xl font-bold text-gray-900">{{ t('users.pageName') }}</h1>
<button @click="openModal('create')" class="btn-primary flex items-center gap-2">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
</svg>
{{ t('user.add') }}
{{ t('users.add') }}
</button>
</div>
@@ -15,14 +15,14 @@
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Login</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Email</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Role</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">IP</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Created</th>
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.id') }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.login') }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.email') }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.role') }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.status') }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.ip') }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.created') }}</th>
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">{{ t('common.actions') }}</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200 bg-white">
@@ -32,11 +32,11 @@
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ user.email }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm">
<span class="px-2 py-1 text-xs rounded-full" :class="user.role === 'admin' ? 'bg-purple-100 text-purple-700' : 'bg-gray-100 text-gray-600'">
{{ user.role === 'admin' ? 'Administrator' : 'User' }}
{{ user.role === 'admin' ? t('app.administrator') : t('app.user') }}
</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm">
<div v-if="user.id === currentUserId" class="text-xs text-gray-500">(You)</div>
<div v-if="user.id === currentUserId" class="text-xs text-gray-500">{{ t('users.you') }}</div>
<label v-else class="relative inline-flex items-center cursor-pointer">
<input
type="checkbox"
@@ -93,23 +93,23 @@
</div>
<form @submit.prevent="submitUser" class="p-6 space-y-5">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Email *</label>
<label class="block text-sm font-medium text-gray-700 mb-1">{{ t('common.email') }} *</label>
<input v-model="form.email" type="email" required class="input-field" />
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Login *</label>
<label class="block text-sm font-medium text-gray-700 mb-1">{{ t('common.login') }} *</label>
<input v-model="form.login" type="text" required class="input-field" />
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Role</label>
<label class="block text-sm font-medium text-gray-700 mb-1">{{ t('common.role') }}</label>
<select v-model="form.role" class="input-field" :disabled="isEditingSelf">
<option value="user">User</option>
<option value="admin">Administrator</option>
<option value="user">{{ t('app.user') }}</option>
<option value="admin">{{ t('app.administrator') }}</option>
</select>
<p v-if="isEditingSelf" class="text-xs text-amber-600 mt-1">You cannot change your own role</p>
<p v-if="isEditingSelf" class="text-xs text-amber-600 mt-1">{{ t('users.cannotChangeOwnRole') }}</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Password</label>
<label class="block text-sm font-medium text-gray-700 mb-1">{{ t('common.password') }}</label>
<input
v-model="form.password"
:required="modalMode === 'create'"
@@ -117,11 +117,11 @@
class="input-field"
autocomplete="new-password"
/>
<p v-if="modalMode === 'edit'" class="text-xs text-gray-500 mt-1">Leave blank to keep current password</p>
<p v-if="modalMode === 'edit'" class="text-xs text-gray-500 mt-1">{{ t('common.leavePasswordBlank') }}</p>
</div>
<div class="flex justify-end space-x-3 pt-2">
<button type="button" @click="closeModal" class="btn-secondary">Cancel</button>
<button type="submit" class="btn-primary">Save</button>
<button type="button" @click="closeModal" class="btn-secondary">{{ t('app.cancel') }}</button>
<button type="submit" class="btn-primary">{{ t('app.save') }}</button>
</div>
</form>
</div>
@@ -141,11 +141,11 @@
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
</svg>
</div>
<h3 class="text-lg font-medium text-gray-900 mb-2">Delete User</h3>
<p class="text-sm text-gray-500 mb-6">Are you sure you want to delete this user? This action cannot be undone.</p>
<h3 class="text-lg font-medium text-gray-900 mb-2">{{ t('users.delete') }}</h3>
<p class="text-sm text-gray-500 mb-6">{{ t('users.deleteConfirmation') }}</p>
<div class="flex justify-center space-x-3">
<button @click="deleteConfirm.show = false" class="btn-secondary">Cancel</button>
<button @click="deleteUser(deleteConfirm.id)" class="bg-red-600 text-white px-4 py-2 rounded-lg hover:bg-red-700 transition-colors">Delete</button>
<button @click="deleteConfirm.show = false" class="btn-secondary">{{ t('app.cancel') }}</button>
<button @click="deleteUser(deleteConfirm.id)" class="bg-red-600 text-white px-4 py-2 rounded-lg hover:bg-red-700 transition-colors">{{ t('app.delete') }}</button>
</div>
</div>
</div>
@@ -208,10 +208,10 @@ function openModal(mode: 'create' | 'edit', user: any = null) {
modalMode.value = mode;
if (mode === 'create') {
form.value = { id: null, login: '', email: '', password: '', role: 'user' };
modalTitle.value = t('user.add');
modalTitle.value = t('users.add');
} else {
form.value = { id: user.id, login: user.login, email: user.email, password: '', role: user.role || 'user' };
modalTitle.value = t('user.edit');
modalTitle.value = t('users.edit');
}
modalOpen.value = true;
}

View File

@@ -8,15 +8,15 @@
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
</svg>
</div>
<h1 class="text-3xl font-bold text-gray-900">Welcome Back</h1>
<p class="text-gray-600 mt-2">Sign in to your account</p>
<h1 class="text-3xl font-bold text-gray-900">{{ t('login.title') }}</h1>
<p class="text-gray-600 mt-2">{{ t('login.subtitle') }}</p>
</div>
<!-- Login Form -->
<div class="bg-white rounded-2xl shadow-xl p-8">
<form @submit.prevent="handleLogin" class="space-y-6">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Username or Email</label>
<label class="block text-sm font-medium text-gray-700 mb-2">{{ t('login.username') }}</label>
<div class="relative">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
@@ -34,7 +34,7 @@
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Password</label>
<label class="block text-sm font-medium text-gray-700 mb-2">{{ t('common.password') }}</label>
<div class="relative">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
@@ -65,14 +65,14 @@
<div class="flex items-center justify-between">
<label class="flex items-center">
<input type="checkbox" class="rounded border-gray-300 text-primary-600 focus:ring-primary-500" />
<span class="ml-2 text-sm text-gray-600">Remember me</span>
<span class="ml-2 text-sm text-gray-600">{{ t('login.remember') }}</span>
</label>
<router-link
v-if="settings.enableRegistration"
to="/register"
class="text-sm text-primary-600 hover:text-primary-700"
>
Create account
{{ t('login.createAccount') }}
</router-link>
</div>
@@ -81,7 +81,7 @@
:disabled="loading"
class="w-full btn-primary py-3 relative"
>
<span v-if="!loading">Sign In</span>
<span v-if="!loading">{{ t('login.signin') }}</span>
<svg v-else class="animate-spin h-5 w-5 mx-auto text-white" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
@@ -105,10 +105,12 @@ import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { useSettingsStore } from '../../stores/settings'
import { useUserStore } from '../../stores/user'
import { useI18n } from 'vue-i18n'
const settings = useSettingsStore()
const userStore = useUserStore()
const router = useRouter()
const { t, locale } = useI18n()
const form = ref({ login: '', password: '' })
const loading = ref(false)
const error = ref('')
@@ -124,15 +126,19 @@ async function handleLogin() {
body: JSON.stringify(form.value)
})
if (res.ok) {
// Загружаем профиль (роль, язык, email)
await userStore.fetchProfile()
// Устанавливаем язык интерфейса из профиля
if (userStore.language) {
locale.value = userStore.language
localStorage.setItem('locale', userStore.language)
}
router.push('/dashboard')
} else {
const text = await res.text()
error.value = text || 'Invalid username or password'
error.value = text || t('login.invalidCredentials')
}
} catch (e) {
error.value = 'Network error. Please try again.'
error.value = t('login.networkError')
} finally {
loading.value = false
}

View File

@@ -7,32 +7,32 @@
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18 9v3m0 0v3m0-3h3m-3 0h-3m-2-5a4 4 0 11-8 0 4 4 0 018 0zM3 20a6 6 0 0112 0v1H3v-1z" />
</svg>
</div>
<h1 class="text-3xl font-bold text-gray-900">Create Account</h1>
<p class="text-gray-600 mt-2">Register and wait for admin approval</p>
<h1 class="text-3xl font-bold text-gray-900">{{ t('register.title') }}</h1>
<p class="text-gray-600 mt-2">{{ t('register.subtitle') }}</p>
</div>
<div class="bg-white rounded-2xl shadow-xl p-8">
<form @submit.prevent="handleRegister" class="space-y-6">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Username</label>
<label class="block text-sm font-medium text-gray-700 mb-2">{{ t('register.username') }}</label>
<input v-model="form.login" type="text" required minlength="3" class="input-field" />
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Email</label>
<label class="block text-sm font-medium text-gray-700 mb-2">{{ t('common.email') }}</label>
<input v-model="form.email" type="email" required class="input-field" />
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Password</label>
<label class="block text-sm font-medium text-gray-700 mb-2">{{ t('common.password') }}</label>
<input v-model="form.password" type="password" required minlength="6" class="input-field" />
</div>
<button type="submit" :disabled="loading" class="w-full btn-primary py-3">
<span v-if="!loading">Register</span>
<span v-if="!loading">{{ t('register.register') }}</span>
<span v-else>Loading...</span>
</button>
</form>
<p v-if="success" class="mt-4 text-green-600 text-center">Account created! Wait for admin activation.</p>
<p v-if="success" class="mt-4 text-green-600 text-center">{{ t('register.success') }}</p>
<p v-if="error" class="mt-4 text-red-600 text-center">{{ error }}</p>
<p class="mt-4 text-center text-sm text-gray-600">
Already have an account? <router-link to="/login" class="text-primary-600">Login</router-link>
{{ t('register.alreadyHaveAccount') }} <router-link to="/login" class="text-primary-600">{{ t('login.signin') }}</router-link>
</p>
</div>
</div>
@@ -41,6 +41,8 @@
<script setup lang="ts">
import { ref } from 'vue'
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
const form = ref({ login: '', email: '', password: '' })
const loading = ref(false)
const error = ref('')

View File

@@ -8,8 +8,8 @@
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
</svg>
</div>
<h1 class="text-3xl font-bold text-gray-900">Setup Admin Account</h1>
<p class="text-gray-600 mt-2">Create your administrator account</p>
<h1 class="text-3xl font-bold text-gray-900">{{ t('setup.title') }}</h1>
<p class="text-gray-600 mt-2">{{ t('setup.subtitle') }}</p>
</div>
<!-- Setup Form -->
@@ -19,19 +19,19 @@
<div class="flex items-center justify-center">
<div class="flex items-center">
<div class="w-8 h-8 bg-primary-600 rounded-full flex items-center justify-center text-white font-semibold">1</div>
<div class="ml-2 text-sm font-medium text-gray-900">Account Details</div>
<div class="ml-2 text-sm font-medium text-gray-900">{{ t('setup.step1') }}</div>
</div>
<div class="mx-4 w-12 h-0.5 bg-gray-300"></div>
<div class="flex items-center">
<div class="w-8 h-8 bg-gray-300 rounded-full flex items-center justify-center text-gray-600 font-semibold">2</div>
<div class="ml-2 text-sm font-medium text-gray-500">Complete</div>
<div class="ml-2 text-sm font-medium text-gray-500">{{ t('setup.step2') }}</div>
</div>
</div>
</div>
<form @submit.prevent="handleSetup" class="space-y-6">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Username</label>
<label class="block text-sm font-medium text-gray-700 mb-2">{{ t('common.username') }}</label>
<div class="relative">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
@@ -52,7 +52,7 @@
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Email</label>
<label class="block text-sm font-medium text-gray-700 mb-2">{{ t('common.email') }}</label>
<div class="relative">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
@@ -72,7 +72,7 @@
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Password</label>
<label class="block text-sm font-medium text-gray-700 mb-2">{{ t('common.password') }}</label>
<div class="relative">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
@@ -105,7 +105,7 @@
<!-- Password Strength -->
<div v-if="form.password" class="mt-2">
<div class="flex items-center justify-between mb-1">
<span class="text-xs text-gray-600">Password strength</span>
<span class="text-xs text-gray-600">{{ t('setup.passwordStrength') }}</span>
<span class="text-xs font-medium" :class="strengthColor">{{ strengthText }}</span>
</div>
<div class="h-1.5 bg-gray-200 rounded-full overflow-hidden">
@@ -123,7 +123,7 @@
:disabled="loading"
class="w-full btn-primary py-3 relative overflow-hidden group"
>
<span v-if="!loading" class="relative z-10">Create Account</span>
<span v-if="!loading" class="relative z-10">{{ t('setup.createAccount') }}</span>
<svg v-else class="animate-spin h-5 w-5 mx-auto text-white" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
@@ -151,7 +151,8 @@
<script setup lang="ts">
import { ref, computed, watch } from 'vue'
import { useRouter } from 'vue-router'
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
const router = useRouter()
const form = ref({ login: '', email: '', password: '' });
const loading = ref(false)
@@ -186,8 +187,9 @@ const passwordStrength = computed(() => {
const strengthPercent = computed(() => (passwordStrength.value / 5) * 100)
const strengthText = computed(() => {
const texts = ['Very Weak', 'Weak', 'Fair', 'Good', 'Strong']
return texts[passwordStrength.value - 1] || ''
const keys = ['setup.veryWeak', 'setup.weak', 'setup.fair', 'setup.good', 'setup.strong']
const key = keys[passwordStrength.value - 1]
return key ? t(key) : ''
})
const strengthColor = computed(() => {

View File

@@ -9,9 +9,7 @@ import io.vertx.sqlclient.Tuple;
import io.vertx.sqlclient.templates.SqlTemplate;
import org.mindrot.jbcrypt.BCrypt;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
public class UserService {
private final Pool pool;
@@ -159,16 +157,30 @@ public class UserService {
public Future<Void> updateProfile(int userId, String email, String password, String language) {
Map<String, Object> params = new HashMap<>();
params.put("id", userId);
List<String> setClauses = new ArrayList<>();
if (email != null) {
setClauses.add("email = #{email}");
params.put("email", email);
if (language != null) params.put("language", language);
String sql;
}
if (password != null && !password.isEmpty()) {
String hash = BCrypt.hashpw(password, BCrypt.gensalt());
setClauses.add("password = #{password}");
params.put("password", hash);
sql = "UPDATE users SET email = #{email}, password = #{password}, language = COALESCE(#{language}, language) WHERE id = #{id}";
} else {
sql = "UPDATE users SET email = #{email}, language = COALESCE(#{language}, language) WHERE id = #{id}";
}
if (language != null) {
setClauses.add("language = #{language}");
params.put("language", language);
}
if (setClauses.isEmpty()) {
// Ни одно поле не обновляется — возвращаем успешный Future
return Future.succeededFuture();
}
String sql = "UPDATE users SET " + String.join(", ", setClauses) + " WHERE id = #{id}";
return SqlTemplate.forUpdate(pool, sql).execute(params).mapEmpty();
}