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
387911c8
Unverified
Commit
387911c8
authored
Dec 10, 2018
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NGRAM] add basic support for offset & limit
parent
1ce81014
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
17 deletions
+31
-17
Config.purs
src/Gargantext/Config.purs
+15
-9
NgramsTable.purs
...Pages/Annuaire/User/Contacts/Tabs/Ngrams/NgramsTable.purs
+8
-4
NgramsTable.purs
src/Gargantext/Pages/Corpus/Tabs/Ngrams/NgramsTable.purs
+8
-4
No files found.
src/Gargantext/Config.purs
View file @
387911c8
...
@@ -102,6 +102,12 @@ tabTypeDocs :: TabType -> UrlPath
...
@@ -102,6 +102,12 @@ tabTypeDocs :: TabType -> UrlPath
tabTypeDocs (TabCorpus t) = "table?view=" <> show t
tabTypeDocs (TabCorpus t) = "table?view=" <> show t
tabTypeDocs (TabPairing t) = "pairing?view=" <> show t
tabTypeDocs (TabPairing t) = "pairing?view=" <> show t
limitUrl :: Limit -> UrlPath
limitUrl l = "&limit=" <> show l
offsetUrl :: Offset -> UrlPath
offsetUrl o = "&offset=" <> show o
tabTypeNgrams :: TabType -> UrlPath
tabTypeNgrams :: TabType -> UrlPath
tabTypeNgrams (TabCorpus t) = "listGet?ngramsType=" <> show t
tabTypeNgrams (TabCorpus t) = "listGet?ngramsType=" <> show t
tabTypeNgrams (TabPairing t) = "listGet?ngramsType=" <> show t -- TODO
tabTypeNgrams (TabPairing t) = "listGet?ngramsType=" <> show t -- TODO
...
@@ -109,18 +115,17 @@ tabTypeNgrams (TabPairing t) = "listGet?ngramsType=" <> show t -- TODO
...
@@ -109,18 +115,17 @@ tabTypeNgrams (TabPairing t) = "listGet?ngramsType=" <> show t -- TODO
pathUrl :: Config -> Path -> Maybe Id -> UrlPath
pathUrl :: Config -> Path -> Maybe Id -> UrlPath
pathUrl c (Tab t o l s) i =
pathUrl c (Tab t o l s) i =
pathUrl c (NodeAPI Node) i <>
pathUrl c (NodeAPI Node) i <>
"/" <> tabTypeDocs t <> "&offset=" <> show o
"/" <> tabTypeDocs t <> offsetUrl o <> limitUrl l <> os
<> "&limit=" <> show l <> os
where
where
os = maybe "" (\x -> "&order=" <> show x) s
os = maybe "" (\x -> "&order=" <> show x) s
pathUrl c (Children n o l s) i =
pathUrl c (Children n o l s) i =
pathUrl c (NodeAPI Node) i <>
pathUrl c (NodeAPI Node) i <>
"/" <> "children?type=" <> show n <> "&offset=" <> show o
"/" <> "children?type=" <> show n <> offsetUrl o <> limitUrl l <> os
<> "&limit=" <> show l <> os
where
where
os = maybe "" (\x -> "&order=" <> show x) s
os = maybe "" (\x -> "&order=" <> show x) s
pathUrl c (Ngrams t listid) i =
pathUrl c (Ngrams t o l listid) i =
pathUrl c (NodeAPI Node) i <> "/" <> tabTypeNgrams t <> listid'
pathUrl c (NodeAPI Node) i <> "/" <> tabTypeNgrams t
<> offsetUrl o <> limitUrl l <> listid'
where
where
listid' = maybe "" (\x -> "&list=" <> show x) listid
listid' = maybe "" (\x -> "&list=" <> show x) listid
pathUrl c Auth Nothing = c.prePath <> "auth"
pathUrl c Auth Nothing = c.prePath <> "auth"
...
@@ -183,7 +188,7 @@ data Path
...
@@ -183,7 +188,7 @@ data Path
= Auth
= Auth
| Tab TabType Offset Limit (Maybe OrderBy)
| Tab TabType Offset Limit (Maybe OrderBy)
| Children NodeType Offset Limit (Maybe OrderBy)
| Children NodeType Offset Limit (Maybe OrderBy)
| Ngrams TabType (Maybe TermList)
| Ngrams TabType
Offset Limit
(Maybe TermList)
| NodeAPI NodeType
| NodeAPI NodeType
data End = Back | Front
data End = Back | Front
...
@@ -241,9 +246,10 @@ data TabType
...
@@ -241,9 +246,10 @@ data TabType
derive instance eqTabType :: Eq TabType
derive instance eqTabType :: Eq TabType
derive instance genericTabType :: Generic TabType _
instance showTabType :: Show TabType where
instance showTabType :: Show TabType where
show (TabCorpus t) = "Corpus" <> show t
show = genericShow
show (TabPairing t) = "Pairing" <> show t
------------------------------------------------------------
------------------------------------------------------------
nodeTypeUrl :: NodeType -> Url
nodeTypeUrl :: NodeType -> Url
...
...
src/Gargantext/Pages/Annuaire/User/Contacts/Tabs/Ngrams/NgramsTable.purs
View file @
387911c8
...
@@ -18,7 +18,7 @@ import Unsafe.Coerce (unsafeCoerce)
...
@@ -18,7 +18,7 @@ import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Types
import Gargantext.Types
import Gargantext.Components.NgramsTable as NT
import Gargantext.Components.NgramsTable as NT
import Gargantext.Prelude
import Gargantext.Prelude
import Gargantext.Config (PTabNgramType(..), End(..), Path(..), TabSubType(..), TabType(..), toUrl)
import Gargantext.Config (PTabNgramType(..),
Offset, Limit,
End(..), Path(..), TabSubType(..), TabType(..), toUrl)
import Gargantext.Config.REST (get)
import Gargantext.Config.REST (get)
import Gargantext.Components.Loader as Loader
import Gargantext.Components.Loader as Loader
import Gargantext.Pages.Annuaire.User.Contacts.Types (Contact)
import Gargantext.Pages.Annuaire.User.Contacts.Types (Contact)
...
@@ -36,8 +36,10 @@ type Props = NT.Props Contact Mode
...
@@ -36,8 +36,10 @@ type Props = NT.Props Contact Mode
type PageParams = NT.PageParams Mode
type PageParams = NT.PageParams Mode
getTable :: PTabNgramType -> Maybe Int -> Aff NT.NgramsTable
getTable :: PTabNgramType -> Maybe Int -> Offset -> Limit -> Aff NT.NgramsTable
getTable tab = get <<< toUrl Back (Ngrams (TabPairing (TabNgramType tab)) Nothing)
getTable tab nodeId offset limit =
get $ toUrl Back (Ngrams (TabPairing (TabNgramType tab))
offset limit Nothing) nodeId
modeTabType :: Mode -> PTabNgramType
modeTabType :: Mode -> PTabNgramType
modeTabType Patents = PTabPatents
modeTabType Patents = PTabPatents
...
@@ -45,7 +47,9 @@ modeTabType Books = PTabBooks
...
@@ -45,7 +47,9 @@ modeTabType Books = PTabBooks
modeTabType Communication = PTabCommunication
modeTabType Communication = PTabCommunication
loadPage :: PageParams -> Aff NT.NgramsTable
loadPage :: PageParams -> Aff NT.NgramsTable
loadPage {nodeId, mode} = getTable (modeTabType mode) (Just nodeId) -- TODO this ignores params
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.NgramsTable
ngramsLoaderClass = Loader.createLoaderClass "ContactsNgramsLoader" loadPage
ngramsLoaderClass = Loader.createLoaderClass "ContactsNgramsLoader" loadPage
...
...
src/Gargantext/Pages/Corpus/Tabs/Ngrams/NgramsTable.purs
View file @
387911c8
...
@@ -17,7 +17,7 @@ import Gargantext.Types
...
@@ -17,7 +17,7 @@ import Gargantext.Types
import Gargantext.Components.Node (NodePoly)
import Gargantext.Components.Node (NodePoly)
import Gargantext.Components.NgramsTable as NT
import Gargantext.Components.NgramsTable as NT
import Gargantext.Prelude
import Gargantext.Prelude
import Gargantext.Config (CTabNgramType(..), End(..), Path(..), TabSubType(..), TabType(..), toUrl)
import Gargantext.Config (CTabNgramType(..), End(..),
Offset, Limit,
Path(..), TabSubType(..), TabType(..), toUrl)
import Gargantext.Config.REST (get)
import Gargantext.Config.REST (get)
import Gargantext.Components.Loader as Loader
import Gargantext.Components.Loader as Loader
import Gargantext.Pages.Corpus.Tabs.Types (CorpusInfo)
import Gargantext.Pages.Corpus.Tabs.Types (CorpusInfo)
...
@@ -35,8 +35,10 @@ type Props = NT.Props (NodePoly CorpusInfo) Mode
...
@@ -35,8 +35,10 @@ type Props = NT.Props (NodePoly CorpusInfo) Mode
type PageParams = NT.PageParams Mode
type PageParams = NT.PageParams Mode
getTable :: CTabNgramType -> Maybe Int -> Aff NT.NgramsTable
getTable :: CTabNgramType -> Maybe Int -> Offset -> Limit -> Aff NT.NgramsTable
getTable tab = get <<< toUrl Back (Ngrams (TabCorpus (TabNgramType tab)) Nothing)
getTable tab nodeId offset limit =
get $ toUrl Back (Ngrams (TabCorpus (TabNgramType tab))
offset limit Nothing) nodeId
modeTabType :: Mode -> CTabNgramType
modeTabType :: Mode -> CTabNgramType
modeTabType Authors = CTabAuthors
modeTabType Authors = CTabAuthors
...
@@ -45,7 +47,9 @@ modeTabType Institutes = CTabInstitutes
...
@@ -45,7 +47,9 @@ modeTabType Institutes = CTabInstitutes
modeTabType Terms = CTabTerms
modeTabType Terms = CTabTerms
loadPage :: PageParams -> Aff NT.NgramsTable
loadPage :: PageParams -> Aff NT.NgramsTable
loadPage {nodeId, mode} = getTable (modeTabType mode) (Just nodeId) -- TODO this ignores params
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.NgramsTable
ngramsLoaderClass = Loader.createLoaderClass "CorpusNgramsLoader" loadPage
ngramsLoaderClass = Loader.createLoaderClass "CorpusNgramsLoader" loadPage
...
...
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