NewDomainInterface is now connected to the other components.
This commit is contained in:
parent
a145577791
commit
5ed167d8bb
@ -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,24 +97,30 @@ 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." ]
|
||||
|
||||
handleAction :: forall o monad. MonadAff monad => Action -> H.HalogenM State Action ChildSlots o monad Unit
|
||||
handleAction = case _ of
|
||||
OutputAuthComponent 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)
|
||||
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
|
||||
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)
|
||||
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)
|
||||
|
||||
-- TODO: depending on the current page, we should provide the received message to different components.
|
||||
AuthDEvent ev -> case ev of
|
||||
@ -130,13 +137,10 @@ 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.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)
|
||||
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)
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user