Better (pseudo-)routing.

beta
Philippe Pittoli 2023-07-08 06:29:37 +02:00
parent 05f751dd21
commit a395b88ef2
2 changed files with 15 additions and 11 deletions

View File

@ -137,7 +137,7 @@ handleAction = case _ of
Routing page -> H.modify_ _ { current_page = page } Routing page -> H.modify_ _ { current_page = page }
AuthenticationComponentEvent 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, current_page = DomainList }
AF.MessageToSend message -> H.tell _ws_auth unit (WS.ToSend message) AF.MessageToSend message -> H.tell _ws_auth unit (WS.ToSend message)
AF.Log message -> H.tell _log unit (Log.Log message) AF.Log message -> H.tell _log unit (Log.Log message)

View File

@ -31,10 +31,12 @@ netlibre_navbar authenticated admin actionHome actionDomainList actionAuthdAdmin
] ]
, navbar_end , navbar_end
[ navbar_item [ navbar_item
[ HH.div [HP.classes C.buttons] [ HH.div [HP.classes C.buttons] $ case authenticated of
[ nav_button_strong "Register" actionRegister false -> [ nav_button_strong "Register" actionRegister
, nav_button_light "Login" actionLogin , nav_button_light "Login" actionLogin
, nav_button_code
] ]
_ -> [ nav_button_code ]
] ]
] ]
] ]
@ -55,12 +57,14 @@ netlibre_navbar authenticated admin actionHome actionDomainList actionAuthdAdmin
link_home = HH.a [HP.classes C.navbar_item, HE.onClick (\_ -> actionHome)] [HH.text "Home"] link_home = HH.a [HP.classes C.navbar_item, HE.onClick (\_ -> actionHome)] [HH.text "Home"]
link_domains = HH.a [HP.classes C.navbar_item, HE.onClick (\_ -> actionDomainList)] [HH.text "Domain List"] link_domains = HH.a [HP.classes C.navbar_item, HE.onClick (\_ -> actionDomainList)] [HH.text "Domain List"]
link_authd_admin = HH.a [HP.classes C.navbar_item, HE.onClick (\_ -> actionAuthdAdmin)] [HH.text "Authd Admin"] link_authd_admin = HH.a [HP.classes C.navbar_item, HE.onClick (\_ -> actionAuthdAdmin)] [HH.text "Authd Admin"]
dropdown title dropdown_elements --dropdown title dropdown_elements
= HH.div [HP.classes (C.navbar_item <> C.has_dropdown <> C.is_hoverable)] -- = HH.div [HP.classes (C.navbar_item <> C.has_dropdown <> C.is_hoverable)]
[ dropdown_title title, HH.div [HP.classes C.navbar_dropdown] dropdown_elements ] -- [ dropdown_title title, HH.div [HP.classes C.navbar_dropdown] dropdown_elements ]
dropdown_title str = HH.a [HP.classes C.navbar_link] [HH.text str] --dropdown_title str = HH.a [HP.classes C.navbar_link] [HH.text str]
dropdown_element str = HH.a [HP.classes C.navbar_item] [HH.text str] --dropdown_element str = HH.a [HP.classes C.navbar_item] [HH.text str]
dropdown_separator = HH.hr [HP.classes C.navbar_divider] --dropdown_separator = HH.hr [HP.classes C.navbar_divider]
nav_button_code
= HH.a [HP.classes (C.button), HP.href "https://git.baguette.netlib.re/Baguette/dnsmanager"] [HH.text "Code"]
nav_button_strong str action nav_button_strong str action
= HH.a [HP.classes (C.button <> C.is_primary), HE.onClick (\_ -> action)] [HH.strong [] [HH.text str]] = HH.a [HP.classes (C.button <> C.is_primary), HE.onClick (\_ -> action)] [HH.strong [] [HH.text str]]
nav_button_light str action nav_button_light str action