Feat: Add System Control (Standby Mode) and Resource Monitor
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
---
|
||||
import AdminLayout from '../../layouts/AdminLayout.astro';
|
||||
import SystemMonitor from '../../components/admin/dashboard/SystemMonitor';
|
||||
import SystemControl from '../../components/admin/SystemControl';
|
||||
---
|
||||
|
||||
<AdminLayout title="Mission Control">
|
||||
@@ -9,6 +10,10 @@ import SystemMonitor from '../../components/admin/dashboard/SystemMonitor';
|
||||
<h1 class="text-3xl font-bold text-white mb-2">Command Station</h1>
|
||||
<p class="text-slate-400">System Monitoring, Sub-Station Status, and Content Integrity.</p>
|
||||
</div>
|
||||
|
||||
<div class="mb-8">
|
||||
<SystemControl client:load />
|
||||
</div>
|
||||
|
||||
<SystemMonitor client:load />
|
||||
</div>
|
||||
|
||||
33
src/pages/api/god/system/control.ts
Normal file
33
src/pages/api/god/system/control.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { APIRoute } from 'astro';
|
||||
import { system } from '@/lib/system/SystemController';
|
||||
|
||||
// GET: Retrieve current metrics and state
|
||||
export const GET: APIRoute = async () => {
|
||||
const metrics = await system.getMetrics();
|
||||
|
||||
return new Response(JSON.stringify(metrics), {
|
||||
status: 200,
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
};
|
||||
|
||||
// POST: Toggle state
|
||||
export const POST: APIRoute = async ({ request }) => {
|
||||
try {
|
||||
const body = await request.json();
|
||||
|
||||
if (body.action === 'toggle') {
|
||||
const newState = system.toggle();
|
||||
return new Response(JSON.stringify({
|
||||
success: true,
|
||||
state: newState,
|
||||
message: `System is now ${newState.toUpperCase()}`
|
||||
}));
|
||||
}
|
||||
|
||||
return new Response(JSON.stringify({ error: 'Invalid action' }), { status: 400 });
|
||||
|
||||
} catch (e: any) {
|
||||
return new Response(JSON.stringify({ error: e.message }), { status: 500 });
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user