Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
93834b1e
Commit
93834b1e
authored
Dec 07, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[searx] searx work + better support for task errors
parent
7ec15fbf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
8 deletions
+60
-8
ErrorsView.purs
src/Gargantext/Components/ErrorsView.purs
+11
-0
Utils.purs
src/Gargantext/Config/Utils.purs
+37
-3
Types.purs
src/Gargantext/Types.purs
+12
-5
No files found.
src/Gargantext/Components/ErrorsView.purs
View file @
93834b1e
...
@@ -51,3 +51,14 @@ errorsViewCpt = here.component "errorsView" cpt
...
@@ -51,3 +51,14 @@ errorsViewCpt = here.component "errorsView" cpt
Nothing -> es
Nothing -> es
Just es' -> es'
Just es' -> es'
) errors
) errors
showError errors i (FOtherError { error }) =
RB.alert { dismissible: true
, onClose
, variant: "danger" } [ H.text $ show error ]
where
onClose = do
here.log2 "click!" error
T.modify_ (\es -> case deleteAt i es of
Nothing -> es
Just es' -> es'
) errors
src/Gargantext/Config/Utils.purs
View file @
93834b1e
...
@@ -4,21 +4,55 @@ import Gargantext.Prelude
...
@@ -4,21 +4,55 @@ import Gargantext.Prelude
import Data.Array as A
import Data.Array as A
import Data.Either (Either(..))
import Data.Either (Either(..))
import Data.Maybe (Maybe(..))
import Effect.Aff (Aff)
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Gargantext.Config.REST (RESTError)
import Gargantext.Config.REST (RESTError)
import Gargantext.Types (FrontendError(..))
import Gargantext.Types (
AsyncProgress(..), AsyncTaskEvent(..), AsyncTaskLog(..),
FrontendError(..))
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Toestand as T
import Toestand as T
here :: R2.Here
here :: R2.Here
here = R2.here "Gargantext.Config.Utils"
here = R2.here "Gargantext.Config.Utils"
handleRESTError :: forall a. T.Box (Array FrontendError)
handleRESTError :: forall a.
T.Box (Array FrontendError)
-> Either RESTError a
-> Either RESTError a
-> (a -> Aff Unit)
-> (a -> Aff Unit)
-> Aff Unit
-> Aff Unit
handleRESTError errors (Left error) _ = liftEffect $ do
handleRESTError errors (Left error) _ = liftEffect $ do
T.modify_ (A.cons $ FRESTError { error }) errors
T.modify_ (A.cons $ FRESTError { error }) errors
here.log2 "[handleTaskError] RESTError" error
here.log2 "[handleTaskError] RESTError" error
handleRESTError _ (Right task) handler = handler task
handleRESTError _ (Right task) handler = do
handler task
handleTaskRESTError :: T.Box (Array FrontendError)
-> Either RESTError AsyncProgress
-> (AsyncProgress -> Aff Unit)
-> Aff Unit
handleTaskRESTError errors eTask handler = do
handleRESTError errors eTask $ \task -> do
handleAsyncTaskError :: AsyncProgress
-> T.Box (Array FrontendError)
-> Aff Unit
handleAsyncTaskError (AsyncProgress { log, status }) errors = do
case A.uncons log of
Nothing -> do
liftEffect $ here.log "[handleAsyncTaskError] log empty"
pure unit
Just { head: AsyncTaskLog { events, failed } } -> do
if failed == 0
then do
liftEffect $ here.log "[handleAsyncTaskError] failed = 0"
pure unit
else case A.uncons events of
Nothing -> do
liftEffect $ here.log "[handleAsyncTaskError] events empty"
pure unit
Just { head: AsyncTaskEvent { message, level } } -> liftEffect $ do
T.modify_ (A.cons $ FOtherError { error: "[" <> level <> "] " <> message }) errors
here.log2 "[handleAsyncTaskError] message" message
here.log2 "[handleAsyncTaskError] level" level
src/Gargantext/Types.purs
View file @
93834b1e
...
@@ -740,8 +740,15 @@ derive instance Generic AsyncProgress _
...
@@ -740,8 +740,15 @@ derive instance Generic AsyncProgress _
derive instance Newtype AsyncProgress _
derive instance Newtype AsyncProgress _
derive newtype instance JSON.ReadForeign AsyncProgress
derive newtype instance JSON.ReadForeign AsyncProgress
newtype AsyncTaskEvent = AsyncTaskEvent
{ message :: String
, level :: String }
derive instance Generic AsyncTaskEvent _
derive instance Newtype AsyncTaskEvent _
derive newtype instance JSON.ReadForeign AsyncTaskEvent
newtype AsyncTaskLog = AsyncTaskLog {
newtype AsyncTaskLog = AsyncTaskLog {
events :: Array
String
events :: Array
AsyncTaskEvent
, failed :: Int
, failed :: Int
, remaining :: Int
, remaining :: Int
, succeeded :: Int
, succeeded :: Int
...
@@ -781,10 +788,10 @@ toggleSidePanelState Opened = Closed
...
@@ -781,10 +788,10 @@ toggleSidePanelState Opened = Closed
---------------------------------------------------------------------------
---------------------------------------------------------------------------
data FrontendError =
FStringError
data FrontendError =
{ error :: String
FStringError { error :: String }
} | FRESTError
| FRESTError { error :: RESTError }
{ error :: RESTError
}
| FOtherError { error :: String
}
derive instance Generic FrontendError _
derive instance Generic FrontendError _
instance Eq FrontendError where eq = genericEq
instance Eq FrontendError where eq = genericEq
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment