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

@@ -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(() => {