module Web.View.Hubs.HubHealthHistory where import Web.Types import Generated.Types import IHP.Prelude import IHP.ViewPrelude import Web.Routes () import Application.Helper.HubHealth (healthScoreBadge) data HubHealthHistoryView = HubHealthHistoryView { hub :: !Hub , snapshots :: ![HubHealthSnapshot] } instance View HubHealthHistoryView where html HubHealthHistoryView { .. } = [hsx|

Hub Health History

{hub.name}

Take Snapshot ← Hub
{renderLatestPanel snapshots} {renderSnapshotsTable snapshots} |] renderLatestPanel :: [HubHealthSnapshot] -> Html renderLatestPanel [] = [hsx|

No snapshots yet. Take the first one.

|] renderLatestPanel (latest : _) = [hsx|

Current Health Score

healthScoreBadge latest.healthScore}> {show latest.healthScore}
Open candidates: {show latest.openCandidates}
Regressed widgets: {show latest.regressedWidgets}
Stale decisions: {show latest.staleDecisions}
Active bottlenecks: {show latest.activeBottlenecks}
|] renderSnapshotsTable :: [HubHealthSnapshot] -> Html renderSnapshotsTable [] = mempty renderSnapshotsTable snaps = [hsx|
{forEach snaps renderRow}
Score Open Cand. Regressed Stale Dec. Bottlenecks Taken At
|] renderRow :: HubHealthSnapshot -> Html renderRow s = [hsx| healthScoreBadge s.healthScore}> {show s.healthScore} {show s.openCandidates} {show s.regressedWidgets} {show s.staleDecisions} {show s.activeBottlenecks} {show s.computedAt} |]