module Web.View.AdaptiveThresholds.Index where import Web.View.Prelude import Data.Time (diffUTCTime) data IndexView = IndexView { hubs :: ![Hub] , configs :: ![AdaptiveThresholdConfig] , insights :: ![LearningInsight] } instance View IndexView where html IndexView { .. } = [hsx|

Adaptive Thresholds

{forM_ hubs (renderHubCard configs)}

Recent Calibration Insights

{forM_ insights renderInsight}
|] where renderHubCard cs h = let mCfg = find (\c -> c.hubId == h.id) cs in [hsx|

{h.name}

{renderCfgStatus mCfg}
{csrfTokenTag}
|] renderInsight i = [hsx|

{i.title}

{i.body}

{show i.computedAt}

|] renderCfgStatus :: Maybe AdaptiveThresholdConfig -> Html renderCfgStatus Nothing = [hsx|

Not calibrated

|] renderCfgStatus (Just cfg) = [hsx|

Last calibrated: {show cfg.calibrationDate}

{maybe "" id cfg.notes}

|]