Code style + (admin) remove users.
parent
5690b0271f
commit
fdc6e0ec62
|
@ -404,6 +404,15 @@ handleAction = case _ of
|
|||
AdminInterface.AskState -> do
|
||||
state <- H.get
|
||||
H.tell _admini unit (AdminInterface.ProvideState state.store_AuthenticationDaemonAdmin_state)
|
||||
AdminInterface.DeleteUserAccount uid -> do
|
||||
handleAction $ Log $ SystemLog "Remove user account. 😿"
|
||||
|
||||
{- User id is provided this time, it's (probably) NOT self termination. -}
|
||||
dns_message <- H.liftEffect $ DNSManager.serialize $ DNSManager.MkDeleteUser { user_id: Just uid }
|
||||
auth_message <- H.liftEffect $ AuthD.serialize $ AuthD.MkDeleteUser { user: Just uid }
|
||||
H.tell _ws_dns unit (WS.ToSend dns_message)
|
||||
H.tell _ws_auth unit (WS.ToSend auth_message)
|
||||
|
||||
|
||||
ZoneInterfaceEvent ev -> case ev of
|
||||
ZoneInterface.MessageToSend message -> H.tell _ws_dns unit (WS.ToSend message)
|
||||
|
|
|
@ -46,6 +46,7 @@ data Output
|
|||
| Log LogMessage
|
||||
| AskState
|
||||
| StoreState State
|
||||
| DeleteUserAccount Int
|
||||
|
||||
data Query a
|
||||
= MessageReceived AuthD.AnswerMessage a
|
||||
|
@ -120,10 +121,10 @@ initialState _ = { addUserForm: { login: "", admin: false, email: "", pass: "
|
|||
|
||||
render :: forall m. State -> H.ComponentHTML Action () m
|
||||
render { addUserForm, searchUserForm, matching_users, current_tab, wsUp }
|
||||
= HH.div_
|
||||
= Bulma.section_small
|
||||
[ fancy_tab_bar
|
||||
, case current_tab of
|
||||
Home -> Bulma.section_small [Bulma.h3 "Select an action"]
|
||||
Home -> Bulma.h3 "Select an action"
|
||||
Search -> Bulma.columns_
|
||||
[ Bulma.column (C.is 3) [Bulma.article (Bulma.p "Search users") render_searchuser_form]
|
||||
, Bulma.column_ [ Bulma.h3 "Result", show_found_users ]
|
||||
|
@ -141,8 +142,8 @@ render { addUserForm, searchUserForm, matching_users, current_tab, wsUp }
|
|||
is_tab_active tab = current_tab == tab
|
||||
|
||||
show_found_users = Bulma.box [ HH.ul_ $ map user_card matching_users ]
|
||||
user_card user = HH.li_ [ Bulma.btn user.login (ShowUser user.uid)
|
||||
, Bulma.alert_btn "remove" (RemoveUser user.uid)
|
||||
user_card user = HH.li_ [ Bulma.btn_delete (RemoveUser user.uid)
|
||||
, Bulma.btn_ (C.is_small) user.login (ShowUser user.uid)
|
||||
]
|
||||
up x = HandleAddUserInput <<< x
|
||||
active = (if wsUp then (HP.enabled true) else (HP.disabled true))
|
||||
|
@ -206,8 +207,7 @@ handleAction = case _ of
|
|||
|
||||
RemoveUser uid -> do
|
||||
H.raise $ Log $ SystemLog $ "Remove user " <> show uid
|
||||
ab <- H.liftEffect $ AuthD.serialize $ AuthD.MkDeleteUser { user: Just uid }
|
||||
H.raise $ MessageToSend ab
|
||||
H.raise $ DeleteUserAccount uid
|
||||
|
||||
AddUserAttempt -> do
|
||||
{ addUserForm } <- H.get
|
||||
|
|
Loading…
Reference in New Issue