feat: Frontend gap closure — Schedules, Alerts, Migration, Changelog views
Implements missing frontend views and API integrations: New Views: - SchedulesView: CRUD for scheduled tasks (restart/announcement/command/plugin_reload) - MigrationView: Export/import interface with file upload and history tracking - ChangelogView: Paginated changelog feed with category badges - ForgotPasswordView: Password reset flow with email submission - AlertsView: Alert config dashboard with threshold settings and history Component Updates: - ErrorBoundary: Global error handler with retry functionality - DashboardLayout: Mobile responsive sidebar, permission-based nav, new menu items - ServerInfoView: Complete rewrite for public server info display Infrastructure: - useApi: Token refresh interceptor with 401 retry and infinite loop prevention - plugins store: Implemented all stubbed methods with real API calls - auth store: Added hasPermission() helper for RBAC UI visibility - Router: Added new routes with catch-all fallback Purpose: Closes frontend implementation gaps. Hardens auth flow, improves mobile UX, enables server automation scheduling, alert configuration, and data migration tools. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
29
CHANGELOG.md
29
CHANGELOG.md
@@ -4,6 +4,35 @@ All notable changes to this project will be documented in this file.
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added (Frontend Gap Closure — 2026-02-15)
|
||||||
|
|
||||||
|
**New Views:**
|
||||||
|
- `SchedulesView.vue` — Scheduled task management with CRUD operations for server automation (restart, announcement, command, plugin reload tasks)
|
||||||
|
- `MigrationView.vue` — Data export/import interface with export history and file upload for server migration
|
||||||
|
- `ChangelogView.vue` — Paginated platform changelog feed with category badges and version display
|
||||||
|
- `ForgotPasswordView.vue` — Password reset flow with email submission and success state
|
||||||
|
- `AlertsView.vue` — Alert configuration dashboard with threshold sliders, notification channel toggles, and alert history table
|
||||||
|
|
||||||
|
**Component Updates:**
|
||||||
|
- `ErrorBoundary.vue` — Global error handler component with retry functionality
|
||||||
|
- `DashboardLayout.vue` — Mobile responsive sidebar with hamburger menu, permission-based nav visibility, and new nav items (Schedules, Alerts, Changelog)
|
||||||
|
- `ServerInfoView.vue` — Complete rewrite for public server info page with header image, MOTD, wipe schedule, mods list, and Discord integration
|
||||||
|
|
||||||
|
**Store & API Integration:**
|
||||||
|
- `plugins.ts` — Implemented all stubbed methods with real API calls (fetchPlugins, installPlugin, uninstallPlugin, reloadPlugin, updatePluginConfig, searchPlugins)
|
||||||
|
- `useApi.ts` — Token refresh interceptor with automatic retry on 401, prevents infinite refresh loops
|
||||||
|
- `auth.ts` — Added `hasPermission()` helper with basic permission checking
|
||||||
|
|
||||||
|
**Router:**
|
||||||
|
- Added routes: `/schedules`, `/migration`, `/changelog`, `/alerts`, `/forgot-password`
|
||||||
|
- Added catch-all route redirecting to home
|
||||||
|
- All new routes under authenticated dashboard layout
|
||||||
|
|
||||||
|
**App Structure:**
|
||||||
|
- Wrapped root `<RouterView>` with `ErrorBoundary` for global error handling
|
||||||
|
|
||||||
|
**Purpose:** Closes frontend implementation gaps identified during Phase 4. Implements critical missing views (scheduled tasks, alerts, migration tools), hardens auth flow with token refresh, adds permission-based UI visibility, and improves mobile UX with responsive sidebar.
|
||||||
|
|
||||||
### Added (NestJS Backend — Core Modules)
|
### Added (NestJS Backend — Core Modules)
|
||||||
|
|
||||||
**Auth Module (`modules/auth/`):**
|
**Auth Module (`modules/auth/`):**
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { RouterView } from 'vue-router'
|
import { RouterView } from 'vue-router'
|
||||||
import ToastNotification from '@/components/ToastNotification.vue'
|
import ToastNotification from '@/components/ToastNotification.vue'
|
||||||
|
import ErrorBoundary from '@/components/ErrorBoundary.vue'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ToastNotification />
|
<ToastNotification />
|
||||||
|
<ErrorBoundary>
|
||||||
<RouterView />
|
<RouterView />
|
||||||
|
</ErrorBoundary>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
37
frontend/src/components/ErrorBoundary.vue
Normal file
37
frontend/src/components/ErrorBoundary.vue
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, onErrorCaptured } from 'vue'
|
||||||
|
import { AlertTriangle } from 'lucide-vue-next'
|
||||||
|
|
||||||
|
const hasError = ref(false)
|
||||||
|
const errorMessage = ref('')
|
||||||
|
|
||||||
|
onErrorCaptured((err) => {
|
||||||
|
hasError.value = true
|
||||||
|
errorMessage.value = err.message || 'An unexpected error occurred'
|
||||||
|
console.error('ErrorBoundary caught:', err)
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
|
||||||
|
function retry() {
|
||||||
|
hasError.value = false
|
||||||
|
errorMessage.value = ''
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div v-if="hasError" class="min-h-screen bg-neutral-950 flex items-center justify-center p-6">
|
||||||
|
<div class="bg-neutral-900 border border-neutral-800 rounded-lg p-8 max-w-md w-full text-center">
|
||||||
|
<AlertTriangle class="w-12 h-12 text-red-500 mx-auto mb-4" />
|
||||||
|
<h1 class="text-xl font-bold text-neutral-100 mb-2">Something went wrong</h1>
|
||||||
|
<p class="text-sm text-neutral-400 mb-6">{{ errorMessage }}</p>
|
||||||
|
<button
|
||||||
|
@click="retry"
|
||||||
|
class="px-4 py-2 bg-oxide-500 hover:bg-oxide-600 text-white font-medium rounded-lg transition-colors"
|
||||||
|
>
|
||||||
|
Retry
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<slot v-else />
|
||||||
|
</template>
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue'
|
||||||
import { RouterView, RouterLink, useRoute, useRouter } from 'vue-router'
|
import { RouterView, RouterLink, useRoute, useRouter } from 'vue-router'
|
||||||
import { useAuthStore } from '@/stores/auth'
|
import { useAuthStore } from '@/stores/auth'
|
||||||
import { useServerStore } from '@/stores/server'
|
import { useServerStore } from '@/stores/server'
|
||||||
@@ -22,28 +23,37 @@ import {
|
|||||||
Key,
|
Key,
|
||||||
CreditCard,
|
CreditCard,
|
||||||
Network,
|
Network,
|
||||||
|
Clock,
|
||||||
|
AlertTriangle,
|
||||||
|
FileText,
|
||||||
|
Menu,
|
||||||
|
X,
|
||||||
} from 'lucide-vue-next'
|
} from 'lucide-vue-next'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const auth = useAuthStore()
|
const auth = useAuthStore()
|
||||||
const server = useServerStore()
|
const server = useServerStore()
|
||||||
|
const sidebarOpen = ref(false)
|
||||||
|
|
||||||
const navItems = [
|
const navItems = [
|
||||||
{ name: 'Dashboard', path: '/', icon: LayoutDashboard },
|
{ name: 'Dashboard', path: '/', icon: LayoutDashboard, permission: null },
|
||||||
{ name: 'Server', path: '/server', icon: Server },
|
{ name: 'Server', path: '/server', icon: Server, permission: 'server.view' },
|
||||||
{ name: 'Console', path: '/console', icon: Terminal },
|
{ name: 'Console', path: '/console', icon: Terminal, permission: 'console.view' },
|
||||||
{ name: 'Players', path: '/players', icon: Users },
|
{ name: 'Players', path: '/players', icon: Users, permission: 'players.view' },
|
||||||
{ name: 'Plugins', path: '/plugins', icon: Puzzle },
|
{ name: 'Plugins', path: '/plugins', icon: Puzzle, permission: 'plugins.view' },
|
||||||
{ name: 'Auto-Wiper', path: '/wipes', icon: RefreshCw },
|
{ name: 'Auto-Wiper', path: '/wipes', icon: RefreshCw, permission: 'wipes.view' },
|
||||||
{ name: 'Maps', path: '/maps', icon: Map },
|
{ name: 'Maps', path: '/maps', icon: Map, permission: 'maps.view' },
|
||||||
{ name: 'Chat Log', path: '/chat', icon: MessageSquare },
|
{ name: 'Chat Log', path: '/chat', icon: MessageSquare, permission: 'chat.view' },
|
||||||
{ name: 'Analytics', path: '/analytics', icon: BarChart3 },
|
{ name: 'Analytics', path: '/analytics', icon: BarChart3, permission: 'analytics.view' },
|
||||||
{ name: 'Notifications', path: '/notifications', icon: Bell },
|
{ name: 'Schedules', path: '/schedules', icon: Clock, permission: 'schedules.view' },
|
||||||
{ name: 'Team', path: '/team', icon: UserPlus },
|
{ name: 'Alerts', path: '/alerts', icon: AlertTriangle, permission: 'alerts.view' },
|
||||||
{ name: 'Store', path: '/store/manage', icon: ShoppingBag },
|
{ name: 'Notifications', path: '/notifications', icon: Bell, permission: 'notifications.view' },
|
||||||
{ name: 'Modules', path: '/modules', icon: Package },
|
{ name: 'Team', path: '/team', icon: UserPlus, permission: null },
|
||||||
{ name: 'Settings', path: '/settings', icon: Settings },
|
{ name: 'Store', path: '/store/config', icon: ShoppingBag, permission: 'store.view' },
|
||||||
|
{ name: 'Modules', path: '/modules', icon: Package, permission: 'modules.view' },
|
||||||
|
{ name: 'Changelog', path: '/changelog', icon: FileText, permission: 'changelog.view' },
|
||||||
|
{ name: 'Settings', path: '/settings', icon: Settings, permission: 'settings.view' },
|
||||||
]
|
]
|
||||||
|
|
||||||
const adminNavItems = [
|
const adminNavItems = [
|
||||||
@@ -63,14 +73,42 @@ function handleLogout() {
|
|||||||
auth.logout()
|
auth.logout()
|
||||||
router.push('/login')
|
router.push('/login')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function closeSidebar() {
|
||||||
|
sidebarOpen.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function canShowNavItem(item: typeof navItems[0]): boolean {
|
||||||
|
if (!item.permission) return true
|
||||||
|
return auth.hasPermission(item.permission)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex h-screen bg-neutral-950">
|
<div class="flex h-screen bg-neutral-950">
|
||||||
|
<!-- Mobile Hamburger -->
|
||||||
|
<button
|
||||||
|
@click="sidebarOpen = true"
|
||||||
|
class="md:hidden fixed top-4 left-4 z-40 p-2 bg-neutral-900 border border-neutral-800 rounded-lg text-neutral-300 hover:text-oxide-400 transition-colors"
|
||||||
|
>
|
||||||
|
<Menu class="w-5 h-5" />
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- Sidebar Overlay (Mobile) -->
|
||||||
|
<div
|
||||||
|
v-if="sidebarOpen"
|
||||||
|
@click="closeSidebar"
|
||||||
|
class="md:hidden fixed inset-0 bg-black/50 z-40"
|
||||||
|
/>
|
||||||
|
|
||||||
<!-- Sidebar -->
|
<!-- Sidebar -->
|
||||||
<aside class="w-64 bg-neutral-900 border-r border-neutral-800 flex flex-col">
|
<aside
|
||||||
|
class="w-64 bg-neutral-900 border-r border-neutral-800 flex flex-col fixed md:static inset-y-0 left-0 z-50 transform transition-transform"
|
||||||
|
:class="sidebarOpen ? 'translate-x-0' : '-translate-x-full md:translate-x-0'"
|
||||||
|
>
|
||||||
<!-- Logo -->
|
<!-- Logo -->
|
||||||
<div class="p-4 border-b border-neutral-800">
|
<div class="p-4 border-b border-neutral-800">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center gap-3">
|
||||||
<img src="/logo.png" alt="Corrosion" class="h-8 w-8" />
|
<img src="/logo.png" alt="Corrosion" class="h-8 w-8" />
|
||||||
<div>
|
<div>
|
||||||
@@ -78,6 +116,13 @@ function handleLogout() {
|
|||||||
<p class="text-xs text-neutral-500">{{ auth.license?.server_name || 'Server Management' }}</p>
|
<p class="text-xs text-neutral-500">{{ auth.license?.server_name || 'Server Management' }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<button
|
||||||
|
@click="closeSidebar"
|
||||||
|
class="md:hidden text-neutral-400 hover:text-neutral-200 transition-colors"
|
||||||
|
>
|
||||||
|
<X class="w-5 h-5" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Server Status Indicator -->
|
<!-- Server Status Indicator -->
|
||||||
@@ -101,8 +146,10 @@ function handleLogout() {
|
|||||||
<nav class="flex-1 overflow-y-auto py-2">
|
<nav class="flex-1 overflow-y-auto py-2">
|
||||||
<RouterLink
|
<RouterLink
|
||||||
v-for="item in navItems"
|
v-for="item in navItems"
|
||||||
|
v-show="canShowNavItem(item)"
|
||||||
:key="item.path"
|
:key="item.path"
|
||||||
:to="item.path"
|
:to="item.path"
|
||||||
|
@click="closeSidebar"
|
||||||
class="flex items-center gap-3 px-4 py-2 mx-2 rounded-lg text-sm transition-colors"
|
class="flex items-center gap-3 px-4 py-2 mx-2 rounded-lg text-sm transition-colors"
|
||||||
:class="isActive(item.path)
|
:class="isActive(item.path)
|
||||||
? 'bg-oxide-500/10 text-oxide-400'
|
? 'bg-oxide-500/10 text-oxide-400'
|
||||||
@@ -125,6 +172,7 @@ function handleLogout() {
|
|||||||
v-for="item in adminNavItems"
|
v-for="item in adminNavItems"
|
||||||
:key="item.path"
|
:key="item.path"
|
||||||
:to="item.path"
|
:to="item.path"
|
||||||
|
@click="closeSidebar"
|
||||||
class="flex items-center gap-3 px-4 py-2 mx-2 rounded-lg text-sm transition-colors"
|
class="flex items-center gap-3 px-4 py-2 mx-2 rounded-lg text-sm transition-colors"
|
||||||
:class="isActive(item.path)
|
:class="isActive(item.path)
|
||||||
? 'bg-oxide-500/10 text-oxide-400'
|
? 'bg-oxide-500/10 text-oxide-400'
|
||||||
@@ -154,7 +202,7 @@ function handleLogout() {
|
|||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<!-- Main Content -->
|
<!-- Main Content -->
|
||||||
<main class="flex-1 overflow-y-auto">
|
<main class="flex-1 overflow-y-auto md:ml-0">
|
||||||
<RouterView />
|
<RouterView />
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ interface RequestOptions {
|
|||||||
headers?: Record<string, string>
|
headers?: Record<string, string>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let isRefreshing = false
|
||||||
|
let refreshPromise: Promise<void> | null = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Composable for making authenticated API requests.
|
* Composable for making authenticated API requests.
|
||||||
* Automatically attaches JWT token and handles token refresh.
|
* Automatically attaches JWT token and handles token refresh.
|
||||||
@@ -15,6 +18,43 @@ interface RequestOptions {
|
|||||||
export function useApi() {
|
export function useApi() {
|
||||||
const auth = useAuthStore()
|
const auth = useAuthStore()
|
||||||
|
|
||||||
|
async function attemptRefresh(): Promise<void> {
|
||||||
|
if (isRefreshing && refreshPromise) {
|
||||||
|
return refreshPromise
|
||||||
|
}
|
||||||
|
|
||||||
|
isRefreshing = true
|
||||||
|
refreshPromise = (async () => {
|
||||||
|
try {
|
||||||
|
const response = await fetch(`${API_BASE}/auth/refresh`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ refresh_token: auth.refreshToken }),
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Refresh failed')
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json()
|
||||||
|
auth.setAuth({
|
||||||
|
access_token: data.access_token,
|
||||||
|
refresh_token: data.refresh_token,
|
||||||
|
user: auth.user!,
|
||||||
|
})
|
||||||
|
} catch {
|
||||||
|
auth.logout()
|
||||||
|
window.location.href = '/login'
|
||||||
|
throw new Error('Session expired')
|
||||||
|
} finally {
|
||||||
|
isRefreshing = false
|
||||||
|
refreshPromise = null
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
|
||||||
|
return refreshPromise
|
||||||
|
}
|
||||||
|
|
||||||
async function request<T>(path: string, options: RequestOptions = {}): Promise<T> {
|
async function request<T>(path: string, options: RequestOptions = {}): Promise<T> {
|
||||||
const headers: Record<string, string> = {
|
const headers: Record<string, string> = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@@ -25,17 +65,22 @@ export function useApi() {
|
|||||||
headers['Authorization'] = `Bearer ${auth.accessToken}`
|
headers['Authorization'] = `Bearer ${auth.accessToken}`
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetch(`${API_BASE}${path}`, {
|
let response = await fetch(`${API_BASE}${path}`, {
|
||||||
method: options.method || 'GET',
|
method: options.method || 'GET',
|
||||||
headers,
|
headers,
|
||||||
body: options.body ? JSON.stringify(options.body) : undefined,
|
body: options.body ? JSON.stringify(options.body) : undefined,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (response.status === 401) {
|
if (response.status === 401 && auth.refreshToken) {
|
||||||
// TODO: Attempt token refresh, retry, or redirect to login
|
await attemptRefresh()
|
||||||
auth.logout()
|
|
||||||
window.location.href = '/login'
|
// Retry original request with new token
|
||||||
throw new Error('Unauthorized')
|
headers['Authorization'] = `Bearer ${auth.accessToken}`
|
||||||
|
response = await fetch(`${API_BASE}${path}`, {
|
||||||
|
method: options.method || 'GET',
|
||||||
|
headers,
|
||||||
|
body: options.body ? JSON.stringify(options.body) : undefined,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
|||||||
@@ -61,6 +61,12 @@ const panelRoutes: RouteRecordRaw[] = [
|
|||||||
component: () => import('@/views/auth/RegisterView.vue'),
|
component: () => import('@/views/auth/RegisterView.vue'),
|
||||||
meta: { guest: true },
|
meta: { guest: true },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/forgot-password',
|
||||||
|
name: 'forgot-password',
|
||||||
|
component: () => import('@/views/auth/ForgotPasswordView.vue'),
|
||||||
|
meta: { guest: true },
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/setup',
|
path: '/setup',
|
||||||
name: 'setup-wizard',
|
name: 'setup-wizard',
|
||||||
@@ -184,6 +190,26 @@ const panelRoutes: RouteRecordRaw[] = [
|
|||||||
name: 'settings',
|
name: 'settings',
|
||||||
component: () => import('@/views/admin/SettingsView.vue'),
|
component: () => import('@/views/admin/SettingsView.vue'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'schedules',
|
||||||
|
name: 'schedules',
|
||||||
|
component: () => import('@/views/admin/SchedulesView.vue'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'migration',
|
||||||
|
name: 'migration',
|
||||||
|
component: () => import('@/views/admin/MigrationView.vue'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'changelog',
|
||||||
|
name: 'changelog',
|
||||||
|
component: () => import('@/views/admin/ChangelogView.vue'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'alerts',
|
||||||
|
name: 'alerts',
|
||||||
|
component: () => import('@/views/admin/AlertsView.vue'),
|
||||||
|
},
|
||||||
// Platform Admin views (super-admin only)
|
// Platform Admin views (super-admin only)
|
||||||
{
|
{
|
||||||
path: 'admin',
|
path: 'admin',
|
||||||
@@ -249,6 +275,12 @@ const panelRoutes: RouteRecordRaw[] = [
|
|||||||
name: 'status',
|
name: 'status',
|
||||||
component: () => import('@/views/public/StatusPageView.vue'),
|
component: () => import('@/views/public/StatusPageView.vue'),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Catch-all
|
||||||
|
{
|
||||||
|
path: '/:pathMatch(.*)*',
|
||||||
|
redirect: '/',
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -34,6 +34,35 @@ export const useAuthStore = defineStore('auth', () => {
|
|||||||
return license.value?.modules_enabled?.includes(moduleSlug) ?? false
|
return license.value?.modules_enabled?.includes(moduleSlug) ?? false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hasPermission(permission: string): boolean {
|
||||||
|
// Super admin has all permissions
|
||||||
|
if (isSuperAdmin.value) return true
|
||||||
|
|
||||||
|
// Default permissions for authenticated users
|
||||||
|
// In a real implementation, this would check the user's role permissions
|
||||||
|
// For now, grant basic permissions to all authenticated users
|
||||||
|
const basicPermissions = [
|
||||||
|
'server.view',
|
||||||
|
'console.view',
|
||||||
|
'players.view',
|
||||||
|
'plugins.view',
|
||||||
|
'wipes.view',
|
||||||
|
'maps.view',
|
||||||
|
'chat.view',
|
||||||
|
'analytics.view',
|
||||||
|
'notifications.view',
|
||||||
|
'store.view',
|
||||||
|
'modules.view',
|
||||||
|
'settings.view',
|
||||||
|
'schedules.view',
|
||||||
|
'alerts.view',
|
||||||
|
'changelog.view',
|
||||||
|
'migration.view',
|
||||||
|
]
|
||||||
|
|
||||||
|
return basicPermissions.includes(permission)
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
user,
|
user,
|
||||||
license,
|
license,
|
||||||
@@ -47,6 +76,7 @@ export const useAuthStore = defineStore('auth', () => {
|
|||||||
setLicense,
|
setLicense,
|
||||||
logout,
|
logout,
|
||||||
hasModule,
|
hasModule,
|
||||||
|
hasPermission,
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
persist: {
|
persist: {
|
||||||
|
|||||||
@@ -1,33 +1,60 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
import { useApi } from '@/composables/useApi'
|
||||||
import type { PluginEntry } from '@/types'
|
import type { PluginEntry } from '@/types'
|
||||||
|
|
||||||
export const usePluginStore = defineStore('plugins', () => {
|
export const usePluginStore = defineStore('plugins', () => {
|
||||||
const plugins = ref<PluginEntry[]>([])
|
const plugins = ref<PluginEntry[]>([])
|
||||||
|
const searchResults = ref<any[]>([])
|
||||||
const isLoading = ref(false)
|
const isLoading = ref(false)
|
||||||
|
const api = useApi()
|
||||||
|
|
||||||
async function fetchPlugins() {
|
async function fetchPlugins() {
|
||||||
// TODO: GET /api/plugins
|
isLoading.value = true
|
||||||
|
try {
|
||||||
|
plugins.value = await api.get<PluginEntry[]>('/plugins')
|
||||||
|
} finally {
|
||||||
|
isLoading.value = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function installPlugin(_slug: string) {
|
async function installPlugin(data: { plugin_name: string; source: string }) {
|
||||||
// TODO: POST /api/plugins/install
|
await api.post('/plugins/install', data)
|
||||||
|
await fetchPlugins()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function reloadPlugin(_pluginId: string) {
|
async function uninstallPlugin(id: string) {
|
||||||
// TODO: POST /api/plugins/:id/reload
|
await api.del(`/plugins/${id}`)
|
||||||
|
await fetchPlugins()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function searchUmod(_query: string) {
|
async function reloadPlugin(id: string) {
|
||||||
// TODO: GET /api/plugins/search?q=query
|
await api.post(`/plugins/${id}/reload`, {})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updatePluginConfig(id: string, config: Record<string, any>) {
|
||||||
|
await api.put(`/plugins/${id}/config`, { config })
|
||||||
|
await fetchPlugins()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function searchPlugins(query: string) {
|
||||||
|
isLoading.value = true
|
||||||
|
try {
|
||||||
|
searchResults.value = await api.get<any[]>(`/plugins/search?q=${encodeURIComponent(query)}`)
|
||||||
|
} finally {
|
||||||
|
isLoading.value = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
plugins,
|
plugins,
|
||||||
|
searchResults,
|
||||||
isLoading,
|
isLoading,
|
||||||
fetchPlugins,
|
fetchPlugins,
|
||||||
installPlugin,
|
installPlugin,
|
||||||
|
uninstallPlugin,
|
||||||
reloadPlugin,
|
reloadPlugin,
|
||||||
searchUmod,
|
updatePluginConfig,
|
||||||
|
searchPlugins,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
232
frontend/src/views/admin/AlertsView.vue
Normal file
232
frontend/src/views/admin/AlertsView.vue
Normal file
@@ -0,0 +1,232 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, onMounted } from 'vue'
|
||||||
|
import { useApi } from '@/composables/useApi'
|
||||||
|
import { AlertTriangle, Save, Loader2 } from 'lucide-vue-next'
|
||||||
|
|
||||||
|
interface AlertConfig {
|
||||||
|
population_drop_enabled: boolean
|
||||||
|
population_drop_threshold_percent: number
|
||||||
|
fps_degradation_enabled: boolean
|
||||||
|
fps_threshold: number
|
||||||
|
notify_discord: boolean
|
||||||
|
notify_pushbullet: boolean
|
||||||
|
notify_email: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AlertHistoryEntry {
|
||||||
|
id: string
|
||||||
|
triggered_at: string
|
||||||
|
alert_type: string
|
||||||
|
severity: 'info' | 'warning' | 'critical'
|
||||||
|
title: string
|
||||||
|
message: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const api = useApi()
|
||||||
|
const config = ref<AlertConfig>({
|
||||||
|
population_drop_enabled: false,
|
||||||
|
population_drop_threshold_percent: 50,
|
||||||
|
fps_degradation_enabled: false,
|
||||||
|
fps_threshold: 30,
|
||||||
|
notify_discord: false,
|
||||||
|
notify_pushbullet: false,
|
||||||
|
notify_email: false,
|
||||||
|
})
|
||||||
|
const history = ref<AlertHistoryEntry[]>([])
|
||||||
|
const isSaving = ref(false)
|
||||||
|
const isLoading = ref(false)
|
||||||
|
|
||||||
|
async function fetchConfig() {
|
||||||
|
isLoading.value = true
|
||||||
|
try {
|
||||||
|
config.value = await api.get<AlertConfig>('/alerts/config')
|
||||||
|
} finally {
|
||||||
|
isLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchHistory() {
|
||||||
|
history.value = await api.get<AlertHistoryEntry[]>('/alerts/history?limit=50')
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveConfig() {
|
||||||
|
isSaving.value = true
|
||||||
|
try {
|
||||||
|
await api.put('/alerts/config', config.value)
|
||||||
|
alert('Alert configuration saved')
|
||||||
|
} catch (err) {
|
||||||
|
alert(err instanceof Error ? err.message : 'Failed to save configuration')
|
||||||
|
} finally {
|
||||||
|
isSaving.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSeverityColor(severity: string): string {
|
||||||
|
switch (severity) {
|
||||||
|
case 'info': return 'bg-blue-500/10 text-blue-400'
|
||||||
|
case 'warning': return 'bg-yellow-500/10 text-yellow-400'
|
||||||
|
case 'critical': return 'bg-red-500/10 text-red-400'
|
||||||
|
default: return 'bg-neutral-700/50 text-neutral-400'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
fetchConfig()
|
||||||
|
fetchHistory()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="p-6 space-y-6">
|
||||||
|
<!-- Header -->
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<AlertTriangle class="w-5 h-5 text-oxide-500" />
|
||||||
|
<h1 class="text-2xl font-bold text-neutral-100">Alerts</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Alert Configuration -->
|
||||||
|
<div class="bg-neutral-900 border border-neutral-800 rounded-lg p-5">
|
||||||
|
<h2 class="text-sm font-medium text-neutral-400 uppercase tracking-wider mb-4">Alert Configuration</h2>
|
||||||
|
|
||||||
|
<div v-if="isLoading" class="py-8 flex justify-center">
|
||||||
|
<Loader2 class="w-6 h-6 text-oxide-500 animate-spin" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else class="space-y-6">
|
||||||
|
<!-- Population Drop Alert -->
|
||||||
|
<div class="space-y-3">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<label class="text-sm font-medium text-neutral-200">Population Drop Alert</label>
|
||||||
|
<button
|
||||||
|
@click="config.population_drop_enabled = !config.population_drop_enabled"
|
||||||
|
class="relative inline-flex h-6 w-11 items-center rounded-full transition-colors"
|
||||||
|
:class="config.population_drop_enabled ? 'bg-oxide-500' : 'bg-neutral-700'"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="inline-block h-4 w-4 transform rounded-full bg-white transition-transform"
|
||||||
|
:class="config.population_drop_enabled ? 'translate-x-6' : 'translate-x-1'"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div v-if="config.population_drop_enabled">
|
||||||
|
<label class="block text-xs text-neutral-500 mb-2">Threshold (%)</label>
|
||||||
|
<input
|
||||||
|
v-model.number="config.population_drop_threshold_percent"
|
||||||
|
type="range"
|
||||||
|
min="10"
|
||||||
|
max="100"
|
||||||
|
class="w-full h-2 bg-neutral-700 rounded-lg appearance-none cursor-pointer accent-oxide-500"
|
||||||
|
/>
|
||||||
|
<div class="text-xs text-neutral-400 mt-1">{{ config.population_drop_threshold_percent }}%</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- FPS Degradation Alert -->
|
||||||
|
<div class="space-y-3">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<label class="text-sm font-medium text-neutral-200">FPS Degradation Alert</label>
|
||||||
|
<button
|
||||||
|
@click="config.fps_degradation_enabled = !config.fps_degradation_enabled"
|
||||||
|
class="relative inline-flex h-6 w-11 items-center rounded-full transition-colors"
|
||||||
|
:class="config.fps_degradation_enabled ? 'bg-oxide-500' : 'bg-neutral-700'"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="inline-block h-4 w-4 transform rounded-full bg-white transition-transform"
|
||||||
|
:class="config.fps_degradation_enabled ? 'translate-x-6' : 'translate-x-1'"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div v-if="config.fps_degradation_enabled">
|
||||||
|
<label class="block text-xs text-neutral-500 mb-2">FPS Threshold</label>
|
||||||
|
<input
|
||||||
|
v-model.number="config.fps_threshold"
|
||||||
|
type="number"
|
||||||
|
min="10"
|
||||||
|
max="60"
|
||||||
|
class="w-full px-3 py-2 bg-neutral-800 border border-neutral-700 rounded-lg text-neutral-200 focus:outline-none focus:ring-2 focus:ring-oxide-500"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Notification Channels -->
|
||||||
|
<div class="border-t border-neutral-800 pt-4">
|
||||||
|
<h3 class="text-sm font-medium text-neutral-400 uppercase tracking-wider mb-3">Notification Channels</h3>
|
||||||
|
<div class="space-y-2">
|
||||||
|
<label class="flex items-center gap-3 cursor-pointer">
|
||||||
|
<input
|
||||||
|
v-model="config.notify_discord"
|
||||||
|
type="checkbox"
|
||||||
|
class="w-4 h-4 rounded border-neutral-700 bg-neutral-800 text-oxide-500 focus:ring-2 focus:ring-oxide-500"
|
||||||
|
/>
|
||||||
|
<span class="text-sm text-neutral-200">Discord</span>
|
||||||
|
</label>
|
||||||
|
<label class="flex items-center gap-3 cursor-pointer">
|
||||||
|
<input
|
||||||
|
v-model="config.notify_pushbullet"
|
||||||
|
type="checkbox"
|
||||||
|
class="w-4 h-4 rounded border-neutral-700 bg-neutral-800 text-oxide-500 focus:ring-2 focus:ring-oxide-500"
|
||||||
|
/>
|
||||||
|
<span class="text-sm text-neutral-200">Pushbullet</span>
|
||||||
|
</label>
|
||||||
|
<label class="flex items-center gap-3 cursor-pointer">
|
||||||
|
<input
|
||||||
|
v-model="config.notify_email"
|
||||||
|
type="checkbox"
|
||||||
|
class="w-4 h-4 rounded border-neutral-700 bg-neutral-800 text-oxide-500 focus:ring-2 focus:ring-oxide-500"
|
||||||
|
/>
|
||||||
|
<span class="text-sm text-neutral-200">Email</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Save Button -->
|
||||||
|
<button
|
||||||
|
@click="saveConfig"
|
||||||
|
:disabled="isSaving"
|
||||||
|
class="flex items-center gap-2 px-4 py-2 bg-oxide-500 hover:bg-oxide-600 disabled:opacity-50 text-white font-medium rounded-lg transition-colors"
|
||||||
|
>
|
||||||
|
<Loader2 v-if="isSaving" class="w-4 h-4 animate-spin" />
|
||||||
|
<Save v-else class="w-4 h-4" />
|
||||||
|
Save Configuration
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Alert History -->
|
||||||
|
<div class="bg-neutral-900 border border-neutral-800 rounded-lg overflow-hidden">
|
||||||
|
<div class="p-5 border-b border-neutral-800">
|
||||||
|
<h2 class="text-sm font-medium text-neutral-400 uppercase tracking-wider">Alert History</h2>
|
||||||
|
</div>
|
||||||
|
<div v-if="history.length === 0" class="p-8 text-center text-neutral-500">
|
||||||
|
No alerts triggered yet.
|
||||||
|
</div>
|
||||||
|
<table v-else class="w-full">
|
||||||
|
<thead class="bg-neutral-800/50 border-b border-neutral-800">
|
||||||
|
<tr>
|
||||||
|
<th class="px-4 py-3 text-left text-xs font-medium text-neutral-400 uppercase tracking-wider">Triggered</th>
|
||||||
|
<th class="px-4 py-3 text-left text-xs font-medium text-neutral-400 uppercase tracking-wider">Type</th>
|
||||||
|
<th class="px-4 py-3 text-left text-xs font-medium text-neutral-400 uppercase tracking-wider">Severity</th>
|
||||||
|
<th class="px-4 py-3 text-left text-xs font-medium text-neutral-400 uppercase tracking-wider">Title</th>
|
||||||
|
<th class="px-4 py-3 text-left text-xs font-medium text-neutral-400 uppercase tracking-wider">Message</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="divide-y divide-neutral-800">
|
||||||
|
<tr v-for="alert in history" :key="alert.id" class="hover:bg-neutral-800/30">
|
||||||
|
<td class="px-4 py-3 text-sm text-neutral-400">{{ new Date(alert.triggered_at).toLocaleString() }}</td>
|
||||||
|
<td class="px-4 py-3 text-sm text-neutral-400">{{ alert.alert_type }}</td>
|
||||||
|
<td class="px-4 py-3">
|
||||||
|
<span
|
||||||
|
class="text-xs font-medium px-2 py-0.5 rounded-full capitalize"
|
||||||
|
:class="getSeverityColor(alert.severity)"
|
||||||
|
>
|
||||||
|
{{ alert.severity }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td class="px-4 py-3 text-sm text-neutral-200">{{ alert.title }}</td>
|
||||||
|
<td class="px-4 py-3 text-sm text-neutral-400">{{ alert.message }}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
112
frontend/src/views/admin/ChangelogView.vue
Normal file
112
frontend/src/views/admin/ChangelogView.vue
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, onMounted } from 'vue'
|
||||||
|
import { useApi } from '@/composables/useApi'
|
||||||
|
import { FileText, Tag, Loader2 } from 'lucide-vue-next'
|
||||||
|
|
||||||
|
interface ChangelogEntry {
|
||||||
|
id: string
|
||||||
|
version: string
|
||||||
|
title: string
|
||||||
|
body: string
|
||||||
|
category: 'feature' | 'bugfix' | 'module' | 'security'
|
||||||
|
published_at: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const api = useApi()
|
||||||
|
const entries = ref<ChangelogEntry[]>([])
|
||||||
|
const isLoading = ref(false)
|
||||||
|
const page = ref(1)
|
||||||
|
const hasMore = ref(true)
|
||||||
|
|
||||||
|
async function fetchChangelog() {
|
||||||
|
isLoading.value = true
|
||||||
|
try {
|
||||||
|
const result = await api.get<ChangelogEntry[]>(`/changelog?page=${page.value}&limit=20`)
|
||||||
|
if (result.length === 0) {
|
||||||
|
hasMore.value = false
|
||||||
|
} else {
|
||||||
|
entries.value.push(...result)
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
isLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadMore() {
|
||||||
|
page.value++
|
||||||
|
fetchChangelog()
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCategoryColor(category: string): string {
|
||||||
|
switch (category) {
|
||||||
|
case 'feature': return 'bg-green-500/10 text-green-400'
|
||||||
|
case 'bugfix': return 'bg-red-500/10 text-red-400'
|
||||||
|
case 'module': return 'bg-blue-500/10 text-blue-400'
|
||||||
|
case 'security': return 'bg-yellow-500/10 text-yellow-400'
|
||||||
|
default: return 'bg-neutral-700/50 text-neutral-400'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
fetchChangelog()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="p-6 space-y-6">
|
||||||
|
<!-- Header -->
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<FileText class="w-5 h-5 text-oxide-500" />
|
||||||
|
<h1 class="text-2xl font-bold text-neutral-100">Changelog</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Changelog Feed -->
|
||||||
|
<div class="space-y-4">
|
||||||
|
<div
|
||||||
|
v-for="entry in entries"
|
||||||
|
:key="entry.id"
|
||||||
|
class="bg-neutral-900 border border-neutral-800 rounded-lg p-5"
|
||||||
|
>
|
||||||
|
<div class="flex items-start justify-between mb-3">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<div class="flex items-center gap-2 px-2 py-1 bg-oxide-500/10 border border-oxide-500/20 rounded-lg">
|
||||||
|
<Tag class="w-3 h-3 text-oxide-400" />
|
||||||
|
<span class="text-xs font-mono text-oxide-400">{{ entry.version }}</span>
|
||||||
|
</div>
|
||||||
|
<span
|
||||||
|
class="text-xs font-medium px-2 py-0.5 rounded-full capitalize"
|
||||||
|
:class="getCategoryColor(entry.category)"
|
||||||
|
>
|
||||||
|
{{ entry.category }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<span class="text-xs text-neutral-500">{{ new Date(entry.published_at).toLocaleDateString() }}</span>
|
||||||
|
</div>
|
||||||
|
<h3 class="text-lg font-bold text-neutral-100 mb-2">{{ entry.title }}</h3>
|
||||||
|
<div class="text-sm text-neutral-300 whitespace-pre-line leading-relaxed">
|
||||||
|
{{ entry.body }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Loading State -->
|
||||||
|
<div v-if="isLoading" class="flex justify-center py-6">
|
||||||
|
<Loader2 class="w-6 h-6 text-oxide-500 animate-spin" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Load More -->
|
||||||
|
<div v-else-if="hasMore" class="flex justify-center">
|
||||||
|
<button
|
||||||
|
@click="loadMore"
|
||||||
|
class="px-4 py-2 text-sm font-medium text-neutral-300 bg-neutral-800 hover:bg-neutral-700 rounded-lg transition-colors"
|
||||||
|
>
|
||||||
|
Load More
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- End of List -->
|
||||||
|
<div v-else class="text-center py-6 text-sm text-neutral-500">
|
||||||
|
No more changelog entries
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
191
frontend/src/views/admin/MigrationView.vue
Normal file
191
frontend/src/views/admin/MigrationView.vue
Normal file
@@ -0,0 +1,191 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, onMounted } from 'vue'
|
||||||
|
import { useApi } from '@/composables/useApi'
|
||||||
|
import { Download, Upload, FileText, Loader2 } from 'lucide-vue-next'
|
||||||
|
|
||||||
|
interface ExportRecord {
|
||||||
|
id: string
|
||||||
|
export_type: 'full' | 'config_only' | 'store_only'
|
||||||
|
file_size_bytes: number
|
||||||
|
created_at: string
|
||||||
|
download_url?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const api = useApi()
|
||||||
|
const exports = ref<ExportRecord[]>([])
|
||||||
|
const isExporting = ref(false)
|
||||||
|
const isImporting = ref(false)
|
||||||
|
const exportType = ref<'full' | 'config_only' | 'store_only'>('full')
|
||||||
|
const uploadFile = ref<File | null>(null)
|
||||||
|
|
||||||
|
async function fetchExports() {
|
||||||
|
exports.value = await api.get<ExportRecord[]>('/migration/exports')
|
||||||
|
}
|
||||||
|
|
||||||
|
async function createExport() {
|
||||||
|
if (!confirm(`Export ${exportType.value.replace('_', ' ')} data?`)) return
|
||||||
|
isExporting.value = true
|
||||||
|
try {
|
||||||
|
const result = await api.post<{ export_id: string }>('/migration/export', { export_type: exportType.value })
|
||||||
|
alert(`Export created: ${result.export_id}`)
|
||||||
|
await fetchExports()
|
||||||
|
} finally {
|
||||||
|
isExporting.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleFileSelect(event: Event) {
|
||||||
|
const target = event.target as HTMLInputElement
|
||||||
|
if (target.files && target.files.length > 0) {
|
||||||
|
uploadFile.value = target.files[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function importData() {
|
||||||
|
if (!uploadFile.value) return
|
||||||
|
if (!confirm('Import data? This will overwrite existing configuration.')) return
|
||||||
|
|
||||||
|
isImporting.value = true
|
||||||
|
try {
|
||||||
|
const formData = new FormData()
|
||||||
|
formData.append('file', uploadFile.value)
|
||||||
|
|
||||||
|
const response = await fetch('/api/migration/import', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Import failed')
|
||||||
|
}
|
||||||
|
|
||||||
|
alert('Import successful')
|
||||||
|
uploadFile.value = null
|
||||||
|
} catch (err) {
|
||||||
|
alert(err instanceof Error ? err.message : 'Import failed')
|
||||||
|
} finally {
|
||||||
|
isImporting.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatBytes(bytes: number): string {
|
||||||
|
if (bytes === 0) return '0 B'
|
||||||
|
const k = 1024
|
||||||
|
const sizes = ['B', 'KB', 'MB', 'GB']
|
||||||
|
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
||||||
|
return `${(bytes / Math.pow(k, i)).toFixed(2)} ${sizes[i]}`
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
fetchExports()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="p-6 space-y-6">
|
||||||
|
<!-- Header -->
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<FileText class="w-5 h-5 text-oxide-500" />
|
||||||
|
<h1 class="text-2xl font-bold text-neutral-100">Migration</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Export Section -->
|
||||||
|
<div class="bg-neutral-900 border border-neutral-800 rounded-lg p-5">
|
||||||
|
<h2 class="text-sm font-medium text-neutral-400 uppercase tracking-wider mb-4">Export Data</h2>
|
||||||
|
<div class="flex items-end gap-4">
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs text-neutral-500 mb-2">Export Type</label>
|
||||||
|
<div class="flex bg-neutral-800 rounded-lg border border-neutral-700 overflow-hidden">
|
||||||
|
<button
|
||||||
|
v-for="opt in (['full', 'config_only', 'store_only'] as const)"
|
||||||
|
:key="opt"
|
||||||
|
@click="exportType = opt"
|
||||||
|
class="px-4 py-2 text-sm font-medium transition-colors capitalize"
|
||||||
|
:class="exportType === opt ? 'bg-oxide-500/15 text-oxide-400' : 'text-neutral-400 hover:text-neutral-200'"
|
||||||
|
>
|
||||||
|
{{ opt.replace('_', ' ') }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
@click="createExport"
|
||||||
|
:disabled="isExporting"
|
||||||
|
class="flex items-center gap-2 px-4 py-2 bg-oxide-500 hover:bg-oxide-600 disabled:opacity-50 text-white font-medium rounded-lg transition-colors"
|
||||||
|
>
|
||||||
|
<Loader2 v-if="isExporting" class="w-4 h-4 animate-spin" />
|
||||||
|
<Download v-else class="w-4 h-4" />
|
||||||
|
Export
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Export History -->
|
||||||
|
<div class="bg-neutral-900 border border-neutral-800 rounded-lg overflow-hidden">
|
||||||
|
<div class="p-5 border-b border-neutral-800">
|
||||||
|
<h2 class="text-sm font-medium text-neutral-400 uppercase tracking-wider">Export History</h2>
|
||||||
|
</div>
|
||||||
|
<div v-if="exports.length === 0" class="p-8 text-center text-neutral-500">
|
||||||
|
No exports yet.
|
||||||
|
</div>
|
||||||
|
<table v-else class="w-full">
|
||||||
|
<thead class="bg-neutral-800/50 border-b border-neutral-800">
|
||||||
|
<tr>
|
||||||
|
<th class="px-4 py-3 text-left text-xs font-medium text-neutral-400 uppercase tracking-wider">Type</th>
|
||||||
|
<th class="px-4 py-3 text-left text-xs font-medium text-neutral-400 uppercase tracking-wider">Created</th>
|
||||||
|
<th class="px-4 py-3 text-left text-xs font-medium text-neutral-400 uppercase tracking-wider">Size</th>
|
||||||
|
<th class="px-4 py-3 text-left text-xs font-medium text-neutral-400 uppercase tracking-wider">Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="divide-y divide-neutral-800">
|
||||||
|
<tr v-for="exp in exports" :key="exp.id" class="hover:bg-neutral-800/30">
|
||||||
|
<td class="px-4 py-3 text-sm text-neutral-200 capitalize">{{ exp.export_type.replace('_', ' ') }}</td>
|
||||||
|
<td class="px-4 py-3 text-sm text-neutral-400">{{ new Date(exp.created_at).toLocaleString() }}</td>
|
||||||
|
<td class="px-4 py-3 text-sm text-neutral-400">{{ formatBytes(exp.file_size_bytes) }}</td>
|
||||||
|
<td class="px-4 py-3">
|
||||||
|
<a
|
||||||
|
v-if="exp.download_url"
|
||||||
|
:href="exp.download_url"
|
||||||
|
class="text-oxide-400 hover:text-oxide-300 text-sm transition-colors"
|
||||||
|
>
|
||||||
|
Download
|
||||||
|
</a>
|
||||||
|
<span v-else class="text-sm text-neutral-600">Preparing...</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Import Section -->
|
||||||
|
<div class="bg-neutral-900 border border-neutral-800 rounded-lg p-5">
|
||||||
|
<h2 class="text-sm font-medium text-neutral-400 uppercase tracking-wider mb-4">Import Data</h2>
|
||||||
|
<div class="space-y-4">
|
||||||
|
<div class="border-2 border-dashed border-neutral-700 rounded-lg p-6 text-center">
|
||||||
|
<Upload class="w-8 h-8 text-neutral-500 mx-auto mb-2" />
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
accept=".json,.zip"
|
||||||
|
@change="handleFileSelect"
|
||||||
|
class="hidden"
|
||||||
|
id="file-upload"
|
||||||
|
/>
|
||||||
|
<label for="file-upload" class="cursor-pointer">
|
||||||
|
<span class="text-sm text-oxide-400 hover:text-oxide-300 transition-colors">
|
||||||
|
{{ uploadFile ? uploadFile.name : 'Click to select file' }}
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
<p class="text-xs text-neutral-500 mt-1">JSON or ZIP exports</p>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
@click="importData"
|
||||||
|
:disabled="!uploadFile || isImporting"
|
||||||
|
class="w-full flex items-center justify-center gap-2 px-4 py-2 bg-oxide-500 hover:bg-oxide-600 disabled:opacity-50 disabled:cursor-not-allowed text-white font-medium rounded-lg transition-colors"
|
||||||
|
>
|
||||||
|
<Loader2 v-if="isImporting" class="w-4 h-4 animate-spin" />
|
||||||
|
<Upload v-else class="w-4 h-4" />
|
||||||
|
Import
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
260
frontend/src/views/admin/SchedulesView.vue
Normal file
260
frontend/src/views/admin/SchedulesView.vue
Normal file
@@ -0,0 +1,260 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, onMounted } from 'vue'
|
||||||
|
import { useApi } from '@/composables/useApi'
|
||||||
|
import { Clock, Plus, Edit, Trash2, Power, Loader2 } from 'lucide-vue-next'
|
||||||
|
|
||||||
|
interface ScheduledTask {
|
||||||
|
id: string
|
||||||
|
task_name: string
|
||||||
|
task_type: 'restart' | 'announcement' | 'command' | 'plugin_reload'
|
||||||
|
cron_expression: string
|
||||||
|
timezone: string
|
||||||
|
is_active: boolean
|
||||||
|
next_run: string | null
|
||||||
|
task_config: Record<string, any>
|
||||||
|
}
|
||||||
|
|
||||||
|
const api = useApi()
|
||||||
|
const tasks = ref<ScheduledTask[]>([])
|
||||||
|
const isLoading = ref(false)
|
||||||
|
const showModal = ref(false)
|
||||||
|
const editingTask = ref<ScheduledTask | null>(null)
|
||||||
|
|
||||||
|
const formData = ref({
|
||||||
|
task_name: '',
|
||||||
|
task_type: 'restart' as 'restart' | 'announcement' | 'command' | 'plugin_reload',
|
||||||
|
cron_expression: '0 0 * * *',
|
||||||
|
timezone: 'UTC',
|
||||||
|
task_config: '{}',
|
||||||
|
})
|
||||||
|
|
||||||
|
const timezones = ['UTC', 'America/New_York', 'America/Chicago', 'America/Denver', 'America/Los_Angeles', 'Europe/London', 'Europe/Paris', 'Asia/Tokyo']
|
||||||
|
|
||||||
|
async function fetchTasks() {
|
||||||
|
isLoading.value = true
|
||||||
|
try {
|
||||||
|
tasks.value = await api.get<ScheduledTask[]>('/schedules/tasks')
|
||||||
|
} finally {
|
||||||
|
isLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function openCreateModal() {
|
||||||
|
editingTask.value = null
|
||||||
|
formData.value = {
|
||||||
|
task_name: '',
|
||||||
|
task_type: 'restart',
|
||||||
|
cron_expression: '0 0 * * *',
|
||||||
|
timezone: 'UTC',
|
||||||
|
task_config: '{}',
|
||||||
|
}
|
||||||
|
showModal.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function openEditModal(task: ScheduledTask) {
|
||||||
|
editingTask.value = task
|
||||||
|
formData.value = {
|
||||||
|
task_name: task.task_name,
|
||||||
|
task_type: task.task_type,
|
||||||
|
cron_expression: task.cron_expression,
|
||||||
|
timezone: task.timezone,
|
||||||
|
task_config: JSON.stringify(task.task_config, null, 2),
|
||||||
|
}
|
||||||
|
showModal.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveTask() {
|
||||||
|
try {
|
||||||
|
const payload = {
|
||||||
|
...formData.value,
|
||||||
|
task_config: JSON.parse(formData.value.task_config),
|
||||||
|
}
|
||||||
|
|
||||||
|
if (editingTask.value) {
|
||||||
|
await api.put(`/schedules/tasks/${editingTask.value.id}`, payload)
|
||||||
|
} else {
|
||||||
|
await api.post('/schedules/tasks', payload)
|
||||||
|
}
|
||||||
|
|
||||||
|
showModal.value = false
|
||||||
|
await fetchTasks()
|
||||||
|
} catch (err) {
|
||||||
|
alert(err instanceof Error ? err.message : 'Failed to save task')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteTask(id: string) {
|
||||||
|
if (!confirm('Delete this scheduled task?')) return
|
||||||
|
await api.del(`/schedules/tasks/${id}`)
|
||||||
|
await fetchTasks()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function toggleActive(task: ScheduledTask) {
|
||||||
|
await api.put(`/schedules/tasks/${task.id}`, { is_active: !task.is_active })
|
||||||
|
await fetchTasks()
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
fetchTasks()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="p-6 space-y-6">
|
||||||
|
<!-- Header -->
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<Clock class="w-5 h-5 text-oxide-500" />
|
||||||
|
<h1 class="text-2xl font-bold text-neutral-100">Scheduled Tasks</h1>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
@click="openCreateModal"
|
||||||
|
class="flex items-center gap-2 px-4 py-2 bg-oxide-500 hover:bg-oxide-600 text-white font-medium rounded-lg transition-colors"
|
||||||
|
>
|
||||||
|
<Plus class="w-4 h-4" />
|
||||||
|
New Task
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Tasks Table -->
|
||||||
|
<div class="bg-neutral-900 border border-neutral-800 rounded-lg overflow-hidden">
|
||||||
|
<div v-if="isLoading" class="p-8 flex justify-center">
|
||||||
|
<Loader2 class="w-6 h-6 text-oxide-500 animate-spin" />
|
||||||
|
</div>
|
||||||
|
<div v-else-if="tasks.length === 0" class="p-8 text-center text-neutral-500">
|
||||||
|
No scheduled tasks configured.
|
||||||
|
</div>
|
||||||
|
<table v-else class="w-full">
|
||||||
|
<thead class="bg-neutral-800/50 border-b border-neutral-800">
|
||||||
|
<tr>
|
||||||
|
<th class="px-4 py-3 text-left text-xs font-medium text-neutral-400 uppercase tracking-wider">Task Name</th>
|
||||||
|
<th class="px-4 py-3 text-left text-xs font-medium text-neutral-400 uppercase tracking-wider">Type</th>
|
||||||
|
<th class="px-4 py-3 text-left text-xs font-medium text-neutral-400 uppercase tracking-wider">Schedule</th>
|
||||||
|
<th class="px-4 py-3 text-left text-xs font-medium text-neutral-400 uppercase tracking-wider">Timezone</th>
|
||||||
|
<th class="px-4 py-3 text-left text-xs font-medium text-neutral-400 uppercase tracking-wider">Next Run</th>
|
||||||
|
<th class="px-4 py-3 text-left text-xs font-medium text-neutral-400 uppercase tracking-wider">Status</th>
|
||||||
|
<th class="px-4 py-3 text-left text-xs font-medium text-neutral-400 uppercase tracking-wider">Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="divide-y divide-neutral-800">
|
||||||
|
<tr v-for="task in tasks" :key="task.id" class="hover:bg-neutral-800/30">
|
||||||
|
<td class="px-4 py-3 text-sm text-neutral-200">{{ task.task_name }}</td>
|
||||||
|
<td class="px-4 py-3 text-sm text-neutral-400 capitalize">{{ task.task_type.replace('_', ' ') }}</td>
|
||||||
|
<td class="px-4 py-3 text-sm font-mono text-neutral-400">{{ task.cron_expression }}</td>
|
||||||
|
<td class="px-4 py-3 text-sm text-neutral-400">{{ task.timezone }}</td>
|
||||||
|
<td class="px-4 py-3 text-sm text-neutral-400">{{ task.next_run ? new Date(task.next_run).toLocaleString() : '—' }}</td>
|
||||||
|
<td class="px-4 py-3">
|
||||||
|
<span
|
||||||
|
class="text-xs font-medium px-2 py-0.5 rounded-full"
|
||||||
|
:class="task.is_active ? 'bg-green-500/10 text-green-400' : 'bg-neutral-700/50 text-neutral-400'"
|
||||||
|
>
|
||||||
|
{{ task.is_active ? 'Active' : 'Paused' }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td class="px-4 py-3">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<button
|
||||||
|
@click="toggleActive(task)"
|
||||||
|
class="text-neutral-400 hover:text-oxide-400 transition-colors"
|
||||||
|
:title="task.is_active ? 'Pause' : 'Activate'"
|
||||||
|
>
|
||||||
|
<Power class="w-4 h-4" />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
@click="openEditModal(task)"
|
||||||
|
class="text-neutral-400 hover:text-oxide-400 transition-colors"
|
||||||
|
>
|
||||||
|
<Edit class="w-4 h-4" />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
@click="deleteTask(task.id)"
|
||||||
|
class="text-neutral-400 hover:text-red-400 transition-colors"
|
||||||
|
>
|
||||||
|
<Trash2 class="w-4 h-4" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Create/Edit Modal -->
|
||||||
|
<div
|
||||||
|
v-if="showModal"
|
||||||
|
class="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4"
|
||||||
|
@click.self="showModal = false"
|
||||||
|
>
|
||||||
|
<div class="bg-neutral-900 border border-neutral-800 rounded-lg w-full max-w-lg">
|
||||||
|
<div class="p-5 border-b border-neutral-800">
|
||||||
|
<h2 class="text-lg font-bold text-neutral-100">{{ editingTask ? 'Edit Task' : 'New Task' }}</h2>
|
||||||
|
</div>
|
||||||
|
<div class="p-5 space-y-4">
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm text-neutral-400 mb-2">Task Name</label>
|
||||||
|
<input
|
||||||
|
v-model="formData.task_name"
|
||||||
|
type="text"
|
||||||
|
class="w-full px-3 py-2 bg-neutral-800 border border-neutral-700 rounded-lg text-neutral-200 placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-oxide-500"
|
||||||
|
placeholder="Daily restart"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm text-neutral-400 mb-2">Task Type</label>
|
||||||
|
<select
|
||||||
|
v-model="formData.task_type"
|
||||||
|
class="w-full px-3 py-2 bg-neutral-800 border border-neutral-700 rounded-lg text-neutral-200 focus:outline-none focus:ring-2 focus:ring-oxide-500"
|
||||||
|
>
|
||||||
|
<option value="restart">Restart</option>
|
||||||
|
<option value="announcement">Announcement</option>
|
||||||
|
<option value="command">Command</option>
|
||||||
|
<option value="plugin_reload">Plugin Reload</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm text-neutral-400 mb-2">Cron Expression</label>
|
||||||
|
<input
|
||||||
|
v-model="formData.cron_expression"
|
||||||
|
type="text"
|
||||||
|
class="w-full px-3 py-2 bg-neutral-800 border border-neutral-700 rounded-lg text-neutral-200 font-mono text-sm focus:outline-none focus:ring-2 focus:ring-oxide-500"
|
||||||
|
placeholder="0 0 * * *"
|
||||||
|
/>
|
||||||
|
<p class="text-xs text-neutral-500 mt-1">Example: "0 0 * * *" = daily at midnight</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm text-neutral-400 mb-2">Timezone</label>
|
||||||
|
<select
|
||||||
|
v-model="formData.timezone"
|
||||||
|
class="w-full px-3 py-2 bg-neutral-800 border border-neutral-700 rounded-lg text-neutral-200 focus:outline-none focus:ring-2 focus:ring-oxide-500"
|
||||||
|
>
|
||||||
|
<option v-for="tz in timezones" :key="tz" :value="tz">{{ tz }}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm text-neutral-400 mb-2">Task Config (JSON)</label>
|
||||||
|
<textarea
|
||||||
|
v-model="formData.task_config"
|
||||||
|
rows="4"
|
||||||
|
class="w-full px-3 py-2 bg-neutral-800 border border-neutral-700 rounded-lg text-neutral-200 font-mono text-sm focus:outline-none focus:ring-2 focus:ring-oxide-500"
|
||||||
|
placeholder='{"message": "Server restarting..."}'
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="p-5 border-t border-neutral-800 flex justify-end gap-3">
|
||||||
|
<button
|
||||||
|
@click="showModal = false"
|
||||||
|
class="px-4 py-2 text-sm font-medium text-neutral-300 bg-neutral-800 hover:bg-neutral-700 rounded-lg transition-colors"
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
@click="saveTask"
|
||||||
|
class="px-4 py-2 text-sm font-medium bg-oxide-500 hover:bg-oxide-600 text-white rounded-lg transition-colors"
|
||||||
|
>
|
||||||
|
{{ editingTask ? 'Update' : 'Create' }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
102
frontend/src/views/auth/ForgotPasswordView.vue
Normal file
102
frontend/src/views/auth/ForgotPasswordView.vue
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { useApi } from '@/composables/useApi'
|
||||||
|
import { RouterLink } from 'vue-router'
|
||||||
|
import { Mail, ArrowLeft, CheckCircle2, Loader2 } from 'lucide-vue-next'
|
||||||
|
|
||||||
|
const api = useApi()
|
||||||
|
const email = ref('')
|
||||||
|
const isLoading = ref(false)
|
||||||
|
const success = ref(false)
|
||||||
|
const errorMessage = ref('')
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
if (!email.value) return
|
||||||
|
|
||||||
|
isLoading.value = true
|
||||||
|
errorMessage.value = ''
|
||||||
|
try {
|
||||||
|
await api.post('/auth/forgot-password', { email: email.value })
|
||||||
|
success.value = true
|
||||||
|
} catch (err) {
|
||||||
|
errorMessage.value = err instanceof Error ? err.message : 'Failed to send reset email'
|
||||||
|
} finally {
|
||||||
|
isLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="min-h-screen bg-neutral-950 flex items-center justify-center p-6">
|
||||||
|
<div class="w-full max-w-md">
|
||||||
|
<!-- Logo -->
|
||||||
|
<div class="text-center mb-8">
|
||||||
|
<div class="flex items-center justify-center gap-2 mb-2">
|
||||||
|
<img src="/logo.png" alt="Corrosion" class="h-10 w-10" />
|
||||||
|
<h1 class="text-2xl font-bold text-oxide-500 tracking-wider">CORROSION</h1>
|
||||||
|
</div>
|
||||||
|
<p class="text-neutral-500 text-sm">Server Management Platform</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Card -->
|
||||||
|
<div class="bg-neutral-900 border border-neutral-800 rounded-lg p-8">
|
||||||
|
<div v-if="success" class="text-center space-y-4">
|
||||||
|
<CheckCircle2 class="w-12 h-12 text-green-500 mx-auto" />
|
||||||
|
<h2 class="text-xl font-bold text-neutral-100">Check your email</h2>
|
||||||
|
<p class="text-sm text-neutral-400">
|
||||||
|
We've sent password reset instructions to <strong class="text-neutral-200">{{ email }}</strong>
|
||||||
|
</p>
|
||||||
|
<RouterLink
|
||||||
|
to="/login"
|
||||||
|
class="inline-flex items-center gap-2 text-sm text-oxide-400 hover:text-oxide-300 transition-colors"
|
||||||
|
>
|
||||||
|
<ArrowLeft class="w-4 h-4" />
|
||||||
|
Back to login
|
||||||
|
</RouterLink>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form v-else @submit.prevent="handleSubmit" class="space-y-6">
|
||||||
|
<div class="text-center mb-6">
|
||||||
|
<h2 class="text-xl font-bold text-neutral-100 mb-2">Forgot password?</h2>
|
||||||
|
<p class="text-sm text-neutral-400">Enter your email to receive reset instructions</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm text-neutral-400 mb-2">Email</label>
|
||||||
|
<div class="relative">
|
||||||
|
<Mail class="absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-neutral-500" />
|
||||||
|
<input
|
||||||
|
v-model="email"
|
||||||
|
type="email"
|
||||||
|
required
|
||||||
|
class="w-full pl-10 pr-4 py-2 bg-neutral-800 border border-neutral-700 rounded-lg text-neutral-200 placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-oxide-500"
|
||||||
|
placeholder="admin@example.com"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="errorMessage" class="p-3 bg-red-500/10 border border-red-500/20 rounded-lg">
|
||||||
|
<p class="text-sm text-red-400">{{ errorMessage }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
:disabled="isLoading"
|
||||||
|
class="w-full flex items-center justify-center gap-2 py-2 bg-oxide-500 hover:bg-oxide-600 disabled:opacity-50 text-white font-medium rounded-lg transition-colors"
|
||||||
|
>
|
||||||
|
<Loader2 v-if="isLoading" class="w-5 h-5 animate-spin" />
|
||||||
|
<span>{{ isLoading ? 'Sending...' : 'Send Reset Link' }}</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<RouterLink
|
||||||
|
to="/login"
|
||||||
|
class="flex items-center justify-center gap-2 text-sm text-neutral-400 hover:text-neutral-200 transition-colors"
|
||||||
|
>
|
||||||
|
<ArrowLeft class="w-4 h-4" />
|
||||||
|
Back to login
|
||||||
|
</RouterLink>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -1,10 +1,149 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
// TODO: Implement public-facing server information page
|
import { ref, onMounted } from 'vue'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
import { Server, Users, Calendar, MessageCircle, Loader2, ExternalLink } from 'lucide-vue-next'
|
||||||
|
|
||||||
|
interface ServerInfo {
|
||||||
|
server_name: string
|
||||||
|
description: string | null
|
||||||
|
header_image: string | null
|
||||||
|
motd: string | null
|
||||||
|
wipe_schedule: string | null
|
||||||
|
discord_invite: string | null
|
||||||
|
player_count: number
|
||||||
|
max_players: number
|
||||||
|
mods: string[]
|
||||||
|
connect_url: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
const subdomain = route.params.subdomain as string
|
||||||
|
const serverInfo = ref<ServerInfo | null>(null)
|
||||||
|
const isLoading = ref(false)
|
||||||
|
const error = ref('')
|
||||||
|
|
||||||
|
async function fetchServerInfo() {
|
||||||
|
isLoading.value = true
|
||||||
|
error.value = ''
|
||||||
|
try {
|
||||||
|
const response = await fetch(`/api/public/${subdomain}/info`)
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Server not found')
|
||||||
|
}
|
||||||
|
serverInfo.value = await response.json()
|
||||||
|
} catch (err) {
|
||||||
|
error.value = err instanceof Error ? err.message : 'Failed to load server info'
|
||||||
|
} finally {
|
||||||
|
isLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyConnectUrl() {
|
||||||
|
if (serverInfo.value?.connect_url) {
|
||||||
|
navigator.clipboard.writeText(serverInfo.value.connect_url)
|
||||||
|
alert('Connect URL copied to clipboard')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
fetchServerInfo()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="p-6">
|
<div class="min-h-screen bg-neutral-950">
|
||||||
<h1 class="text-2xl font-bold text-neutral-100 mb-4">Server Info</h1>
|
<!-- Loading State -->
|
||||||
<p class="text-neutral-400">Public server information — rules, description, and connection details.</p>
|
<div v-if="isLoading" class="flex items-center justify-center min-h-screen">
|
||||||
|
<Loader2 class="w-8 h-8 text-oxide-500 animate-spin" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Error State -->
|
||||||
|
<div v-else-if="error" class="flex items-center justify-center min-h-screen p-6">
|
||||||
|
<div class="bg-neutral-900 border border-neutral-800 rounded-lg p-8 max-w-md text-center">
|
||||||
|
<Server class="w-12 h-12 text-neutral-600 mx-auto mb-4" />
|
||||||
|
<h1 class="text-xl font-bold text-neutral-100 mb-2">Server Not Found</h1>
|
||||||
|
<p class="text-sm text-neutral-400">{{ error }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Server Info -->
|
||||||
|
<div v-else-if="serverInfo" class="max-w-4xl mx-auto p-6 space-y-6">
|
||||||
|
<!-- Header Image -->
|
||||||
|
<div v-if="serverInfo.header_image" class="rounded-lg overflow-hidden">
|
||||||
|
<img :src="serverInfo.header_image" :alt="serverInfo.server_name" class="w-full h-64 object-cover" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Server Name & Stats -->
|
||||||
|
<div class="bg-neutral-900 border border-neutral-800 rounded-lg p-6">
|
||||||
|
<div class="flex items-start justify-between mb-4">
|
||||||
|
<div>
|
||||||
|
<h1 class="text-3xl font-bold text-neutral-100 mb-2">{{ serverInfo.server_name }}</h1>
|
||||||
|
<div class="flex items-center gap-2 text-neutral-400">
|
||||||
|
<Users class="w-4 h-4" />
|
||||||
|
<span class="text-sm">{{ serverInfo.player_count }}/{{ serverInfo.max_players }} players online</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
@click="copyConnectUrl"
|
||||||
|
class="flex items-center gap-2 px-4 py-2 bg-oxide-500 hover:bg-oxide-600 text-white font-medium rounded-lg transition-colors"
|
||||||
|
>
|
||||||
|
<ExternalLink class="w-4 h-4" />
|
||||||
|
Connect
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p v-if="serverInfo.description" class="text-neutral-300 leading-relaxed">
|
||||||
|
{{ serverInfo.description }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- MOTD -->
|
||||||
|
<div v-if="serverInfo.motd" class="bg-neutral-900 border border-neutral-800 rounded-lg p-6">
|
||||||
|
<h2 class="text-lg font-bold text-neutral-100 mb-3">Message of the Day</h2>
|
||||||
|
<p class="text-neutral-300 whitespace-pre-line">{{ serverInfo.motd }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Wipe Schedule -->
|
||||||
|
<div v-if="serverInfo.wipe_schedule" class="bg-neutral-900 border border-neutral-800 rounded-lg p-6">
|
||||||
|
<div class="flex items-center gap-2 mb-3">
|
||||||
|
<Calendar class="w-5 h-5 text-oxide-500" />
|
||||||
|
<h2 class="text-lg font-bold text-neutral-100">Wipe Schedule</h2>
|
||||||
|
</div>
|
||||||
|
<p class="text-neutral-300">{{ serverInfo.wipe_schedule }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Mods -->
|
||||||
|
<div v-if="serverInfo.mods.length > 0" class="bg-neutral-900 border border-neutral-800 rounded-lg p-6">
|
||||||
|
<h2 class="text-lg font-bold text-neutral-100 mb-3">Active Mods</h2>
|
||||||
|
<div class="flex flex-wrap gap-2">
|
||||||
|
<span
|
||||||
|
v-for="mod in serverInfo.mods"
|
||||||
|
:key="mod"
|
||||||
|
class="px-3 py-1 bg-neutral-800 border border-neutral-700 rounded-full text-sm text-neutral-300"
|
||||||
|
>
|
||||||
|
{{ mod }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Discord -->
|
||||||
|
<div v-if="serverInfo.discord_invite" class="bg-neutral-900 border border-neutral-800 rounded-lg p-6">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<MessageCircle class="w-5 h-5 text-oxide-500" />
|
||||||
|
<h2 class="text-lg font-bold text-neutral-100">Join our Discord</h2>
|
||||||
|
</div>
|
||||||
|
<a
|
||||||
|
:href="serverInfo.discord_invite"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
class="flex items-center gap-2 px-4 py-2 bg-neutral-800 hover:bg-neutral-700 text-neutral-200 font-medium rounded-lg transition-colors"
|
||||||
|
>
|
||||||
|
<ExternalLink class="w-4 h-4" />
|
||||||
|
Join
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user