feat: Implement server endpoints, store, and live dashboard

Backend: Server connection/config/admins DB queries, server API routes
with auth-gated endpoints (overview, config CRUD, admin management).
Frontend: Server store wired to API, dashboard fetches server data on
mount with live status indicators, uptime formatting, and server
config display. Logout now redirects to /login.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Vantz Stockwell
2026-02-14 21:51:49 -05:00
parent 5668675b6a
commit a53cb4d8a5
5 changed files with 387 additions and 85 deletions

View File

@@ -1,6 +1,7 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
import type { ServerConnection, ServerConfig, ServerStats } from '@/types'
import { useApi } from '@/composables/useApi'
export const useServerStore = defineStore('server', () => {
const connection = ref<ServerConnection | null>(null)
@@ -8,28 +9,45 @@ export const useServerStore = defineStore('server', () => {
const stats = ref<ServerStats | null>(null)
const isLoading = ref(false)
async function fetchServerStatus() {
// TODO: Fetch from API
const api = useApi()
async function fetchServer() {
isLoading.value = true
try {
const data = await api.get<{ connection: ServerConnection | null; config: ServerConfig | null }>('/servers')
connection.value = data.connection
config.value = data.config
} catch (e) {
console.error('Failed to fetch server:', e)
} finally {
isLoading.value = false
}
}
async function fetchServerConfig() {
// TODO: Fetch from API
}
async function startServer() {
// TODO: POST /api/servers/:id/start
}
async function stopServer() {
// TODO: POST /api/servers/:id/stop
}
async function restartServer() {
// TODO: POST /api/servers/:id/restart
async function updateConfig(updates: Partial<ServerConfig>) {
try {
await api.put('/servers/config', updates)
await fetchServer()
} catch (e) {
console.error('Failed to update config:', e)
throw e
}
}
async function sendCommand(command: string) {
// TODO: POST /api/servers/:id/command
return api.post('/servers/command', { command })
}
async function startServer() {
return api.post('/servers/start')
}
async function stopServer() {
return api.post('/servers/stop')
}
async function restartServer() {
return api.post('/servers/restart')
}
function updateStats(newStats: ServerStats) {
@@ -41,12 +59,12 @@ export const useServerStore = defineStore('server', () => {
config,
stats,
isLoading,
fetchServerStatus,
fetchServerConfig,
fetchServer,
updateConfig,
sendCommand,
startServer,
stopServer,
restartServer,
sendCommand,
updateStats,
}
})