feat: autogen admin panel — schedule, queue, topic bank, run controls

This commit is contained in:
Alexey Pavlov
2026-05-31 14:48:38 +03:00
parent 14053131cd
commit 980d39c6a0
7 changed files with 384 additions and 1 deletions
+28
View File
@@ -0,0 +1,28 @@
import { requireAdminAuth } from '@/lib/adminAuth';
import AutogenPanel from '@/components/admin/AutogenPanel';
export const dynamic = 'force-dynamic';
export const metadata = { title: 'Автогенерация' };
const ENGINE_URL = process.env.ENGINE_URL || 'http://127.0.0.1:3030';
const ENGINE_SECRET = process.env.ENGINE_SECRET || 'zeropost_internal_2026';
async function engineCall(path) {
const res = await fetch(`${ENGINE_URL}${path}`, {
headers: { 'x-internal-secret': ENGINE_SECRET },
cache: 'no-store',
});
if (!res.ok) return null;
return res.json();
}
export default async function AutogenPage() {
await requireAdminAuth();
const [status, queue, topics] = await Promise.all([
engineCall('/api/autogen/status'),
engineCall('/api/autogen/queue'),
engineCall('/api/autogen/topics'),
]);
return <AutogenPanel status={status || []} queue={queue || []} topics={topics || {}} />;
}
+10
View File
@@ -0,0 +1,10 @@
import { NextResponse } from 'next/server';
import { checkAdminAuth } from '@/lib/adminAuth';
const E = process.env.ENGINE_URL||'http://127.0.0.1:3030';
const S = process.env.ENGINE_SECRET||'zeropost_internal_2026';
export async function DELETE(req, { params }) {
if (!(await checkAdminAuth())) return NextResponse.json({error:'Unauthorized'},{status:401});
const { id } = await params;
await fetch(`${E}/api/autogen/queue/${id}`,{method:'DELETE',headers:{'x-internal-secret':S}});
return NextResponse.json({ok:true});
}
+11
View File
@@ -0,0 +1,11 @@
import { NextResponse } from 'next/server';
import { checkAdminAuth } from '@/lib/adminAuth';
const E = process.env.ENGINE_URL||'http://127.0.0.1:3030';
const S = process.env.ENGINE_SECRET||'zeropost_internal_2026';
const h = { 'Content-Type':'application/json','x-internal-secret':S };
export async function POST(req) {
if (!(await checkAdminAuth())) return NextResponse.json({error:'Unauthorized'},{status:401});
const body = await req.json();
const res = await fetch(`${E}/api/autogen/queue`,{method:'POST',headers:h,body:JSON.stringify(body)});
return NextResponse.json(await res.json());
}
+13
View File
@@ -0,0 +1,13 @@
import { NextResponse } from 'next/server';
import { checkAdminAuth } from '@/lib/adminAuth';
const E = process.env.ENGINE_URL || 'http://127.0.0.1:3030';
const S = process.env.ENGINE_SECRET || 'zeropost_internal_2026';
const h = { 'Content-Type': 'application/json', 'x-internal-secret': S };
export async function POST(req) {
if (!(await checkAdminAuth())) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
const body = await req.json();
const res = await fetch(`${E}/api/autogen/run`, { method: 'POST', headers: h, body: JSON.stringify(body) });
return NextResponse.json(await res.json());
}
+11
View File
@@ -0,0 +1,11 @@
import { NextResponse } from 'next/server';
import { checkAdminAuth } from '@/lib/adminAuth';
const E = process.env.ENGINE_URL||'http://127.0.0.1:3030';
const S = process.env.ENGINE_SECRET||'zeropost_internal_2026';
const h = { 'Content-Type':'application/json','x-internal-secret':S };
export async function PATCH(req) {
if (!(await checkAdminAuth())) return NextResponse.json({error:'Unauthorized'},{status:401});
const { category, ...data } = await req.json();
const res = await fetch(`${E}/api/autogen/settings/${category}`,{method:'PATCH',headers:h,body:JSON.stringify(data)});
return NextResponse.json(await res.json());
}