Change some names.

This commit is contained in:
Philippe Pittoli 2023-07-05 03:52:28 +02:00
parent 85df40cc23
commit fb7c07e64d
2 changed files with 27 additions and 27 deletions

View File

@ -10,18 +10,18 @@ import App.AuthenticationForm as AF
import App.Log as Log import App.Log as Log
import App.WS as WS import App.WS as WS
import App.AuthenticationDaemonAdminInterface as AAI import App.AuthenticationDaemonAdminInterface as AAI
import App.DNSManagerDomainsInterface as NewDomainInterface import App.DomainListInterface as DomainListInterface
import Halogen as H import Halogen as H
import Halogen.HTML as HH import HalogenEvent.HTML as HH
import Type.Proxy (Proxy(..)) import Type.Proxy (Proxy(..))
import Effect.Aff.Class (class MonadAff) import Effect.Aff.Class (class MonadAff)
data Action data Action
= OutputAuthComponent AF.Output = AuthenticationComponentEvent AF.Output
| OutputAuthAdminComponent AAI.Output -- Admin interface. | AuthenticationDaemonAdminComponentEvent AAI.Output -- Admin interface for authd.
| NewDomainComponent NewDomainInterface.Output | NewDomainComponentEvent DomainListInterface.Output
| AuthDEvent WS.Output -- Events from authd. | AuthenticationDaemonEvent WS.Output
| DNSManagerDEvent WS.Output -- Events from dnsmanagerd. | DNSManagerDaemonEvent WS.Output
type State = { token :: Maybe String type State = { token :: Maybe String
, uid :: Maybe Int , uid :: Maybe Int
@ -33,7 +33,7 @@ type ChildSlots =
, ws_dns :: WS.Slot Unit , ws_dns :: WS.Slot Unit
, af :: AF.Slot Unit , af :: AF.Slot Unit
, aai :: AAI.Slot Unit , aai :: AAI.Slot Unit
, ndi :: NewDomainInterface.Slot Unit , ndi :: DomainListInterface.Slot Unit
) )
_log = Proxy :: Proxy "log" _log = Proxy :: Proxy "log"
@ -69,31 +69,31 @@ render state
render_logs = Bulma.box [ HH.slot_ _log unit Log.component unit ] 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 :: 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 :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad
render_dnsmanager_WS = case state.token of render_dnsmanager_WS = case state.token of
Nothing -> render_nothing 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 :: 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 AuthenticationComponentEvent ]
Just _ -> render_nothing 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 = case state.token of render_authd_admin_interface = case state.token of
Just _ -> Bulma.box $ 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 AuthenticationDaemonAdminComponentEvent
] ]
Nothing -> render_nothing NothingEvent -> 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 = case state.token of render_newdomain_interface = case state.token of
Just token -> Bulma.box $ 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 DomainListInterface.component token NewDomainComponentEvent
] ]
Nothing -> render_nothing 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 :: forall o monad. MonadAff monad => Action -> H.HalogenM State Action ChildSlots o monad Unit
handleAction = case _ of 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.AuthToken (Tuple uid token) -> H.modify_ _ { uid = Just uid, token = Just token }
AF.MessageToSend message -> H.tell _ws_auth unit (WS.ToSend message) AF.MessageToSend message -> H.tell _ws_auth unit (WS.ToSend message)
AF.AppendMessage message -> H.tell _log unit (Log.SimpleLog message) AF.AppendMessage message -> H.tell _log unit (Log.SimpleLog message)
AF.SystemMessage message -> H.tell _log unit (Log.SystemLog message) AF.SystemMessage message -> H.tell _log unit (Log.SystemLog message)
AF.UnableToSend message -> H.tell _log unit (Log.UnableToSend 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.MessageToSend message -> H.tell _ws_auth unit (WS.ToSend message)
AAI.AppendMessage message -> H.tell _log unit (Log.SimpleLog message) AAI.AppendMessage message -> H.tell _log unit (Log.SimpleLog message)
AAI.SystemMessage message -> H.tell _log unit (Log.SystemLog message) AAI.SystemMessage message -> H.tell _log unit (Log.SystemLog message)
AAI.UnableToSend message -> H.tell _log unit (Log.UnableToSend message) AAI.UnableToSend message -> H.tell _log unit (Log.UnableToSend message)
NewDomainComponent ev -> case ev of NewDomainComponentEvent ev -> case ev of
NewDomainInterface.MessageToSend message -> H.tell _ws_dns unit (WS.ToSend message) DomainListInterface.MessageToSend message -> H.tell _ws_dns unit (WS.ToSend message)
NewDomainInterface.AppendMessage message -> H.tell _log unit (Log.SimpleLog message) DomainListInterface.AppendMessage message -> H.tell _log unit (Log.SimpleLog message)
NewDomainInterface.SystemMessage message -> H.tell _log unit (Log.SystemLog message) DomainListInterface.SystemMessage message -> H.tell _log unit (Log.SystemLog message)
NewDomainInterface.UnableToSend message -> H.tell _log unit (Log.UnableToSend 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. -- 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 WS.MessageReceived (Tuple _ message) -> do
{ token } <- H.get { token } <- H.get
case token of case token of
@ -138,10 +138,10 @@ handleAction = case _ of
WS.AppendSystemMessage msg -> H.tell _log unit (Log.SystemLog msg) WS.AppendSystemMessage msg -> H.tell _log unit (Log.SystemLog msg)
WS.UnableToSend msg -> H.tell _log unit (Log.UnableToSend msg) WS.UnableToSend msg -> H.tell _log unit (Log.UnableToSend msg)
DNSManagerDEvent ev -> case ev of DNSManagerDaemonEvent ev -> case ev of
WS.MessageReceived (Tuple _ message) -> H.tell _ndi unit (NewDomainInterface.MessageReceived message) WS.MessageReceived (Tuple _ message) -> H.tell _ndi unit (DomainListInterface.MessageReceived message)
WS.WSJustConnected -> H.tell _ndi unit NewDomainInterface.ConnectionIsUp WS.WSJustConnected -> H.tell _ndi unit DomainListInterface.ConnectionIsUp
WS.WSJustClosed -> H.tell _ndi unit NewDomainInterface.ConnectionIsDown WS.WSJustClosed -> H.tell _ndi unit DomainListInterface.ConnectionIsDown
WS.AppendMessage msg -> H.tell _log unit (Log.SimpleLog msg) WS.AppendMessage msg -> H.tell _log unit (Log.SimpleLog msg)
WS.AppendSystemMessage msg -> H.tell _log unit (Log.SystemLog msg) WS.AppendSystemMessage msg -> H.tell _log unit (Log.SystemLog msg)
WS.UnableToSend msg -> H.tell _log unit (Log.UnableToSend msg) WS.UnableToSend msg -> H.tell _log unit (Log.UnableToSend msg)

View File

@ -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. {- Simple component with the list of own domains and a form to add a new domain.
This interface allows to: This interface allows to: