feat: Initialize FastAPI application with Azure authentication and transaction management
- Added .env.example for environment variable configuration. - Created app initialization files and core settings management. - Implemented API routers for reporting and transaction endpoints. - Developed transaction management service with CRUD operations. - Integrated Azure OAuth for user authentication. - Designed dashboard view with transaction filtering and display. - Added Swagger UI documentation with custom dark theme. - Created static and template files for frontend styling and layout.
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import APIRouter, Query, Request
|
||||
from fastapi.responses import HTMLResponse, RedirectResponse
|
||||
from fastapi.templating import Jinja2Templates
|
||||
|
||||
from app.service.recon_service import list_transactions
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
project_root = Path(__file__).resolve().parents[2]
|
||||
templates = Jinja2Templates(directory=str(project_root / "data" / "templates"))
|
||||
|
||||
|
||||
@router.get("/", response_class=HTMLResponse, include_in_schema=False)
|
||||
async def dashboard(
|
||||
request: Request,
|
||||
recon_job_name: str | None = Query(default=None),
|
||||
as_at_date: str | None = Query(default=None),
|
||||
) -> HTMLResponse:
|
||||
user = request.session.get("user")
|
||||
if not user:
|
||||
return RedirectResponse(url="/login", status_code=302)
|
||||
|
||||
transactions = list_transactions()
|
||||
|
||||
if as_at_date:
|
||||
transactions = [item for item in transactions if item.date.isoformat() == as_at_date]
|
||||
|
||||
results = [
|
||||
{
|
||||
"Transaction ID": item.transaction_id,
|
||||
"Date": item.date.isoformat(),
|
||||
"Account": item.account,
|
||||
"Amount": f"{item.amount:,.2f}",
|
||||
"Status": item.status,
|
||||
"Flag": item.flag,
|
||||
}
|
||||
for item in transactions
|
||||
]
|
||||
|
||||
return templates.TemplateResponse(
|
||||
request=request,
|
||||
name="dashboard.html",
|
||||
context={
|
||||
"request": request,
|
||||
"title": "Recon Ranger Dashboard",
|
||||
"results": results,
|
||||
"user": user,
|
||||
"recon_job_name": recon_job_name,
|
||||
"as_at_date": as_at_date,
|
||||
"prev_cursor": None,
|
||||
"next_cursor": None,
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user