God Mode Valhalla: Initial Standalone Commit

This commit is contained in:
cawcenter
2025-12-14 19:19:14 -05:00
commit 153102b23e
127 changed files with 30781 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
---
import Layout from '@/layouts/AdminLayout.astro';
import ContentFactoryDashboard from '@/components/admin/content/ContentFactoryDashboard';
---
<Layout title="Factory Command Center">
<div class="p-8">
<ContentFactoryDashboard client:load />
</div>
</Layout>

View File

@@ -0,0 +1,180 @@
---
// src/pages/admin/db-console.astro
import Layout from '@/layouts/BaseLayout.astro'; // Assuming BaseLayout exists, or check existing layout
import { MECHANIC_OPS } from '@/lib/db/mechanic';
// Server-side Logic (runs on build or request in SSR)
let health;
try {
health = await MECHANIC_OPS.getHealth();
} catch (e) {
console.error('Failed to get health:', e);
health = {
size: 'Error',
connections: [],
cache: { ratio: 0 }
};
}
const activeConnections = health.connections.find((c: any) => c.state === 'active')?.active || 0;
const idleConnections = health.connections.find((c: any) => c.state === 'idle')?.active || 0;
const token = import.meta.env.GOD_MODE_TOKEN || '';
---
<html lang="en" class="dark">
<head>
<meta charset="UTF-8">
<title>DB Command Center - Valhalla</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
colors: {
zinc: { 800: '#27272a', 900: '#18181b' }
}
}
}
}
</script>
</head>
<body class="bg-zinc-900 text-white min-h-screen">
<div class="p-8 space-y-8 max-w-7xl mx-auto">
<header class="flex justify-between items-center mb-8">
<div>
<h1 class="text-3xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-yellow-400 to-red-500">
Valhalla DB Command Center
</h1>
<p class="text-gray-400">Direct PostgreSQL Interface</p>
</div>
<a href="/" class="text-gray-400 hover:text-white">Back to Dashboard</a>
</header>
<!-- Stats Grid -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<div class="bg-zinc-800 p-6 rounded-lg border-l-4 border-green-500 shadow-lg">
<h3 class="text-gray-400 text-sm uppercase font-semibold">DB Size</h3>
<p class="text-4xl font-bold mt-2">{health.size}</p>
</div>
<div class="bg-zinc-800 p-6 rounded-lg border-l-4 border-blue-500 shadow-lg">
<h3 class="text-gray-400 text-sm uppercase font-semibold">Connections</h3>
<div class="flex items-end gap-2 mt-2">
<p class="text-4xl font-bold">{activeConnections}</p>
<span class="text-xl text-gray-500">active</span>
</div>
<p class="text-sm text-gray-500 mt-1">{idleConnections} idle</p>
</div>
<div class="bg-zinc-800 p-6 rounded-lg border-l-4 border-purple-500 shadow-lg">
<h3 class="text-gray-400 text-sm uppercase font-semibold">Cache Efficiency</h3>
<p class="text-4xl font-bold mt-2">{Math.round(health.cache.ratio * 100)}%</p>
</div>
</div>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
<!-- Emergency Controls -->
<div class="bg-zinc-800/50 border border-zinc-700 p-6 rounded-xl">
<h2 class="text-xl mb-6 text-red-400 flex items-center gap-2">
<span>🚨</span> Emergency Fixes
</h2>
<div class="space-y-4">
<button onclick="runOp('vacuum')" class="w-full group relative overflow-hidden bg-yellow-600 hover:bg-yellow-500 transition-all p-4 rounded-lg font-bold text-left flex justify-between items-center">
<div>
<div class="text-white">Run Vacuum</div>
<div class="text-xs text-yellow-200 opacity-70">Optimize dead rows</div>
</div>
<span class="text-2xl opacity-50 group-hover:opacity-100">🧹</span>
</button>
<button onclick="runOp('reindex')" class="w-full group relative overflow-hidden bg-orange-600 hover:bg-orange-500 transition-all p-4 rounded-lg font-bold text-left flex justify-between items-center">
<div>
<div class="text-white">Reindex Database</div>
<div class="text-xs text-orange-200 opacity-70">Fix corrupted indexes</div>
</div>
<span class="text-2xl opacity-50 group-hover:opacity-100">📑</span>
</button>
<button onclick="runOp('kill_locks')" class="w-full group relative overflow-hidden bg-red-700 hover:bg-red-600 transition-all p-4 rounded-lg font-bold text-left flex justify-between items-center">
<div>
<div class="text-white">Kill Stuck Queries</div>
<div class="text-xs text-red-200 opacity-70">Terminate > 5min processes</div>
</div>
<span class="text-2xl opacity-50 group-hover:opacity-100">💀</span>
</button>
</div>
</div>
<!-- Throttles -->
<div class="lg:col-span-2 bg-zinc-800/50 border border-zinc-700 p-6 rounded-xl">
<h2 class="text-xl mb-6 text-blue-400 flex items-center gap-2">
<span>🎚️</span> Factory Throttles
</h2>
<form id="throttleForm" class="space-y-8">
<div class="space-y-2">
<div class="flex justify-between">
<label class="font-medium text-gray-300">Batch Size (Items per Chunk)</label>
<span class="text-blue-400 font-mono" id="batchOutput">100</span>
</div>
<input type="range" min="10" max="1000" value="100" step="10"
class="w-full h-2 bg-zinc-700 rounded-lg appearance-none cursor-pointer accent-blue-500"
oninput="document.getElementById('batchOutput').textContent = this.value + ' rows'">
<p class="text-sm text-gray-500">Higher values use more memory but process faster.</p>
</div>
<div class="space-y-2">
<div class="flex justify-between">
<label class="font-medium text-gray-300">Concurrency (Parallel Workers)</label>
<span class="text-blue-400 font-mono" id="concurrencyOutput">5</span>
</div>
<input type="range" min="1" max="50" value="5" step="1"
class="w-full h-2 bg-zinc-700 rounded-lg appearance-none cursor-pointer accent-blue-500"
oninput="document.getElementById('concurrencyOutput').textContent = this.value + ' threads'">
<p class="text-sm text-gray-500">Higher values allow more simultaneous DB connections.</p>
</div>
<div class="pt-4 border-t border-zinc-700">
<button type="button" class="bg-blue-600 hover:bg-blue-500 text-white px-8 py-3 rounded-lg font-bold transition-colors">
Update Runtime Engine
</button>
</div>
</form>
</div>
</div>
</div>
<!-- Hidden Token for Client Script -->
<div id="god-token" data-token={token} style="display:none;"></div>
<script is:inline>
async function runOp(operation) {
const token = document.getElementById('god-token')?.dataset.token;
if(!confirm(`⚠️ Are you sure you want to RUN ${operation.toUpperCase()}? This may affect database performance.`)) return;
try {
const res = await fetch('/api/god/db-ops', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({ operation })
});
const text = await res.text();
if (res.ok) {
alert('✅ Success: ' + text);
location.reload();
} else {
alert('❌ Error: ' + text);
}
} catch (err) {
alert('Connection Error: ' + err.message);
}
}
</script>
</body>
</html>

