Change some names.
This commit is contained in:
parent
85df40cc23
commit
fb7c07e64d
@ -10,18 +10,18 @@ import App.AuthenticationForm as AF
|
||||
import App.Log as Log
|
||||
import App.WS as WS
|
||||
import App.AuthenticationDaemonAdminInterface as AAI
|
||||
import App.DNSManagerDomainsInterface as NewDomainInterface
|
||||
import App.DomainListInterface as DomainListInterface
|
||||
import Halogen as H
|
||||
import Halogen.HTML as HH
|
||||
import HalogenEvent.HTML as HH
|
||||
import Type.Proxy (Proxy(..))
|
||||
import Effect.Aff.Class (class MonadAff)
|
||||
|
||||
data Action
|
||||
= OutputAuthComponent AF.Output
|
||||
| OutputAuthAdminComponent AAI.Output -- Admin interface.
|
||||
| NewDomainComponent NewDomainInterface.Output
|
||||
| AuthDEvent WS.Output -- Events from authd.
|
||||
| DNSManagerDEvent WS.Output -- Events from dnsmanagerd.
|
||||
= AuthenticationComponentEvent AF.Output
|
||||
| AuthenticationDaemonAdminComponentEvent AAI.Output -- Admin interface for authd.
|
||||
| NewDomainComponentEvent DomainListInterface.Output
|
||||
| AuthenticationDaemonEvent WS.Output
|
||||
| DNSManagerDaemonEvent WS.Output
|
||||
|
||||
type State = { token :: Maybe String
|
||||
, uid :: Maybe Int
|
||||
@ -33,7 +33,7 @@ type ChildSlots =
|
||||
, ws_dns :: WS.Slot Unit
|
||||
, af :: AF.Slot Unit
|
||||
, aai :: AAI.Slot Unit
|
||||
, ndi :: NewDomainInterface.Slot Unit
|
||||
, ndi :: DomainListInterface.Slot Unit
|
||||
)
|
||||
|
||||
_log = Proxy :: Proxy "log"
|
||||
@ -69,31 +69,31 @@ render state
|
||||
render_logs = Bulma.box [ HH.slot_ _log unit Log.component unit ]
|
||||
|
||||
render_auth_WS :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad
|
||||
render_auth_WS = HH.slot _ws_auth unit WS.component "ws://127.0.0.1:8080" AuthDEvent
|
||||
render_auth_WS = HH.slot _ws_auth unit WS.component "ws://127.0.0.1:8080" AuthenticationDaemonEvent
|
||||
|
||||
render_dnsmanager_WS :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad
|
||||
render_dnsmanager_WS = case state.token of
|
||||
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" DNSManagerDaemonEvent
|
||||
|
||||
render_auth_form :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad
|
||||
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 AuthenticationComponentEvent ]
|
||||
Just _ -> render_nothing
|
||||
|
||||
render_authd_admin_interface :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad
|
||||
render_authd_admin_interface = case state.token of
|
||||
Just _ -> Bulma.box $
|
||||
[ Bulma.h1 "Administrative interface for authd"
|
||||
, HH.slot _aai unit AAI.component unit OutputAuthAdminComponent
|
||||
, HH.slot _aai unit AAI.component unit AuthenticationDaemonAdminComponentEvent
|
||||
]
|
||||
Nothing -> render_nothing
|
||||
NothingEvent -> render_nothing
|
||||
|
||||
render_newdomain_interface :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad
|
||||
render_newdomain_interface = case state.token of
|
||||
Just token -> Bulma.box $
|
||||
[ Bulma.h1 "New domain interface!"
|
||||
, HH.slot _ndi unit NewDomainInterface.component token NewDomainComponent
|
||||
, HH.slot _ndi unit DomainListInterface.component token NewDomainComponentEvent
|
||||
]
|
||||
Nothing -> render_nothing
|
||||
|
||||
@ -102,27 +102,27 @@ render state
|
||||
|
||||
handleAction :: forall o monad. MonadAff monad => Action -> H.HalogenM State Action ChildSlots o monad Unit
|
||||
handleAction = case _ of
|
||||
OutputAuthComponent ev -> case ev of
|
||||
AuthenticationComponentEvent ev -> case ev of
|
||||
AF.AuthToken (Tuple uid token) -> H.modify_ _ { uid = Just uid, token = Just token }
|
||||
AF.MessageToSend message -> H.tell _ws_auth unit (WS.ToSend message)
|
||||
AF.AppendMessage message -> H.tell _log unit (Log.SimpleLog message)
|
||||
AF.SystemMessage message -> H.tell _log unit (Log.SystemLog message)
|
||||
AF.UnableToSend message -> H.tell _log unit (Log.UnableToSend message)
|
||||
|
||||
OutputAuthAdminComponent ev -> case ev of
|
||||
AuthenticationDaemonAdminComponentEvent ev -> case ev of
|
||||
AAI.MessageToSend message -> H.tell _ws_auth unit (WS.ToSend message)
|
||||
AAI.AppendMessage message -> H.tell _log unit (Log.SimpleLog message)
|
||||
AAI.SystemMessage message -> H.tell _log unit (Log.SystemLog message)
|
||||
AAI.UnableToSend message -> H.tell _log unit (Log.UnableToSend message)
|
||||
|
||||
NewDomainComponent ev -> case ev of
|
||||
NewDomainInterface.MessageToSend message -> H.tell _ws_dns unit (WS.ToSend message)
|
||||
NewDomainInterface.AppendMessage message -> H.tell _log unit (Log.SimpleLog message)
|
||||
NewDomainInterface.SystemMessage message -> H.tell _log unit (Log.SystemLog message)
|
||||
NewDomainInterface.UnableToSend message -> H.tell _log unit (Log.UnableToSend message)
|
||||
NewDomainComponentEvent ev -> case ev of
|
||||
DomainListInterface.MessageToSend message -> H.tell _ws_dns unit (WS.ToSend message)
|
||||
DomainListInterface.AppendMessage message -> H.tell _log unit (Log.SimpleLog message)
|
||||
DomainListInterface.SystemMessage message -> H.tell _log unit (Log.SystemLog message)
|
||||
DomainListInterface.UnableToSend message -> H.tell _log unit (Log.UnableToSend message)
|
||||
|
||||
-- TODO: depending on the current page, we should provide the received message to different components.
|
||||
AuthDEvent ev -> case ev of
|
||||
AuthenticationDaemonEvent ev -> case ev of
|
||||
WS.MessageReceived (Tuple _ message) -> do
|
||||
{ token } <- H.get
|
||||
case token of
|
||||
@ -138,10 +138,10 @@ handleAction = case _ of
|
||||
WS.AppendSystemMessage msg -> H.tell _log unit (Log.SystemLog msg)
|
||||
WS.UnableToSend msg -> H.tell _log unit (Log.UnableToSend msg)
|
||||
|
||||
DNSManagerDEvent ev -> case ev of
|
||||
WS.MessageReceived (Tuple _ message) -> H.tell _ndi unit (NewDomainInterface.MessageReceived message)
|
||||
WS.WSJustConnected -> H.tell _ndi unit NewDomainInterface.ConnectionIsUp
|
||||
WS.WSJustClosed -> H.tell _ndi unit NewDomainInterface.ConnectionIsDown
|
||||
DNSManagerDaemonEvent ev -> case ev of
|
||||
WS.MessageReceived (Tuple _ message) -> H.tell _ndi unit (DomainListInterface.MessageReceived message)
|
||||
WS.WSJustConnected -> H.tell _ndi unit DomainListInterface.ConnectionIsUp
|
||||
WS.WSJustClosed -> H.tell _ndi unit DomainListInterface.ConnectionIsDown
|
||||
WS.AppendMessage msg -> H.tell _log unit (Log.SimpleLog msg)
|
||||
WS.AppendSystemMessage msg -> H.tell _log unit (Log.SystemLog msg)
|
||||
WS.UnableToSend msg -> H.tell _log unit (Log.UnableToSend msg)
|
||||
|
@ -1,4 +1,4 @@
|
||||
module App.DNSManagerDomainsInterface where
|
||||
module App.DomainListInterface where
|
||||
|
||||
{- Simple component with the list of own domains and a form to add a new domain.
|
||||
This interface allows to:
|
Loading…
Reference in New Issue
Block a user