"""Shared semantic HTML for the MinerOps Internal Alpha shell."""
from html import escape
from typing import Callable
NAVIGATION = (
("dashboard", "Dashboard", "/dashboard", "dashboard.view"),
("map", "Mine Map", "/monitoring/map", "locations.view"),
("repairs", "Repair Center", "/operations/repairs", "repairs.view"),
("miners", "Miners", "/assets/miners", "miners.view"),
)
PAGE_DETAILS = {
"dashboard": (
"Fleet overview",
"Dashboard",
"A concise starting point for operational state and recent activity.",
),
"map": (
"Monitoring / Spatial operations",
"Mine Map",
"Inspect where miners and operational conditions are concentrated.",
),
"repairs": (
"Operations",
"Repair Center",
"Review miners currently represented in the backend repair queue.",
),
"miners": (
"Assets",
"Miners",
"Search durable miner inventory and inspect current identity and state.",
),
}
def _dashboard_content() -> str:
metrics = (
("Site health", "--", "Live health summary not yet connected"),
("Total miners", "--", "Inventory summary not yet connected"),
("Miners in repair", "--", "Repair summary not yet connected"),
("Current hashrate", "-- TH/s", "Telemetry not yet connected"),
("Current power", "-- kW", "Telemetry not yet connected"),
)
metric_html = "".join(
""
f"{escape(label)}"
f"{escape(value)}"
f"{escape(state)}"
""
for label, value, state in metrics
)
return f"""
Recent activity
Operational events will appear here when
the dashboard activity feed is connected.
No activity feed connected
No events are fabricated for this placeholder.
"""
def _map_content(can_manage_locations: bool = False) -> str:
manage_link = (
'Manage locations'
if can_manage_locations
else ""
)
return f"""
Map context
Select a site and room.
{manage_link}
Filters
Map unavailable
The map could not be loaded.
Loading Mine Map
Requesting the current physical layout and operational observations.
Miner details require inventory access. Layout and occupancy remain visible.
Unscoped legacy positions
Stored positions without a durable room relationship. They are not assigned to the selected site or room.
Unplaced and operational areas
Miner records without a configured rack position.
"""
def _state_messages(noun: str) -> str:
return f"""
Loading {noun}
Requesting current information from MinerOps.
No {noun} found
There is no information to show in this view.
Access unavailable
Your account cannot view this information.
Could not load {noun}
Retry after checking the MinerOps connection.
"""
def _repairs_content() -> str:
return f"""
Current repair queue
Real records from the existing repair queue
API. Open a miner to continue in its current detail view.
Loaded on request
{_state_messages("repair records")}
| Miner | Model | Repair state |
Reported issue | Last update |
"""
def _miners_content() -> str:
return f"""
Miner inventory
Real inventory records. Search matches the
fields supported by the Inventory API.
Up to 100 results
{_state_messages("miners")}
| Asset ID | Current MAC | Model |
Lifecycle | Runtime | Location |
"""
CONTENT = {
"dashboard": _dashboard_content,
"map": _map_content,
"repairs": _repairs_content,
"miners": _miners_content,
}
def render_app_page(
view: str,
current_user: dict,
has_permission: Callable[[str], bool],
) -> str:
context, title, summary = PAGE_DETAILS[view]
display_name = escape(
str(
current_user.get("display_name")
or current_user.get("username")
or "MinerOps user"
)
)
role = escape(str(current_user.get("role") or "Authenticated user"))
can_view_miners = has_permission("miners.view")
navigation = "".join(
(
f'{escape(label)}'
if key == view
else f'{escape(label)}'
)
for key, label, href, permission in NAVIGATION
if has_permission(permission)
)
global_search = (
''
if can_view_miners
else ''
)
content = (
_map_content(has_permission("locations.manage"))
if view == "map"
else CONTENT[view]()
)
map_script = (
''
if view == "map"
else ""
)
return f"""
{escape(title)} | MinerOps
Skip to main content
{escape(context)}
{escape(title)}
{escape(summary)}
Current view: {escape(title)}
{content}
{map_script}
"""