View File

@@ -0,0 +1,20 @@
---
import Layout from '@/layouts/AdminLayout.astro';
import PostEditor from '@/components/admin/posts/PostEditor';
const { id } = Astro.params;
---
<Layout title="Edit Post">
<div class="p-6">
<div class="mb-6">
<a href="/admin/posts" class="text-slate-400 hover:text-white flex items-center gap-2 mb-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18" /></svg>
Back to Posts
</a>
<h1 class="text-3xl font-bold text-slate-100">Edit Post</h1>
</div>
<PostEditor id={id} client:only="react" />
</div>
</Layout>

View File

@@ -0,0 +1,21 @@
---
import Layout from '@/layouts/AdminLayout.astro';
import PostList from '@/components/admin/posts/PostList';
---
<Layout title="Post Management">
<div class="p-6 space-y-6">
<div class="flex justify-between items-center">
<div>
<h1 class="text-3xl font-bold text-slate-100">Posts</h1>
<p class="text-slate-400">Manage blog posts and articles.</p>
</div>
<a href="/admin/posts/new" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg font-medium transition-colors 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>
New Post
</a>
</div>
<PostList client:load />
</div>
</Layout>

View File

@@ -0,0 +1,20 @@
---
import Layout from '@/layouts/AdminLayout.astro';
import SiteEditor from '@/components/admin/sites/SiteEditor';
const { id } = Astro.params;
---
<Layout title="Edit Site">
<div class="p-6">
<div class="mb-6">
<a href="/admin/sites" class="text-slate-400 hover:text-white flex items-center gap-2 mb-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18" /></svg>
Back to Sites
</a>
<h1 class="text-3xl font-bold text-slate-100">Configure Site</h1>
</div>
<SiteEditor id={id} client:only="react" />
</div>
</Layout>

