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 data Action
= OutputAuthComponent AF.Output = OutputAuthComponent AF.Output
| OutputAuthAdminComponent AAI.Output -- Admin interface. | OutputAuthAdminComponent AAI.Output -- Admin interface.
| NewDomainComponent NewDomainInterface.Output
| AuthDEvent WS.Output -- Events from authd. | AuthDEvent WS.Output -- Events from authd.
| DNSManagerDEvent WS.Output -- Events from dnsmanagerd. | DNSManagerDEvent WS.Output -- Events from dnsmanagerd.
@ -96,7 +97,7 @@ render state
render_newdomain_interface = Bulma.box $ case state.token of render_newdomain_interface = Bulma.box $ case state.token of
Just token -> Just token ->
[ Bulma.h1 "New domain interface!" [ 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." ] 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.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
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. -- 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) ->
@ -130,12 +137,9 @@ handleAction = case _ of
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 DNSManagerDEvent ev -> case ev of
WS.MessageReceived (Tuple _ _) -> pure unit WS.MessageReceived (Tuple _ message) -> H.tell _ndi unit (NewDomainInterface.MessageReceived message)
-- TODO: H.tell _ndi unit (NewDomainInterface.MessageReceived message) WS.WSJustConnected -> H.tell _ndi unit NewDomainInterface.ConnectionIsUp
WS.WSJustConnected -> do WS.WSJustClosed -> H.tell _ndi unit NewDomainInterface.ConnectionIsDown
H.tell _ndi unit NewDomainInterface.ConnectionIsUp
WS.WSJustClosed -> do
H.tell _ndi unit NewDomainInterface.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

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