module Web.View.ModelRoutingPolicies.New where
import Web.View.Prelude
data NewView = NewView
{ policy :: !ModelRoutingPolicy
, hubs :: ![Hub]
, agents :: ![AgentRegistration]
}
taskTypeOptions :: [Text]
taskTypeOptions =
[ "requirement_draft"
, "triage"
, "synthesis"
, "policy_check"
, "implementation"
]
instance View NewView where
html NewView { .. } = [hsx|
Add Routing Policy
{renderForm policy hubs agents}
|]
renderForm :: ModelRoutingPolicy -> [Hub] -> [AgentRegistration] -> Html
renderForm policy hubs agents = formFor policy [hsx|
Hub
{forEach hubs renderHubOption}
Task Type
{forEach taskTypeOptions renderTaskTypeOption}
Agent
{forEach agents renderAgentOption}
{(numberField #priority) { fieldLabel = "Priority (higher wins)", placeholder = "0" }}
{submitButton { label = "Create Policy" }}
Cancel
|]
renderHubOption :: Hub -> Html
renderHubOption h = [hsx|{h.name} |]
renderTaskTypeOption :: Text -> Html
renderTaskTypeOption t = [hsx|{t} |]
renderAgentOption :: AgentRegistration -> Html
renderAgentOption a = [hsx|{a.name} ({a.provider} / {a.modelName}) |]