diff --git a/app/main.py b/app/main.py index 033cb29..9d09c94 100644 --- a/app/main.py +++ b/app/main.py @@ -196,6 +196,25 @@ async def api_metrics(request: Request): return JSONResponse({"error": e.detail}, status_code=e.status_code) +@app.get("/api/money-series") +async def api_money_series(request: Request): + """Revenue / token-spend / OC-balance series, for the Co-op usage view. + + Aggregate and non-personal, exactly like /api/metrics: cumulative revenue, + cumulative token spend, and the co-op's Open Collective balance — no member + identities. The co-op's finances are charted beside its other charts so + members and stewards see the same picture, from the same shared chart + definition (CoOpChart.CHART_METRICS "money"). + """ + identity = get_user_identity(request) + if not identity: + return JSONResponse({"error": "unauthenticated"}, status_code=401) + try: + return await broker_get(identity, "/broker/money-series") + except HTTPException as e: + return JSONResponse({"error": e.detail}, status_code=e.status_code) + + @app.post("/api/keys") async def api_create_key(request: Request): identity = get_user_identity(request) @@ -579,6 +598,9 @@ PAGE_HTML = """ .coop-stats .lbl { font-size: 12px; color: var(--muted); } .trend-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; } .coop-trend-body svg { display: block; width: 100%; height: auto; overflow: visible; } + .coop-legend { display: inline-flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); font-weight: 600; margin-left: auto; } + .coop-legend .key { display: inline-flex; align-items: center; gap: 5px; } + .coop-legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; } .board-row { display: flex; align-items: flex-start; gap: 14px; padding: 12px 0; border-top: 1px solid #f0ede6; @@ -811,20 +833,19 @@ PAGE_HTML = """