module Web.View.ModelRoutingPolicies.Index where
import Web.View.Prelude
data IndexView = IndexView
{ policies :: ![ModelRoutingPolicy]
, hubs :: ![Hub]
, agents :: ![AgentRegistration]
}
instance View IndexView where
html IndexView { .. } = [hsx|
| Hub |
Task Type |
Agent |
Priority |
Active |
|
{forEach policies renderRow}
|]
where
hubName hid = maybe "Unknown" (.name) (find (\h -> h.id == hid) hubs)
agentName aid = maybe "Unknown" (.name) (find (\a -> a.id == aid) agents)
renderRow p = [hsx|
| {hubName p.hubId} |
{p.taskType} |
{agentName p.agentRegistrationId}
|
{show p.priority} |
{renderActiveStatus p.isActive}
|
Delete
|
|]
renderActiveStatus :: Bool -> Html
renderActiveStatus True = [hsx|Yes|]
renderActiveStatus False = [hsx|No|]