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
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
03fbb087
Commit
03fbb087
authored
Jul 23, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Tree] texts/lists redirection with proper views
parent
e35e8ce6
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
326 additions
and
48 deletions
+326
-48
Config.purs
src/Gargantext/Config.purs
+7
-1
Corpus.purs
src/Gargantext/Pages/Corpus.purs
+7
-32
Tabs.purs
src/Gargantext/Pages/Corpus/Tabs.purs
+0
-6
Layout.purs
src/Gargantext/Pages/Layout.purs
+6
-0
Specs.purs
src/Gargantext/Pages/Layout/Specs.purs
+5
-1
Lists.purs
src/Gargantext/Pages/Lists.purs
+51
-0
Tabs.purs
src/Gargantext/Pages/Lists/Tabs.purs
+6
-0
Specs.purs
src/Gargantext/Pages/Lists/Tabs/Specs.purs
+4
-7
Types.purs
src/Gargantext/Pages/Lists/Tabs/Types.purs
+1
-1
Texts.purs
src/Gargantext/Pages/Texts.purs
+51
-0
Tabs.purs
src/Gargantext/Pages/Texts/Tabs.purs
+6
-0
Specs.purs
src/Gargantext/Pages/Texts/Tabs/Specs.purs
+124
-0
Types.purs
src/Gargantext/Pages/Texts/Tabs/Types.purs
+52
-0
Router.purs
src/Gargantext/Router.purs
+6
-0
No files found.
src/Gargantext/Config.purs
View file @
03fbb087
...
...
@@ -217,6 +217,8 @@ routesPath R.AddCorpus = "addCorpus"
routesPath (R.CorpusDocument c l i) = "corpus/" <> show c <> "/list/" <> show l <> "/document/" <> show i
routesPath (R.Document l i) = "list/" <> show l <> "/document/" <> show i
routesPath (R.PGraphExplorer i) = "#/"
routesPath (R.Texts i) = "texts/" <> show i
routesPath (R.Lists i) = "lists/" <> show i
routesPath R.Dashboard = "dashboard"
routesPath (R.Annuaire i) = "annuaire/" <> show i
routesPath (R.UserPage i) = "user/" <> show i
...
...
@@ -258,6 +260,7 @@ data NodeType = NodeUser
| Nodes
| Tree
| NodeList
| Texts
derive instance eqNodeType :: Eq NodeType
...
...
@@ -278,6 +281,7 @@ instance showNodeType :: Show NodeType where
show Nodes = "Nodes"
show Tree = "NodeTree"
show NodeList = "NodeList"
show Texts = "NodeTexts"
readNodeType :: String -> NodeType
readNodeType "NodeAnnuaire" = Annuaire
...
...
@@ -295,6 +299,7 @@ readNodeType "NodeUser" = NodeUser
readNodeType "NodeContact" = NodeContact
readNodeType "Tree" = Tree
readNodeType "NodeList" = NodeList
readNodeType "NodeTexts" = Texts
readNodeType _ = Error
{-
------------------------------------------------------------
...
...
@@ -330,6 +335,7 @@ nodeTypeUrl NodeUser = "user"
nodeTypeUrl NodeContact = "contact"
nodeTypeUrl Tree = "tree"
nodeTypeUrl NodeList = "list"
nodeTypeUrl Texts = "texts"
------------------------------------------------------------
type ListId = Int
...
...
src/Gargantext/Pages/Corpus.purs
View file @
03fbb087
...
...
@@ -5,6 +5,7 @@ import Data.Maybe (Maybe(..))
import Effect.Aff (Aff, throwError)
import Effect.Exception (error)
import Reactix as R
import Reactix.DOM.HTML as H
import Thermite (Spec)
--------------------------------------------------------
import Gargantext.Prelude
...
...
@@ -13,39 +14,13 @@ import Gargantext.Components.Loader2 (useLoader)
import Gargantext.Components.Table as Table
import Gargantext.Config (toUrl, Path(..), NodeType(..), End(..))
import Gargantext.Config.REST (get)
import Gargantext.Pages.
Corpu
s.Tabs.Types (CorpusData, CorpusInfo(..))
import Gargantext.Pages.
Corpu
s.Tabs.Specs (elt) as Tabs
import Gargantext.Pages.
Text
s.Tabs.Types (CorpusData, CorpusInfo(..))
import Gargantext.Pages.
Text
s.Tabs.Specs (elt) as Tabs
import Gargantext.Utils.Reactix as R2
------------------------------------------------------------------------
layout :: Spec {} {nodeId :: Int} Void
layout =
R2.elSpec $ R.hooksComponent "CorpusLoader" \{nodeId} _ ->
useLoader nodeId getCorpus $ \{path: corpusId
,loaded: corpusData} ->
let {corpusNode:
NodePoly { name: title
, date: date'
, hyperdata: CorpusInfo corpus
}
} = corpusData in
R2.toElement $
Table.renderTableHeaderLayout
{ title: "Corpus " <> title
, desc: corpus.desc
, query: corpus.query
, date: date'
, user: corpus.authors
}
<> [Tabs.elt {corpusId, corpusData}]
------------------------------------------------------------------------
getCorpus :: Int -> Aff CorpusData
getCorpus corpusId = do
corpusNode <- get $ toUrl Back Corpus $ Just corpusId
defaultListIds <- get $ toUrl Back (Children NodeList 0 1 Nothing) $ Just corpusId
case (head defaultListIds :: Maybe (NodePoly HyperdataList)) of
Just (NodePoly { id: defaultListId }) ->
pure {corpusNode, defaultListId}
Nothing ->
throwError $ error "Missing default list"
layout = R2.elSpec $ R.hooksComponent "CorpusLoader" cpt
where
cpt {nodeId} _children = do
pure $ H.div {} [H.text "Empty page"]
src/Gargantext/Pages/Corpus/Tabs.purs
deleted
100644 → 0
View file @
e35e8ce6
module Gargantext.Pages.Corpus.Tabs
( module Gargantext.Pages.Corpus.Tabs.Specs
) where
import Gargantext.Pages.Corpus.Tabs.Specs
src/Gargantext/Pages/Layout.purs
View file @
03fbb087
...
...
@@ -59,5 +59,11 @@ dispatchAction dispatcher _ (PGraphExplorer nid) = do
dispatcher $ GraphExplorerA $ GE.LoadGraph nid
--dispatcher $ GraphExplorerA $ GE.LoadGraph "imtNew.json"
dispatchAction dispatcher _ (Texts nid) = do
dispatcher $ SetRoute $ Texts nid
dispatchAction dispatcher _ (Lists nid) = do
dispatcher $ SetRoute $ Lists nid
dispatchAction dispatcher _ Dashboard = do
dispatcher $ SetRoute Dashboard
src/Gargantext/Pages/Layout/Specs.purs
View file @
03fbb087
...
...
@@ -22,6 +22,8 @@ import Gargantext.Pages.Corpus as Corpus
import Gargantext.Pages.Corpus.Document as Annotation
import Gargantext.Pages.Corpus.Dashboard as Dsh
import Gargantext.Pages.Corpus.Graph as GE
import Gargantext.Pages.Lists as Lists
import Gargantext.Pages.Texts as Texts
import Gargantext.Pages.Home as L
import Gargantext.Pages.Layout.Actions (Action(..), _addCorpusAction, _graphExplorerAction, _loginAction, _searchAction, performAction)
import Gargantext.Pages.Layout.Specs.AddCorpus as AC
...
...
@@ -63,6 +65,8 @@ pagesComponent s = case s.currentRoute of
selectSpec (CorpusDocument c l i) = layout0 $ cmapProps (const {nodeId: i, listId: l, corpusId: Just c}) $ noState Annotation.layout
selectSpec (Document l i) = layout0 $ cmapProps (const {nodeId: i, listId: l, corpusId: Nothing}) $ noState Annotation.layout
selectSpec (PGraphExplorer i)= layout1 $ focus _graphExplorerState _graphExplorerAction GE.specOld
selectSpec (Texts i) = layout0 $ cmapProps (const {nodeId: i}) $ noState Texts.layout
selectSpec (Lists i) = layout0 $ cmapProps (const {nodeId: i}) $ noState Lists.layout
selectSpec Dashboard = layout0 $ noState Dsh.layoutDashboard
selectSpec (Annuaire i) = layout0 $ cmapProps (const {annuaireId: i}) $ noState A.layout
selectSpec (UserPage i) = layout0 $ cmapProps (const {nodeId: i}) $ noState C.layoutUser
...
...
src/Gargantext/Pages/Lists.purs
0 → 100644
View file @
03fbb087
module Gargantext.Pages.Lists where
import Data.Array (head)
import Data.Maybe (Maybe(..))
import Effect.Aff (Aff, throwError)
import Effect.Exception (error)
import Reactix as R
import Thermite (Spec)
--------------------------------------------------------
import Gargantext.Prelude
import Gargantext.Components.Node (NodePoly(..), HyperdataList)
import Gargantext.Components.Loader2 (useLoader)
import Gargantext.Components.Table as Table
import Gargantext.Config (toUrl, Path(..), NodeType(..), End(..))
import Gargantext.Config.REST (get)
import Gargantext.Pages.Lists.Tabs.Types (CorpusData, CorpusInfo(..))
import Gargantext.Pages.Lists.Tabs.Specs (elt) as Tabs
import Gargantext.Utils.Reactix as R2
------------------------------------------------------------------------
layout :: Spec {} {nodeId :: Int} Void
layout =
R2.elSpec $ R.hooksComponent "ListsLoader" \{nodeId} _ ->
useLoader nodeId getCorpus $ \{path: corpusId
,loaded: corpusData} ->
let {corpusNode:
NodePoly { name: title
, date: date'
, hyperdata: CorpusInfo corpus
}
} = corpusData in
R2.toElement $
Table.renderTableHeaderLayout
{ title: "Corpus " <> title
, desc: corpus.desc
, query: corpus.query
, date: date'
, user: corpus.authors
}
<> [Tabs.elt {corpusId, corpusData}]
------------------------------------------------------------------------
getCorpus :: Int -> Aff CorpusData
getCorpus corpusId = do
corpusNode <- get $ toUrl Back Corpus $ Just corpusId
defaultListIds <- get $ toUrl Back (Children NodeList 0 1 Nothing) $ Just corpusId
case (head defaultListIds :: Maybe (NodePoly HyperdataList)) of
Just (NodePoly { id: defaultListId }) ->
pure {corpusNode, defaultListId}
Nothing ->
throwError $ error "Missing default list"
src/Gargantext/Pages/Lists/Tabs.purs
0 → 100644
View file @
03fbb087
module Gargantext.Pages.Lists.Tabs
( module Gargantext.Pages.Lists.Tabs.Specs
) where
import Gargantext.Pages.Lists.Tabs.Specs
src/Gargantext/Pages/
Corpu
s/Tabs/Specs.purs
→
src/Gargantext/Pages/
List
s/Tabs/Specs.purs
View file @
03fbb087
module Gargantext.Pages.
Corpu
s.Tabs.Specs where
module Gargantext.Pages.
List
s.Tabs.Specs where
import Prelude hiding (div)
...
...
@@ -9,7 +9,7 @@ import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..))
import Gargantext.Config (CTabNgramType(..), End(..), Path(..), TabSubType(..), TabType(..), toUrl)
import Gargantext.Pages.
Corpu
s.Tabs.Types (Props, PropsRow)
import Gargantext.Pages.
List
s.Tabs.Types (Props, PropsRow)
import Gargantext.Pages.Corpus.Chart.Histo (histoSpec)
import Gargantext.Pages.Corpus.Chart.Metrics (metricsSpec)
...
...
@@ -45,7 +45,7 @@ elt :: Props -> ReactElement
elt props = createElement tabsClass props []
tabsClass :: ReactClass { children :: Children | PropsRow }
tabsClass = createClass "CorpusTabs" pureTabs
(const {})
tabsClass = createClass "CorpusTabs" pureTabs
$ const {}
pureTabs :: Spec {} Props Void
pureTabs = hideState (const {activeTab: 0}) statefulTabs
...
...
@@ -53,13 +53,10 @@ pureTabs = hideState (const {activeTab: 0}) statefulTabs
statefulTabs :: Spec Tab.State Props Tab.Action
statefulTabs =
Tab.tabs identity identity $ fromFoldable
[ Tuple "Documents" $ docs
, Tuple "Sources" $ ngramsViewSpec {mode: Sources }
[ Tuple "Sources" $ ngramsViewSpec {mode: Sources }
, Tuple "Authors" $ ngramsViewSpec {mode: Authors }
, Tuple "Institutes" $ ngramsViewSpec {mode: Institutes}
, Tuple "Terms" $ ngramsViewSpec {mode: Terms }
, Tuple "" $ trash -- TODO empty here
, Tuple "Trash" $ trash
]
where
-- TODO totalRecords
...
...
src/Gargantext/Pages/
Corpu
s/Tabs/Types.purs
→
src/Gargantext/Pages/
List
s/Tabs/Types.purs
View file @
03fbb087
module Gargantext.Pages.
Corpu
s.Tabs.Types where
module Gargantext.Pages.
List
s.Tabs.Types where
import Data.Argonaut (class DecodeJson, decodeJson, (.?), (.??))
import Data.Maybe (Maybe(..))
...
...
src/Gargantext/Pages/Texts.purs
0 → 100644
View file @
03fbb087
module Gargantext.Pages.Texts where
import Data.Array (head)
import Data.Maybe (Maybe(..))
import Effect.Aff (Aff, throwError)
import Effect.Exception (error)
import Reactix as R
import Thermite (Spec)
--------------------------------------------------------
import Gargantext.Prelude
import Gargantext.Components.Node (NodePoly(..), HyperdataList)
import Gargantext.Components.Loader2 (useLoader)
import Gargantext.Components.Table as Table
import Gargantext.Config (toUrl, Path(..), NodeType(..), End(..))
import Gargantext.Config.REST (get)
import Gargantext.Pages.Texts.Tabs.Types (CorpusData, CorpusInfo(..))
import Gargantext.Pages.Texts.Tabs.Specs (elt) as Tabs
import Gargantext.Utils.Reactix as R2
------------------------------------------------------------------------
layout :: Spec {} {nodeId :: Int} Void
layout =
R2.elSpec $ R.hooksComponent "TextsLoader" \{nodeId} _ ->
useLoader nodeId getCorpus $ \{path: corpusId
,loaded: corpusData} ->
let {corpusNode:
NodePoly { name: title
, date: date'
, hyperdata: CorpusInfo corpus
}
} = corpusData in
R2.toElement $
Table.renderTableHeaderLayout
{ title: "Corpus " <> title
, desc: corpus.desc
, query: corpus.query
, date: date'
, user: corpus.authors
}
<> [Tabs.elt {corpusId, corpusData}]
------------------------------------------------------------------------
getCorpus :: Int -> Aff CorpusData
getCorpus corpusId = do
corpusNode <- get $ toUrl Back Corpus $ Just corpusId
defaultListIds <- get $ toUrl Back (Children NodeList 0 1 Nothing) $ Just corpusId
case (head defaultListIds :: Maybe (NodePoly HyperdataList)) of
Just (NodePoly { id: defaultListId }) ->
pure {corpusNode, defaultListId}
Nothing ->
throwError $ error "Missing default list"
src/Gargantext/Pages/Texts/Tabs.purs
0 → 100644
View file @
03fbb087
module Gargantext.Pages.Texts.Tabs
( module Gargantext.Pages.Texts.Tabs.Specs
) where
import Gargantext.Pages.Texts.Tabs.Specs
src/Gargantext/Pages/Texts/Tabs/Specs.purs
0 → 100644
View file @
03fbb087
module Gargantext.Pages.Texts.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.Maybe (Maybe(..))
import Data.Tuple (Tuple(..))
import Gargantext.Config (CTabNgramType(..), End(..), Path(..), TabSubType(..), TabType(..), toUrl)
import Gargantext.Pages.Texts.Tabs.Types (Props, PropsRow)
import Gargantext.Pages.Corpus.Chart.Histo (histoSpec)
import Gargantext.Pages.Corpus.Chart.Metrics (metricsSpec)
import Gargantext.Pages.Corpus.Chart.Pie (pieSpec, barSpec)
import Gargantext.Pages.Corpus.Chart.Tree (treeSpec)
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 Gargantext.Utils.Reactix as R2
import React (ReactElement, ReactClass, createElement, Children)
import React.DOM (div)
import Thermite (Spec, hideState, noState, cmapProps, createClass)
data Mode = MoreLikeFav | MoreLikeTrash
derive instance genericMode :: Generic Mode _
instance showMode :: Show Mode where
show = genericShow
derive instance eqMode :: Eq Mode
modeTabType :: Mode -> CTabNgramType
modeTabType MoreLikeFav = CTabAuthors -- TODO
modeTabType MoreLikeTrash = CTabSources -- TODO
elt :: Props -> ReactElement
elt props = createElement tabsClass props []
tabsClass :: ReactClass { children :: Children | PropsRow }
tabsClass = createClass "CorpusTabs" pureTabs $ const {}
pureTabs :: Spec {} Props Void
pureTabs = hideState (const {activeTab: 0}) statefulTabs
statefulTabs :: Spec Tab.State Props Tab.Action
statefulTabs =
Tab.tabs identity identity $ fromFoldable
[ Tuple "Documents" $ docs
--, Tuple "Sources" $ ngramsViewSpec {mode: Sources }
--, Tuple "Authors" $ ngramsViewSpec {mode: Authors }
--, Tuple "Institutes" $ ngramsViewSpec {mode: Institutes}
--, Tuple "Terms" $ ngramsViewSpec {mode: Terms }
--, Tuple "" $ trash -- TODO empty here
, Tuple "Trash" $ trash
, Tuple "More like fav" $ docs -- TODO
, Tuple "More like trash" $ docs -- TODO
]
where
-- TODO totalRecords
docs = noState ( cmapProps (\{corpusId} -> {corpusId, tabType: TabCorpus TabDocs}) histoSpec
<>
(cmapProps (\{corpusId, corpusData: {defaultListId}} ->
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, chart : div [][]
, tabType: TabCorpus TabDocs
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId}) $ noState DT.docViewSpec
)
)
trash = cmapProps (\{corpusId, corpusData: {defaultListId}} ->
{ nodeId: corpusId
, chart: div [][]
, tabType: TabCorpus TabTrash
, totalRecords: 4736
, listId: defaultListId
, corpusId: Nothing}) $ noState DT.docViewSpec
-- 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
-- ngramsViewSpec :: {mode :: Mode} -> Spec Tab.State Props Tab.Action
-- ngramsViewSpec {mode} =
-- noState $ chart mode <>
-- cmapProps (\{corpusData: {defaultListId}, corpusId: nodeId} ->
-- {defaultListId, nodeId, tabType})
-- (NT.mainNgramsTableSpec (modeTabType mode))
-- where
-- tabType = TabCorpus $ TabNgramType $ modeTabType mode
-- chart Authors = cmapProps (\{corpusId} -> {corpusId, tabType}) pieSpec
-- chart Sources = cmapProps (\{corpusId} -> {corpusId, tabType}) barSpec
-- chart Institutes = cmapProps (\{corpusData: {defaultListId}, corpusId} ->
-- {corpusId, listId: defaultListId, tabType, limit: (Just 1000)})
-- treeSpec
-- chart Terms = cmapProps (\{corpusData: {defaultListId}, corpusId} ->
-- {corpusId, listId: defaultListId, tabType, limit: (Just 1000)})
-- -- TODO limit should be select in the chart by default it is 1000
-- metricsSpec
src/Gargantext/Pages/Texts/Tabs/Types.purs
0 → 100644
View file @
03fbb087
module Gargantext.Pages.Texts.Tabs.Types where
import Data.Argonaut (class DecodeJson, decodeJson, (.?), (.??))
import Data.Maybe (Maybe(..))
--------------------------------------------------------
import Gargantext.Prelude
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.Loader as Loader
newtype CorpusInfo = CorpusInfo { title :: String
, desc :: String
, query :: String
, authors :: String
, chart :: (Maybe (Array Number))
, totalRecords :: Int
}
corpusInfoDefault :: NodePoly CorpusInfo
corpusInfoDefault = NodePoly { id : 0
, typename : 0
, userId : 0
, parentId : 0
, name : "Default name"
, date : " Default date"
, hyperdata : CorpusInfo
{ title : "Default title"
, desc : " Default desc"
, query : " Default Query"
, authors : " Author(s): default"
, chart : Nothing
, totalRecords : 0
}
}
instance decodeCorpusInfo :: DecodeJson CorpusInfo where
decodeJson json = do
obj <- decodeJson json
title <- obj .? "title"
desc <- obj .? "desc"
query <- obj .? "query"
authors <- obj .? "authors"
chart <- obj .?? "chart"
let totalRecords = 47361 -- TODO
pure $ CorpusInfo {title, desc, query, authors, chart, totalRecords}
type CorpusData = {corpusNode :: NodePoly CorpusInfo, defaultListId :: Int}
type PropsRow = ( corpusId :: Int, corpusData :: CorpusData )
type Props = Record PropsRow
-- TODO include Gargantext.Pages.Corpus.Tabs.States
-- TODO include Gargantext.Pages.Corpus.Tabs.Actions
src/Gargantext/Router.purs
View file @
03fbb087
...
...
@@ -24,6 +24,8 @@ data Routes
| CorpusDocument Int Int Int
| PGraphExplorer Int
| Dashboard
| Texts Int
| Lists Int
| Annuaire Int
| UserPage Int
| ContactPage Int
...
...
@@ -39,6 +41,8 @@ routing = oneOf
, Document <$> (route "list" *> int) <*> (lit "document" *> int)
, Dashboard <$ route "dashboard"
, PGraphExplorer <$> (route "graph" *> int)
, Texts <$> (route "texts" *> int)
, Lists <$> (route "lists" *> int)
, Annuaire <$> (route "annuaire" *> int)
, UserPage <$> (route "user" *> int)
, ContactPage <$> (route "contact" *> int)
...
...
@@ -64,4 +68,6 @@ instance showRoutes :: Show Routes where
show (Folder i) = "Folder" <> show i
show Dashboard = "Dashboard"
show (PGraphExplorer i) = "graphExplorer" <> show i
show (Texts i) = "texts" <> show i
show (Lists i) = "lists" <> show i
show Home = "Home"
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