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
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
gargantext
purescript-gargantext
Commits
2a4b56fc
Commit
2a4b56fc
authored
Sep 20, 2019
by
James Laver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace G.C.Loader2 with G.Hooks.Loader
parent
da48c2fc
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
63 additions
and
52 deletions
+63
-52
DocsTable.purs
src/Gargantext/Components/DocsTable.purs
+3
-1
Loader2.purs
src/Gargantext/Components/Loader2.purs
+0
-42
Tree.purs
src/Gargantext/Components/Tree.purs
+1
-1
Loader.purs
src/Gargantext/Hooks/Loader.purs
+45
-0
Histo.purs
src/Gargantext/Pages/Corpus/Chart/Histo.purs
+3
-1
Metrics.purs
src/Gargantext/Pages/Corpus/Chart/Metrics.purs
+2
-1
Pie.purs
src/Gargantext/Pages/Corpus/Chart/Pie.purs
+3
-2
Tree.purs
src/Gargantext/Pages/Corpus/Chart/Tree.purs
+3
-1
Document.purs
src/Gargantext/Pages/Corpus/Document.purs
+1
-1
Lists.purs
src/Gargantext/Pages/Lists.purs
+1
-1
Texts.purs
src/Gargantext/Pages/Texts.purs
+1
-1
No files found.
src/Gargantext/Components/DocsTable.purs
View file @
2a4b56fc
...
...
@@ -25,9 +25,11 @@ import Reactix.DOM.HTML as H
import Gargantext.Prelude
import Gargantext.Config (End(..), NodeType(..), OrderBy(..), Path(..), TabType, TabPostQuery(..), toUrl, endConfigStateful, toLink)
import Gargantext.Config.REST (get, put, post, deleteWithBody, delete)
import Gargantext.Components.
Loader2 (useLoader
)
import Gargantext.Components.
Node (NodePoly(..)
)
import Gargantext.Components.Search.Types (Category(..), CategoryQuery(..), favCategory, trashCategory, decodeCategory, putCategories)
import Gargantext.Components.Table as T
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Utils.DecodeMaybe ((.|))
import Gargantext.Utils.Reactix as R2
import Gargantext.Router as Router
------------------------------------------------------------------------
...
...
src/Gargantext/Components/Loader2.purs
deleted
100644 → 0
View file @
da48c2fc
module Gargantext.Components.Loader2 where
import Data.Maybe (Maybe(..), isNothing)
import Data.Tuple.Nested ((/\))
import Gargantext.Prelude
import Effect.Aff (Aff, launchAff, launchAff_, killFiber)
import Effect.Class (liftEffect)
import Effect.Exception (error)
import Reactix as R
type Props path loaded = { path :: path, loaded :: loaded }
type State path loaded = { currentPath :: path, loaded :: Maybe loaded }
useLoader
:: forall path loaded
. Eq path
=> Show path
=> path
-> (path -> Aff loaded)
-> (Props path loaded -> R.Element)
-> R.Hooks R.Element
useLoader newPath loader render = do
{currentPath, loaded} /\ setState <- R.useState' { currentPath: newPath, loaded: Nothing }
R.useEffect $
if (isNothing loaded || newPath /= currentPath) then do
logs $ "useLoader " <> show {newPath, currentPath, loadedIsNothing: isNothing loaded}
fiber <- launchAff do
freshlyLoaded <- loader newPath
liftEffect $ setState $ const { currentPath: newPath, loaded: Just freshlyLoaded }
pure $ launchAff_ $ killFiber (error "useLoader") fiber
else do
pure $ pure $ unit
pure case loaded of
Nothing ->
-- TODO load spinner
R.fragment []
Just loadedData ->
render {path: currentPath, loaded: loadedData}
src/Gargantext/Components/Tree.purs
View file @
2a4b56fc
...
...
@@ -28,10 +28,10 @@ import Web.File.File (toBlob)
import Web.File.FileList (FileList, item)
import Web.File.FileReader.Aff (readAsText)
import Gargantext.Components.Loader2 (useLoader)
import Gargantext.Config (toUrl, EndConfig, endConfig, End(..), NodeType(..), readNodeType)
import Gargantext.Config as C
import Gargantext.Config.REST (get, put, post, postWwwUrlencoded, delete)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Router as Router
import Gargantext.Types (class ToQuery, toQuery)
import Gargantext.Utils (id)
...
...
src/Gargantext/Hooks/Loader.purs
0 → 100644
View file @
2a4b56fc
module Gargantext.Hooks.Loader where
import Data.Maybe (Maybe(..), isNothing, maybe)
import Data.Tuple (fst)
import Data.Tuple.Nested ((/\))
import Gargantext.Prelude
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Reactix as R
import Gargantext.Utils.Reactix as R2
import Gargantext.Components.LoadingSpinner (loadingSpinner)
useLoader :: forall path state. path -> (path -> Aff state) -> (state -> R.Element) -> R.Hooks R.Element
useLoader path loader render = do
state <- R.useState' Nothing
loader' <- R.useMemo2 path loader (\_ -> loader path)
useLoaderEffect state loader'
pure $ maybe (loadingSpinner {}) render (fst state)
useLoader2 :: forall path state. R.State path -> (path -> Aff state) -> (state -> R.Element) -> R.Hooks R.Element
useLoader2 path loader render = do
state <- R.useState' Nothing
useLoaderEffect2 path state loader
pure $ maybe (loadingSpinner {}) render (fst state)
useLoaderEffect :: forall state. R.State (Maybe state) -> Aff state -> R.Hooks Unit
useLoaderEffect (state /\ setState) loader = do
R.useEffect2 state loader $ do
if isNothing state then
R2.affEffect "useLoader" $ loader >>= (liftEffect <<< setState <<< const <<< Just)
else pure R.nothing
useLoaderEffect' :: forall state. Aff state -> R.Hooks (R.State (Maybe state))
useLoaderEffect' aff = do
state <- R.useState' Nothing
useLoaderEffect state aff
pure state
useLoaderEffect2 :: forall st path. R.State path -> R.State (Maybe st) -> (path -> Aff st) -> R.Hooks Unit
useLoaderEffect2 path state loader = useRepointer path loader >>= useLoaderEffect state
useRepointer :: forall path st. R.State path -> (path -> Aff st) -> R.Hooks (Aff st)
useRepointer path@(path' /\ _) loader = R.useMemo1 path' (\_ -> loader path')
src/Gargantext/Pages/Corpus/Chart/Histo.purs
View file @
2a4b56fc
...
...
@@ -9,12 +9,14 @@ import Reactix as R
import Thermite (Spec)
import Gargantext.Prelude
import Gargantext.Components.Loader2 (useLoader)
import Gargantext.Types (TermList(..))
import Gargantext.Components.Loader as Loader
import Gargantext.Components.Charts.Options.ECharts
import Gargantext.Components.Charts.Options.Series
import Gargantext.Components.Charts.Options.Color
import Gargantext.Components.Charts.Options.Font
import Gargantext.Components.Charts.Options.Data
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Utils.Reactix as R2
import Gargantext.Pages.Corpus.Chart.Utils as U
...
...
src/Gargantext/Pages/Corpus/Chart/Metrics.purs
View file @
2a4b56fc
...
...
@@ -12,13 +12,14 @@ import Reactix as R
import Gargantext.Prelude
import Gargantext.Types (TermList(..))
import Gargantext.Components.Loader
2 (useLoader)
import Gargantext.Components.Loader
as Loader
import Gargantext.Components.Charts.Options.ECharts
import Gargantext.Components.Charts.Options.Type
import Gargantext.Components.Charts.Options.Series
import Gargantext.Components.Charts.Options.Color
import Gargantext.Components.Charts.Options.Font
import Gargantext.Components.Charts.Options.Data
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Utils.Reactix as R2
import Gargantext.Pages.Corpus.Chart.Utils as U
...
...
src/Gargantext/Pages/Corpus/Chart/Pie.purs
View file @
2a4b56fc
...
...
@@ -13,12 +13,13 @@ import Reactix as R
import Thermite (Spec)
import Gargantext.Prelude
import Gargantext.
Components.Loader2 (useLoader
)
import Gargantext.
Types (TermList(..)
)
import Gargantext.Components.Charts.Options.ECharts
import Gargantext.Components.Charts.Options.Series (seriesBarD1, seriesPieD1)
import Gargantext.Components.Charts.Options.Color (blue)
import Gargantext.Components.Charts.Options.Font
import Gargantext.Components.Charts.Options.Data (dataSerie)
import Gargantext.Components.Charts.Options.Data
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Utils.Reactix as R2
import Gargantext.Pages.Corpus.Chart.Utils as U
...
...
src/Gargantext/Pages/Corpus/Chart/Tree.purs
View file @
2a4b56fc
...
...
@@ -10,10 +10,12 @@ import Reactix.DOM.HTML as H
import Thermite (Spec)
import Gargantext.Prelude
import Gargantext.
Components.Loader2 (useLoader
)
import Gargantext.
Types (TermList(..)
)
import Gargantext.Components.Charts.Options.ECharts
import Gargantext.Components.Charts.Options.Series
import Gargantext.Components.Charts.Options.Font
import Gargantext.Components.Charts.Options.Data
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Utils.Reactix as R2
import Gargantext.Pages.Corpus.Chart.Utils as U
...
...
src/Gargantext/Pages/Corpus/Document.purs
View file @
2a4b56fc
...
...
@@ -15,10 +15,10 @@ import Gargantext.Prelude
import Gargantext.Config (toUrl, endConfigStateful, NodeType(..), End(..), TabSubType(..), TabType(..), CTabNgramType(..), CTabNgramType(..))
import Gargantext.Config.REST (get)
import Gargantext.Components.AutoUpdate (autoUpdateElt)
import Gargantext.Components.Loader2 (useLoader)
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.NgramsTable.Core
import Gargantext.Components.Annotation.AnnotatedField as AnnotatedField
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Types (TermList)
import Gargantext.Utils.Reactix as R2
...
...
src/Gargantext/Pages/Lists.purs
View file @
2a4b56fc
...
...
@@ -9,12 +9,12 @@ import Thermite (Spec)
--------------------------------------------------------
import Gargantext.Prelude
import Gargantext.Components.Node (NodePoly(..), HyperdataList)
import Gargantext.Components.Loader2 (useLoader)
import Gargantext.Components.Table as Table
import Gargantext.Config (toUrl, endConfigStateful, Path(..), NodeType(..), End(..))
import Gargantext.Config.REST (get)
import Gargantext.Pages.Lists.Tabs.Types (CorpusData, CorpusInfo(..))
import Gargantext.Pages.Lists.Tabs.Specs (elt) as Tabs
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Utils.Reactix as R2
------------------------------------------------------------------------
...
...
src/Gargantext/Pages/Texts.purs
View file @
2a4b56fc
...
...
@@ -9,12 +9,12 @@ import Thermite (Spec)
--------------------------------------------------------
import Gargantext.Prelude
import Gargantext.Components.Node (NodePoly(..), HyperdataList)
import Gargantext.Components.Loader2 (useLoader)
import Gargantext.Components.Table as Table
import Gargantext.Config (toUrl, endConfigStateful, Path(..), NodeType(..), End(..))
import Gargantext.Config.REST (get)
import Gargantext.Pages.Texts.Tabs.Types (CorpusData, CorpusInfo(..))
import Gargantext.Pages.Texts.Tabs.Specs (elt) as Tabs
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Utils.Reactix as R2
------------------------------------------------------------------------
...
...
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