Can now delete a domain. No automatic domain list update.

beta
Philippe Pittoli 2023-07-03 04:31:00 +02:00
parent e0fc55e5ca
commit 99fb18c57a
1 changed files with 50 additions and 2 deletions

View File

@ -5,7 +5,8 @@ module App.DNSManagerDomainsInterface where
- display the list of own domains
- show and select accepted domains (TLDs)
- create new domains
- TODO: delete a domain (+ TODO: ask for confirmation)
- delete a domain
- TODO: ask for confirmation
- TODO: show and modify the content of a Zone
Authentication is automatic with the token.
@ -73,6 +74,8 @@ data Action
| HandleNewDomainInput NewDomainFormAction
| NewDomainAttempt Event
| RemoveDomain String
| EnterDomain String
| Finalize
| HandleWebSocket (WebSocketEvent WebSocketMessageType)
@ -155,7 +158,24 @@ render {
list_of_own_domains
= [ Bulma.h3 "My domains:"
, HH.ul_ $ map (\domain -> HH.li_ [ HH.text domain ]) my_domains
, HH.ul_ $ map (\domain -> HH.li_ (domain_buttons domain)) my_domains
]
domain_buttons domain
= [ HH.button
[ HP.style "padding: 0.5rem 1.25rem;"
, HP.type_ HP.ButtonSubmit
, HE.onClick \_ -> EnterDomain domain
, maybe (HP.disabled true) (\_ -> HP.enabled true) wsInfo.connection
]
[ HH.text domain ]
, HH.button
[ HP.style "padding: 0.5rem 1.25rem;"
, HP.type_ HP.ButtonSubmit
, HE.onClick \_ -> RemoveDomain domain
, maybe (HP.disabled true) (\_ -> HP.enabled true) wsInfo.connection
]
[ HH.text "x" ]
]
should_be_disabled = (maybe (HP.disabled true) (\_ -> HP.enabled true) wsInfo.connection)
@ -250,6 +270,34 @@ handleAction = case _ of
UpdateSelectedDomain domain -> do
H.modify_ _ { newDomainForm { selected_domain = domain } }
EnterDomain domain -> do
appendMessage $ "[???] trying to enter domain: " <> domain
RemoveDomain domain -> do
{ wsInfo } <- H.get
case wsInfo.connection of
Nothing ->
unableToSend "Not connected to server."
Just webSocket ->
H.liftEffect (WS.readyState webSocket) >>= case _ of
Connecting ->
unableToSend "Still connecting to server."
Closing ->
unableToSend "Connection to server is closing."
Closed -> do
unableToSend "Connection to server has been closed."
maybeCurrentConnection <- H.gets _.wsInfo.connection
when (isJust maybeCurrentConnection) do
H.modify_ _ { wsInfo { connection = Nothing, reconnect = true } }
Open -> do
H.liftEffect $ do
ab <- DNSManager.serialize $ DNSManager.MkDeleteDomain { domain: domain }
sendArrayBuffer webSocket ab
appendMessageReset $ "[😇] Removing domain: " <> domain
NewDomainAttempt ev -> do
H.liftEffect $ Event.preventDefault ev