feat: enhance project and scenario detail pages with metrics, improved layouts, and updated styles
This commit is contained in:
@@ -7,7 +7,7 @@ from fastapi.responses import HTMLResponse, RedirectResponse
|
||||
from fastapi.templating import Jinja2Templates
|
||||
|
||||
from dependencies import get_unit_of_work
|
||||
from models import MiningOperationType, Project
|
||||
from models import MiningOperationType, Project, ScenarioStatus
|
||||
from schemas.project import ProjectCreate, ProjectRead, ProjectUpdate
|
||||
from services.exceptions import EntityConflictError, EntityNotFoundError
|
||||
from services.unit_of_work import UnitOfWork
|
||||
@@ -205,12 +205,23 @@ def view_project(
|
||||
) from exc
|
||||
|
||||
scenarios = sorted(project.scenarios, key=lambda s: s.created_at)
|
||||
scenario_stats = {
|
||||
"total": len(scenarios),
|
||||
"active": sum(1 for scenario in scenarios if scenario.status == ScenarioStatus.ACTIVE),
|
||||
"draft": sum(1 for scenario in scenarios if scenario.status == ScenarioStatus.DRAFT),
|
||||
"archived": sum(1 for scenario in scenarios if scenario.status == ScenarioStatus.ARCHIVED),
|
||||
"latest_update": max(
|
||||
(scenario.updated_at for scenario in scenarios if scenario.updated_at),
|
||||
default=None,
|
||||
),
|
||||
}
|
||||
return templates.TemplateResponse(
|
||||
"projects/detail.html",
|
||||
{
|
||||
"request": request,
|
||||
"project": project,
|
||||
"scenarios": scenarios,
|
||||
"scenario_stats": scenario_stats,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -339,12 +339,20 @@ def view_scenario(
|
||||
scenario.simulation_parameters, key=lambda item: item.created_at
|
||||
)
|
||||
|
||||
scenario_metrics = {
|
||||
"financial_count": len(financial_inputs),
|
||||
"parameter_count": len(simulation_parameters),
|
||||
"currency": scenario.currency,
|
||||
"primary_resource": scenario.primary_resource.value.replace('_', ' ').title() if scenario.primary_resource else None,
|
||||
}
|
||||
|
||||
return templates.TemplateResponse(
|
||||
"scenarios/detail.html",
|
||||
{
|
||||
"request": request,
|
||||
"project": project,
|
||||
"scenario": scenario,
|
||||
"scenario_metrics": scenario_metrics,
|
||||
"financial_inputs": financial_inputs,
|
||||
"simulation_parameters": simulation_parameters,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user