Let's select a domain!
parent
8fe25f8aca
commit
8d32f9933b
|
@ -11,6 +11,7 @@
|
|||
, "codec-argonaut"
|
||||
, "console"
|
||||
, "const"
|
||||
, "dom-indexed"
|
||||
, "effect"
|
||||
, "either"
|
||||
, "exceptions"
|
||||
|
|
|
@ -15,9 +15,11 @@ import Prelude
|
|||
|
||||
import Bulma as Bulma
|
||||
|
||||
import Halogen.HTML.Events as HHE
|
||||
import Control.Monad.Except (runExcept)
|
||||
import Control.Monad.State (class MonadState)
|
||||
import Data.Array as A
|
||||
-- import Data.Array.Partial as DAP
|
||||
import Data.Tuple (Tuple(..))
|
||||
import Data.Bifunctor (lmap)
|
||||
import Data.Const (Const)
|
||||
|
@ -154,6 +156,7 @@ data Action
|
|||
|
||||
| UpdateAcceptedDomains (Array String)
|
||||
| UpdateMyDomains (Array String)
|
||||
| UpdateSelectedDomain String
|
||||
|
||||
| AuthenticateToDNSManager
|
||||
|
||||
|
@ -174,6 +177,7 @@ type State =
|
|||
, newDomainForm :: NewDomainFormState
|
||||
|
||||
, accepted_domains :: Array String
|
||||
, selected_domain :: String
|
||||
, my_domains :: Array String
|
||||
|
||||
-- TODO: put network stuff in a record.
|
||||
|
@ -194,6 +198,9 @@ component =
|
|||
}
|
||||
}
|
||||
|
||||
default_domain :: String
|
||||
default_domain = "netlib.re"
|
||||
|
||||
initialState :: Input -> State
|
||||
initialState (Tuple url token) =
|
||||
{ messages: []
|
||||
|
@ -202,7 +209,8 @@ initialState (Tuple url token) =
|
|||
, token: token
|
||||
, newDomainForm: { new_domain: "" }
|
||||
|
||||
, accepted_domains: [ "netlib.re" ]
|
||||
, accepted_domains: [ default_domain ]
|
||||
, selected_domain: default_domain
|
||||
, my_domains: [ ]
|
||||
|
||||
-- TODO: put network stuff in a record.
|
||||
|
@ -221,7 +229,6 @@ render {
|
|||
newDomainForm }
|
||||
= HH.div_
|
||||
[ Bulma.columns_ [ Bulma.column_ newdomain_form
|
||||
, Bulma.column_ list_acceptable_domains
|
||||
, Bulma.column_ list_of_own_domains ]
|
||||
, render_messages
|
||||
, renderReconnectButton (isNothing wsConnection && canReconnect)
|
||||
|
@ -233,11 +240,6 @@ render {
|
|||
, render_adduser_form
|
||||
]
|
||||
|
||||
list_acceptable_domains
|
||||
= [ Bulma.h3 "Acceptable domains:"
|
||||
, Bulma.select $ map Bulma.option accepted_domains
|
||||
]
|
||||
|
||||
list_of_own_domains
|
||||
= [ Bulma.h3 "My domains:"
|
||||
, HH.ul_ $ map (\domain -> HH.li_ [ HH.text domain ]) my_domains
|
||||
|
@ -253,6 +255,7 @@ render {
|
|||
true -- validity (TODO)
|
||||
should_be_disabled -- condition
|
||||
-- TODO: list of options for TLD
|
||||
, Bulma.select [ HHE.onSelectedIndexChange (\i -> UpdateSelectedDomain $ maybe "netlib.re" (\x -> x) $ accepted_domains A.!! i) ] $ map Bulma.option accepted_domains
|
||||
, HH.div_
|
||||
[ HH.button
|
||||
[ HP.style "padding: 0.5rem 1.25rem;"
|
||||
|
@ -314,6 +317,9 @@ handleAction = case _ of
|
|||
UpdateMyDomains domains -> do
|
||||
H.modify_ _ { my_domains = domains }
|
||||
|
||||
UpdateSelectedDomain domain -> do
|
||||
H.modify_ _ { selected_domain = domain }
|
||||
|
||||
AuthenticateToDNSManager -> do
|
||||
{ wsConnection, token } <- H.get
|
||||
appendMessage $ "[🤖] Trying to authenticate..."
|
||||
|
|
|
@ -4,7 +4,7 @@ module Bulma where
|
|||
import Prelude
|
||||
|
||||
import Halogen.HTML as HH
|
||||
-- import DOM.HTML.Indexed as DHI
|
||||
import DOM.HTML.Indexed as DHI
|
||||
import Halogen.HTML.Properties as HP
|
||||
import Halogen.HTML.Events as HE
|
||||
|
||||
|
@ -337,6 +337,7 @@ box = HH.div [HP.classes class_box]
|
|||
option :: forall w i. String -> HH.HTML w i
|
||||
option value = HH.option_ [HH.text value]
|
||||
|
||||
select :: forall w i. Array (HH.HTML w i) -> HH.HTML w i
|
||||
select options = HH.div [HP.classes (class_select <> class_primary)]
|
||||
[ HH.select_ options]
|
||||
select :: forall w i. HH.Node DHI.HTMLselect w i
|
||||
select action options
|
||||
= HH.div [ HP.classes (class_select <> class_primary) ]
|
||||
[ HH.select action options]
|
||||
|
|
Loading…
Reference in New Issue