Better message routing.
parent
634b30bbf5
commit
85df40cc23
|
@ -59,16 +59,12 @@ initialState _ = { token: Nothing
|
||||||
render :: forall m. MonadAff m => State -> H.ComponentHTML Action ChildSlots m
|
render :: forall m. MonadAff m => State -> H.ComponentHTML Action ChildSlots m
|
||||||
render state
|
render state
|
||||||
= HH.div_ $
|
= HH.div_ $
|
||||||
[ Bulma.columns_ [ Bulma.column_ [ render_logs ], Bulma.column_ [ render_auth_WS, render_dnsmanager_WS ] ]
|
[ render_auth_form
|
||||||
, render_auth_form
|
|
||||||
, render_authd_admin_interface
|
|
||||||
, render_newdomain_interface
|
, render_newdomain_interface
|
||||||
, div_token
|
, render_authd_admin_interface
|
||||||
|
, Bulma.columns_ [ Bulma.column_ [ render_logs ], Bulma.column_ [ render_auth_WS, render_dnsmanager_WS ] ]
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
div_token :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad
|
|
||||||
div_token = Bulma.box [ Bulma.p ("User [" <> show state.uid <> "] has token: " <> show state.token) ]
|
|
||||||
|
|
||||||
render_logs :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad
|
render_logs :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad
|
||||||
render_logs = Bulma.box [ HH.slot_ _log unit Log.component unit ]
|
render_logs = Bulma.box [ HH.slot_ _log unit Log.component unit ]
|
||||||
|
|
||||||
|
@ -77,29 +73,32 @@ render state
|
||||||
|
|
||||||
render_dnsmanager_WS :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad
|
render_dnsmanager_WS :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad
|
||||||
render_dnsmanager_WS = case state.token of
|
render_dnsmanager_WS = case state.token of
|
||||||
Nothing -> Bulma.p "We don't have a token right now."
|
Nothing -> render_nothing
|
||||||
Just _ -> HH.slot _ws_dns unit WS.component "ws://127.0.0.1:8081" DNSManagerDEvent
|
Just _ -> HH.slot _ws_dns unit WS.component "ws://127.0.0.1:8081" DNSManagerDEvent
|
||||||
|
|
||||||
render_auth_form :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad
|
render_auth_form :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad
|
||||||
render_auth_form = case state.token of
|
render_auth_form = case state.token of
|
||||||
Nothing -> Bulma.box [ HH.slot _af unit AF.component unit OutputAuthComponent ]
|
Nothing -> Bulma.box [ HH.slot _af unit AF.component unit OutputAuthComponent ]
|
||||||
Just current_token -> Bulma.p ("Token is: " <> current_token)
|
Just _ -> render_nothing
|
||||||
|
|
||||||
render_authd_admin_interface :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad
|
render_authd_admin_interface :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad
|
||||||
render_authd_admin_interface = Bulma.box $ case state.token of
|
render_authd_admin_interface = case state.token of
|
||||||
Just _ ->
|
Just _ -> Bulma.box $
|
||||||
[ Bulma.h1 "Administrative interface for authd"
|
[ Bulma.h1 "Administrative interface for authd"
|
||||||
, HH.slot _aai unit AAI.component unit OutputAuthAdminComponent
|
, HH.slot _aai unit AAI.component unit OutputAuthAdminComponent
|
||||||
]
|
]
|
||||||
Nothing -> [ Bulma.p "Here will be the administrative box." ]
|
Nothing -> render_nothing
|
||||||
|
|
||||||
render_newdomain_interface :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad
|
render_newdomain_interface :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad
|
||||||
render_newdomain_interface = Bulma.box $ case state.token of
|
render_newdomain_interface = case state.token of
|
||||||
Just token ->
|
Just token -> Bulma.box $
|
||||||
[ Bulma.h1 "New domain interface!"
|
[ Bulma.h1 "New domain interface!"
|
||||||
, HH.slot _ndi unit NewDomainInterface.component token NewDomainComponent
|
, HH.slot _ndi unit NewDomainInterface.component token NewDomainComponent
|
||||||
]
|
]
|
||||||
Nothing -> [ Bulma.p "Here will be the new domain box." ]
|
Nothing -> render_nothing
|
||||||
|
|
||||||
|
render_nothing :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad
|
||||||
|
render_nothing = HH.div_ []
|
||||||
|
|
||||||
handleAction :: forall o monad. MonadAff monad => Action -> H.HalogenM State Action ChildSlots o monad Unit
|
handleAction :: forall o monad. MonadAff monad => Action -> H.HalogenM State Action ChildSlots o monad Unit
|
||||||
handleAction = case _ of
|
handleAction = case _ of
|
||||||
|
@ -124,8 +123,11 @@ handleAction = case _ of
|
||||||
|
|
||||||
-- TODO: depending on the current page, we should provide the received message to different components.
|
-- TODO: depending on the current page, we should provide the received message to different components.
|
||||||
AuthDEvent ev -> case ev of
|
AuthDEvent ev -> case ev of
|
||||||
WS.MessageReceived (Tuple _ message) ->
|
WS.MessageReceived (Tuple _ message) -> do
|
||||||
H.tell _af unit (AF.MessageReceived message)
|
{ token } <- H.get
|
||||||
|
case token of
|
||||||
|
Nothing -> H.tell _af unit (AF.MessageReceived message)
|
||||||
|
Just _ -> H.tell _aai unit (AAI.MessageReceived message)
|
||||||
WS.WSJustConnected -> do
|
WS.WSJustConnected -> do
|
||||||
H.tell _af unit AF.ConnectionIsUp
|
H.tell _af unit AF.ConnectionIsUp
|
||||||
H.tell _aai unit AAI.ConnectionIsUp
|
H.tell _aai unit AAI.ConnectionIsUp
|
||||||
|
|
Loading…
Reference in New Issue