feat: v3.1 대시보드 추가 (React + FastAPI)
Media Engine Control Panel — 6탭 웹 대시보드 [백엔드] FastAPI (dashboard/backend/) - server.py: 포트 8080, CORS, React SPA 서빙 - api_overview.py: KPI 카드 + 파이프라인 상태 + 활동 로그 - api_content.py: 칸반 보드 + 승인/거부 + 수동 트리거 - api_analytics.py: 방문자 추이 + 플랫폼/코너별 성과 - api_novels.py: 소설 목록/생성/에피소드 관리 - api_settings.py: engine.json CRUD - api_connections.py: AI 서비스 연결 관리 + 키 저장 - api_tools.py: 기능별 AI 도구 선택 - api_cost.py: 구독 현황 + API 사용량 추적 - api_logs.py: 시스템 로그 필터/검색 [프론트엔드] React + Vite + Tailwind + Recharts (dashboard/frontend/) - Overview: KPI 카드 + 파이프라인 + 코너별 바차트 + 활동 로그 - Content: 4열 칸반 보드 + 상세 모달 + 승인/거부 - Analytics: LineChart 방문자 추이 + 플랫폼별 성과 - Novel: 소설 목록 + 에피소드 테이블 + 새 소설 생성 폼 - Settings: 5개 서브탭 (AI연결/도구선택/배포채널/품질/비용관리) - Logs: 필터/검색 시스템 로그 뷰어 [디자인] CNN 다크+골드 테마 - 배경 #0a0a0d + 액센트 #c8a84e - 모바일 반응형 (Tailscale 외부 접속 대응) [실행] - dashboard/start.bat 더블클릭 → http://localhost:8080 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,113 @@
|
||||
"""
|
||||
dashboard/backend/api_tools.py
|
||||
Settings > 생성도구 선택 탭 API
|
||||
"""
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from pydantic import BaseModel
|
||||
|
||||
BASE_DIR = Path(__file__).parent.parent.parent
|
||||
CONFIG_PATH = BASE_DIR / "config" / "engine.json"
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
TOOL_CATEGORIES = {
|
||||
"writing": {
|
||||
"label": "글쓰기",
|
||||
"options": ["claude", "gemini", "openclaw"],
|
||||
"option_labels": {
|
||||
"claude": "Claude (Anthropic)",
|
||||
"gemini": "Google Gemini",
|
||||
"openclaw": "OpenClaw AI",
|
||||
},
|
||||
},
|
||||
"image_generation": {
|
||||
"label": "이미지 생성",
|
||||
"options": ["dalle", "external"],
|
||||
"option_labels": {
|
||||
"dalle": "DALL-E 3 (OpenAI)",
|
||||
"external": "수동 제공",
|
||||
},
|
||||
},
|
||||
"tts": {
|
||||
"label": "TTS (음성합성)",
|
||||
"options": ["google_cloud", "openai", "elevenlabs", "gtts"],
|
||||
"option_labels": {
|
||||
"google_cloud": "Google Cloud TTS",
|
||||
"openai": "OpenAI TTS (tts-1-hd)",
|
||||
"elevenlabs": "ElevenLabs",
|
||||
"gtts": "gTTS (무료)",
|
||||
},
|
||||
},
|
||||
"video_generation": {
|
||||
"label": "영상 생성",
|
||||
"options": ["ffmpeg_slides", "seedance", "runway", "sora", "veo"],
|
||||
"option_labels": {
|
||||
"ffmpeg_slides": "FFmpeg 슬라이드 (로컬)",
|
||||
"seedance": "Seedance 2.0",
|
||||
"runway": "Runway Gen-3",
|
||||
"sora": "OpenAI Sora",
|
||||
"veo": "Google Veo",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class ToolUpdate(BaseModel):
|
||||
tools: dict # {"writing": "claude", "tts": "gtts", ...}
|
||||
|
||||
|
||||
def _load_config() -> dict:
|
||||
if not CONFIG_PATH.exists():
|
||||
return {}
|
||||
try:
|
||||
return json.loads(CONFIG_PATH.read_text(encoding="utf-8"))
|
||||
except Exception:
|
||||
return {}
|
||||
|
||||
|
||||
@router.get("/tools")
|
||||
async def get_tools():
|
||||
"""현재 선택된 도구 + 선택 가능 목록 반환"""
|
||||
config = _load_config()
|
||||
result = {}
|
||||
|
||||
for category, meta in TOOL_CATEGORIES.items():
|
||||
current = config.get(category, {}).get("provider", meta["options"][0])
|
||||
result[category] = {
|
||||
"label": meta["label"],
|
||||
"current": current,
|
||||
"options": [
|
||||
{
|
||||
"value": opt,
|
||||
"label": meta["option_labels"].get(opt, opt),
|
||||
}
|
||||
for opt in meta["options"]
|
||||
],
|
||||
}
|
||||
|
||||
return {"tools": result}
|
||||
|
||||
|
||||
@router.put("/tools")
|
||||
async def update_tools(req: ToolUpdate):
|
||||
"""engine.json 도구 섹션 업데이트"""
|
||||
config = _load_config()
|
||||
|
||||
for category, provider in req.tools.items():
|
||||
if category in TOOL_CATEGORIES:
|
||||
if category not in config:
|
||||
config[category] = {}
|
||||
config[category]["provider"] = provider
|
||||
|
||||
try:
|
||||
CONFIG_PATH.parent.mkdir(parents=True, exist_ok=True)
|
||||
CONFIG_PATH.write_text(
|
||||
json.dumps(config, ensure_ascii=False, indent=2),
|
||||
encoding="utf-8"
|
||||
)
|
||||
return {"success": True, "message": "도구 설정 저장 완료"}
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"저장 실패: {e}")
|
||||
Reference in New Issue
Block a user