Commit bf7780e4 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[refactoring] some small refactorings for log

parent dfd1a8db
module Gargantext.Components.Forest.Tree.Node.Tools.Sync where module Gargantext.Components.Forest.Tree.Node.Tools.Sync where
import Gargantext.Prelude
( Unit, bind, const, discard, pure, unit, ($), (<>), (==) )
import Effect.Aff (Aff, launchAff_) import Effect.Aff (Aff, launchAff_)
import Data.Tuple.Nested ((/\))
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Tuple (fst)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Reactix as R import Reactix as R
import Toestand as T import Toestand as T
import Gargantext.Prelude (Unit, bind, discard, pure, unit, ($), (<>), (==))
import Gargantext.Components.GraphExplorer.API as GraphAPI import Gargantext.Components.GraphExplorer.API as GraphAPI
import Gargantext.Types as GT import Gargantext.Types as GT
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
...@@ -62,7 +60,7 @@ graphUpdateButtonCpt = here.component "graphUpdateButton" cpt ...@@ -62,7 +60,7 @@ graphUpdateButtonCpt = here.component "graphUpdateButton" cpt
then "enabled" then "enabled"
else "disabled text-muted" else "disabled text-muted"
} [ H.span { className: "fa fa-refresh" } [ H.span { className: "fa fa-refresh"
, on: { click: onClick enabled' enabled } } [] , on: { click: onClick enabled' enabled } } []
] ]
where where
onClick false _ = pure unit onClick false _ = pure unit
...@@ -86,7 +84,6 @@ type NodeActionsNodeListProps = ...@@ -86,7 +84,6 @@ type NodeActionsNodeListProps =
nodeActionsNodeList :: Record NodeActionsNodeListProps -> R.Element nodeActionsNodeList :: Record NodeActionsNodeListProps -> R.Element
nodeActionsNodeList p = R.createElement nodeActionsNodeListCpt p [] nodeActionsNodeList p = R.createElement nodeActionsNodeListCpt p []
nodeActionsNodeListCpt :: R.Component NodeActionsNodeListProps nodeActionsNodeListCpt :: R.Component NodeActionsNodeListProps
nodeActionsNodeListCpt = here.component "nodeActionsNodeList" cpt nodeActionsNodeListCpt = here.component "nodeActionsNodeList" cpt
where where
...@@ -105,7 +102,6 @@ type NodeListUpdateButtonProps = ...@@ -105,7 +102,6 @@ type NodeListUpdateButtonProps =
nodeListUpdateButton :: Record NodeListUpdateButtonProps -> R.Element nodeListUpdateButton :: Record NodeListUpdateButtonProps -> R.Element
nodeListUpdateButton p = R.createElement nodeListUpdateButtonCpt p [] nodeListUpdateButton p = R.createElement nodeListUpdateButtonCpt p []
nodeListUpdateButtonCpt :: R.Component NodeListUpdateButtonProps nodeListUpdateButtonCpt :: R.Component NodeListUpdateButtonProps
nodeListUpdateButtonCpt = here.component "nodeListUpdateButton" cpt nodeListUpdateButtonCpt = here.component "nodeListUpdateButton" cpt
where where
......
...@@ -4,7 +4,6 @@ import Affjax (defaultRequest, printError, request) ...@@ -4,7 +4,6 @@ import Affjax (defaultRequest, printError, request)
import Affjax.RequestBody (RequestBody(..), formData, formURLEncoded) import Affjax.RequestBody (RequestBody(..), formData, formURLEncoded)
import Affjax.RequestHeader as ARH import Affjax.RequestHeader as ARH
import Affjax.ResponseFormat as ResponseFormat import Affjax.ResponseFormat as ResponseFormat
import DOM.Simple.Console (log, log2)
import Data.Argonaut (class DecodeJson, decodeJson, class EncodeJson, encodeJson) import Data.Argonaut (class DecodeJson, decodeJson, class EncodeJson, encodeJson)
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Foldable (foldMap) import Data.Foldable (foldMap)
...@@ -12,18 +11,18 @@ import Data.FormURLEncoded as FormURLEncoded ...@@ -12,18 +11,18 @@ import Data.FormURLEncoded as FormURLEncoded
import Data.HTTP.Method (Method(..)) import Data.HTTP.Method (Method(..))
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.MediaType.Common (applicationFormURLEncoded, applicationJSON, multipartFormData) import Data.MediaType.Common (applicationFormURLEncoded, applicationJSON, multipartFormData)
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple)
import DOM.Simple.Console (log2)
import Effect.Aff (Aff, throwError) import Effect.Aff (Aff, throwError)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Effect.Exception (error) import Effect.Exception (error)
import Milkis as Milkis
import Unsafe.Coerce (unsafeCoerce)
import Web.XHR.FormData as XHRFormData import Web.XHR.FormData as XHRFormData
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
here :: R2.Here
here = R2.here "Gargantext.Config.REST"
type Token = String type Token = String
-- TODO too much duplicate code in `postWwwUrlencoded` -- TODO too much duplicate code in `postWwwUrlencoded`
...@@ -51,12 +50,14 @@ send m mtoken url reqbody = do ...@@ -51,12 +50,14 @@ send m mtoken url reqbody = do
R2.setCookie cookie R2.setCookie cookie
case affResp of case affResp of
Left err -> do Left err -> do
_ <- liftEffect $ log $ printError err _ <- liftEffect $ do
here.log2 "error during request to url" url
here.log $ printError err
throwError $ error $ printError err throwError $ error $ printError err
Right resp -> do Right resp -> do
--_ <- liftEffect $ log json.status --_ <- liftEffect $ here.log json.status
--_ <- liftEffect $ log json.headers --_ <- liftEffect $ here.log json.headers
--_ <- liftEffect $ log json.body --_ <- liftEffect $ here.log json.body
case decodeJson resp.body of case decodeJson resp.body of
Left err -> throwError $ error $ "decodeJson affResp.body: " <> show err Left err -> throwError $ error $ "decodeJson affResp.body: " <> show err
Right b -> pure b Right b -> pure b
...@@ -103,12 +104,12 @@ postWwwUrlencoded mtoken url bodyParams = do ...@@ -103,12 +104,12 @@ postWwwUrlencoded mtoken url bodyParams = do
} }
case affResp of case affResp of
Left err -> do Left err -> do
_ <- liftEffect $ log $ printError err _ <- liftEffect $ here.log $ printError err
throwError $ error $ printError err throwError $ error $ printError err
Right resp -> do Right resp -> do
--_ <- liftEffect $ log json.status --_ <- liftEffect $ here.log json.status
--_ <- liftEffect $ log json.headers --_ <- liftEffect $ here.log json.headers
--_ <- liftEffect $ log json.body --_ <- liftEffect $ here.log json.body
case decodeJson resp.body of case decodeJson resp.body of
Left err -> throwError $ error $ "decodeJson affResp.body: " <> show err Left err -> throwError $ error $ "decodeJson affResp.body: " <> show err
Right b -> pure b Right b -> pure b
...@@ -133,7 +134,7 @@ postMultipartFormData mtoken url body = do ...@@ -133,7 +134,7 @@ postMultipartFormData mtoken url body = do
} }
case affResp of case affResp of
Left err -> do Left err -> do
_ <- liftEffect $ log $ printError err _ <- liftEffect $ here.log $ printError err
throwError $ error $ printError err throwError $ error $ printError err
Right resp -> do Right resp -> do
case decodeJson resp.body of case decodeJson resp.body of
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment