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
1ec62fb5
Unverified
Commit
1ec62fb5
authored
Jan 10, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NGRAMS-TABLE] rework mode/tabType, use tabType in commit
parent
1007af86
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
56 deletions
+71
-56
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+20
-16
Config.purs
src/Gargantext/Config.purs
+12
-8
NgramsTable.purs
...Pages/Annuaire/User/Contacts/Tabs/Ngrams/NgramsTable.purs
+21
-17
NgramsTable.purs
src/Gargantext/Pages/Corpus/Tabs/Ngrams/NgramsTable.purs
+18
-15
No files found.
src/Gargantext/Components/NgramsTable.purs
View file @
1ec62fb5
...
@@ -52,7 +52,7 @@ import Thermite (PerformAction, Render, Spec, StateCoTransformer, modifyState_,
...
@@ -52,7 +52,7 @@ import Thermite (PerformAction, Render, Spec, StateCoTransformer, modifyState_,
import Unsafe.Coerce (unsafeCoerce)
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(..))
import Gargantext.Config (toUrl, End(..), Path(..)
, TabType
)
import Gargantext.Config.REST (put)
import Gargantext.Config.REST (put)
import Gargantext.Components.Table as T
import Gargantext.Components.Table as T
import Gargantext.Prelude
import Gargantext.Prelude
...
@@ -60,12 +60,16 @@ import Gargantext.Components.Loader as Loader
...
@@ -60,12 +60,16 @@ import Gargantext.Components.Loader as Loader
type Props a mode = Loader.InnerProps Int a ( mode :: mode )
type Props a mode = Loader.InnerProps Int a ( mode :: mode )
type PageParams mode = {nodeId :: Int, params :: T.Params, mode :: mode}
type PageParams =
{ nodeId :: Int
, params :: T.Params
, tabType :: TabType
}
initialPageParams ::
forall mode. Int -> mode -> PageParams mode
initialPageParams ::
Int -> TabType -> PageParams
initialPageParams nodeId
mode = {nodeId, params: T.initialParams, mod
e}
initialPageParams nodeId
tabType = {nodeId, params: T.initialParams, tabTyp
e}
type Props'
mode = Loader.InnerProps (PageParams mode)
VersionedNgramsTable ()
type Props'
= Loader.InnerProps PageParams
VersionedNgramsTable ()
type NgramsTerm = String
type NgramsTerm = String
...
@@ -477,10 +481,10 @@ tableContainer {searchQuery, dispatch, ngramsParent, ngramsChildren, ngramsTable
...
@@ -477,10 +481,10 @@ tableContainer {searchQuery, dispatch, ngramsParent, ngramsChildren, ngramsTable
]
]
]
]
putTable :: {nodeId :: Int} -> Versioned NgramsTablePatch -> Aff (Versioned NgramsTablePatch)
putTable :: {nodeId :: Int
, tabType :: TabType
} -> Versioned NgramsTablePatch -> Aff (Versioned NgramsTablePatch)
putTable {nodeId
} = put (toUrl Back (PutNgrams
Nothing) $ Just nodeId)
putTable {nodeId
, tabType} = put (toUrl Back (PutNgrams tabType
Nothing) $ Just nodeId)
commitPatch :: {nodeId :: Int} -> NgramsTablePatch -> StateCoTransformer State Unit
commitPatch :: {nodeId :: Int
, tabType :: TabType
} -> NgramsTablePatch -> StateCoTransformer State Unit
commitPatch props pt = do
commitPatch props pt = do
Versioned {version, data: new_patch} <- lift $ putTable props $ Versioned {version: 1, data: pt}
Versioned {version, data: new_patch} <- lift $ putTable props $ Versioned {version: 1, data: pt}
when (version /= 1) $
when (version /= 1) $
...
@@ -493,13 +497,13 @@ toggleMap :: forall a. a -> Maybe a -> Maybe a
...
@@ -493,13 +497,13 @@ toggleMap :: forall a. a -> Maybe a -> Maybe a
toggleMap _ (Just _) = Nothing
toggleMap _ (Just _) = Nothing
toggleMap b Nothing = Just b
toggleMap b Nothing = Just b
ngramsTableSpec ::
forall mode. Spec State (Props' mode)
Action
ngramsTableSpec ::
Spec State Props'
Action
ngramsTableSpec = simpleSpec performAction render
ngramsTableSpec = simpleSpec performAction render
where
where
setParentResetChildren :: Maybe NgramsTerm -> State -> State
setParentResetChildren :: Maybe NgramsTerm -> State -> State
setParentResetChildren p = _ { ngramsParent = p, ngramsChildren = mempty }
setParentResetChildren p = _ { ngramsParent = p, ngramsChildren = mempty }
performAction :: PerformAction State
(Props' mode)
Action
performAction :: PerformAction State
Props'
Action
performAction (SetTermListFilter c) _ _ = modifyState_ $ _ { termListFilter = c }
performAction (SetTermListFilter c) _ _ = modifyState_ $ _ { termListFilter = c }
performAction (SetTermTypeFilter c) _ _ = modifyState_ $ _ { termTypeFilter = c }
performAction (SetTermTypeFilter c) _ _ = modifyState_ $ _ { termTypeFilter = c }
performAction (SetSearchQuery s) _ _ = modifyState_ $ _ { searchQuery = s }
performAction (SetSearchQuery s) _ _ = modifyState_ $ _ { searchQuery = s }
...
@@ -507,19 +511,19 @@ ngramsTableSpec = simpleSpec performAction render
...
@@ -507,19 +511,19 @@ 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 (SetTermListItem n pl) {path: {nodeId
}} _ = commitPatch {nodeId
} pt
performAction (SetTermListItem n pl) {path: {nodeId
, tabType}} _ = commitPatch {nodeId, tabType
} pt
where
where
pe = NgramsPatch { patch_list: pl, patch_children: mempty }
pe = NgramsPatch { patch_list: pl, patch_children: mempty }
pt = PatchMap $ Map.singleton n pe
pt = PatchMap $ Map.singleton n pe
performAction AddTermChildren _ {ngramsParent: Nothing} =
performAction AddTermChildren _ {ngramsParent: Nothing} =
-- impossible but harmless
-- impossible but harmless
pure unit
pure unit
performAction AddTermChildren {path: {nodeId}}
performAction AddTermChildren {path: {nodeId
, tabType
}}
{ ngramsParent: Just parent
{ ngramsParent: Just parent
, ngramsChildren
, ngramsChildren
} = do
} = do
modifyState_ $ setParentResetChildren Nothing
modifyState_ $ setParentResetChildren Nothing
commitPatch {nodeId} pt
commitPatch {nodeId
, tabType
} pt
where
where
pc = patchSetFromMap ngramsChildren
pc = patchSetFromMap ngramsChildren
pe = NgramsPatch { patch_list: mempty, patch_children: pc }
pe = NgramsPatch { patch_list: mempty, patch_children: pc }
...
@@ -527,8 +531,8 @@ ngramsTableSpec = simpleSpec performAction render
...
@@ -527,8 +531,8 @@ ngramsTableSpec = simpleSpec performAction render
-- TODO ROOT-UPDATE
-- TODO ROOT-UPDATE
-- patch the root of the child to be equal to the root of the parent.
-- patch the root of the child to be equal to the root of the parent.
render :: Render State
(Props' mode)
Action
render :: Render State
Props'
Action
render dispatch { path: {nodeId,
mod
e}
render dispatch { path: {nodeId,
tabTyp
e}
, loaded: Versioned { version, data: initTable }
, loaded: Versioned { version, data: initTable }
, dispatch: loaderDispatch }
, dispatch: loaderDispatch }
{ ngramsTablePatch, ngramsParent, ngramsChildren, searchQuery }
{ ngramsTablePatch, ngramsParent, ngramsChildren, searchQuery }
...
@@ -537,7 +541,7 @@ ngramsTableSpec = simpleSpec performAction render
...
@@ -537,7 +541,7 @@ ngramsTableSpec = simpleSpec performAction render
| otherwise =
| otherwise =
[ T.tableElt
[ T.tableElt
{ rows
{ rows
, setParams: \params -> loaderDispatch (Loader.SetPath {nodeId, params,
mod
e})
, setParams: \params -> loaderDispatch (Loader.SetPath {nodeId, params,
tabTyp
e})
, container: tableContainer {searchQuery, dispatch, ngramsParent, ngramsChildren, ngramsTable}
, container: tableContainer {searchQuery, dispatch, ngramsParent, ngramsChildren, ngramsTable}
, colNames:
, colNames:
T.ColumnName <$>
T.ColumnName <$>
...
...
src/Gargantext/Config.purs
View file @
1ec62fb5
...
@@ -111,9 +111,13 @@ offsetUrl o = "&offset=" <> show o
...
@@ -111,9 +111,13 @@ offsetUrl o = "&offset=" <> show o
orderUrl :: forall a. Show a => Maybe a -> UrlPath
orderUrl :: forall a. Show a => Maybe a -> UrlPath
orderUrl = maybe "" (\x -> "&order=" <> show x)
orderUrl = maybe "" (\x -> "&order=" <> show x)
tabTypeNgrams :: TabType -> UrlPath
tabTypeNgramsGet :: TabType -> UrlPath
tabTypeNgrams (TabCorpus t) = "listGet?ngramsType=" <> show t
tabTypeNgramsGet (TabCorpus t) = "listGet?ngramsType=" <> show t
tabTypeNgrams (TabPairing t) = "listGet?ngramsType=" <> show t -- TODO
tabTypeNgramsGet (TabPairing t) = "listGet?ngramsType=" <> show t -- TODO
tabTypeNgramsPut :: TabType -> UrlPath
tabTypeNgramsPut (TabCorpus t) = "list?ngramsType=" <> show t
tabTypeNgramsPut (TabPairing t) = "list?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 =
...
@@ -123,14 +127,14 @@ pathUrl c (Children n o l s) i =
...
@@ -123,14 +127,14 @@ pathUrl c (Children n o l s) i =
pathUrl c (NodeAPI Node) i <>
pathUrl c (NodeAPI Node) i <>
"/" <> "children?type=" <> show n <> offsetUrl o <> limitUrl l <> orderUrl s
"/" <> "children?type=" <> show n <> offsetUrl o <> limitUrl l <> orderUrl s
pathUrl c (GetNgrams t o l listid) i =
pathUrl c (GetNgrams t o l listid) i =
pathUrl c (NodeAPI Node) i <> "/" <> tabTypeNgrams t
pathUrl c (NodeAPI Node) i <> "/" <> tabTypeNgrams
Get
t
<> offsetUrl o <> limitUrl l <> listid'
<> offsetUrl o <> limitUrl l <> listid'
where
where
listid' = maybe "" (\x -> "&list=" <> show x) listid
listid' = maybe "" (\x -> "&list=" <> show x) listid
pathUrl c (PutNgrams listid) i =
pathUrl c (PutNgrams
t
listid) i =
pathUrl c (NodeAPI Node) i <> "/
list"
<> listid'
pathUrl c (NodeAPI Node) i <> "/
" <> tabTypeNgramsPut t
<> 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"
pathUrl c Auth (Just _) = "impossible" -- TODO better types
pathUrl c Auth (Just _) = "impossible" -- TODO better types
pathUrl c (NodeAPI nt) i = c.prePath <> nodeTypeUrl nt <> (maybe "" (\i' -> "/" <> show i') i)
pathUrl c (NodeAPI nt) i = c.prePath <> nodeTypeUrl nt <> (maybe "" (\i' -> "/" <> show i') i)
...
@@ -194,7 +198,7 @@ data Path
...
@@ -194,7 +198,7 @@ data Path
| Tab TabType Offset Limit (Maybe OrderBy)
| Tab TabType Offset Limit (Maybe OrderBy)
| Children NodeType Offset Limit (Maybe OrderBy)
| Children NodeType Offset Limit (Maybe OrderBy)
| GetNgrams TabType Offset Limit (Maybe TermList)
| GetNgrams TabType Offset Limit (Maybe TermList)
| PutNgrams (Maybe TermList)
| PutNgrams
TabType
(Maybe TermList)
| NodeAPI NodeType
| NodeAPI NodeType
| Search { {-id :: Int
| Search { {-id :: Int
, query :: Array String
, query :: Array String
...
...
src/Gargantext/Pages/Annuaire/User/Contacts/Tabs/Ngrams/NgramsTable.purs
View file @
1ec62fb5
...
@@ -27,33 +27,35 @@ instance showMode :: Show Mode where
...
@@ -27,33 +27,35 @@ instance showMode :: Show Mode where
derive instance eqMode :: Eq Mode
derive instance eqMode :: Eq Mode
type Props = NT.Props Contact Mode
type PageParams = NT.PageParams Mode
getTable :: { tab :: PTabNgramType, nodeId :: Int, offset :: Offset, limit :: Limit }
-> Aff NT.VersionedNgramsTable
getTable {tab, nodeId, offset, limit} =
get $ toUrl Back (GetNgrams (TabPairing (TabNgramType tab))
offset limit Nothing) (Just nodeId)
modeTabType :: Mode -> PTabNgramType
modeTabType :: Mode -> PTabNgramType
modeTabType Patents = PTabPatents
modeTabType Patents = PTabPatents
modeTabType Books = PTabBooks
modeTabType Books = PTabBooks
modeTabType Communication = PTabCommunication
modeTabType Communication = PTabCommunication
loadPage :: PageParams -> Aff NT.VersionedNgramsTable
type Props = NT.Props Contact Mode
loadPage {nodeId, mode, params: {offset, limit}} =
getTable {tab: modeTabType mode, nodeId, offset, limit}
-- TODO: Move to Components.NgramsTable
getTable :: { tabType :: TabType, nodeId :: Int, offset :: Offset, limit :: Limit }
-> Aff NT.VersionedNgramsTable
getTable {tabType, nodeId, offset, limit} =
get $ toUrl Back (GetNgrams tabType offset limit Nothing) (Just nodeId)
-- TODO: Move to Components.NgramsTable
loadPage :: NT.PageParams -> Aff NT.VersionedNgramsTable
loadPage {nodeId, tabType, params: {offset, limit}} =
getTable {tabType, nodeId, offset, limit}
-- TODO this ignores orderBy
-- TODO this ignores orderBy
ngramsLoaderClass :: Loader.LoaderClass PageParams NT.VersionedNgramsTable
-- TODO: Move to Components.NgramsTable?
ngramsLoaderClass :: Loader.LoaderClass NT.PageParams NT.VersionedNgramsTable
ngramsLoaderClass = Loader.createLoaderClass "ContactsNgramsLoader" loadPage
ngramsLoaderClass = Loader.createLoaderClass "ContactsNgramsLoader" loadPage
ngramsLoader :: Loader.Props' PageParams NT.VersionedNgramsTable -> ReactElement
-- TODO: Move to Components.NgramsTable?
ngramsLoader :: Loader.Props' NT.PageParams NT.VersionedNgramsTable -> ReactElement
ngramsLoader props = React.createElement ngramsLoaderClass props []
ngramsLoader props = React.createElement ngramsLoaderClass props []
ngramsTableClass :: Loader.InnerClass PageParams NT.VersionedNgramsTable
-- TODO: Move to Components.NgramsTable?
ngramsTableClass :: Loader.InnerClass NT.PageParams NT.VersionedNgramsTable
ngramsTableClass = createClass "ContactsNgramsTable" NT.ngramsTableSpec NT.initialState
ngramsTableClass = createClass "ContactsNgramsTable" NT.ngramsTableSpec NT.initialState
ngramsTableSpec :: Spec {} Props Void
ngramsTableSpec :: Spec {} Props Void
...
@@ -62,6 +64,8 @@ ngramsTableSpec = simpleSpec defaultPerformAction render
...
@@ -62,6 +64,8 @@ ngramsTableSpec = simpleSpec defaultPerformAction render
render :: Render {} Props Void
render :: Render {} Props Void
render _ {path: nodeId, mode} _ _ =
render _ {path: nodeId, mode} _ _ =
-- TODO: ignored loaded
-- TODO: ignored loaded
[ ngramsLoader { path: NT.initialPageParams nodeId
mod
e
[ ngramsLoader { path: NT.initialPageParams nodeId
tabTyp
e
, component: ngramsTableClass
, component: ngramsTableClass
} ]
} ]
where
tabType = TabPairing $ TabNgramType $ modeTabType mode
src/Gargantext/Pages/Corpus/Tabs/Ngrams/NgramsTable.purs
View file @
1ec62fb5
...
@@ -29,32 +29,33 @@ derive instance eqMode :: Eq Mode
...
@@ -29,32 +29,33 @@ derive instance eqMode :: Eq Mode
type Props = NT.Props (NodePoly CorpusInfo) Mode
type Props = NT.Props (NodePoly CorpusInfo) Mode
type PageParams = NT.PageParams Mode
getTable :: { tab :: CTabNgramType, nodeId :: Int, offset :: Offset, limit :: Limit }
-> Aff NT.VersionedNgramsTable
getTable {tab, nodeId, offset, limit} =
get $ toUrl Back (GetNgrams (TabCorpus (TabNgramType tab))
offset limit Nothing) (Just nodeId)
modeTabType :: Mode -> CTabNgramType
modeTabType :: Mode -> CTabNgramType
modeTabType Authors = CTabAuthors
modeTabType Authors = CTabAuthors
modeTabType Sources = CTabSources
modeTabType Sources = CTabSources
modeTabType Institutes = CTabInstitutes
modeTabType Institutes = CTabInstitutes
modeTabType Terms = CTabTerms
modeTabType Terms = CTabTerms
loadPage :: PageParams -> Aff NT.VersionedNgramsTable
getTable :: { tabType :: TabType, nodeId :: Int, offset :: Offset, limit :: Limit }
loadPage {nodeId, mode, params: {offset, limit}} =
-> Aff NT.VersionedNgramsTable
getTable {tab: modeTabType mode, nodeId, offset, limit}
getTable {tabType, nodeId, offset, limit} =
get $ toUrl Back (GetNgrams tabType offset limit Nothing) (Just nodeId)
-- TODO: Move to Components.NgramsTable?
loadPage :: NT.PageParams -> Aff NT.VersionedNgramsTable
loadPage {nodeId, tabType, params: {offset, limit}} =
getTable {tabType, nodeId, offset, limit}
-- TODO this ignores orderBy
-- TODO this ignores orderBy
ngramsLoaderClass :: Loader.LoaderClass PageParams NT.VersionedNgramsTable
-- TODO: Move to Components.NgramsTable?
ngramsLoaderClass :: Loader.LoaderClass NT.PageParams NT.VersionedNgramsTable
ngramsLoaderClass = Loader.createLoaderClass "CorpusNgramsLoader" loadPage
ngramsLoaderClass = Loader.createLoaderClass "CorpusNgramsLoader" loadPage
ngramsLoader :: Loader.Props' PageParams NT.VersionedNgramsTable -> ReactElement
-- TODO: Move to Components.NgramsTable?
ngramsLoader :: Loader.Props' NT.PageParams NT.VersionedNgramsTable -> ReactElement
ngramsLoader props = React.createElement ngramsLoaderClass props []
ngramsLoader props = React.createElement ngramsLoaderClass props []
ngramsTableClass :: Loader.InnerClass PageParams NT.VersionedNgramsTable
-- TODO: Move to Components.NgramsTable?
ngramsTableClass :: Loader.InnerClass NT.PageParams NT.VersionedNgramsTable
ngramsTableClass = createClass "CorpusNgramsTable" NT.ngramsTableSpec NT.initialState
ngramsTableClass = createClass "CorpusNgramsTable" NT.ngramsTableSpec NT.initialState
ngramsTableSpec :: Spec {} Props Void
ngramsTableSpec :: Spec {} Props Void
...
@@ -63,6 +64,8 @@ ngramsTableSpec = simpleSpec defaultPerformAction render
...
@@ -63,6 +64,8 @@ ngramsTableSpec = simpleSpec defaultPerformAction render
render :: Render {} Props Void
render :: Render {} Props Void
render _ {path: nodeId, mode} _ _ =
render _ {path: nodeId, mode} _ _ =
-- TODO: ignored loaded param
-- TODO: ignored loaded param
[ ngramsLoader { path: NT.initialPageParams nodeId
mod
e
[ ngramsLoader { path: NT.initialPageParams nodeId
tabTyp
e
, component: ngramsTableClass
, component: ngramsTableClass
} ]
} ]
where
tabType = TabCorpus $ TabNgramType $ modeTabType mode
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