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
6cf771f9
Commit
6cf771f9
authored
Sep 20, 2019
by
James Laver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor table components to use reactix
parent
6213f074
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
584 additions
and
743 deletions
+584
-743
DocsTable.purs
src/Gargantext/Components/DocsTable.purs
+53
-68
FacetsTable.purs
src/Gargantext/Components/FacetsTable.purs
+182
-269
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+163
-176
Core.purs
src/Gargantext/Components/NgramsTable/Core.purs
+34
-31
Types.purs
src/Gargantext/Components/Search/Types.purs
+4
-4
Table.purs
src/Gargantext/Components/Table.purs
+148
-195
No files found.
src/Gargantext/Components/DocsTable.purs
View file @
6cf771f9
This diff is collapsed.
Click to expand it.
src/Gargantext/Components/FacetsTable.purs
View file @
6cf771f9
This diff is collapsed.
Click to expand it.
src/Gargantext/Components/NgramsTable.purs
View file @
6cf771f9
This diff is collapsed.
Click to expand it.
src/Gargantext/Components/NgramsTable/Core.purs
View file @
6cf771f9
...
@@ -86,7 +86,7 @@ import Partial.Unsafe (unsafePartial)
...
@@ -86,7 +86,7 @@ import Partial.Unsafe (unsafePartial)
import Gargantext.Utils.KarpRabin (indicesOfAny)
import Gargantext.Utils.KarpRabin (indicesOfAny)
import Gargantext.Types (TermList(..), TermSize)
import Gargantext.Types (TermList(..), TermSize)
import Gargantext.Config (
toUrl, endConfigStateful, End(..), Path(..), TabType, OrderBy(..), CTabNgramType(..)
)
import Gargantext.Config (
Ends, BackendRoute(..), TabType, OrderBy(..), CTabNgramType(..), url
)
import Gargantext.Config.REST (get, put, post)
import Gargantext.Config.REST (get, put, post)
import Gargantext.Components.Table as T
import Gargantext.Components.Table as T
import Gargantext.Prelude
import Gargantext.Prelude
...
@@ -106,10 +106,11 @@ type PageParams =
...
@@ -106,10 +106,11 @@ type PageParams =
, 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
, ends :: Ends
)
)
initialPageParams :: Int -> Array Int -> TabType -> PageParams
initialPageParams ::
Ends ->
Int -> Array Int -> TabType -> PageParams
initialPageParams nodeId listIds tabType =
initialPageParams
ends
nodeId listIds tabType =
{ nodeId
{ nodeId
, listIds
, listIds
, params: T.initialParams
, params: T.initialParams
...
@@ -117,6 +118,7 @@ initialPageParams nodeId listIds tabType =
...
@@ -117,6 +118,7 @@ initialPageParams nodeId listIds tabType =
, termSizeFilter: Nothing
, termSizeFilter: Nothing
, termListFilter: Just GraphTerm
, termListFilter: Just GraphTerm
, searchQuery: ""
, searchQuery: ""
, ends
}
}
type NgramsTerm = String
type NgramsTerm = String
...
@@ -561,47 +563,48 @@ type CoreState s =
...
@@ -561,47 +563,48 @@ type CoreState s =
| s
| s
}
}
postNewNgrams :: forall s. Array NgramsTerm -> Maybe TermList -> CoreParams s -> Aff Unit
postNewNgrams :: forall s.
Ends ->
Array NgramsTerm -> Maybe TermList -> CoreParams s -> Aff Unit
postNewNgrams newNgrams mayList {nodeId, listIds, tabType} =
postNewNgrams
ends
newNgrams mayList {nodeId, listIds, tabType} =
when (not (A.null newNgrams)) $ do
when (not (A.null newNgrams)) $ do
(_ :: Array Unit) <- post (
toUrl endConfigStateful Back (PutNgrams tabType (head listIds) mayList) $ Just nodeId
) newNgrams
(_ :: Array Unit) <- post (
url ends put
) newNgrams
pure unit
pure unit
where put = PutNgrams tabType (head listIds) mayList (Just nodeId)
postNewElems :: forall s. NewElems -> CoreParams s -> Aff Unit
postNewElems :: forall s.
Ends ->
NewElems -> CoreParams s -> Aff Unit
postNewElems newElems params = void $ traverseWithIndex postNewElem newElems
postNewElems
ends
newElems params = void $ traverseWithIndex postNewElem newElems
where
where
postNewElem ngrams list = postNewNgrams [ngrams] (Just list) params
postNewElem ngrams list = postNewNgrams
ends
[ngrams] (Just list) params
addNewNgram :: CTabNgramType -> NgramsTerm -> TermList -> NgramsTablePatch
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 :: {nodeId :: Int, listIds :: Array Int, tabType :: TabType} -> Versioned NgramsPatches -> Aff (Versioned NgramsPatches)
putNgramsPatches ::
Ends ->
{nodeId :: Int, listIds :: Array Int, tabType :: TabType} -> Versioned NgramsPatches -> Aff (Versioned NgramsPatches)
putNgramsPatches
{nodeId, listIds, tabType} =
putNgramsPatches
ends {nodeId, listIds, tabType} = put $ url ends putNgrams
put (toUrl endConfigStateful Back (PutNgrams tabType (head listIds) Nothing) $
Just nodeId)
where putNgrams = PutNgrams tabType (head listIds) Nothing (
Just nodeId)
commitPatch :: forall s. {nodeId :: Int, listIds :: Array Int, tabType :: TabType}
commitPatch :: forall s.
Ends ->
{nodeId :: Int, listIds :: Array Int, tabType :: TabType}
-> Versioned NgramsTablePatch -> StateCoTransformer (CoreState s) Unit
-> Versioned NgramsTablePatch -> StateCoTransformer (CoreState s) Unit
commitPatch props (Versioned {version, data: tablePatch@{ngramsPatches, ngramsNewElems}}) = do
commitPatch
ends
props (Versioned {version, data: tablePatch@{ngramsPatches, ngramsNewElems}}) = do
let pt = Versioned { version, data: ngramsPatches }
let pt = Versioned { version, data: ngramsPatches }
lift $ postNewElems ngramsNewElems props
lift $ postNewElems
ends
ngramsNewElems props
Versioned {version: newVersion, data: newPatch} <- lift $ putNgramsPatches props pt
Versioned {version: newVersion, data: newPatch} <- lift $ putNgramsPatches
ends
props pt
modifyState_ $ \s ->
modifyState_ $ \s ->
s { ngramsVersion = newVersion
s { ngramsVersion = newVersion
, ngramsTablePatch = fromNgramsPatches newPatch <> tablePatch <> s.ngramsTablePatch
, ngramsTablePatch = fromNgramsPatches newPatch <> tablePatch <> s.ngramsTablePatch
}
}
-- TODO: check that pt.version == s.ngramsTablePatch.version
-- TODO: check that pt.version == s.ngramsTablePatch.version
loadNgramsTable :: PageParams -> Aff VersionedNgramsTable
loadNgramsTable ::
Ends ->
PageParams -> Aff VersionedNgramsTable
loadNgramsTable
{ nodeId, listIds, termListFilter, termSizeFilter
loadNgramsTable
ends
, searchQuery, tabType, params: {offset, limit, orderBy}} =
{ nodeId, listIds, termListFilter, termSizeFilter
get $ toUrl endConfigStateful Back
, searchQuery, tabType, params: {offset, limit, orderBy}}
(GetNgrams { tabType, offset, limit, listIds
= get $ url ends query
, orderBy: convOrderBy <$> orderBy
where query = GetNgrams { tabType, offset, limit, listIds
, termListFilter, termSizeFilter
, orderBy: convOrderBy <$> orderBy
, searchQuery
, termListFilter, termSizeFilter
}
)
, searchQuery } (Just nodeId
)
(Just nodeId)
convOrderBy :: T.OrderByDirection T.ColumnName -> OrderBy
convOrderBy :: T.OrderByDirection T.ColumnName -> OrderBy
convOrderBy (T.ASC (T.ColumnName "Score (Occurrences)")) = ScoreAsc
convOrderBy (T.ASC (T.ColumnName "Score (Occurrences)")) = ScoreAsc
...
@@ -609,10 +612,10 @@ convOrderBy (T.DESC (T.ColumnName "Score (Occurrences)")) = ScoreDesc
...
@@ -609,10 +612,10 @@ convOrderBy (T.DESC (T.ColumnName "Score (Occurrences)")) = ScoreDesc
convOrderBy (T.ASC _) = TermAsc
convOrderBy (T.ASC _) = TermAsc
convOrderBy (T.DESC _) = TermDesc
convOrderBy (T.DESC _) = TermDesc
ngramsLoaderClass :: Loader.LoaderClass PageParams VersionedNgramsTable
ngramsLoaderClass ::
Ends ->
Loader.LoaderClass PageParams VersionedNgramsTable
ngramsLoaderClass
= Loader.createLoaderClass "NgramsTableLoader" loadNgramsTable
ngramsLoaderClass
ends = Loader.createLoaderClass "NgramsTableLoader" (loadNgramsTable ends)
ngramsLoader :: Loader.Props' PageParams VersionedNgramsTable -> ReactElement
ngramsLoader ::
Ends ->
Loader.Props' PageParams VersionedNgramsTable -> ReactElement
ngramsLoader
props = React.createElement ngramsLoaderClass
props []
ngramsLoader
ends props = React.createElement (ngramsLoaderClass ends)
props []
type LoadedNgramsTableProps =
Loader.InnerProps PageParams VersionedNgramsTable (
)
type LoadedNgramsTableProps =
( path :: PageParams, loaded :: VersionedNgramsTable
)
src/Gargantext/Components/Search/Types.purs
View file @
6cf771f9
...
@@ -167,8 +167,8 @@ instance encodeJsonCategoryQuery :: EncodeJson CategoryQuery where
...
@@ -167,8 +167,8 @@ instance encodeJsonCategoryQuery :: EncodeJson CategoryQuery where
~> "ntc_category" := encodeJson post.category
~> "ntc_category" := encodeJson post.category
~> jsonEmptyObject
~> jsonEmptyObject
categoryUrl :: Int -> String
categoryUrl ::
Ends ->
Int -> String
categoryUrl
nodeId = toUrl endConfigStateful Back Node (Just nodeId
) <> "/category"
categoryUrl
ends nodeId = url ends (NodeAPI Node (Just nodeId)
) <> "/category"
putCategories :: Int -> CategoryQuery -> Aff (Array Int)
putCategories ::
Ends ->
Int -> CategoryQuery -> Aff (Array Int)
putCategories
nodeId = put $ categoryUrl nodeId
putCategories
= put <<< categoryUrl
src/Gargantext/Components/Table.purs
View file @
6cf771f9
This diff is collapsed.
Click to expand it.
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