module Web.View.AgentRegistrations.Index where
import IHP.ViewPrelude
data IndexView = IndexView
{ agents :: ![AgentRegistration]
, hubs :: ![Hub]
}
instance View IndexView where
html IndexView { .. } = [hsx|
| Name |
Hub |
Provider |
Model |
Trust |
Status |
|
{forEach agents renderRow}
|]
where
hubName agentHubId =
case find (\h -> h.id == agentHubId) hubs of
Just h -> h.name
Nothing -> "Unknown"
renderRow agent = [hsx|
|
{agent.name}
|
{hubName agent.hubId} |
{agent.provider}
|
{agent.modelName} |
{trustBadge agent.trustLevel} |
{statusBadge agent.isActive} |
Edit
|
|]
trustBadge :: Text -> Html
trustBadge "autonomous" = [hsx|autonomous|]
trustBadge "elevated" = [hsx|elevated|]
trustBadge _ = [hsx|advisory|]
statusBadge :: Bool -> Html
statusBadge True = [hsx|active|]
statusBadge False = [hsx|inactive|]