NewDomainInterface is now connected to the other components.

beta
Philippe Pittoli 2023-07-05 02:38:20 +02:00
parent a145577791
commit 5ed167d8bb
2 changed files with 26 additions and 24 deletions

View File

@ -19,6 +19,7 @@ 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.
@ -96,7 +97,7 @@ render state
render_newdomain_interface = Bulma.box $ case state.token of
Just token ->
[ Bulma.h1 "New domain interface!"
, HH.slot_ _ndi unit NewDomainInterface.component token
, HH.slot _ndi unit NewDomainInterface.component token NewDomainComponent
]
Nothing -> [ Bulma.p "Here will be the new domain box." ]
@ -115,6 +116,12 @@ handleAction = case _ of
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)
-- TODO: depending on the current page, we should provide the received message to different components.
AuthDEvent ev -> case ev of
WS.MessageReceived (Tuple _ message) ->
@ -130,12 +137,9 @@ handleAction = case _ of
WS.UnableToSend msg -> H.tell _log unit (Log.UnableToSend msg)
DNSManagerDEvent ev -> case ev of
WS.MessageReceived (Tuple _ _) -> pure unit
-- TODO: H.tell _ndi unit (NewDomainInterface.MessageReceived message)
WS.WSJustConnected -> do
H.tell _ndi unit NewDomainInterface.ConnectionIsUp
WS.WSJustClosed -> do
H.tell _ndi unit NewDomainInterface.ConnectionIsDown
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
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)

View File

@ -44,10 +44,6 @@ import App.Messages.DNSManagerDaemon as DNSManager
import Data.ArrayBuffer.Types (ArrayBuffer)
import Web.Socket.BinaryType (BinaryType(ArrayBuffer))
--------------------------------------------------------------------------------
-- Root component module
--------------------------------------------------------------------------------
data Output
= MessageToSend ArrayBuffer
| AppendMessage String
@ -99,7 +95,8 @@ component =
{ initialState
, render
, eval: H.mkEval $ H.defaultEval
{ handleAction = handleAction
{ initialize = Just AuthenticateToDNSManager
, handleAction = handleAction
, handleQuery = handleQuery
}
}
@ -207,6 +204,7 @@ handleAction = case _ of
NewDomainAttempt ev -> do
H.liftEffect $ Event.preventDefault ev
H.raise $ AppendMessage "[😇] Trying to add a new domain"
{ newDomainForm } <- H.get
let new_domain = build_new_domain newDomainForm.new_domain newDomainForm.selected_domain