Unify UI workflows and streamline fleet management
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { getServer } from '$lib/server/fleet/servers.js';
|
||||
import { listServerScripts } from '$lib/server/fleet/inventory.js';
|
||||
import { db } from '$lib/server/db/index.js';
|
||||
|
||||
export async function GET({ params }: { params: { name: string } }) {
|
||||
const server = getServer(params.name);
|
||||
if (!server) return json({ ok: false, error: 'no such server' }, { status: 404 });
|
||||
const metadata = db().prepare(`SELECT i.rel_path, s.kind FROM server_scripts i
|
||||
JOIN script_versions v ON v.id = i.script_version_id JOIN scripts s ON s.id = v.script_id
|
||||
WHERE i.server = ?`).all(params.name) as Array<{ rel_path: string; kind: string }>;
|
||||
const kinds = new Map(metadata.map(row => [row.rel_path, row.kind]));
|
||||
const scripts = listServerScripts(params.name).map((r) => ({
|
||||
relPath: r.rel_path,
|
||||
kind: kinds.get(r.rel_path) ?? (/\.cfg$/i.test(r.rel_path) ? 'config' : /\.dll$/i.test(r.rel_path) ? 'plugin' : /\.gsc$/i.test(r.rel_path) ? 'script' : 'file'),
|
||||
scriptVersionId: r.script_version_id,
|
||||
sha256: r.sha256,
|
||||
size: r.size,
|
||||
|
||||
Reference in New Issue
Block a user