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
0952715c
Commit
0952715c
authored
Dec 10, 2018
by
Sudhir Kumar
Browse files
Options
Browse Files
Download
Plain Diff
merged master
parents
3d385a7f
2f764449
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
406 deletions
+71
-406
DocsTable.purs
src/Gargantext/Components/DocsTable.purs
+35
-33
Config.purs
src/Gargantext/Config.purs
+12
-0
Specs.purs
src/Gargantext/Pages/Annuaire/User/Contacts/Tabs/Specs.purs
+11
-4
Documents.purs
src/Gargantext/Pages/Corpus/Tabs/Documents.purs
+0
-365
Specs.purs
src/Gargantext/Pages/Corpus/Tabs/Specs.purs
+13
-4
No files found.
src/Gargantext/
Pages/Annuaire/User/Contacts/Tabs/Documents
.purs
→
src/Gargantext/
Components/DocsTable
.purs
View file @
0952715c
-- TODO copy of Gargantext.Pages.Corpus.Tabs.Documents
module Gargantext.Components.DocsTable where
module Gargantext.Pages.Annuaire.User.Contacts.Tabs.Documents where
import Data.Array (take, drop)
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, jsonEmptyObject, (.?), (:=), (~>))
import Affjax (defaultRequest, request)
import Affjax (defaultRequest, request)
import Affjax.RequestBody (RequestBody(..))
import Affjax.RequestBody (RequestBody(..))
...
@@ -26,18 +22,14 @@ import React as React
...
@@ -26,18 +22,14 @@ import React as React
import React (ReactClass, ReactElement, Children)
import React (ReactClass, ReactElement, Children)
------------------------------------------------------------------------
------------------------------------------------------------------------
import Gargantext.Prelude
import Gargantext.Prelude
import Gargantext.Config (
Path(..), NodeType(..), TabType(..), TabSubType(..), toUrl, End(..), OrderBy(..)
)
import Gargantext.Config (
End(..), NodeType(..), OrderBy(..), Path(..), TabType, toUrl
)
import Gargantext.Config.REST (get, put, post, deleteWithBody)
import Gargantext.Config.REST (get, put, post, deleteWithBody)
import Gargantext.Utils.DecodeMaybe ((.|))
--import Gargantext.Components.Charts.Options.ECharts (chart)
import Gargantext.Components.Loader as Loader
import Gargantext.Components.Loader as Loader
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.Table as T
import Gargantext.Components.Table as T
import Gargantext.Pages.Corpus.Dashboard (globalPublis)
import Gargantext.Pages.Annuaire.User.Contacts.Types (Contact, Props)
import Gargantext.Utils.DecodeMaybe ((.|))
import Gargantext.Utils.DecodeMaybe ((.|))
import React.DOM (a, br', button, div, i, input, p, text)
import React.DOM (a, br', button, div, i, input, p, text)
import React.DOM.Props (_type, className, href,
name, onClick, placeholder, style, valu
e)
import React.DOM.Props (_type, className, href,
onClick, placeholder, styl
e)
import Thermite (PerformAction, Render, Spec, defaultPerformAction, modifyState_, simpleSpec, hideState)
import Thermite (PerformAction, Render, Spec, defaultPerformAction, modifyState_, simpleSpec, hideState)
------------------------------------------------------------------------
------------------------------------------------------------------------
-- TODO: Pagination Details are not available from the BackEnd
-- TODO: Pagination Details are not available from the BackEnd
...
@@ -45,7 +37,18 @@ import Thermite (PerformAction, Render, Spec, defaultPerformAction, modifyState_
...
@@ -45,7 +37,18 @@ import Thermite (PerformAction, Render, Spec, defaultPerformAction, modifyState_
-- TODO: Fav is pending
-- TODO: Fav is pending
-- TODO: Sort is Pending
-- TODO: Sort is Pending
-- TODO: Filter is Pending
-- TODO: Filter is Pending
-- TODO: When a pagination link is clicked, reload data.
type NodeID = Int
type TotalRecords = Int
type Props =
{ nodeId :: Int
, totalRecords :: Int
, chart :: ReactElement
, tabType :: TabType
-- ^ tabType is not ideal here since it is too much entangled with tabs and
-- ngramtable. Let's see how this evolves.
}
type State =
type State =
{ documentIdsToDelete :: Set Int
{ documentIdsToDelete :: Set Int
...
@@ -132,7 +135,7 @@ instance decodeResponse :: DecodeJson Response where
...
@@ -132,7 +135,7 @@ instance decodeResponse :: DecodeJson Response where
-- | Filter
-- | Filter
filterSpec ::
Spec State Props A
ction
filterSpec ::
forall state props action. Spec state props a
ction
filterSpec = simpleSpec defaultPerformAction render
filterSpec = simpleSpec defaultPerformAction render
where
where
render d p s c = [div [] [ text " Filter "
render d p s c = [div [] [ text " Filter "
...
@@ -142,17 +145,17 @@ filterSpec = simpleSpec defaultPerformAction render
...
@@ -142,17 +145,17 @@ filterSpec = simpleSpec defaultPerformAction render
docViewSpec :: Spec {} Props Void
docViewSpec :: Spec {} Props Void
docViewSpec = hideState (const initialState) layoutDocview
docViewSpec = hideState (const initialState) layoutDocview
-- | Main layout of the Documents Tab of a
n Annuaire
-- | Main layout of the Documents Tab of a
Corpus
layoutDocview :: Spec State Props Action
layoutDocview :: Spec State Props Action
layoutDocview = simpleSpec performAction render
layoutDocview = simpleSpec performAction render
where
where
performAction :: PerformAction State Props Action
performAction :: PerformAction State Props Action
performAction (MarkFavorites nids) {
path :
nodeId} _ =
performAction (MarkFavorites nids) {nodeId} _ =
void $ lift $ putFavorites nodeId (FavoriteQuery {favorites: nids})
void $ lift $ putFavorites nodeId (FavoriteQuery {favorites: nids})
--TODO add array of delete rows here
--TODO add array of delete rows here
performAction (ToggleDocumentToDelete nid) _ _ =
performAction (ToggleDocumentToDelete nid) _ _ =
modifyState_ \state -> state {documentIdsToDelete = toggleSet nid state.documentIdsToDelete}
modifyState_ \state -> state {documentIdsToDelete = toggleSet nid state.documentIdsToDelete}
performAction Trash {
path:
nodeId} {documentIdsToDelete} =
performAction Trash {nodeId} {documentIdsToDelete} =
void $ lift $ deleteDocuments nodeId (DeleteDocumentQuery {documents: Set.toUnfoldable documentIdsToDelete})
void $ lift $ deleteDocuments nodeId (DeleteDocumentQuery {documents: Set.toUnfoldable documentIdsToDelete})
-- TODO: what to do now that the documents are deleted
-- TODO: what to do now that the documents are deleted
-- * should we reload? NO (if you change page, yes and come back yes)
-- * should we reload? NO (if you change page, yes and come back yes)
...
@@ -165,17 +168,17 @@ layoutDocview = simpleSpec performAction render
...
@@ -165,17 +168,17 @@ layoutDocview = simpleSpec performAction render
-- `checked: Set.member n state.documentIdsToDelete`
-- `checked: Set.member n state.documentIdsToDelete`
render :: Render State Props Action
render :: Render State Props Action
render dispatch {
path: nodeId, loaded: contac
t} _ _ =
render dispatch {
nodeId, tabType, totalRecords, char
t} _ _ =
[ p [] []
[ p [] []
, div [ style {textAlign : "center"}] [input [placeholder "Filter here"]]
, div [ style {textAlign : "center"}] [input [placeholder "Filter here"]]
, br'
, br'
, div [className "container1"]
, div [className "container1"]
[ div [className "row"]
[ div [className "row"]
[
-- chart globalPublis
[
chart
div [className "col-md-12"]
,
div [className "col-md-12"]
[ pageLoader
[ pageLoader
{ path: initialPageParams
nodeId
{ path: initialPageParams
{nodeId, tabType}
,
contact
,
totalRecords
, dispatch
, dispatch
}
}
]
]
...
@@ -194,16 +197,15 @@ layoutDocview = simpleSpec performAction render
...
@@ -194,16 +197,15 @@ layoutDocview = simpleSpec performAction render
mock :: Boolean
mock :: Boolean
mock = false
mock = false
type PageParams = {nodeId :: Int, params :: T.Params}
type PageParams = {nodeId :: Int,
tabType :: TabType,
params :: T.Params}
initialPageParams ::
Int
-> PageParams
initialPageParams ::
{nodeId :: Int, tabType :: TabType}
-> PageParams
initialPageParams
nodeId = {nodeId
, params: T.initialParams}
initialPageParams
{nodeId, tabType} = {nodeId, tabType
, params: T.initialParams}
loadPage :: PageParams -> Aff (Array DocumentsView)
loadPage :: PageParams -> Aff (Array DocumentsView)
loadPage {nodeId, params: {limit, offset, orderBy}} = do
loadPage {nodeId,
tabType,
params: {limit, offset, orderBy}} = do
logs "loading documents page: loadPage with Offset and limit"
logs "loading documents page: loadPage with Offset and limit"
--res <- get $ toUrl Back (Children Url_Document offset limit) nodeId
res <- get $ toUrl Back (Tab tabType offset limit (convOrderBy <$> orderBy)) (Just nodeId)
res <- get $ toUrl Back (Tab (TabPairing TabDocs) offset limit (convOrderBy <$> orderBy)) (Just nodeId)
let docs = res2corpus <$> res
let docs = res2corpus <$> res
--_ <- logs "Ok: loading page documents"
--_ <- logs "Ok: loading page documents"
--_ <- logs $ map show docs
--_ <- logs $ map show docs
...
@@ -231,23 +233,23 @@ loadPage {nodeId, params: {limit, offset, orderBy}} = do
...
@@ -231,23 +233,23 @@ loadPage {nodeId, params: {limit, offset, orderBy}} = do
type PageLoaderProps row =
type PageLoaderProps row =
{ path :: PageParams
{ path :: PageParams
,
contact :: Contac
t
,
totalRecords :: In
t
, dispatch :: Action -> Effect Unit
, dispatch :: Action -> Effect Unit
| row
| row
}
}
renderPage :: forall props path.
renderPage :: forall props path.
Render (Loader.State {nodeId :: Int | path} (Array DocumentsView))
Render (Loader.State {nodeId :: Int
, tabType :: TabType
| path} (Array DocumentsView))
{
contact :: Contac
t
{
totalRecords :: In
t
, dispatch :: Action -> Effect Unit
, dispatch :: Action -> Effect Unit
| props
| props
}
}
(Loader.Action PageParams)
(Loader.Action PageParams)
renderPage _ _ {loaded: Nothing} _ = [] -- TODO loading spinner
renderPage _ _ {loaded: Nothing} _ = [] -- TODO loading spinner
renderPage loaderDispatch {
contact, dispatch} {currentPath: {nodeId
}, loaded: Just res} _ =
renderPage loaderDispatch {
totalRecords, dispatch} {currentPath: {nodeId, tabType
}, loaded: Just res} _ =
[ T.tableElt
[ T.tableElt
{ rows
{ rows
, setParams: \params -> liftEffect $ loaderDispatch (Loader.SetPath {nodeId, params})
, setParams: \params -> liftEffect $ loaderDispatch (Loader.SetPath {nodeId,
tabType,
params})
, container: T.defaultContainer { title: "Documents" }
, container: T.defaultContainer { title: "Documents" }
, colNames:
, colNames:
T.ColumnName <$>
T.ColumnName <$>
...
@@ -257,7 +259,7 @@ renderPage loaderDispatch {contact, dispatch} {currentPath: {nodeId}, loaded: Ju
...
@@ -257,7 +259,7 @@ renderPage loaderDispatch {contact, dispatch} {currentPath: {nodeId}, loaded: Ju
, "Source"
, "Source"
, "Delete"
, "Delete"
]
]
, totalRecords
: 47361 -- TODO
, totalRecords
}
}
]
]
where
where
...
...
src/Gargantext/Config.purs
View file @
0952715c
...
@@ -209,6 +209,8 @@ instance showApiVersion :: Show ApiVersion where
...
@@ -209,6 +209,8 @@ instance showApiVersion :: Show ApiVersion where
data CTabNgramType = CTabTerms | CTabSources | CTabAuthors | CTabInstitutes
data CTabNgramType = CTabTerms | CTabSources | CTabAuthors | CTabInstitutes
derive instance eqCTabNgramType :: Eq CTabNgramType
instance showCTabNgramType :: Show CTabNgramType where
instance showCTabNgramType :: Show CTabNgramType where
show CTabTerms = "Terms"
show CTabTerms = "Terms"
show CTabSources = "Sources"
show CTabSources = "Sources"
...
@@ -217,6 +219,8 @@ instance showCTabNgramType :: Show CTabNgramType where
...
@@ -217,6 +219,8 @@ instance showCTabNgramType :: Show CTabNgramType where
data PTabNgramType = PTabPatents | PTabBooks | PTabCommunication
data PTabNgramType = PTabPatents | PTabBooks | PTabCommunication
derive instance eqPTabNgramType :: Eq PTabNgramType
instance showPTabNgramType :: Show PTabNgramType where
instance showPTabNgramType :: Show PTabNgramType where
show PTabPatents = "Patents"
show PTabPatents = "Patents"
show PTabBooks = "Books"
show PTabBooks = "Books"
...
@@ -224,6 +228,8 @@ instance showPTabNgramType :: Show PTabNgramType where
...
@@ -224,6 +228,8 @@ instance showPTabNgramType :: Show PTabNgramType where
data TabSubType a = TabDocs | TabNgramType a | TabTrash
data TabSubType a = TabDocs | TabNgramType a | TabTrash
derive instance eqTabSubType :: Eq a => Eq (TabSubType a)
instance showTabSubType :: Show a => Show (TabSubType a) where
instance showTabSubType :: Show a => Show (TabSubType a) where
show TabDocs = "Docs"
show TabDocs = "Docs"
show (TabNgramType a) = show a
show (TabNgramType a) = show a
...
@@ -233,6 +239,12 @@ data TabType
...
@@ -233,6 +239,12 @@ data TabType
= TabCorpus (TabSubType CTabNgramType)
= TabCorpus (TabSubType CTabNgramType)
| TabPairing (TabSubType PTabNgramType)
| TabPairing (TabSubType PTabNgramType)
derive instance eqTabType :: Eq TabType
instance showTabType :: Show TabType where
show (TabCorpus t) = "Corpus" <> show t
show (TabPairing t) = "Pairing" <> show t
------------------------------------------------------------
------------------------------------------------------------
nodeTypeUrl :: NodeType -> Url
nodeTypeUrl :: NodeType -> Url
nodeTypeUrl Annuaire = "annuaire"
nodeTypeUrl Annuaire = "annuaire"
...
...
src/Gargantext/Pages/Annuaire/User/Contacts/Tabs/Specs.purs
View file @
0952715c
...
@@ -6,10 +6,11 @@ import Prelude hiding (div)
...
@@ -6,10 +6,11 @@ import Prelude hiding (div)
import Data.List (fromFoldable)
import Data.List (fromFoldable)
import Data.Tuple (Tuple(..))
import Data.Tuple (Tuple(..))
import Gargantext.Config (TabType(..), TabSubType(..))
import Gargantext.Components.DocsTable as DT
import Gargantext.Components.Tab as Tab
import Gargantext.Pages.Annuaire.User.Contacts.Types (Props)
import Gargantext.Pages.Annuaire.User.Contacts.Types (Props)
import Gargantext.Pages.Annuaire.User.Contacts.Tabs.Documents as DV
import Gargantext.Pages.Annuaire.User.Contacts.Tabs.Ngrams.NgramsTable as NV
import Gargantext.Pages.Annuaire.User.Contacts.Tabs.Ngrams.NgramsTable as NV
import Gargantext.Components.Tab as Tab
import Thermite (Spec, focus, hideState, noState, cmapProps)
import Thermite (Spec, focus, hideState, noState, cmapProps)
pureTabs :: Spec {} Props Void
pureTabs :: Spec {} Props Void
...
@@ -18,12 +19,18 @@ pureTabs = hideState (const {activeTab: 0}) statefulTabs
...
@@ -18,12 +19,18 @@ pureTabs = hideState (const {activeTab: 0}) statefulTabs
statefulTabs :: Spec Tab.State Props Tab.Action
statefulTabs :: Spec Tab.State Props Tab.Action
statefulTabs =
statefulTabs =
Tab.tabs identity identity $ fromFoldable
Tab.tabs identity identity $ fromFoldable
[ Tuple "Documents" $
noState DV.docViewSpec
[ Tuple "Documents" $
docs
, Tuple "Patents" $ ngramsViewSpec {mode: NV.Patents}
, Tuple "Patents" $ ngramsViewSpec {mode: NV.Patents}
, Tuple "Books" $ ngramsViewSpec {mode: NV.Books}
, Tuple "Books" $ ngramsViewSpec {mode: NV.Books}
, Tuple "Communication" $ ngramsViewSpec {mode: NV.Communication}
, Tuple "Communication" $ ngramsViewSpec {mode: NV.Communication}
, Tuple "Trash" $
noState DV.docViewSpec
-- TODO pass-in trash mode
, Tuple "Trash" $
docs
-- TODO pass-in trash mode
]
]
where
chart = mempty
-- TODO totalRecords
docs = cmapProps (\{path: nodeId} ->
{nodeId, chart, tabType: TabPairing TabDocs, totalRecords: 4736}) $
noState DT.docViewSpec
ngramsViewSpec :: {mode :: NV.Mode} -> Spec Tab.State Props Tab.Action
ngramsViewSpec :: {mode :: NV.Mode} -> Spec Tab.State Props Tab.Action
ngramsViewSpec {mode} =
ngramsViewSpec {mode} =
...
...
src/Gargantext/Pages/Corpus/Tabs/Documents.purs
deleted
100644 → 0
View file @
3d385a7f
This diff is collapsed.
Click to expand it.
src/Gargantext/Pages/Corpus/Tabs/Specs.purs
View file @
0952715c
...
@@ -5,12 +5,15 @@ import Prelude hiding (div)
...
@@ -5,12 +5,15 @@ import Prelude hiding (div)
import Data.List (fromFoldable)
import Data.List (fromFoldable)
import Data.Tuple (Tuple(..))
import Data.Tuple (Tuple(..))
import Gargantext.Config (TabType(..), TabSubType(..))
import Gargantext.Pages.Corpus.Tabs.Types (Props)
import Gargantext.Pages.Corpus.Tabs.Types (Props)
import Gargantext.Pages.Corpus.Tabs.Documents as DV
import Gargantext.Pages.Corpus.Tabs.Ngrams.NgramsTable as NV
import Gargantext.Pages.Corpus.Tabs.Ngrams.NgramsTable as NV
import Gargantext.Pages.Corpus.Dashboard (globalPublis)
import Gargantext.Components.Charts.Options.ECharts (chart) as ECharts
import Gargantext.Components.DocsTable as DT
import Gargantext.Components.Tab as Tab
import Gargantext.Components.Tab as Tab
import Thermite (Spec,
focus,
hideState, noState, cmapProps)
import Thermite (Spec, hideState, noState, cmapProps)
pureTabs :: Spec {} Props Void
pureTabs :: Spec {} Props Void
pureTabs = hideState (const {activeTab: 0}) statefulTabs
pureTabs = hideState (const {activeTab: 0}) statefulTabs
...
@@ -18,13 +21,19 @@ pureTabs = hideState (const {activeTab: 0}) statefulTabs
...
@@ -18,13 +21,19 @@ pureTabs = hideState (const {activeTab: 0}) statefulTabs
statefulTabs :: Spec Tab.State Props Tab.Action
statefulTabs :: Spec Tab.State Props Tab.Action
statefulTabs =
statefulTabs =
Tab.tabs identity identity $ fromFoldable
Tab.tabs identity identity $ fromFoldable
[ Tuple "Documents" $
noState DV.docViewSpec
[ Tuple "Documents" $
docs
, Tuple "Authors" $ ngramsViewSpec {mode: NV.Authors}
, Tuple "Authors" $ ngramsViewSpec {mode: NV.Authors}
, Tuple "Sources" $ ngramsViewSpec {mode: NV.Sources}
, Tuple "Sources" $ ngramsViewSpec {mode: NV.Sources}
, Tuple "Institutes" $ ngramsViewSpec {mode: NV.Institutes}
, Tuple "Institutes" $ ngramsViewSpec {mode: NV.Institutes}
, Tuple "Terms" $ ngramsViewSpec {mode: NV.Terms}
, Tuple "Terms" $ ngramsViewSpec {mode: NV.Terms}
, Tuple "Trash" $
noState DV.docViewSpec
-- TODO pass-in trash mode
, Tuple "Trash" $
docs
-- TODO pass-in trash mode
]
]
where
-- TODO totalRecords
chart = ECharts.chart globalPublis
docs = cmapProps (\{path: nodeId} ->
{nodeId, chart, tabType: TabCorpus TabDocs, totalRecords: 4736}) $
noState DT.docViewSpec
ngramsViewSpec :: {mode :: NV.Mode} -> Spec Tab.State Props Tab.Action
ngramsViewSpec :: {mode :: NV.Mode} -> Spec Tab.State Props Tab.Action
ngramsViewSpec {mode} =
ngramsViewSpec {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