Add persistent match history to server pages
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { serverMatchHistory } from '$lib/server/fleet/match-history.js';
|
||||
|
||||
export function GET({ params, url }: { params: { name: string }; url: URL }) {
|
||||
const limit = Number(url.searchParams.get('limit') ?? 25);
|
||||
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 10000) {
|
||||
return json({ error: 'limit must be between 1 and 10000' }, { status: 400 });
|
||||
}
|
||||
return json(serverMatchHistory(params.name, limit));
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import MatchHistory from '$ui/components/MatchHistory.svelte';
|
||||
import RoundTelemetry from '$ui/components/RoundTelemetry.svelte';
|
||||
import TelemetryDiagnostics from '$ui/components/TelemetryDiagnostics.svelte';
|
||||
import { pollVisible } from '$ui/poll.js';
|
||||
@@ -102,7 +103,7 @@
|
||||
let rconProbe = $state<RconProbeResult | null>(null);
|
||||
let probingRcon = $state(false);
|
||||
let destroyOpen = $state(false);
|
||||
const sectionIds = ['scoreboard', 'chat', 'logs', 'config', 'inventory', 'diagnostics', 'history'];
|
||||
const sectionIds = ['scoreboard', 'matches', 'chat', 'logs', 'config', 'inventory', 'diagnostics', 'history'];
|
||||
const activeTab = $derived(sectionIds.includes($page.url.searchParams.get('tab') ?? '') ? $page.url.searchParams.get('tab')! : 'scoreboard');
|
||||
function changeTab(tab: string) {
|
||||
const url = new URL($page.url);
|
||||
@@ -214,6 +215,7 @@
|
||||
let tabs = $derived([
|
||||
{ id: 'scoreboard', label: 'Scoreboard', badge: scoreboard?.players.length ?? null },
|
||||
{ id: 'chat', label: 'Chat' },
|
||||
{ id: 'matches', label: 'Matches' },
|
||||
{ id: 'logs', label: 'Logs' },
|
||||
{ id: 'config', label: 'Config' },
|
||||
{ id: 'inventory', label: 'Inventory', badge: inventory.length || null },
|
||||
@@ -516,6 +518,8 @@
|
||||
</div>
|
||||
</Card>
|
||||
<div id="telemetry">{#key name}<TelemetryDiagnostics server={name} />{/key}</div>
|
||||
{:else if activeTab === 'matches'}
|
||||
{#key name}<MatchHistory server={name} />{/key}
|
||||
{:else if activeTab === 'history'}
|
||||
{#if operations.length}
|
||||
<Card padding="lg">
|
||||
|
||||
Reference in New Issue
Block a user