View File

@@ -0,0 +1,28 @@
---
import Layout from '@/layouts/AdminLayout.astro';
import SiteDashboard from '@/components/admin/sites/SiteDashboard';
import { Button } from '@/components/ui/button';
import { ArrowLeft } from 'lucide-react';
const { siteId } = Astro.params;
---
<Layout title="Manage Site | Spark Launchpad">
<div class="h-screen flex flex-col">
<div class="border-b border-zinc-800 bg-zinc-950 p-4 flex items-center gap-4">
<a href="/admin/sites">
<Button variant="ghost" size="icon" class="text-zinc-400 hover:text-white">
<ArrowLeft className="h-4 w-4" />
</Button>
</a>
<div>
<h1 class="text-xl font-bold text-white tracking-tight">Site Management</h1>
<p class="text-xs text-zinc-500 font-mono">ID: {siteId}</p>
</div>
</div>
<div class="flex-1 overflow-auto p-8">
<SiteDashboard client:only="react" siteId={siteId!} />
</div>
</div>
</Layout>

View File

@@ -0,0 +1,10 @@
---
import Layout from '@/layouts/AdminLayout.astro';
import PageEditor from '@/components/admin/sites/PageEditor';
const { pageId } = Astro.params;
---
<Layout title="Page Editor | Spark Launchpad" hideSidebar={true}>
<PageEditor client:only="react" pageId={pageId!} onBack={() => history.back()} />
</Layout>

View File

@@ -0,0 +1,18 @@
---
import Layout from '@/layouts/AdminLayout.astro';
import WPImporter from '@/components/admin/wordpress/WPImporter';
---
<Layout title="Import WordPress Site">
<div class="p-6 space-y-6">
<div class="flex items-center gap-2 text-slate-400 text-sm">
<a href="/admin/sites" class="hover:text-blue-400">Sites</a>
<span>/</span>
<span class="text-white">Import Wizard</span>
</div>
<h1 class="text-3xl font-bold text-slate-100">Content Import & Refactor</h1>
<WPImporter client:load />
</div>
</Layout>

View File

@@ -0,0 +1,22 @@
---
import Layout from '@/layouts/AdminLayout.astro';
import SitesManager from '@/components/admin/sites/SitesManager';
import { CoreProvider } from '@/components/providers/CoreProviders';
---
<Layout title="Sites | Spark Launchpad">
<div class="p-8 space-y-6">
<div class="flex justify-between items-start">
<div>
<h1 class="text-3xl font-bold text-white tracking-tight">🚀 Launchpad</h1>
<p class="text-zinc-400 mt-2 max-w-2xl">
Deploy and manage multiple websites from a single dashboard.
</p>
</div>
</div>
<CoreProvider client:load>
<SitesManager client:only="react" />
</CoreProvider>
</div>
</Layout>

View File

@@ -0,0 +1,10 @@
---
import Layout from '@/layouts/AdminLayout.astro';
import JumpstartWizard from '@/components/admin/jumpstart/JumpstartWizard';
---
<Layout title="Guided Jumpstart Test">
<div class="p-8">
<JumpstartWizard client:load />
</div>
</Layout>