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
b134255c
Commit
b134255c
authored
Jan 03, 2019
by
Nicolas Pouillard
Committed by
Alexandre Delanoë
Feb 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NGRAMS-TABLE] add the Versioned type to follow the API change
parent
a913e33d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
13 deletions
+34
-13
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+24
-3
NgramsTable.purs
...Pages/Annuaire/User/Contacts/Tabs/Ngrams/NgramsTable.purs
+5
-5
NgramsTable.purs
src/Gargantext/Pages/Corpus/Tabs/Ngrams/NgramsTable.purs
+5
-5
No files found.
src/Gargantext/Components/NgramsTable.purs
View file @
b134255c
...
...
@@ -4,6 +4,9 @@ module Gargantext.Components.NgramsTable
, PatchMap
, NgramsPatch
, NgramsTable
, VersionedNgramsTable
, Version
, Versioned(..)
, Action
, initialPageParams
, initialState
...
...
@@ -55,7 +58,7 @@ type PageParams mode = {nodeId :: Int, params :: T.Params, mode :: mode}
initialPageParams :: forall mode. Int -> mode -> PageParams mode
initialPageParams nodeId mode = {nodeId, params: T.initialParams, mode}
type Props' mode = Loader.InnerProps (PageParams mode) NgramsTable ()
type Props' mode = Loader.InnerProps (PageParams mode)
Versioned
NgramsTable ()
type NgramsTerm = String
...
...
@@ -87,6 +90,20 @@ instance decodeJsonNgramsElement :: DecodeJson NgramsElement where
let children = Set.fromFoldable (children' :: Array NgramsTerm)
pure $ NgramsElement {ngrams, list, occurrences, parent, children}
type Version = Int
newtype Versioned a = Versioned
{ version :: Version
, data :: a
}
instance decodeJsonVersioned :: DecodeJson a => DecodeJson (Versioned a) where
decodeJson json = do
obj <- decodeJson json
version <- obj .? "version"
data_ <- obj .? "data"
pure $ Versioned {version, data: data_}
-- type NgramsTable = Array (NTree NgramsElement)
-- type NgramsTable = Array NgramsElement
newtype NgramsTable = NgramsTable (Map NgramsTerm NgramsElement)
...
...
@@ -111,6 +128,8 @@ instance decodeJsonNgramsTable :: DecodeJson NgramsTable where
where
f e@(NgramsElement e') = Tuple e'.ngrams e
type VersionedNgramsTable = Versioned NgramsTable
data Replace a
= Keep
| Replace { old :: a, new :: a }
...
...
@@ -424,10 +443,12 @@ ngramsTableSpec = simpleSpec performAction render
render :: Render State (Props' mode) Action
render dispatch { path: {nodeId, mode}
, loaded:
initTable
, loaded:
Versioned { version, data: initTable }
, dispatch: loaderDispatch }
{ ngramsTablePatch, ngramsParent, ngramsChildren, searchQuery }
_reactChildren =
_reactChildren
| version /= 1 = [ p [] [text "Invalid version"] ]
| otherwise =
[ T.tableElt
{ rows
, setParams: \params -> loaderDispatch (Loader.SetPath {nodeId, params, mode})
...
...
src/Gargantext/Pages/Annuaire/User/Contacts/Tabs/Ngrams/NgramsTable.purs
View file @
b134255c
...
...
@@ -31,7 +31,7 @@ type Props = NT.Props Contact Mode
type PageParams = NT.PageParams Mode
getTable :: PTabNgramType -> Maybe Int -> Offset -> Limit -> Aff NT.NgramsTable
getTable :: PTabNgramType -> Maybe Int -> Offset -> Limit -> Aff NT.
Versioned
NgramsTable
getTable tab nodeId offset limit =
get $ toUrl Back (Ngrams (TabPairing (TabNgramType tab))
offset limit Nothing) nodeId
...
...
@@ -41,18 +41,18 @@ modeTabType Patents = PTabPatents
modeTabType Books = PTabBooks
modeTabType Communication = PTabCommunication
loadPage :: PageParams -> Aff NT.NgramsTable
loadPage :: PageParams -> Aff NT.
Versioned
NgramsTable
loadPage {nodeId, mode, params: {offset, limit}} =
getTable (modeTabType mode) (Just nodeId) offset limit
-- TODO this ignores orderBy
ngramsLoaderClass :: Loader.LoaderClass PageParams NT.NgramsTable
ngramsLoaderClass :: Loader.LoaderClass PageParams NT.
Versioned
NgramsTable
ngramsLoaderClass = Loader.createLoaderClass "ContactsNgramsLoader" loadPage
ngramsLoader :: Loader.Props' PageParams NT.NgramsTable -> ReactElement
ngramsLoader :: Loader.Props' PageParams NT.
Versioned
NgramsTable -> ReactElement
ngramsLoader props = React.createElement ngramsLoaderClass props []
ngramsTableClass :: Loader.InnerClass PageParams NT.NgramsTable
ngramsTableClass :: Loader.InnerClass PageParams NT.
Versioned
NgramsTable
ngramsTableClass = createClass "ContactsNgramsTable" NT.ngramsTableSpec NT.initialState
ngramsTableSpec :: Spec {} Props Void
...
...
src/Gargantext/Pages/Corpus/Tabs/Ngrams/NgramsTable.purs
View file @
b134255c
...
...
@@ -31,7 +31,7 @@ type Props = NT.Props (NodePoly CorpusInfo) Mode
type PageParams = NT.PageParams Mode
getTable :: CTabNgramType -> Maybe Int -> Offset -> Limit -> Aff NT.NgramsTable
getTable :: CTabNgramType -> Maybe Int -> Offset -> Limit -> Aff NT.
Versioned
NgramsTable
getTable tab nodeId offset limit =
get $ toUrl Back (Ngrams (TabCorpus (TabNgramType tab))
offset limit Nothing) nodeId
...
...
@@ -42,18 +42,18 @@ modeTabType Sources = CTabSources
modeTabType Institutes = CTabInstitutes
modeTabType Terms = CTabTerms
loadPage :: PageParams -> Aff NT.NgramsTable
loadPage :: PageParams -> Aff NT.
Versioned
NgramsTable
loadPage {nodeId, mode, params: {offset, limit}} =
getTable (modeTabType mode) (Just nodeId) offset limit
-- TODO this ignores orderBy
ngramsLoaderClass :: Loader.LoaderClass PageParams NT.NgramsTable
ngramsLoaderClass :: Loader.LoaderClass PageParams NT.
Versioned
NgramsTable
ngramsLoaderClass = Loader.createLoaderClass "CorpusNgramsLoader" loadPage
ngramsLoader :: Loader.Props' PageParams NT.NgramsTable -> ReactElement
ngramsLoader :: Loader.Props' PageParams NT.
Versioned
NgramsTable -> ReactElement
ngramsLoader props = React.createElement ngramsLoaderClass props []
ngramsTableClass :: Loader.InnerClass PageParams NT.NgramsTable
ngramsTableClass :: Loader.InnerClass PageParams NT.
Versioned
NgramsTable
ngramsTableClass = createClass "CorpusNgramsTable" NT.ngramsTableSpec NT.initialState
ngramsTableSpec :: Spec {} Props Void
...
...
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