Add campaign layer, GPU model caching, file browser cleanup
- Campaigns: new table, CRUD API, React context + provider
- Sessions: scoped to campaigns, paths under campaigns/{id}/
- File browser: scoped per campaign, removed copy/paste/autoPlay
- Sidebar: campaign selector dropdown at top
- Transcribe: GPU model cached/released via job counter
- Jobs: status text updates dynamically in real-time
- Auto-redirect: blocked when summarize job is active
This commit is contained in:
47
backend/app/routers/campaigns.py
Normal file
47
backend/app/routers/campaigns.py
Normal file
@@ -0,0 +1,47 @@
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
from .. import database as db
|
||||
|
||||
router = APIRouter(prefix="/api/campaigns", tags=["campaigns"])
|
||||
|
||||
|
||||
@router.get("")
|
||||
def list_campaigns():
|
||||
return db.list_campaigns()
|
||||
|
||||
|
||||
@router.post("")
|
||||
def create_campaign(body: dict):
|
||||
name = body.get("name", "").strip()
|
||||
if not name:
|
||||
raise HTTPException(400, "Name is required")
|
||||
desc = body.get("description", "").strip()
|
||||
return db.create_campaign(name, desc)
|
||||
|
||||
|
||||
@router.get("/{campaign_id}")
|
||||
def get_campaign(campaign_id: str):
|
||||
campaign = db.get_campaign(campaign_id)
|
||||
if not campaign:
|
||||
raise HTTPException(404, "Campaign not found")
|
||||
return campaign
|
||||
|
||||
|
||||
@router.put("/{campaign_id}")
|
||||
def update_campaign(campaign_id: str, body: dict):
|
||||
if not db.get_campaign(campaign_id):
|
||||
raise HTTPException(404, "Campaign not found")
|
||||
updated = db.update_campaign(
|
||||
campaign_id,
|
||||
name=body.get("name"),
|
||||
description=body.get("description"),
|
||||
)
|
||||
return updated
|
||||
|
||||
|
||||
@router.delete("/{campaign_id}")
|
||||
def delete_campaign(campaign_id: str):
|
||||
if not db.get_campaign(campaign_id):
|
||||
raise HTTPException(404, "Campaign not found")
|
||||
db.delete_campaign(campaign_id)
|
||||
return {"ok": True}
|
||||
Reference in New Issue
Block a user