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
148
Issues
148
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
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
9d2cb1ee
Commit
9d2cb1ee
authored
Nov 05, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP
parent
3e4ae118
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
31 deletions
+53
-31
Core.purs
src/Gargantext/Components/NgramsTable/Core.purs
+16
-13
Document.purs
src/Gargantext/Components/Nodes/Corpus/Document.purs
+2
-2
Ends.purs
src/Gargantext/Ends.purs
+19
-11
Routes.purs
src/Gargantext/Routes.purs
+5
-4
Types.purs
src/Gargantext/Types.purs
+11
-1
No files found.
src/Gargantext/Components/NgramsTable/Core.purs
View file @
9d2cb1ee
...
@@ -89,28 +89,30 @@ import Gargantext.Sessions (Session, get, put, post)
...
@@ -89,28 +89,30 @@ import Gargantext.Sessions (Session, get, put, post)
import Gargantext.Types (OrderBy(..), CTabNgramType(..), TabType, TermList(..), TermSize)
import Gargantext.Types (OrderBy(..), CTabNgramType(..), TabType, TermList(..), TermSize)
import Gargantext.Utils.KarpRabin (indicesOfAny)
import Gargantext.Utils.KarpRabin (indicesOfAny)
-- TODO the name is misleading
data NodeId = NodeId { corpusId :: Int
data NodeId = NodeId { corpusId :: Int
, documentId :: Maybe Int
, documentId :: Maybe Int
}
}
type CoreParams
s
=
type CoreParams
nodeId extra
=
{ nodeId ::
N
odeId
{ nodeId ::
n
odeId
-- ^ This node can be a corpus or contact.
-- ^ This node can be a corpus or contact.
, listIds :: Array Int
, listIds :: Array Int
, tabType :: TabType
, tabType :: TabType
, session :: Session
, session :: Session
|
s
|
extra
}
}
type PageParams =
type PageParams
nodeId
=
CoreParams
CoreParams
nodeId
( params :: T.Params
( params :: T.Params
, searchQuery :: String
, searchQuery :: String
, termListFilter :: Maybe TermList -- Nothing means all
, termListFilter :: Maybe TermList -- Nothing means all
, termSizeFilter :: Maybe TermSize -- Nothing means all
, termSizeFilter :: Maybe TermSize -- Nothing means all
)
)
initialPageParams ::
Session -> Int -> Array Int -> TabType -> PageParams
initialPageParams ::
forall nodeId. Session -> nodeId -> Array Int -> TabType -> PageParams nodeId
initialPageParams session nodeId listIds tabType =
initialPageParams session nodeId listIds tabType =
{ nodeId
{ nodeId
, listIds
, listIds
...
@@ -564,14 +566,14 @@ type CoreState s =
...
@@ -564,14 +566,14 @@ type CoreState s =
| s
| s
}
}
postNewNgrams :: forall
s. Array NgramsTerm -> Maybe TermList -> CoreParams
s -> Aff Unit
postNewNgrams :: forall
n s. Array NgramsTerm -> Maybe TermList -> CoreParams n
s -> Aff Unit
postNewNgrams newNgrams mayList {nodeId, listIds, tabType, session} =
postNewNgrams newNgrams mayList {nodeId, listIds, tabType, session} =
when (not (A.null newNgrams)) $ do
when (not (A.null newNgrams)) $ do
(_ :: Array Unit) <- post session p newNgrams
(_ :: Array Unit) <- post session p newNgrams
pure unit
pure unit
where p = PutNgrams tabType (head listIds) mayList (Just nodeId)
where p = PutNgrams tabType (head listIds) mayList (Just nodeId)
postNewElems :: forall
s. NewElems -> CoreParams
s -> Aff Unit
postNewElems :: forall
n s. NewElems -> CoreParams n
s -> Aff Unit
postNewElems newElems params = void $ traverseWithIndex postNewElem newElems
postNewElems newElems params = void $ traverseWithIndex postNewElem newElems
where
where
postNewElem ngrams list = postNewNgrams [ngrams] (Just list) params
postNewElem ngrams list = postNewNgrams [ngrams] (Just list) params
...
@@ -580,11 +582,12 @@ addNewNgram :: CTabNgramType -> NgramsTerm -> TermList -> NgramsTablePatch
...
@@ -580,11 +582,12 @@ addNewNgram :: CTabNgramType -> NgramsTerm -> TermList -> NgramsTablePatch
addNewNgram ntype ngrams list = { ngramsPatches: mempty
addNewNgram ntype ngrams list = { ngramsPatches: mempty
, ngramsNewElems: Map.singleton (normNgram ntype ngrams) list }
, ngramsNewElems: Map.singleton (normNgram ntype ngrams) list }
putNgramsPatches :: forall s. CoreParams s -> Versioned NgramsPatches -> Aff (Versioned NgramsPatches)
-- TODO putNgramsPatches :: forall s. CoreParams Int s -> Versioned NgramsPatches -> Aff (Versioned NgramsPatches)
putNgramsPatches :: forall n s. CoreParams n s -> Versioned NgramsPatches -> Aff (Versioned NgramsPatches)
putNgramsPatches {session, nodeId, listIds, tabType} = put session putNgrams
putNgramsPatches {session, nodeId, listIds, tabType} = put session putNgrams
where putNgrams = PutNgrams tabType (head listIds) Nothing (Just nodeId)
where putNgrams = PutNgrams tabType (head listIds) Nothing (Just nodeId)
commitPatch :: forall
p s. CoreParams
p
commitPatch :: forall
n p s. CoreParams n
p
-> Versioned NgramsTablePatch -> StateCoTransformer (CoreState s) Unit
-> Versioned NgramsTablePatch -> StateCoTransformer (CoreState s) Unit
commitPatch props (Versioned {version, data: tablePatch@{ngramsPatches, ngramsNewElems}}) = do
commitPatch props (Versioned {version, data: tablePatch@{ngramsPatches, ngramsNewElems}}) = do
let pt = Versioned { version, data: ngramsPatches }
let pt = Versioned { version, data: ngramsPatches }
...
@@ -596,7 +599,7 @@ commitPatch props (Versioned {version, data: tablePatch@{ngramsPatches, ngramsNe
...
@@ -596,7 +599,7 @@ commitPatch props (Versioned {version, data: tablePatch@{ngramsPatches, ngramsNe
}
}
-- TODO: check that pt.version == s.ngramsTablePatch.version
-- TODO: check that pt.version == s.ngramsTablePatch.version
loadNgramsTable :: PageParams -> Aff VersionedNgramsTable
loadNgramsTable :: PageParams
NodeId
-> Aff VersionedNgramsTable
loadNgramsTable
loadNgramsTable
{ nodeId, listIds, termListFilter, termSizeFilter, session
{ nodeId, listIds, termListFilter, termSizeFilter, session
, searchQuery, tabType, params: {offset, limit, orderBy}}
, searchQuery, tabType, params: {offset, limit, orderBy}}
...
...
src/Gargantext/Components/Nodes/Corpus/Document.purs
View file @
9d2cb1ee
...
@@ -369,14 +369,14 @@ documentLayoutCpt = R.hooksComponent "G.P.Corpus.Document.documentLayout" cpt
...
@@ -369,14 +369,14 @@ documentLayoutCpt = R.hooksComponent "G.P.Corpus.Document.documentLayout" cpt
------------------------------------------------------------------------
------------------------------------------------------------------------
loadDocument :: Session -> Maybe Int -> Int -> Aff NodeDocument
loadDocument :: Session -> Maybe Int -> Int -> Aff NodeDocument
loadDocument session corpusId nodeId =
loadDocument session corpusId nodeId =
get session $
SessionCorpusDocument
corpusId (Just nodeId)
get session $
CorpusDocumentAPI
corpusId (Just nodeId)
loadData :: DocPath -> Aff LoadedData
loadData :: DocPath -> Aff LoadedData
loadData {session, nodeId, corpusId, listIds, tabType} = do
loadData {session, nodeId, corpusId, listIds, tabType} = do
document <- loadDocument session corpusId nodeId
document <- loadDocument session corpusId nodeId
ngramsTable <- loadNgramsTable
ngramsTable <- loadNgramsTable
{ session
{ session
, NodeId corpusId (Just nodeId)
--
, NodeId corpusId (Just nodeId)
, listIds
, listIds
, params: { offset : 0, limit : 100, orderBy: Nothing}
, params: { offset : 0, limit : 100, orderBy: Nothing}
, tabType
, tabType
...
...
src/Gargantext/Ends.purs
View file @
9d2cb1ee
...
@@ -14,6 +14,12 @@ import Gargantext.Types
...
@@ -14,6 +14,12 @@ import Gargantext.Types
( ApiVersion, Limit, NodePath, NodeType(..), Offset, TabType(..)
( ApiVersion, Limit, NodePath, NodeType(..), Offset, TabType(..)
, TermSize(..), nodePath, nodeTypePath, showTabType')
, TermSize(..), nodePath, nodeTypePath, showTabType')
joinUrl :: String -> String -> String
joinUrl p "" = p
joinUrl p q = p <> "/" <> q
infixr 5 joinUrl as </>
-- | A means of generating a url to visit, a destination
-- | A means of generating a url to visit, a destination
class ToUrl conf p where
class ToUrl conf p where
toUrl :: conf -> p -> String
toUrl :: conf -> p -> String
...
@@ -33,7 +39,7 @@ backend version prePath baseUrl name = Backend { name, version, prePath, baseUrl
...
@@ -33,7 +39,7 @@ backend version prePath baseUrl name = Backend { name, version, prePath, baseUrl
-- | Creates a backend url from a backend and the path as a string
-- | Creates a backend url from a backend and the path as a string
backendUrl :: Backend -> String -> String
backendUrl :: Backend -> String -> String
backendUrl (Backend b) path = b.baseUrl <> b.prePath <> show b.version <
> "/" <
> path
backendUrl (Backend b) path = b.baseUrl <> b.prePath <> show b.version <
/
> path
derive instance genericBackend :: Generic Backend _
derive instance genericBackend :: Generic Backend _
...
@@ -117,7 +123,7 @@ sessionPath :: R.SessionRoute -> String
...
@@ -117,7 +123,7 @@ sessionPath :: R.SessionRoute -> String
sessionPath (R.Tab t i) = sessionPath (R.NodeAPI Node i (showTabType' t))
sessionPath (R.Tab t i) = sessionPath (R.NodeAPI Node i (showTabType' t))
sessionPath (R.Children n o l s i) = sessionPath (R.NodeAPI Node i ("children?type=" <> show n <> offsetUrl o <> limitUrl l <> orderUrl s))
sessionPath (R.Children n o l s i) = sessionPath (R.NodeAPI Node i ("children?type=" <> show n <> offsetUrl o <> limitUrl l <> orderUrl s))
sessionPath (R.NodeAPI Phylo pId p) = "phyloscape?nodeId=" <> (show $ maybe 0 identity pId) <> p
sessionPath (R.NodeAPI Phylo pId p) = "phyloscape?nodeId=" <> (show $ maybe 0 identity pId) <> p
sessionPath (R.GetNgrams opts
c i)
=
sessionPath (R.GetNgrams opts
)
=
base opts.tabType
base opts.tabType
$ "ngrams?ngramsType="
$ "ngrams?ngramsType="
<> showTabType' opts.tabType
<> showTabType' opts.tabType
...
@@ -129,24 +135,26 @@ sessionPath (R.GetNgrams opts c i) =
...
@@ -129,24 +135,26 @@ sessionPath (R.GetNgrams opts c i) =
<> foldMap termSizeFilter opts.termSizeFilter
<> foldMap termSizeFilter opts.termSizeFilter
<> search opts.searchQuery
<> search opts.searchQuery
where
where
base :: TabType -> String
base :: TabType -> String -> String
base (TabCorpus _) = sessionPath <<< R.NodeAPI Node c
base (TabCorpus _) = case opts.nodeId of
base _ = sessionPath <<< (R.SessionCorpusDocument c i)
-- Just _ -> error
Nothing -> sessionPath <<< R.NodeAPI Node opts.corpusId
base _ = sessionPath <<< R.CorpusDocumentAPI opts.corpusId opts.nodeId
termSizeFilter MonoTerm = "&minTermSize=0&maxTermSize=1"
termSizeFilter MonoTerm = "&minTermSize=0&maxTermSize=1"
termSizeFilter MultiTerm = "&minTermSize=2"
termSizeFilter MultiTerm = "&minTermSize=2"
search "" = ""
search "" = ""
search s = "&search=" <> s
search s = "&search=" <> s
sessionPath (R.
SessionCorpusDocument cId dId
) =
sessionPath (R.
CorpusDocumentAPI cId dId p
) =
sessionPath $ R.NodeAPI Corpus cId
("document/" <> (show $ maybe 0 identity dId))
sessionPath $ R.NodeAPI Corpus cId
$ "document" </> show (maybe 0 identity dId) </> p
sessionPath (R.PutNgrams
t listId termList i
) =
sessionPath (R.PutNgrams
{tabType, listId, termList, nodeId, corpusId}
) =
sessionPath $ R.NodeAPI Node i
sessionPath $ R.NodeAPI Node i
$ "ngrams?ngramsType="
$ "ngrams?ngramsType="
<> showTabType' t
<> showTabType' t
abType
<> maybe "" (\x -> "&list=" <> show x) listId
<> maybe "" (\x -> "&list=" <> show x) listId
<> foldMap (\x -> "&listType=" <> show x) termList
<> foldMap (\x -> "&listType=" <> show x) termList
sessionPath (R.NodeAPI nt i p) = nodeTypePath nt
sessionPath (R.NodeAPI nt i p) = nodeTypePath nt
<
> (maybe "" (\i' -> "/" <> show i') i)
<
/> maybe "" show i
<
> (if p == "" then "" else "/" <> p)
<
/> p
sessionPath (R.Search {listId,limit,offset,orderBy} i) =
sessionPath (R.Search {listId,limit,offset,orderBy} i) =
sessionPath $ R.NodeAPI Corpus i
sessionPath $ R.NodeAPI Corpus i
$ "search?list_id=" <> show listId
$ "search?list_id=" <> show listId
...
...
src/Gargantext/Routes.purs
View file @
9d2cb1ee
...
@@ -2,7 +2,7 @@ module Gargantext.Routes where
...
@@ -2,7 +2,7 @@ module Gargantext.Routes where
import Prelude
import Prelude
import Data.Maybe (Maybe)
import Data.Maybe (Maybe)
import Gargantext.Types (ChartOpts, CorpusMetricOpts, Id, Limit, ListId, NgramsGet
Opt
s, NodeType, Offset, OrderBy, SearchOpts, SessionId, TabType, TermList)
import Gargantext.Types (ChartOpts, CorpusMetricOpts, Id, Limit, ListId, NgramsGet
Params, NgramsPutParam
s, NodeType, Offset, OrderBy, SearchOpts, SessionId, TabType, TermList)
data AppRoute
data AppRoute
= Home
= Home
...
@@ -19,14 +19,15 @@ data AppRoute
...
@@ -19,14 +19,15 @@ data AppRoute
| UserPage SessionId Int
| UserPage SessionId Int
| ContactPage SessionId Int
| ContactPage SessionId Int
-- TODO renaming suggestion RouteAPI?
data SessionRoute
data SessionRoute
= Tab TabType (Maybe Id)
= Tab TabType (Maybe Id)
| Children NodeType Offset Limit (Maybe OrderBy) (Maybe Id)
| Children NodeType Offset Limit (Maybe OrderBy) (Maybe Id)
| GetNgrams
NgramsGetOpts (Maybe Id) (Maybe Id)
| GetNgrams
NgramsGetParams
| PutNgrams
TabType (Maybe ListId) (Maybe TermList) (Maybe Id)
| PutNgrams
NgramsPutParams
-- ^ This name is not good. In particular this URL is used both in PUT and POST.
-- ^ This name is not good. In particular this URL is used both in PUT and POST.
| NodeAPI NodeType (Maybe Id) String
| NodeAPI NodeType (Maybe Id) String
|
SessionCorpusDocument (Maybe Id) (Maybe Id)
|
CorpusDocumentAPI (Maybe Id) (Maybe Id) String
| Search SearchOpts (Maybe Id)
| Search SearchOpts (Maybe Id)
| CorpusMetrics CorpusMetricOpts (Maybe Id)
| CorpusMetrics CorpusMetricOpts (Maybe Id)
| Chart ChartOpts (Maybe Id)
| Chart ChartOpts (Maybe Id)
...
...
src/Gargantext/Types.purs
View file @
9d2cb1ee
...
@@ -267,7 +267,7 @@ nodeTypePath Team = "team"
...
@@ -267,7 +267,7 @@ nodeTypePath Team = "team"
type ListId = Int
type ListId = Int
type NgramsGet
Opt
s =
type NgramsGet
Param
s =
{ tabType :: TabType
{ tabType :: TabType
, offset :: Offset
, offset :: Offset
, limit :: Limit
, limit :: Limit
...
@@ -276,6 +276,16 @@ type NgramsGetOpts =
...
@@ -276,6 +276,16 @@ type NgramsGetOpts =
, termListFilter :: Maybe TermList
, termListFilter :: Maybe TermList
, termSizeFilter :: Maybe TermSize
, termSizeFilter :: Maybe TermSize
, searchQuery :: String
, searchQuery :: String
, corpusId :: Maybe Id
, nodeId :: Maybe Id
}
type NgramsPutParams =
{ tabType :: TabType
, listId :: Maybe ListId
, termList :: Maybe TermList
, corpusId :: Maybe Id
, nodeId :: Maybe Id
}
}
type SearchOpts =
type SearchOpts =
...
...
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