feat: add ReconConfig API and UI for managing configurations
- Added a new API endpoint for managing ReconConfigs at /api/configs, including GET, POST, PUT, and a test URL feature. - Implemented a new configuration editor UI at /configs for creating and editing ReconConfigs. - Introduced a new configs list page at /configs to display existing configurations with options to edit. - Updated base HTML template to include a link to the new configs page. - Created stub configuration and authentication models for workspace development. - Added a stub configuration module to handle database configuration without a real database.
This commit is contained in:
@@ -14,6 +14,7 @@ from fastapi.templating import Jinja2Templates
|
||||
from app.models.recon_job import ReconJob # noqa: F401 (validates that the real model imports cleanly)
|
||||
from app.service.fake_jobs import FakeReconJob, get_fake_jobs
|
||||
from app.service.fake_configs import FakeReconConfig, get_fake_configs
|
||||
from app.core.refdata import ReconPatterns, ReconConfigStatus
|
||||
|
||||
|
||||
router = APIRouter(prefix="", tags=["User_Interface"])
|
||||
@@ -505,3 +506,59 @@ async def job_detail_view(request: Request, job_id: int):
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
# ── Config editor ────────────────────────────────────────────────────────────
|
||||
|
||||
_EDITOR_CONTEXT = {
|
||||
"patterns": [p.value for p in ReconPatterns],
|
||||
"statuses": [s.value for s in ReconConfigStatus],
|
||||
"frequencies": ["Ad Hoc", "Intra Day", "Daily", "Weekly", "Monthly", "Quarterly"],
|
||||
"schema_types": ["str", "int", "float", "date('%Y-%m-%d')", "datetime('%Y-%m-%d %H:%M:%S')", "bool"],
|
||||
}
|
||||
|
||||
|
||||
@router.get("/configs/new", response_class=HTMLResponse)
|
||||
async def config_new_view(request: Request):
|
||||
return templates.TemplateResponse(
|
||||
request=request,
|
||||
name="config_editor.html",
|
||||
context={
|
||||
"title": "New Config",
|
||||
"config": None,
|
||||
"is_new": True,
|
||||
**_EDITOR_CONTEXT,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@router.get("/configs/{reference}/edit", response_class=HTMLResponse)
|
||||
async def config_edit_view(request: Request, reference: str):
|
||||
now = datetime.now()
|
||||
configs = get_fake_configs(now)
|
||||
config = next((c for c in configs if c.reference == reference), None)
|
||||
return templates.TemplateResponse(
|
||||
request=request,
|
||||
name="config_editor.html",
|
||||
context={
|
||||
"title": f"Edit — {reference}" if config else "Edit Config",
|
||||
"config": config,
|
||||
"reference": reference,
|
||||
"is_new": False,
|
||||
**_EDITOR_CONTEXT,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@router.get("/configs", response_class=HTMLResponse)
|
||||
async def configs_list_view(request: Request):
|
||||
now = datetime.now()
|
||||
configs = get_fake_configs(now)
|
||||
return templates.TemplateResponse(
|
||||
request=request,
|
||||
name="configs_list.html",
|
||||
context={
|
||||
"title": "Recon Configs",
|
||||
"configs": configs,
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user