feat: Pipeline-System Frontend - Admin UI (Issue #28, Phase 2 Part 1)
Implementiert Admin-UI für Pipeline-Konfigurationen: - Pipeline-Config Dialog mit Module-Auswahl - Stage-Konfiguration (Stage 1/2/3 Prompts) - Admin-UI: Zwei Tabs (Prompts + Pipeline-Configs) - CRUD-Operationen für Pipeline-Configs - API-Integration: Pipeline-Config Endpoints **Frontend:** - components/PipelineConfigModal.jsx (neu): Dialog für Pipeline-Konfiguration - Module-Auswahl mit Zeiträumen (7 Module) - Stage 1: Multi-Select für parallele Prompts - Stage 2: Synthese-Prompt Auswahl - Stage 3: Optional (Goals) - Validierung (mind. 1 Modul, mind. 1 Stage-1-Prompt, Stage-2 erforderlich) - pages/AdminPromptsPage.jsx (erweitert): Tab-Navigation - Tab 1: Prompts (bestehend) - Tab 2: Pipeline-Konfigurationen (neu) - Liste aller Configs mit Status (Aktiv, Standard) - Aktionen: Bearbeiten, Löschen, Als Standard setzen - Icons: Star, Edit, Trash2 - utils/api.js (erweitert): - listPipelineConfigs, createPipelineConfig, updatePipelineConfig - deletePipelineConfig, setDefaultPipelineConfig - executePipeline, resetPromptToDefault **Nächste Schritte:** - Pipeline-Auswahl in AnalysisPage (User-Seite) - Mobile-Responsive Design Issue #28 Progress: Frontend 2/3 (67%) | Design 0/3 | Testing 0/1 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
053a9e18cf
commit
b23e361791
3 files changed
+605
-6
No files matched your search
@@ -1,8 +1,13 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import { api } from '../utils/api'
|
||||
import PromptEditModal from '../components/PromptEditModal'
|
||||
import PipelineConfigModal from '../components/PipelineConfigModal'
|
||||
import { Star, Trash2, Edit, Copy } from 'lucide-react'
|
||||
|
||||
export default function AdminPromptsPage() {
|
||||
const [activeTab, setActiveTab] = useState('prompts') // 'prompts' | 'pipelines'
|
||||
|
||||
// Prompts state
|
||||
const [prompts, setPrompts] = useState([])
|
||||
const [filteredPrompts, setFilteredPrompts] = useState([])
|
||||
const [category, setCategory] = useState('all')
|
||||
@@ -11,6 +16,12 @@ export default function AdminPromptsPage() {
|
||||
const [editingPrompt, setEditingPrompt] = useState(null)
|
||||
const [showNewPrompt, setShowNewPrompt] = useState(false)
|
||||
|
||||
// Pipeline configs state
|
||||
const [pipelineConfigs, setPipelineConfigs] = useState([])
|
||||
const [pipelineLoading, setPipelineLoading] = useState(false)
|
||||
const [editingPipeline, setEditingPipeline] = useState(null)
|
||||
const [showNewPipeline, setShowNewPipeline] = useState(false)
|
||||
|
||||
const categories = [
|
||||
{ id: 'all', label: 'Alle Kategorien' },
|
||||
{ id: 'körper', label: 'Körper' },
|
||||
@@ -24,6 +35,7 @@ export default function AdminPromptsPage() {
|
||||
|
||||
useEffect(() => {
|
||||
loadPrompts()
|
||||
loadPipelineConfigs()
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
@@ -116,6 +128,45 @@ export default function AdminPromptsPage() {
|
||||
setShowNewPrompt(false)
|
||||
}
|
||||
|
||||
// Pipeline Config handlers
|
||||
const loadPipelineConfigs = async () => {
|
||||
try {
|
||||
setPipelineLoading(true)
|
||||
const data = await api.listPipelineConfigs()
|
||||
setPipelineConfigs(data)
|
||||
} catch (e) {
|
||||
setError(e.message)
|
||||
} finally {
|
||||
setPipelineLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
const handleDeletePipeline = async (config) => {
|
||||
if (!confirm(`Pipeline-Config "${config.name}" wirklich löschen?`)) return
|
||||
|
||||
try {
|
||||
await api.deletePipelineConfig(config.id)
|
||||
await loadPipelineConfigs()
|
||||
} catch (e) {
|
||||
alert('Fehler: ' + e.message)
|
||||
}
|
||||
}
|
||||
|
||||
const handleSetDefaultPipeline = async (config) => {
|
||||
try {
|
||||
await api.setDefaultPipelineConfig(config.id)
|
||||
await loadPipelineConfigs()
|
||||
} catch (e) {
|
||||
alert('Fehler: ' + e.message)
|
||||
}
|
||||
}
|
||||
|
||||
const handleSavePipeline = async () => {
|
||||
await loadPipelineConfigs()
|
||||
setEditingPipeline(null)
|
||||
setShowNewPipeline(false)
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="page">
|
||||
@@ -129,12 +180,38 @@ export default function AdminPromptsPage() {
|
||||
return (
|
||||
<div className="page">
|
||||
<div style={{display:'flex', justifyContent:'space-between', alignItems:'center', marginBottom:24}}>
|
||||
<h1 className="page-title">KI-Prompts Verwaltung</h1>
|
||||
<h1 className="page-title">KI-Prompts & Pipelines</h1>
|
||||
<button
|
||||
className="btn btn-primary"
|
||||
onClick={() => setShowNewPrompt(true)}
|
||||
onClick={() => activeTab === 'prompts' ? setShowNewPrompt(true) : setShowNewPipeline(true)}
|
||||
>
|
||||
+ Neuer Prompt
|
||||
{activeTab === 'prompts' ? '+ Neuer Prompt' : '+ Neue Pipeline'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Tab Switcher */}
|
||||
<div style={{display:'flex', gap:12, marginBottom:24, borderBottom:'2px solid var(--border)'}}>
|
||||
<button
|
||||
onClick={() => setActiveTab('prompts')}
|
||||
style={{
|
||||
padding:'12px 24px', background:'none', border:'none',
|
||||
borderBottom: activeTab === 'prompts' ? '2px solid var(--accent)' : '2px solid transparent',
|
||||
marginBottom:-2, cursor:'pointer', fontSize:14, fontWeight:activeTab === 'prompts' ? 600 : 400,
|
||||
color: activeTab === 'prompts' ? 'var(--accent)' : 'var(--text2)'
|
||||
}}
|
||||
>
|
||||
Prompts ({prompts.length})
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setActiveTab('pipelines')}
|
||||
style={{
|
||||
padding:'12px 24px', background:'none', border:'none',
|
||||
borderBottom: activeTab === 'pipelines' ? '2px solid var(--accent)' : '2px solid transparent',
|
||||
marginBottom:-2, cursor:'pointer', fontSize:14, fontWeight:activeTab === 'pipelines' ? 600 : 400,
|
||||
color: activeTab === 'pipelines' ? 'var(--accent)' : 'var(--text2)'
|
||||
}}
|
||||
>
|
||||
Pipeline-Konfigurationen ({pipelineConfigs.length})
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -144,8 +221,11 @@ export default function AdminPromptsPage() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Category Filter */}
|
||||
<div style={{marginBottom:24}}>
|
||||
{/* Prompts Tab */}
|
||||
{activeTab === 'prompts' && (
|
||||
<>
|
||||
{/* Category Filter */}
|
||||
<div style={{marginBottom:24}}>
|
||||
<label style={{fontSize:13, fontWeight:600, marginBottom:8, display:'block'}}>
|
||||
Kategorie filtern:
|
||||
</label>
|
||||
@@ -276,8 +356,119 @@ export default function AdminPromptsPage() {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Edit Modal */}
|
||||
{/* Pipelines Tab */}
|
||||
{activeTab === 'pipelines' && (
|
||||
<>
|
||||
{pipelineLoading ? (
|
||||
<div style={{textAlign:'center', padding:40}}>
|
||||
<div className="spinner"/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="card">
|
||||
<table style={{width:'100%', borderCollapse:'collapse'}}>
|
||||
<thead>
|
||||
<tr style={{borderBottom:'2px solid var(--border)', textAlign:'left'}}>
|
||||
<th style={{padding:'12px 8px', fontSize:12, fontWeight:600, color:'var(--text3)'}}>Name</th>
|
||||
<th style={{padding:'12px 8px', fontSize:12, fontWeight:600, color:'var(--text3)'}}>Module</th>
|
||||
<th style={{padding:'12px 8px', fontSize:12, fontWeight:600, color:'var(--text3)'}}>Stages</th>
|
||||
<th style={{padding:'12px 8px', fontSize:12, fontWeight:600, color:'var(--text3)'}}>Status</th>
|
||||
<th style={{padding:'12px 8px', fontSize:12, fontWeight:600, color:'var(--text3)'}}>Aktionen</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{pipelineConfigs.map(config => {
|
||||
const activeModules = Object.entries(config.modules || {}).filter(([_, active]) => active)
|
||||
|
||||
return (
|
||||
<tr key={config.id} style={{borderBottom:'1px solid var(--border)'}}>
|
||||
<td style={{padding:'12px 8px'}}>
|
||||
<div style={{fontWeight:500, fontSize:14}}>{config.name}</div>
|
||||
{config.is_default && (
|
||||
<span style={{
|
||||
fontSize:10, padding:'2px 6px', background:'var(--accent)',
|
||||
color:'white', borderRadius:3, marginTop:4, display:'inline-block'
|
||||
}}>
|
||||
Standard
|
||||
</span>
|
||||
)}
|
||||
{config.description && (
|
||||
<div style={{fontSize:11, color:'var(--text3)', marginTop:2}}>
|
||||
{config.description}
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
<td style={{padding:'12px 8px'}}>
|
||||
<div style={{fontSize:11}}>
|
||||
{activeModules.map(([name]) => name).join(', ')}
|
||||
</div>
|
||||
<div style={{fontSize:10, color:'var(--text3)', marginTop:2}}>
|
||||
{activeModules.length} Module
|
||||
</div>
|
||||
</td>
|
||||
<td style={{padding:'12px 8px'}}>
|
||||
<div style={{fontSize:11}}>
|
||||
S1: {config.stage1_prompts?.length || 0} Prompts
|
||||
</div>
|
||||
<div style={{fontSize:10, color:'var(--text3)'}}>
|
||||
S2: {config.stage2_prompt ? '✓' : '-'} | S3: {config.stage3_prompt ? '✓' : '-'}
|
||||
</div>
|
||||
</td>
|
||||
<td style={{padding:'12px 8px'}}>
|
||||
<span style={{
|
||||
fontSize:11, padding:'3px 8px', borderRadius:4,
|
||||
background: config.active ? 'var(--accent-light)' : 'var(--surface2)',
|
||||
color: config.active ? 'var(--accent)' : 'var(--text3)'
|
||||
}}>
|
||||
{config.active ? 'Aktiv' : 'Inaktiv'}
|
||||
</span>
|
||||
</td>
|
||||
<td style={{padding:'12px 8px'}}>
|
||||
<div style={{display:'flex', gap:6}}>
|
||||
{!config.is_default && (
|
||||
<button
|
||||
onClick={() => handleSetDefaultPipeline(config)}
|
||||
style={{padding:'4px 8px', fontSize:11}}
|
||||
title="Als Standard setzen"
|
||||
>
|
||||
<Star size={14} />
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
onClick={() => setEditingPipeline(config)}
|
||||
style={{padding:'4px 8px', fontSize:11}}
|
||||
title="Bearbeiten"
|
||||
>
|
||||
<Edit size={14} />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleDeletePipeline(config)}
|
||||
style={{padding:'4px 8px', fontSize:11, color:'var(--danger)'}}
|
||||
title="Löschen"
|
||||
>
|
||||
<Trash2 size={14} />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{pipelineConfigs.length === 0 && (
|
||||
<div style={{padding:40, textAlign:'center', color:'var(--text3)'}}>
|
||||
Noch keine Pipeline-Konfigurationen vorhanden
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Edit Modals */}
|
||||
{(editingPrompt || showNewPrompt) && (
|
||||
<PromptEditModal
|
||||
prompt={editingPrompt}
|
||||
@@ -288,6 +479,17 @@ export default function AdminPromptsPage() {
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
{(editingPipeline || showNewPipeline) && (
|
||||
<PipelineConfigModal
|
||||
config={editingPipeline}
|
||||
onSave={handleSavePipeline}
|
||||
onClose={() => {
|
||||
setEditingPipeline(null)
|
||||
setShowNewPipeline(false)
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user