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
e9233997
Unverified
Commit
e9233997
authored
Feb 20, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NGRAMS-REPO] add an AutoUpdate component and use it to refresh the NgramsTable every 3 seconds
parent
45cb0325
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
1 deletion
+53
-1
psc-package.json
psc-package.json
+1
-0
AutoUpdate.purs
src/Gargantext/Components/AutoUpdate.purs
+44
-0
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+8
-1
No files found.
psc-package.json
View file @
e9233997
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
"set"
:
"master"
,
"set"
:
"master"
,
"source"
:
"https://github.com/np/package-sets.git"
,
"source"
:
"https://github.com/np/package-sets.git"
,
"depends"
:
[
"depends"
:
[
"js-timers"
,
"psci-support"
,
"psci-support"
,
"css"
,
"css"
,
"generics-rep"
,
"generics-rep"
,
...
...
src/Gargantext/Components/AutoUpdate.purs
0 → 100644
View file @
e9233997
module Gargantext.Components.AutoUpdate where
import Control.Monad.Cont.Trans (lift)
import Data.Maybe (Maybe(..))
import Data.Traversable (traverse_)
import React as React
import React (ReactClass, ReactElement, Children)
import React.DOM (div')
import Gargantext.Prelude
import Effect (Effect)
import Effect.Aff (Aff)
import Effect.Timer (IntervalId, setInterval, clearInterval)
import Thermite (Render, PerformAction, simpleSpec, modifyState_,
createReactSpec, defaultRender)
data Action = Update
type PropsRow =
( duration :: Int
, effect :: Effect Unit
)
type Props = { | PropsRow }
type State = { intervalId :: Maybe IntervalId }
autoUpdateClass :: ReactClass { children :: Children | PropsRow }
autoUpdateClass =
React.component "AutoUpdate"
(\this -> do
pure { state: {intervalId: Nothing}
, render: pure $ div' []
, componentDidMount: do
{duration,effect} <- React.getProps this
intervalId <- setInterval duration effect
React.setState this {intervalId: Just intervalId}
, componentWillUnmount: do
{intervalId} <- React.getState this
traverse_ clearInterval intervalId
})
autoUpdateElt :: Props -> ReactElement
autoUpdateElt props = React.createElement autoUpdateClass props []
src/Gargantext/Components/NgramsTable.purs
View file @
e9233997
...
@@ -55,6 +55,7 @@ import Unsafe.Coerce (unsafeCoerce)
...
@@ -55,6 +55,7 @@ import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Types (TermList(..), TermType, readTermList, readTermType, termLists, termTypes)
import Gargantext.Types (TermList(..), TermType, readTermList, readTermType, termLists, termTypes)
import Gargantext.Config (toUrl, End(..), Path(..), TabType)
import Gargantext.Config (toUrl, End(..), Path(..), TabType)
import Gargantext.Config.REST (put)
import Gargantext.Config.REST (put)
import Gargantext.Components.AutoUpdate (autoUpdateElt)
import Gargantext.Components.Table as T
import Gargantext.Components.Table as T
import Gargantext.Prelude
import Gargantext.Prelude
import Gargantext.Components.Loader as Loader
import Gargantext.Components.Loader as Loader
...
@@ -400,6 +401,7 @@ data Action
...
@@ -400,6 +401,7 @@ data Action
| SetTermListFilter (Maybe TermList)
| SetTermListFilter (Maybe TermList)
| SetTermTypeFilter (Maybe TermType)
| SetTermTypeFilter (Maybe TermType)
| SetSearchQuery String
| SetSearchQuery String
| Refresh
type Dispatch = Action -> Effect Unit
type Dispatch = Action -> Effect Unit
...
@@ -520,6 +522,8 @@ ngramsTableSpec = simpleSpec performAction render
...
@@ -520,6 +522,8 @@ ngramsTableSpec = simpleSpec performAction render
modifyState_ $ setParentResetChildren p
modifyState_ $ setParentResetChildren p
performAction (ToggleChild b c) _ _ =
performAction (ToggleChild b c) _ _ =
modifyState_ $ _ngramsChildren <<< at c %~ toggleMap b
modifyState_ $ _ngramsChildren <<< at c %~ toggleMap b
performAction Refresh {path: {nodeId, listIds, tabType}} {ngramsVersion} = do
commitPatch {nodeId, listIds, tabType} (Versioned {version: ngramsVersion, data: mempty})
performAction (SetTermListItem n pl) {path: {nodeId, listIds, tabType}} {ngramsVersion} =
performAction (SetTermListItem n pl) {path: {nodeId, listIds, tabType}} {ngramsVersion} =
commitPatch {nodeId, listIds, tabType} (Versioned {version: ngramsVersion, data: pt})
commitPatch {nodeId, listIds, tabType} (Versioned {version: ngramsVersion, data: pt})
where
where
...
@@ -550,7 +554,10 @@ ngramsTableSpec = simpleSpec performAction render
...
@@ -550,7 +554,10 @@ ngramsTableSpec = simpleSpec performAction render
, dispatch: loaderDispatch }
, dispatch: loaderDispatch }
{ ngramsTablePatch, ngramsParent, ngramsChildren, searchQuery }
{ ngramsTablePatch, ngramsParent, ngramsChildren, searchQuery }
_reactChildren =
_reactChildren =
[ T.tableElt
[ autoUpdateElt { duration: 3000
, effect: dispatch Refresh
}
, T.tableElt
{ rows
{ rows
, setParams: \params -> loaderDispatch (Loader.SetPath {nodeId, listIds, params, tabType})
, setParams: \params -> loaderDispatch (Loader.SetPath {nodeId, listIds, params, tabType})
, container: tableContainer {searchQuery, dispatch, ngramsParent, ngramsChildren, ngramsTable}
, container: tableContainer {searchQuery, dispatch, ngramsParent, ngramsChildren, ngramsTable}
...
...
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