New API for logs, no more SimpleLog.

beta
Philippe Pittoli 2024-02-20 19:46:16 +01:00
parent 1d15a47c77
commit f668edda86
8 changed files with 12 additions and 16 deletions

View File

@ -14,7 +14,7 @@ import Prelude (Unit, bind, discard, not, pure, show, ($), (<<<), (<>), (=<<), m
import Bulma as Bulma
import Data.Maybe (Maybe(..), maybe)
import Data.Maybe (Maybe(..))
import Data.Array as A
import Effect.Aff.Class (class MonadAff)
import Halogen as H

View File

@ -166,7 +166,7 @@ handleAction = case _ of
login, pass -> do
H.raise $ AuthenticateToAuthd (Tuple login pass)
H.raise $ Log $ SimpleLog $ "[😇] Trying to authenticate (login: " <> login <> ")"
H.raise $ Log $ SystemLog $ "authenticate (login: " <> login <> ")"
PasswordRecoveryAttempt ev -> do
H.liftEffect $ Event.preventDefault ev
@ -176,14 +176,12 @@ handleAction = case _ of
email = passwordRecoveryForm.email
case login, email of
"", "" ->
H.raise $ Log $ UnableToSend "Write at least either your login or your email!"
"", "" -> H.raise $ Log $ UnableToSend "Write your login or your email!"
_, _ -> do
message <- H.liftEffect $ AuthD.serialize $
AuthD.MkAskPasswordRecovery { user: (Just login), email: Just (Email.Email email) }
H.raise $ MessageToSend message
H.raise $ Log $ SimpleLog "[😇] Trying to recover the password!"
H.raise $ Log $ SystemLog "password recovery"
handleQuery :: forall a m. MonadAff m => Query a -> H.HalogenM State Action () Output m (Maybe a)
handleQuery = case _ of
@ -192,7 +190,7 @@ handleQuery = case _ of
MessageReceived message _ -> do
case message of
_ -> do
H.raise $ Log $ SimpleLog $ "[😈] Message not handled in AuthenticationInterface."
H.raise $ Log $ ErrorLog $ "Message not handled in AuthenticationInterface."
pure Nothing
ConnectionIsDown a -> do

View File

@ -242,7 +242,7 @@ handleAction = case _ of
RemoveDomain domain -> do
message <- H.liftEffect $ DNSManager.serialize $ DNSManager.MkDeleteDomain { domain: domain }
H.raise $ MessageToSend message
H.raise $ Log $ SimpleLog $ "[😇] Removing domain: " <> domain
H.raise $ Log $ SystemLog $ "Remove domain: " <> domain
H.modify_ _ { active_modal = Nothing }
NewDomainAttempt ev -> do
@ -261,7 +261,7 @@ handleAction = case _ of
$ DNSManager.serialize
$ DNSManager.MkNewDomain { domain: new_domain }
H.raise $ MessageToSend message
H.raise $ Log $ SimpleLog $ "[😇] Trying to add a new domain (" <> new_domain <> ")"
H.raise $ Log $ SystemLog $ "Add a new domain (" <> new_domain <> ")"
handleAction $ HandleNewDomainInput $ INP_newdomain ""
where
show_error :: Maybe DomainError -> String
@ -295,7 +295,7 @@ handleQuery = case _ of
(DNSManager.MkDomainDeleted response) -> do
{ my_domains } <- H.get
handleAction $ UpdateMyDomains $ A.filter ((/=) response.domain) my_domains
_ -> H.raise $ Log $ SimpleLog $ "[😈] Message not handled in DomainListInterface."
_ -> H.raise $ Log $ ErrorLog $ "Message not handled in DomainListInterface."
pure (Just a)
ConnectionIsDown a -> do

View File

@ -52,7 +52,6 @@ handleQuery :: forall a m. MonadAff m => Query a -> H.HalogenM State Action () O
handleQuery = case _ of
Log message a -> do
case message of
SimpleLog str -> appendMessage str
SystemLog str -> systemMessage str
UnableToSend str -> unableToSend str
ErrorLog str -> errorMessage str

View File

@ -1,8 +1,7 @@
module App.LogMessage where
data LogMessage
= SimpleLog String
| SystemLog String
= SystemLog String
| UnableToSend String
| ErrorLog String
| SuccessLog String

View File

@ -153,7 +153,7 @@ handleAction = case _ of
let { login, token } = mailValidationForm
message <- H.liftEffect $ AuthD.serialize $ AuthD.MkValidateUser { user: login, activation_key: token }
H.raise $ MessageToSend message
H.raise $ Log $ SimpleLog $ "[😇] Trying to register (login: " <> login <> ")"
H.raise $ Log $ SystemLog $ "Trying to validate email address of user \"" <> login <> "\""
show_error :: Error -> String
show_error = case _ of

View File

@ -168,7 +168,7 @@ handleAction = case _ of
message <- H.liftEffect $ AuthD.serialize $
AuthD.MkRegister { login, email: Just (Email.Email email), password: pass }
H.raise $ MessageToSend message
H.raise $ Log $ SimpleLog $ "[😇] Trying to register (login: " <> login <> ")"
H.raise $ Log $ SystemLog $ "Trying to register (login: " <> login <> ")"
show_error :: Error -> String
show_error = case _ of

View File

@ -177,7 +177,7 @@ handleAction action = do
SendMessage array_buffer_to_send -> do
case wsInfo.connection of
Nothing -> H.raise $ Log $ SimpleLog $ "[🤖] Can't send a message, websocket is down!"
Nothing -> H.raise $ Log $ UnableToSend $ "Websocket is down!"
Just webSocket -> H.liftEffect $ do
sendArrayBuffer webSocket array_buffer_to_send