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
37be629b
Unverified
Commit
37be629b
authored
Feb 27, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NGRAMS-TABLE] refactor support for filtering
parent
733b0f61
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
121 additions
and
177 deletions
+121
-177
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+46
-7
Specs.purs
src/Gargantext/Pages/Annuaire/User/Contacts/Specs.purs
+16
-7
NgramsTable.purs
...Pages/Annuaire/User/Contacts/Tabs/Ngrams/NgramsTable.purs
+0
-73
Specs.purs
src/Gargantext/Pages/Annuaire/User/Contacts/Tabs/Specs.purs
+27
-8
Types.purs
src/Gargantext/Pages/Annuaire/User/Contacts/Types.purs
+3
-1
NgramsTable.purs
src/Gargantext/Pages/Corpus/Tabs/Ngrams/NgramsTable.purs
+0
-73
Specs.purs
src/Gargantext/Pages/Corpus/Tabs/Specs.purs
+29
-8
No files found.
src/Gargantext/Components/NgramsTable.purs
View file @
37be629b
module Gargantext.Components.NgramsTable
( Props
, PageParams
( PageParams
, PatchMap
, NgramsPatch
, NgramsTable
...
...
@@ -11,6 +10,11 @@ module Gargantext.Components.NgramsTable
, initialPageParams
, initialState
, ngramsTableSpec
, ngramsLoaderClass
, ngramsLoader
, ngramsTableClass
, MainNgramsTableProps
, mainNgramsTableSpec
)
where
...
...
@@ -45,22 +49,21 @@ import Effect (Effect)
import Effect.Aff (Aff)
import Foreign.Object as FO
import React (ReactElement)
import React as React
import React.DOM (a, button, div, h2, i, input, li, option, p, select, span, table, tbody, text, thead, ul)
import React.DOM.Props (_id, _type, checked, className, name, onChange, onClick, onInput, placeholder, style, value)
import React.DOM.Props as DOM
import Thermite (PerformAction, Render, Spec, StateCoTransformer,
modifyState_, simpleSpec
)
import Thermite (PerformAction, Render, Spec, StateCoTransformer,
defaultPerformAction, modifyState_, simpleSpec, createClass
)
import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Types (TermList(..), TermType, readTermList, readTermType, termLists, termTypes)
import Gargantext.Config (toUrl, End(..), Path(..), TabType)
import Gargantext.Config.REST (put)
import Gargantext.Config (toUrl, End(..), Path(..), TabType
(..), OrderBy(..)
)
import Gargantext.Config.REST (
get,
put)
import Gargantext.Components.AutoUpdate (autoUpdateElt)
import Gargantext.Components.Table as T
import Gargantext.Prelude
import Gargantext.Components.Loader as Loader
type Props a mode = Loader.InnerProps Int a ( mode :: mode )
type PageParams =
{ nodeId :: Int
, listIds :: Array Int
...
...
@@ -617,6 +620,42 @@ ngramsTableSpec = simpleSpec performAction render
, delete: false
}
loadPage :: PageParams -> Aff VersionedNgramsTable
loadPage { nodeId, listIds, termListFilter, termTypeFilter
, searchQuery, tabType, params: {offset, limit, orderBy}} =
get $ toUrl Back
(GetNgrams { tabType, offset, limit, listIds
, orderBy: convOrderBy <$> orderBy
, termListFilter, termTypeFilter
, searchQuery
})
(Just nodeId)
where
convOrderBy _ = DateAsc -- TODO
ngramsLoaderClass :: Loader.LoaderClass PageParams VersionedNgramsTable
ngramsLoaderClass = Loader.createLoaderClass "NgramsTableLoader" loadPage
ngramsLoader :: Loader.Props' PageParams VersionedNgramsTable -> ReactElement
ngramsLoader props = React.createElement ngramsLoaderClass props []
ngramsTableClass :: Loader.InnerClass PageParams VersionedNgramsTable
ngramsTableClass = createClass "NgramsTable" ngramsTableSpec initialState
type MainNgramsTableProps =
Loader.InnerProps Int { defaultListId :: Int }
( tabType :: TabType )
mainNgramsTableSpec :: Spec {} MainNgramsTableProps Void
mainNgramsTableSpec = simpleSpec defaultPerformAction render
where
render :: Render {} MainNgramsTableProps Void
render _ {path: nodeId, loaded: {defaultListId}, tabType} _ _ =
[ ngramsLoader
{ path: initialPageParams nodeId [defaultListId] tabType
, component: ngramsTableClass
} ]
tree :: { ngramsTable :: NgramsTable
, ngramsStyle :: Array DOM.Props
, ngramsClick :: NgramsTerm -> Maybe (Effect Unit)
...
...
src/Gargantext/Pages/Annuaire/User/Contacts/Specs.purs
View file @
37be629b
...
...
@@ -14,15 +14,17 @@ import Data.Unfoldable (class Unfoldable)
import Data.Maybe (Maybe(..))
import Data.Newtype (unwrap)
import Data.String (joinWith)
import Effect.Aff (Aff)
import Effect.Aff (Aff, throwError)
import Effect.Exception (error)
import Thermite (Render, Spec, defaultPerformAction, simpleSpec, createClass)
import React as React
import React (ReactClass, ReactElement)
import React.DOM (div, h3, img, li, span, text, ul, text)
import React.DOM.Props (_id, className, src)
import Gargantext.Prelude
import Gargantext.Config (toUrl, End(..), NodeType(..))
import Gargantext.Config (toUrl, End(..), NodeType(..)
, Path(..)
)
import Gargantext.Config.REST (get)
import Gargantext.Components.Node (NodePoly(..), HyperdataList(..))
import Gargantext.Components.Loader as Loader
import Gargantext.Pages.Annuaire.User.Contacts.Types
import Gargantext.Pages.Annuaire.User.Contacts.Tabs.Specs as Tabs
...
...
@@ -171,19 +173,26 @@ layoutUser' = simpleSpec defaultPerformAction render
<> Tabs.pureTabs
where
render :: Render {} Props Void
render dispatch {loaded:
Contact {name, hyperdata
}} _ _ =
render dispatch {loaded:
{contactNode: Contact {name, hyperdata}
}} _ _ =
[ ul [className "col-md-12 list-group"] $
display (fromMaybe "no name" name) (contactInfos hyperdata)
]
-- | toUrl to get data
getContact :: Int -> Aff Contact
getContact id = get $ toUrl Back Node $ Just id
getContact :: Int -> Aff ContactData
getContact id = do
contactNode <- get $ toUrl Back Node $ Just id
defaultListIds <- get $ toUrl Back (Children NodeList 0 1 Nothing) $ Just id
case (head defaultListIds :: Maybe (NodePoly HyperdataList)) of
Just (NodePoly { id: defaultListId }) ->
pure {contactNode, defaultListId}
Nothing ->
throwError $ error "Missing default list"
-- | Change name for you
contactLoaderClass :: ReactClass (Loader.Props Int Contact)
contactLoaderClass :: ReactClass (Loader.Props Int Contact
Data
)
contactLoaderClass = Loader.createLoaderClass "ContactLoader" getContact
-- | Change type according to what has been loaded
contactLoader :: Loader.Props' Int Contact -> ReactElement
contactLoader :: Loader.Props' Int Contact
Data
-> ReactElement
contactLoader props = React.createElement contactLoaderClass props []
src/Gargantext/Pages/Annuaire/User/Contacts/Tabs/Ngrams/NgramsTable.purs
deleted
100644 → 0
View file @
733b0f61
-- TODO copy of Gargantext.Pages.Corpus.Tabs.Ngrams.NgramsTable where
module Gargantext.Pages.Annuaire.User.Contacts.Tabs.Ngrams.NgramsTable
(Mode(..), ngramsTableSpec)
where
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..))
import Effect.Aff (Aff)
import React (ReactElement)
import React as React
import Thermite (Render, Spec, createClass, defaultPerformAction, simpleSpec)
import Gargantext.Components.NgramsTable as NT
import Gargantext.Prelude
import Gargantext.Config (PTabNgramType(..), Offset, Limit, OrderBy(..), End(..), Path(..), TabSubType(..), TabType(..), toUrl)
import Gargantext.Config.REST (get)
import Gargantext.Components.Loader as Loader
import Gargantext.Pages.Annuaire.User.Contacts.Types (Contact)
data Mode = Patents | Books | Communication
derive instance genericMode :: Generic Mode _
instance showMode :: Show Mode where
show = genericShow
derive instance eqMode :: Eq Mode
modeTabType :: Mode -> PTabNgramType
modeTabType Patents = PTabPatents
modeTabType Books = PTabBooks
modeTabType Communication = PTabCommunication
type Props = NT.Props Contact Mode
-- TODO: Move to Components.NgramsTable?
loadPage :: NT.PageParams -> Aff NT.VersionedNgramsTable
loadPage { nodeId, listIds, termListFilter, termTypeFilter
, searchQuery, tabType, params: {offset, limit, orderBy}} =
get $ toUrl Back
(GetNgrams { tabType, offset, limit, listIds
, orderBy: convOrderBy <$> orderBy
, termListFilter, termTypeFilter
, searchQuery
})
(Just nodeId)
where
convOrderBy _ = DateAsc -- TODO
-- TODO: Move to Components.NgramsTable?
ngramsLoaderClass :: Loader.LoaderClass NT.PageParams NT.VersionedNgramsTable
ngramsLoaderClass = Loader.createLoaderClass "ContactsNgramsLoader" loadPage
-- TODO: Move to Components.NgramsTable?
ngramsLoader :: Loader.Props' NT.PageParams NT.VersionedNgramsTable -> ReactElement
ngramsLoader props = React.createElement ngramsLoaderClass props []
-- TODO: Move to Components.NgramsTable?
ngramsTableClass :: Loader.InnerClass NT.PageParams NT.VersionedNgramsTable
ngramsTableClass = createClass "ContactsNgramsTable" NT.ngramsTableSpec NT.initialState
ngramsTableSpec :: Spec {} Props Void
ngramsTableSpec = simpleSpec defaultPerformAction render
where
render :: Render {} Props Void
render _ {path: nodeId, mode} _ _ =
-- TODO: ignored loaded
[ ngramsLoader { path: NT.initialPageParams nodeId [] tabType
, component: ngramsTableClass
} ]
where
tabType = TabPairing $ TabNgramType $ modeTabType mode
src/Gargantext/Pages/Annuaire/User/Contacts/Tabs/Specs.purs
View file @
37be629b
...
...
@@ -3,16 +3,32 @@ module Gargantext.Pages.Annuaire.User.Contacts.Tabs.Specs where
import Prelude hiding (div)
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.List (fromFoldable)
import Data.Tuple (Tuple(..))
import Gargantext.Config (TabType(..), TabSubType(..))
import Gargantext.Config (TabType(..), TabSubType(..)
, PTabNgramType(..)
)
import Gargantext.Components.DocsTable as DT
import Gargantext.Components.NgramsTable as NT
import Gargantext.Components.Tab as Tab
import Gargantext.Pages.Annuaire.User.Contacts.Types (Props)
import Gargantext.Pages.Annuaire.User.Contacts.Tabs.Ngrams.NgramsTable as NV
import Thermite (Spec, focus, hideState, noState, cmapProps)
data Mode = Patents | Books | Communication
derive instance genericMode :: Generic Mode _
instance showMode :: Show Mode where
show = genericShow
derive instance eqMode :: Eq Mode
modeTabType :: Mode -> PTabNgramType
modeTabType Patents = PTabPatents
modeTabType Books = PTabBooks
modeTabType Communication = PTabCommunication
pureTabs :: Spec {} Props Void
pureTabs = hideState (const {activeTab: 0}) statefulTabs
...
...
@@ -20,9 +36,9 @@ statefulTabs :: Spec Tab.State Props Tab.Action
statefulTabs =
Tab.tabs identity identity $ fromFoldable
[ Tuple "Documents" $ docs
, Tuple "Patents" $ ngramsViewSpec {mode:
NV.
Patents}
, Tuple "Books" $ ngramsViewSpec {mode:
NV.
Books}
, Tuple "Communication" $ ngramsViewSpec {mode:
NV.
Communication}
, Tuple "Patents" $ ngramsViewSpec {mode: Patents}
, Tuple "Books" $ ngramsViewSpec {mode: Books}
, Tuple "Communication" $ ngramsViewSpec {mode: Communication}
, Tuple "Trash" $ docs -- TODO pass-in trash mode
]
where
...
...
@@ -32,7 +48,10 @@ statefulTabs =
{nodeId, chart, tabType: TabPairing TabDocs, totalRecords: 4736}) $
noState DT.docViewSpec
ngramsViewSpec :: {mode ::
NV.
Mode} -> Spec Tab.State Props Tab.Action
ngramsViewSpec :: {mode :: Mode} -> Spec Tab.State Props Tab.Action
ngramsViewSpec {mode} =
cmapProps (\{loaded, path, dispatch} -> {mode,loaded,path, dispatch})
(noState NV.ngramsTableSpec)
cmapProps (\{loaded: {defaultListId}, path, dispatch} ->
{loaded: {defaultListId}, path, dispatch, tabType})
(noState NT.mainNgramsTableSpec)
where
tabType = TabPairing $ TabNgramType $ modeTabType mode
src/Gargantext/Pages/Annuaire/User/Contacts/Types.purs
View file @
37be629b
...
...
@@ -168,5 +168,7 @@ instance decodeUser :: DecodeJson Contact where
, hyperdata
}
type PropsRow = Loader.InnerPropsRow Int Contact ()
type ContactData = {contactNode :: Contact, defaultListId :: Int}
type PropsRow = Loader.InnerPropsRow Int ContactData ()
type Props = Record PropsRow
src/Gargantext/Pages/Corpus/Tabs/Ngrams/NgramsTable.purs
deleted
100644 → 0
View file @
733b0f61
module Gargantext.Pages.Corpus.Tabs.Ngrams.NgramsTable
(Mode(..), ngramsTableSpec)
where
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..))
import Effect.Aff (Aff)
import React (ReactElement)
import React as React
import Thermite (Render, Spec, createClass, defaultPerformAction, simpleSpec)
import Gargantext.Components.Node (NodePoly)
import Gargantext.Components.NgramsTable as NT
import Gargantext.Prelude
import Gargantext.Config (CTabNgramType(..), End(..), Offset, Limit, OrderBy(..), Path(..), TabSubType(..), TabType(..), toUrl)
import Gargantext.Config.REST (get)
import Gargantext.Components.Loader as Loader
import Gargantext.Pages.Corpus.Tabs.Types (CorpusData)
data Mode = Authors | Sources | Institutes | Terms
derive instance genericMode :: Generic Mode _
instance showMode :: Show Mode where
show = genericShow
derive instance eqMode :: Eq Mode
type Props = NT.Props CorpusData Mode
modeTabType :: Mode -> CTabNgramType
modeTabType Authors = CTabAuthors
modeTabType Sources = CTabSources
modeTabType Institutes = CTabInstitutes
modeTabType Terms = CTabTerms
-- TODO: Move to Components.NgramsTable?
loadPage :: NT.PageParams -> Aff NT.VersionedNgramsTable
loadPage { nodeId, listIds, termListFilter, termTypeFilter
, searchQuery, tabType, params: {offset, limit, orderBy}} =
get $ toUrl Back
(GetNgrams { tabType, offset, limit, listIds
, orderBy: convOrderBy <$> orderBy
, termListFilter, termTypeFilter
, searchQuery
})
(Just nodeId)
where
convOrderBy _ = DateAsc -- TODO
-- TODO: Move to Components.NgramsTable?
ngramsLoaderClass :: Loader.LoaderClass NT.PageParams NT.VersionedNgramsTable
ngramsLoaderClass = Loader.createLoaderClass "CorpusNgramsLoader" loadPage
-- TODO: Move to Components.NgramsTable?
ngramsLoader :: Loader.Props' NT.PageParams NT.VersionedNgramsTable -> ReactElement
ngramsLoader props = React.createElement ngramsLoaderClass props []
-- TODO: Move to Components.NgramsTable?
ngramsTableClass :: Loader.InnerClass NT.PageParams NT.VersionedNgramsTable
ngramsTableClass = createClass "CorpusNgramsTable" NT.ngramsTableSpec NT.initialState
ngramsTableSpec :: Spec {} Props Void
ngramsTableSpec = simpleSpec defaultPerformAction render
where
render :: Render {} Props Void
render _ {path: nodeId, loaded: {defaultListId}, mode} _ _ =
[ ngramsLoader { path: NT.initialPageParams nodeId [defaultListId] tabType
, component: ngramsTableClass
} ]
where
tabType = TabCorpus $ TabNgramType $ modeTabType mode
src/Gargantext/Pages/Corpus/Tabs/Specs.purs
View file @
37be629b
...
...
@@ -2,19 +2,37 @@ module Gargantext.Pages.Corpus.Tabs.Specs where
import Prelude hiding (div)
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.List (fromFoldable)
import Data.Tuple (Tuple(..))
import Gargantext.Config (TabType(..), TabSubType(..))
import Gargantext.Config (CTabNgramType(..), End(..), Path(..), TabSubType(..), TabType(..), toUrl)
import Gargantext.Pages.Corpus.Tabs.Types (Props)
import Gargantext.Pages.Corpus.Tabs.Ngrams.NgramsTable as NV
import Gargantext.Pages.Corpus.Dashboard (globalPublis)
import Gargantext.Components.NgramsTable as NT
import Gargantext.Components.Charts.Options.ECharts (chart) as ECharts
import Gargantext.Components.DocsTable as DT
import Gargantext.Components.Tab as Tab
import Thermite (Spec, hideState, noState, cmapProps)
data Mode = Authors | Sources | Institutes | Terms
derive instance genericMode :: Generic Mode _
instance showMode :: Show Mode where
show = genericShow
derive instance eqMode :: Eq Mode
modeTabType :: Mode -> CTabNgramType
modeTabType Authors = CTabAuthors
modeTabType Sources = CTabSources
modeTabType Institutes = CTabInstitutes
modeTabType Terms = CTabTerms
pureTabs :: Spec {} Props Void
pureTabs = hideState (const {activeTab: 0}) statefulTabs
...
...
@@ -22,10 +40,10 @@ statefulTabs :: Spec Tab.State Props Tab.Action
statefulTabs =
Tab.tabs identity identity $ fromFoldable
[ Tuple "Documents" $ docs
, Tuple "Authors" $ ngramsViewSpec {mode:
NV.
Authors}
, Tuple "Sources" $ ngramsViewSpec {mode:
NV.
Sources}
, Tuple "Institutes" $ ngramsViewSpec {mode:
NV.
Institutes}
, Tuple "Terms" $ ngramsViewSpec {mode:
NV.
Terms}
, Tuple "Authors" $ ngramsViewSpec {mode: Authors}
, Tuple "Sources" $ ngramsViewSpec {mode: Sources}
, Tuple "Institutes" $ ngramsViewSpec {mode: Institutes}
, Tuple "Terms" $ ngramsViewSpec {mode: Terms}
, Tuple "Trash" $ docs -- TODO pass-in trash mode
]
where
...
...
@@ -35,7 +53,10 @@ statefulTabs =
{nodeId, chart, tabType: TabCorpus TabDocs, totalRecords: 4736}) $
noState DT.docViewSpec
ngramsViewSpec :: {mode ::
NV.
Mode} -> Spec Tab.State Props Tab.Action
ngramsViewSpec :: {mode :: Mode} -> Spec Tab.State Props Tab.Action
ngramsViewSpec {mode} =
cmapProps (\{loaded, path, dispatch} -> {mode,loaded,path, dispatch})
(noState NV.ngramsTableSpec)
cmapProps (\{loaded: {defaultListId}, path, dispatch} ->
{loaded: {defaultListId}, path, dispatch, tabType})
(noState NT.mainNgramsTableSpec)
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