Skip to content

feat: set OCF status via the Status API + tidy up the status page#443

Open
braddf wants to merge 3 commits into
mainfrom
feat/status-page-status-api
Open

feat: set OCF status via the Status API + tidy up the status page#443
braddf wants to merge 3 commits into
mainfrom
feat/status-page-status-api

Conversation

@braddf

@braddf braddf commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Changes in this Pull Request

Hooks the status page up to the new Status API's authenticated PUT action instead of writing straight to the DB — and gives the page a bit of a tidy-up while I was in there.

Status API routes

  • Reads and writes OCF product statuses through the Status API, using the logged-in user's Auth0 token (OCF folks have the read:admin permission).
  • Products: National → gb-solar, Assets → asset-solar, NL → nl-solar.
  • India stays on the legacy DB path for now — we'll move it once there's a Status API product for it.

Page tidy-up

  • Product statuses are now stacked as cards in the main area (one per product) rather than hidden behind a sidebar dropdown — so you can see and set any of them without switching context.
  • Example messages reorganised into colour-coded tabs (major / minor / maintenance / data providers / resolved), each a one-click-copy block.

Warning

Needs the matching status-api change (permissions-based admin check) deployed to status-pro for the writes to authorise. This is in the Status Dev API already, just needs merging before deploying this side to prod, along with updating the API/UI to point at the respective Status API counterparts for their /status checks.

Contributes to https://github.com/openclimatefix/client-private/issues/455

Contribution Checklist

  • Followed the OCF Contribution Guidelines
  • Referenced the Issue this PR addresses
  • Checked there aren't other open PRs for the same change
  • Added a summary of the changes
  • Written new tests — n/a

braddf added 2 commits July 17, 2026 12:46
Hook the status page up to the Status API's authenticated PUT action
(PUT /products/{key}/status) instead of writing directly to the
nowcasting/pvsite databases. Current status is now read from
GET /products/{key} too, keyed on product (National->gb-solar,
Sites->asset-solar, NL->nl-solar). India keeps the legacy DB path until
it has a Status API product.

Auth: request the Status API audience so the logged-in user's Auth0 token
carries the read:admin permission, and stash the token in session_state
for the PUT. Config is read from env vars with a Streamlit-secrets
fallback, and AUTH0_DOMAIN is normalised to a bare host.

Took 3 hours 12 minutes
Took 39 minutes

Took 12 minutes

# Commit time for manual adjustment:
# Took 4 minutes
@braddf
braddf requested a review from peterdudfield July 21, 2026 17:55
Comment thread src/status.py
f"**{status.get('name', product_name)}**   :{colour}[{status.get('status')}]"
)
with updated_col:
st.caption(f"Last updated {format_updated_at(status.get('updatedAt'))} UTC", text_alignment="right")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, good to have the UTC in there

Comment thread src/status.py
db_url_sites = os.getenv("SITES_DB_URL", None)
national_or_sites = "Sites"

connection = SitesDatabaseConnection(url=db_url_sites, echo=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, we can leave that for the moment, good idea

@peterdudfield peterdudfield left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for this

you might need to resolve conflicts on uv.lock, i smaller change i think went in from #444

Something not urgent / next time: If possible add a screen shot to the PR, then its really easy to see the layout of things, and all the nice improvements made

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants