f7a8007af8
Nový DB helper bez ORM: app/db/scheduled_scripts.py
Nové route/UI: app/routes/scheduled_scripts.py
Router registrovaný v app/main.py
Menu doplněné v app/templates/layout.py
Job filtr rozšířený o run_script v app/routes/jobs.py
Implementováno:
GET /portal/scheduled-scripts
GET /portal/scheduled-scripts/{id}
GET/POST /portal/scheduled-scripts/new
GET/POST /portal/scheduled-scripts/{id}/edit
POST /portal/scheduled-scripts/{id}/run-now
POST /portal/scheduled-scripts/{id}/toggle
POST /portal/scheduled-scripts/{id}/delete
Ruční spuštění vytváří run_script job přes existující create_job(...) se source="portal_manual" a payloadem podle zadání. Mazání je blokované, pokud is_running = 1. Validace script_name, schedule_type a timeout_seconds je v route vrstvě.
Audit eventy jsou přidané:
scheduled_script.created
scheduled_script.updated
scheduled_script.deleted
scheduled_script.enabled
scheduled_script.disabled
scheduled_script.run_now
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
from pathlib import Path
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.staticfiles import StaticFiles
|
|
from starlette.middleware.sessions import SessionMiddleware
|
|
|
|
from .config import read_env_value
|
|
from .routes import apps, audit, auth, backups, deployments, health, incidents, jobs, operations, scheduled_scripts, workers
|
|
|
|
|
|
def create_app() -> FastAPI:
|
|
app = FastAPI(title="CSBot Services Portal")
|
|
session_secret = read_env_value("PORTAL_SESSION_SECRET", "") or "dev-only-appfactory-session-secret"
|
|
|
|
app.add_middleware(
|
|
SessionMiddleware,
|
|
secret_key=session_secret,
|
|
same_site="lax",
|
|
https_only=False,
|
|
)
|
|
|
|
static_dir = Path(__file__).parent / "static"
|
|
app.mount("/static", StaticFiles(directory=static_dir), name="static")
|
|
|
|
app.include_router(health.router)
|
|
app.include_router(auth.router)
|
|
app.include_router(apps.router)
|
|
app.include_router(backups.router)
|
|
app.include_router(deployments.router)
|
|
app.include_router(incidents.router)
|
|
app.include_router(operations.router)
|
|
app.include_router(scheduled_scripts.router)
|
|
app.include_router(jobs.router)
|
|
app.include_router(workers.router)
|
|
app.include_router(audit.router)
|
|
|
|
return app
|
|
|
|
|
|
app = create_app()
|