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
4f0fae64
Unverified
Commit
4f0fae64
authored
Nov 19, 2018
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve the loader component
parent
2a9787c1
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
80 additions
and
36 deletions
+80
-36
Loader.purs
src/Gargantext/Components/Loader.purs
+52
-9
Table.purs
src/Gargantext/Components/Table.purs
+2
-2
Annuaire.purs
src/Gargantext/Pages/Annuaire.purs
+3
-3
Corpus.purs
src/Gargantext/Pages/Corpus.purs
+5
-5
Document.purs
src/Gargantext/Pages/Corpus/Document.purs
+2
-2
NgramsTable.purs
src/Gargantext/Pages/Corpus/Tabs/Ngrams/NgramsTable.purs
+9
-8
Specs.purs
src/Gargantext/Pages/Corpus/Tabs/Specs.purs
+2
-2
States.purs
src/Gargantext/Pages/Corpus/Tabs/States.purs
+2
-2
Specs.purs
src/Gargantext/Pages/Home/Specs.purs
+1
-1
States.purs
src/Gargantext/Pages/Layout/States.purs
+1
-1
Main.purs
src/Main.purs
+1
-1
No files found.
src/Gargantext/Components/Loader.purs
View file @
4f0fae64
module Gargantext.Components.Loader where
module Gargantext.Components.Loader where
import Control.Monad.Cont.Trans (lift)
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..))
import Data.Either (Either(..))
import Data.Traversable (traverse_)
import React as React
import React as React
import React (ReactClass)
import React (ReactClass
, Children
)
import Gargantext.Prelude
import Gargantext.Prelude
import Effect.Aff (Aff, launchAff, launchAff_, makeAff, nonCanceler, killFiber)
import Effect.Aff (Aff)
import Effect.Exception (error)
import Thermite (Render, PerformAction, simpleSpec, modifyState_, createReactSpec)
type InnerProps a b =
type InnerProps a b =
{ path :: a
{ path :: a
, loaded :: Maybe b
, loaded :: Maybe b
, children ::
React.
Children
, children :: Children
}
}
type Props a b = { path :: a
type PropsRow a b c =
, component :: ReactClass (InnerProps a b)
( path :: a
}
, component :: ReactClass (InnerProps a b)
| c
)
type Props a b = Record (PropsRow a b (children :: Children))
type Props' a b = Record (PropsRow a b ())
data Action a = ForceReload | SetPath a
type State a b = { currentPath :: a, loaded :: Maybe b }
createLoaderClass :: forall a b
. Eq a
=> String
-> (a -> Aff b)
-> ReactClass (Record (PropsRow a b (children :: Children)))
createLoaderClass name loader =
React.component name
(\this -> do
s <- spec this
pure { state: s.state
, render: s.render
, componentDidMount: dispatcher this ForceReload
})
where
initialState {path} = {currentPath: path, loaded: Nothing}
performAction :: PerformAction (State a b) (Props' a b) (Action a)
performAction ForceReload _ {currentPath} = do
loaded <- lift $ loader currentPath
modifyState_ $ _ { loaded = Just loaded }
performAction (SetPath newPath) _ {currentPath} =
when (newPath /= currentPath) $ do
loaded <- lift $ loader newPath
modifyState_ $ _ { currentPath = newPath, loaded = Just loaded }
render :: Render (State a b) (Props' a b) (Action a)
render _d {component} {currentPath, loaded} c =
[React.createElement component {path: currentPath, loaded} c]
{spec, dispatcher} = createReactSpec (simpleSpec performAction render) initialState
{-
createLoaderClass :: forall a b
createLoaderClass :: forall a b
. String
. String
-> (a -> Aff b)
-> (a -> Aff b)
...
@@ -49,3 +91,4 @@ createLoaderClass name loader = React.component name mk
...
@@ -49,3 +91,4 @@ createLoaderClass name loader = React.component name mk
{loaded} <- React.getState this
{loaded} <- React.getState this
pure $ React.createElement component {path, loaded} []
pure $ React.createElement component {path, loaded} []
}
}
-}
src/Gargantext/Components/Table.purs
View file @
4f0fae64
...
@@ -57,8 +57,8 @@ type State =
...
@@ -57,8 +57,8 @@ type State =
--, tree :: FTree
--, tree :: FTree
}
}
initialState :: State
initialState ::
Props ->
State
initialState =
initialState
_
=
{ rows : Nothing
{ rows : Nothing
, currentPage : 1
, currentPage : 1
, pageSize : PS10
, pageSize : PS10
...
...
src/Gargantext/Pages/Annuaire.purs
View file @
4f0fae64
...
@@ -71,7 +71,7 @@ layout = simpleSpec defaultPerformAction render
...
@@ -71,7 +71,7 @@ layout = simpleSpec defaultPerformAction render
render _ {annuaireId} _ _ =
render _ {annuaireId} _ _ =
[ annuaireLoader
[ annuaireLoader
{ path: annuaireId
{ path: annuaireId
, component: createClass "LoadedAnnuaire" loadedAnnuaireSpec
{}
, component: createClass "LoadedAnnuaire" loadedAnnuaireSpec
(const {})
} ]
} ]
loadedAnnuaireSpec :: Spec {} Props Void
loadedAnnuaireSpec :: Spec {} Props Void
...
@@ -178,5 +178,5 @@ getAnnuaireInfo id = get $ toUrl Back Node id
...
@@ -178,5 +178,5 @@ getAnnuaireInfo id = get $ toUrl Back Node id
annuaireLoaderClass :: ReactClass (Loader.Props Int AnnuaireInfo)
annuaireLoaderClass :: ReactClass (Loader.Props Int AnnuaireInfo)
annuaireLoaderClass = createLoaderClass "AnnuaireLoader" getAnnuaireInfo
annuaireLoaderClass = createLoaderClass "AnnuaireLoader" getAnnuaireInfo
annuaireLoader :: Loader.Props Int AnnuaireInfo -> ReactElement
annuaireLoader :: Loader.Props
'
Int AnnuaireInfo -> ReactElement
annuaireLoader
= React.createLeafElement annuaireLoaderClass
annuaireLoader
props = React.createElement annuaireLoaderClass props []
src/Gargantext/Pages/Corpus.purs
View file @
4f0fae64
...
@@ -28,9 +28,9 @@ type Props = Tabs.Props
...
@@ -28,9 +28,9 @@ type Props = Tabs.Props
type State = { tabsView :: Tabs.State
type State = { tabsView :: Tabs.State
}
}
initialState :: State
initialState ::
Props ->
State
initialState
= { tabsView : Tabs.initialState
initialState
_props =
}
{ tabsView : Tabs.initialState {}
}
------------------------------------------------------------------------
------------------------------------------------------------------------
_tabsView :: forall a b. Lens' { tabsView :: a | b } a
_tabsView :: forall a b. Lens' { tabsView :: a | b } a
...
@@ -87,5 +87,5 @@ getCorpus = get <<< toUrl Back Corpus
...
@@ -87,5 +87,5 @@ getCorpus = get <<< toUrl Back Corpus
corpusLoaderClass :: ReactClass (Loader.Props Int (NodePoly CorpusInfo))
corpusLoaderClass :: ReactClass (Loader.Props Int (NodePoly CorpusInfo))
corpusLoaderClass = createLoaderClass "CorpusLoader" getCorpus
corpusLoaderClass = createLoaderClass "CorpusLoader" getCorpus
corpusLoader :: Loader.Props Int (NodePoly CorpusInfo) -> ReactElement
corpusLoader :: Loader.Props
'
Int (NodePoly CorpusInfo) -> ReactElement
corpusLoader
= React.createLeafElement corpusLoaderClass
corpusLoader
props = React.createElement corpusLoaderClass props []
src/Gargantext/Pages/Corpus/Document.purs
View file @
4f0fae64
...
@@ -26,8 +26,8 @@ type State =
...
@@ -26,8 +26,8 @@ type State =
, inputValue :: String
, inputValue :: String
}
}
initialState :: State
initialState ::
{} ->
State
initialState =
initialState
{}
=
{ document : Nothing
{ document : Nothing
, inputValue : ""
, inputValue : ""
}
}
...
...
src/Gargantext/Pages/Corpus/Tabs/Ngrams/NgramsTable.purs
View file @
4f0fae64
...
@@ -173,12 +173,13 @@ type State =
...
@@ -173,12 +173,13 @@ type State =
, termTypeFilter :: Maybe TermType -- Nothing means all
, termTypeFilter :: Maybe TermType -- Nothing means all
}
}
initialState :: State
initialState :: forall props. props -> State
initialState = { ngramsTablePatch: mempty
initialState _ =
, searchQuery: ""
{ ngramsTablePatch: mempty
, termListFilter: Nothing
, searchQuery: ""
, termTypeFilter: Nothing
, termListFilter: Nothing
}
, termTypeFilter: Nothing
}
data Action
data Action
= SetTermListItem NgramsTerm (Replace TermList)
= SetTermListItem NgramsTerm (Replace TermList)
...
@@ -322,8 +323,8 @@ getNgramsTable = get <<< toUrl Back (Ngrams TabTerms Nothing)
...
@@ -322,8 +323,8 @@ getNgramsTable = get <<< toUrl Back (Ngrams TabTerms Nothing)
ngramsLoaderClass :: ReactClass (Loader.Props Int NgramsTable)
ngramsLoaderClass :: ReactClass (Loader.Props Int NgramsTable)
ngramsLoaderClass = Loader.createLoaderClass "NgramsLoader" getNgramsTable
ngramsLoaderClass = Loader.createLoaderClass "NgramsLoader" getNgramsTable
ngramsLoader :: Loader.Props Int NgramsTable -> ReactElement
ngramsLoader :: Loader.Props
'
Int NgramsTable -> ReactElement
ngramsLoader
= React.createLeafElement ngramsLoaderClass
ngramsLoader
props = React.createElement ngramsLoaderClass props []
ngramsTableSpec :: Spec {} Props Void
ngramsTableSpec :: Spec {} Props Void
ngramsTableSpec = simpleSpec defaultPerformAction render
ngramsTableSpec = simpleSpec defaultPerformAction render
...
...
src/Gargantext/Pages/Corpus/Tabs/Specs.purs
View file @
4f0fae64
...
@@ -15,8 +15,8 @@ import Gargantext.Components.Tab as Tab
...
@@ -15,8 +15,8 @@ import Gargantext.Components.Tab as Tab
import Thermite (Spec, focus, hideState, cmapProps)
import Thermite (Spec, focus, hideState, cmapProps)
pureTabs :: Spec {} Props Void
--
pureTabs :: Spec {} Props Void
pureTabs = hideState initialState statefulTabs
--
pureTabs = hideState initialState statefulTabs
statefulTabs :: Spec State Props Action
statefulTabs :: Spec State Props Action
statefulTabs =
statefulTabs =
...
...
src/Gargantext/Pages/Corpus/Tabs/States.purs
View file @
4f0fae64
...
@@ -12,8 +12,8 @@ type State =
...
@@ -12,8 +12,8 @@ type State =
, activeTab :: Int
, activeTab :: Int
}
}
initialState :: State
initialState ::
{} ->
State
initialState =
initialState
_
=
{ docsView : {}
{ docsView : {}
, ngramsView : {} -- N.initialState
, ngramsView : {} -- N.initialState
, activeTab : 0
, activeTab : 0
...
...
src/Gargantext/Pages/Home/Specs.purs
View file @
4f0fae64
...
@@ -26,7 +26,7 @@ landingData FR = Fr.landingData
...
@@ -26,7 +26,7 @@ landingData FR = Fr.landingData
landingData EN = En.landingData
landingData EN = En.landingData
layoutLanding :: Lang -> Spec {} {} Void
layoutLanding :: Lang -> Spec {} {} Void
layoutLanding = hideState (unwrap initialState)
layoutLanding = hideState (
const $
unwrap initialState)
<<< focusState (re _Newtype)
<<< focusState (re _Newtype)
<<< layoutLanding' <<< landingData
<<< layoutLanding' <<< landingData
...
...
src/Gargantext/Pages/Layout/States.purs
View file @
4f0fae64
...
@@ -36,7 +36,7 @@ initAppState =
...
@@ -36,7 +36,7 @@ initAppState =
, addCorpusState : AC.initialState
, addCorpusState : AC.initialState
, searchState : S.initialState
, searchState : S.initialState
, userPageState : C.initialState
, userPageState : C.initialState
, documentState : D.initialState
, documentState : D.initialState
{}
, ntreeState : Tree.exampleTree
, ntreeState : Tree.exampleTree
, search : ""
, search : ""
, showLogin : false
, showLogin : false
...
...
src/Main.purs
View file @
4f0fae64
...
@@ -24,7 +24,7 @@ setUnsafeComponentWillMount = unsafeSet "unsafeComponentWillMount"
...
@@ -24,7 +24,7 @@ setUnsafeComponentWillMount = unsafeSet "unsafeComponentWillMount"
main :: Effect Unit
main :: Effect Unit
main = do
main = do
case T.createReactSpec layoutSpec
initAppState
of
case T.createReactSpec layoutSpec
(const initAppState)
of
{ spec, dispatcher } -> void $ do
{ spec, dispatcher } -> void $ do
let setRouting this = void $ do
let setRouting this = void $ do
matches routing (routeHandler (dispatchAction (dispatcher this)))
matches routing (routeHandler (dispatchAction (dispatcher this)))
...
...
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