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
1
Merge Requests
1
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
Przemyslaw Kaminski
purescript-gargantext
Commits
b928fd92
Commit
b928fd92
authored
Jul 01, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
routing: corpus document view
parent
76948b36
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
55 additions
and
39 deletions
+55
-39
DocsTable.purs
src/Gargantext/Components/DocsTable.purs
+26
-20
Config.purs
src/Gargantext/Config.purs
+1
-0
Specs.purs
src/Gargantext/Pages/Annuaire/User/Contacts/Tabs/Specs.purs
+3
-1
Document.purs
src/Gargantext/Pages/Corpus/Document.purs
+3
-3
Specs.purs
src/Gargantext/Pages/Corpus/Tabs/Specs.purs
+12
-11
Layout.purs
src/Gargantext/Pages/Layout.purs
+3
-0
Specs.purs
src/Gargantext/Pages/Layout/Specs.purs
+2
-2
Router.purs
src/Gargantext/Router.purs
+5
-2
No files found.
src/Gargantext/Components/DocsTable.purs
View file @
b928fd92
...
@@ -50,6 +50,7 @@ type Props =
...
@@ -50,6 +50,7 @@ type Props =
, chart :: ReactElement
, chart :: ReactElement
, tabType :: TabType
, tabType :: TabType
, listId :: Int
, listId :: Int
, corpusId :: Maybe Int
-- ^ tabType is not ideal here since it is too much entangled with tabs and
-- ^ tabType is not ideal here since it is too much entangled with tabs and
-- ngramtable. Let's see how this evolves.
-- ngramtable. Let's see how this evolves.
}
}
...
@@ -175,7 +176,7 @@ layoutDocview = simpleSpec performAction render
...
@@ -175,7 +176,7 @@ layoutDocview = simpleSpec performAction render
(_documentIdsDeleted <>~ documentIdsToDelete)
(_documentIdsDeleted <>~ documentIdsToDelete)
render :: Render State Props Action
render :: Render State Props Action
render dispatch {nodeId, tabType, listId, totalRecords, chart} deletionState _ =
render dispatch {nodeId, tabType, listId,
corpusId,
totalRecords, chart} deletionState _ =
[ {- br'
[ {- br'
, div [ style {textAlign : "center"}] [ text " Filter "
, div [ style {textAlign : "center"}] [ text " Filter "
, input [className "form-control", style {width : "120px", display : "inline-block"}, placeholder "Filter here"]
, input [className "form-control", style {width : "120px", display : "inline-block"}, placeholder "Filter here"]
...
@@ -188,8 +189,9 @@ layoutDocview = simpleSpec performAction render
...
@@ -188,8 +189,9 @@ layoutDocview = simpleSpec performAction render
[ chart
[ chart
, div [className "col-md-12"]
, div [className "col-md-12"]
[ pageLoader
[ pageLoader
{ path: initialPageParams {nodeId, tabType, listId}
{ path: initialPageParams {nodeId, tabType, listId
, corpusId
}
, listId
, listId
, corpusId
, totalRecords
, totalRecords
, deletionState
, deletionState
, dispatch
, dispatch
...
@@ -210,14 +212,14 @@ layoutDocview = simpleSpec performAction render
...
@@ -210,14 +212,14 @@ layoutDocview = simpleSpec performAction render
mock :: Boolean
mock :: Boolean
mock = false
mock = false
type PageParams = {nodeId :: Int, listId :: Int, tabType :: TabType, params :: T.Params}
type PageParams = {nodeId :: Int, listId :: Int,
corpusId :: Maybe Int,
tabType :: TabType, params :: T.Params}
initialPageParams :: {nodeId :: Int, listId :: Int, tabType :: TabType} -> PageParams
initialPageParams :: {nodeId :: Int, listId :: Int,
corpusId :: Maybe Int,
tabType :: TabType} -> PageParams
initialPageParams {nodeId, listId, tabType} =
initialPageParams {nodeId, listId,
corpusId,
tabType} =
{nodeId, tabType, listId, params: T.initialParams}
{nodeId, tabType, listId,
corpusId,
params: T.initialParams}
loadPage :: PageParams -> Aff (Array DocumentsView)
loadPage :: PageParams -> Aff (Array DocumentsView)
loadPage {nodeId, tabType, listId, params: {limit, offset, orderBy}} = do
loadPage {nodeId, tabType, listId,
corpusId,
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 (Tab tabType offset limit (convOrderBy <$> orderBy)) (Just nodeId)
res <- get $ toUrl Back (Tab tabType offset limit (convOrderBy <$> orderBy)) (Just nodeId)
let docs = res2corpus <$> res
let docs = res2corpus <$> res
...
@@ -253,25 +255,27 @@ type PageLoaderProps row =
...
@@ -253,25 +255,27 @@ type PageLoaderProps row =
, dispatch :: Action -> Effect Unit
, dispatch :: Action -> Effect Unit
, deletionState :: State
, deletionState :: State
, listId :: Int
, listId :: Int
, corpusId :: Maybe Int
| row
| row
}
}
renderPage :: forall props path.
renderPage :: forall props path.
Render (Loader.State {nodeId :: Int, listId :: Int, tabType :: TabType | path} (Array DocumentsView))
Render (Loader.State {nodeId :: Int, listId :: Int,
corpusId :: Maybe Int,
tabType :: TabType | path} (Array DocumentsView))
{ totalRecords :: Int
{ totalRecords :: Int
, dispatch :: Action -> Effect Unit
, dispatch :: Action -> Effect Unit
, deletionState :: State
, deletionState :: State
, listId :: Int
, listId :: Int
, corpusId :: Maybe Int
| props
| props
}
}
(Loader.Action PageParams)
(Loader.Action PageParams)
renderPage _ _ {loaded: Nothing} _ = [] -- TODO loading spinner
renderPage _ _ {loaded: Nothing} _ = [] -- TODO loading spinner
renderPage loaderDispatch { totalRecords, dispatch, listId
renderPage loaderDispatch { totalRecords, dispatch, listId
, corpusId
, deletionState: {documentIdsToDelete, documentIdsDeleted, localFavorites}}
, deletionState: {documentIdsToDelete, documentIdsDeleted, localFavorites}}
{currentPath: {nodeId, tabType}, loaded: Just res} _ =
{currentPath: {nodeId, tabType}, loaded: Just res} _ =
[ T.tableElt
[ T.tableElt
{ rows
{ rows
, setParams: \params -> liftEffect $ loaderDispatch (Loader.SetPath {nodeId, tabType, listId, params})
, setParams: \params -> liftEffect $ loaderDispatch (Loader.SetPath {nodeId, tabType, listId,
corpusId,
params})
, container: T.defaultContainer { title: "Documents" }
, container: T.defaultContainer { title: "Documents" }
, colNames:
, colNames:
T.ColumnName <$>
T.ColumnName <$>
...
@@ -287,38 +291,40 @@ renderPage loaderDispatch { totalRecords, dispatch, listId
...
@@ -287,38 +291,40 @@ renderPage loaderDispatch { totalRecords, dispatch, listId
where
where
gi true = "glyphicon glyphicon-star"
gi true = "glyphicon glyphicon-star"
gi false = "glyphicon glyphicon-star-empty"
gi false = "glyphicon glyphicon-star-empty"
isChecked _id = Set.member _id documentIdsToDelete
toDelete (DocumentsView {_id}) = Set.member _id documentIdsToDelete
toDelete (DocumentsView {_id}) = Set.member _id documentIdsToDelete
isDeleted (DocumentsView {_id}) = Set.member _id documentIdsDeleted
isDeleted (DocumentsView {_id}) = Set.member _id documentIdsDeleted
isFavorite {_id,fav} = maybe fav identity (localFavorites ^. at _id)
isFavorite {_id,fav} = maybe fav identity (localFavorites ^. at _id)
corpusDocument (Just corpusId) = R.CorpusDocument corpusId
corpusDocument _ = R.Document
rows = (\(DocumentsView r) ->
rows = (\(DocumentsView r) ->
let isFav = isFavorite r in
let isFav = isFavorite r
toDel = toDelete $ DocumentsView r in
{ row:
{ row:
[ div []
[ div []
[ a [ className $ gi isFav
[ a [ className $ gi isFav
, if
(toDelete $ DocumentsView r)
then style {textDecoration : "line-through"}
, if
toDel
then style {textDecoration : "line-through"}
else style {textDecoration : "none"}
else style {textDecoration : "none"}
, onClick $ (\_-> dispatch $ MarkFavorites r._id (not isFav))] []
, onClick $ (\_-> dispatch $ MarkFavorites r._id (not isFav))] []
]
]
-- TODO show date: Year-Month-Day only
-- TODO show date: Year-Month-Day only
, if
(toDelete $ DocumentsView r)
then
, if
toDel
then
div [ style {textDecoration : "line-through"}][text (show r.date)]
div [ style {textDecoration : "line-through"}][text (show r.date)]
else
else
div [ ][text (show r.date)]
div [ ][text (show r.date)]
, if
(toDelete $ DocumentsView r)
then
, if
toDel
then
a [ href (toLink $
R.Document
listId r._id)
a [ href (toLink $
(corpusDocument corpusId)
listId r._id)
, style {textDecoration : "line-through"}
, style {textDecoration : "line-through"}
, target "_blank"
, target "_blank"
] [ text r.title ]
] [ text r.title ]
else
else
a [ href (toLink $
R.Document
listId r._id)
a [ href (toLink $
(corpusDocument corpusId)
listId r._id)
, target "_blank" ] [ text r.title ]
, target "_blank" ] [ text r.title ]
, if
(toDelete $ DocumentsView r)
then
, if
toDel
then
div [style {textDecoration : "line-through"}] [ text r.source]
div [style {textDecoration : "line-through"}] [ text r.source]
else
else
div [] [ text r.source]
div [] [ text r.source]
, input [ _type "checkbox"
, input [ _type "checkbox"
, checked
(isChecked r._id)
, checked
toDel
, onClick $ (\_ -> dispatch $ ToggleDocumentToDelete r._id)]
, onClick $ (\_ -> dispatch $ ToggleDocumentToDelete r._id)]
]
]
, delete: true
, delete: true
...
...
src/Gargantext/Config.purs
View file @
b928fd92
...
@@ -210,6 +210,7 @@ routesPath R.SearchView = "search"
...
@@ -210,6 +210,7 @@ routesPath R.SearchView = "search"
routesPath (R.Folder i) = "folder/" <> show i
routesPath (R.Folder i) = "folder/" <> show i
routesPath (R.Corpus i) = "corpus/" <> show i
routesPath (R.Corpus i) = "corpus/" <> show i
routesPath R.AddCorpus = "addCorpus"
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.Document l i) = "list/" <> show l <> "/document/" <> show i
routesPath (R.PGraphExplorer i) = "#/"
routesPath (R.PGraphExplorer i) = "#/"
routesPath R.Dashboard = "dashboard"
routesPath R.Dashboard = "dashboard"
...
...
src/Gargantext/Pages/Annuaire/User/Contacts/Tabs/Specs.purs
View file @
b928fd92
...
@@ -6,6 +6,7 @@ import Prelude hiding (div)
...
@@ -6,6 +6,7 @@ import Prelude hiding (div)
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Generic.Rep.Show (genericShow)
import Data.List (fromFoldable)
import Data.List (fromFoldable)
import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..))
import Data.Tuple (Tuple(..))
import Gargantext.Config (TabType(..), TabSubType(..), PTabNgramType(..))
import Gargantext.Config (TabType(..), TabSubType(..), PTabNgramType(..))
...
@@ -48,7 +49,8 @@ statefulTabs =
...
@@ -48,7 +49,8 @@ statefulTabs =
{ nodeId, chart
{ nodeId, chart
, tabType: TabPairing TabDocs
, tabType: TabPairing TabDocs
, totalRecords: 4736
, totalRecords: 4736
, listId: loaded.defaultListId}) $
, listId: loaded.defaultListId
, corpusId: Nothing}) $
noState DT.docViewSpec
noState DT.docViewSpec
ngramsViewSpec :: {mode :: Mode} -> Spec Tab.State Props Tab.Action
ngramsViewSpec :: {mode :: Mode} -> Spec Tab.State Props Tab.Action
...
...
src/Gargantext/Pages/Corpus/Document.purs
View file @
b928fd92
...
@@ -24,7 +24,7 @@ import Gargantext.Components.Annotation.AnnotatedField as AnnotatedField
...
@@ -24,7 +24,7 @@ import Gargantext.Components.Annotation.AnnotatedField as AnnotatedField
import Gargantext.Types (TermList)
import Gargantext.Types (TermList)
import Gargantext.Utils.Reactix ( scuff )
import Gargantext.Utils.Reactix ( scuff )
type DocPath = { nodeId :: Int, listIds :: Array Int, tabType :: TabType }
type DocPath = { nodeId :: Int, listIds :: Array Int,
corpusId :: Maybe Int,
tabType :: TabType }
type NodeDocument = NodePoly Document
type NodeDocument = NodePoly Document
...
@@ -333,8 +333,8 @@ docViewSpec = simpleSpec performAction render
...
@@ -333,8 +333,8 @@ docViewSpec = simpleSpec performAction render
badge s = span [className "badge badge-default badge-pill"] [text s]
badge s = span [className "badge badge-default badge-pill"] [text s]
NodePoly {hyperdata : Document doc} = document
NodePoly {hyperdata : Document doc} = document
layout :: Spec {} {nodeId :: Int, listId :: Int} Void
layout :: Spec {} {nodeId :: Int, listId :: Int
, corpusId :: Maybe Int
} Void
layout = cmapProps (\{nodeId, listId
} -> {nodeId, listIds: [listId]
, tabType})
layout = cmapProps (\{nodeId, listId
, corpusId} -> {nodeId, listIds: [listId], corpusId
, tabType})
$ simpleSpec defaultPerformAction render
$ simpleSpec defaultPerformAction render
where
where
tabType = TabDocument (TabNgramType CTabTerms)
tabType = TabDocument (TabNgramType CTabTerms)
...
...
src/Gargantext/Pages/Corpus/Tabs/Specs.purs
View file @
b928fd92
...
@@ -8,7 +8,6 @@ import Data.List (fromFoldable)
...
@@ -8,7 +8,6 @@ import Data.List (fromFoldable)
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..))
import Data.Tuple (Tuple(..))
import Gargantext.Config (TabType(..), TabSubType(..))
import Gargantext.Config (CTabNgramType(..), End(..), Path(..), TabSubType(..), TabType(..), toUrl)
import Gargantext.Config (CTabNgramType(..), End(..), Path(..), TabSubType(..), TabType(..), toUrl)
import Gargantext.Pages.Corpus.Tabs.Types (Props)
import Gargantext.Pages.Corpus.Tabs.Types (Props)
...
@@ -59,22 +58,24 @@ statefulTabs =
...
@@ -59,22 +58,24 @@ statefulTabs =
where
where
-- TODO totalRecords
-- TODO totalRecords
docs = noState ( cmapProps (\{path: corpusId} -> {corpusId
: corpusId
, tabType: TabCorpus TabDocs}) histoSpec
docs = noState ( cmapProps (\{path: corpusId} -> {corpusId, tabType: TabCorpus TabDocs}) histoSpec
<>
<>
(cmapProps (\{path: nodeId, loaded
: loaded
} ->
(cmapProps (\{path: nodeId, loaded} ->
{ nodeId
: nodeId
{ nodeId
, chart : div [][]
, chart : div [][]
, tabType: TabCorpus TabDocs
, tabType: TabCorpus TabDocs
, totalRecords: 4737
, totalRecords: 4737
, listId: loaded.defaultListId}) $ noState DT.docViewSpec
, listId: loaded.defaultListId
, corpusId: Just nodeId}) $ noState DT.docViewSpec
)
)
)
)
trash = cmapProps (\{path: nodeId, loaded
: loaded
} ->
trash = cmapProps (\{path: nodeId, loaded} ->
{ nodeId
{ nodeId
, chart: div [][]
, chart: div [][]
, tabType: TabCorpus TabTrash
, tabType: TabCorpus TabTrash
, totalRecords: 4736
, totalRecords: 4736
, listId: loaded.defaultListId}) $ noState DT.docViewSpec
, listId: loaded.defaultListId
, corpusId: Nothing}) $ noState DT.docViewSpec
ngramsViewSpec :: {mode :: Mode} -> Spec Tab.State Props Tab.Action
ngramsViewSpec :: {mode :: Mode} -> Spec Tab.State Props Tab.Action
...
@@ -86,8 +87,8 @@ ngramsViewSpec {mode} =
...
@@ -86,8 +87,8 @@ ngramsViewSpec {mode} =
)
)
where
where
tabType = TabCorpus $ TabNgramType $ modeTabType mode
tabType = TabCorpus $ TabNgramType $ modeTabType mode
chart Authors = cmapProps (\{path: corpusId} -> {corpusId
: corpusId
, tabType}) pieSpec
chart Authors = cmapProps (\{path: corpusId} -> {corpusId, tabType}) pieSpec
chart Sources = cmapProps (\{path: corpusId} -> {corpusId
: corpusId
, tabType}) barSpec
chart Sources = cmapProps (\{path: corpusId} -> {corpusId, tabType}) barSpec
chart Institutes = cmapProps (\{loaded: {defaultListId}, path: corpusId} ->
chart Institutes = cmapProps (\{loaded: {defaultListId}, path: corpusId} ->
{corpusId, listId: defaultListId, tabType, limit: (Just 1000)})
{corpusId, listId: defaultListId, tabType, limit: (Just 1000)})
...
...
src/Gargantext/Pages/Layout.purs
View file @
b928fd92
...
@@ -48,6 +48,9 @@ dispatchAction dispatcher _ (Annuaire id) = do
...
@@ -48,6 +48,9 @@ dispatchAction dispatcher _ (Annuaire id) = do
dispatchAction dispatcher _ (Folder id) = do
dispatchAction dispatcher _ (Folder id) = do
dispatcher $ SetRoute $ Folder id
dispatcher $ SetRoute $ Folder id
dispatchAction dispatcher _ (CorpusDocument c i n) = do
dispatcher $ SetRoute $ CorpusDocument c i n
dispatchAction dispatcher _ (Document i n) = do
dispatchAction dispatcher _ (Document i n) = do
dispatcher $ SetRoute $ Document i n
dispatcher $ SetRoute $ Document i n
...
...
src/Gargantext/Pages/Layout/Specs.purs
View file @
b928fd92
...
@@ -60,7 +60,8 @@ pagesComponent s = case s.currentRoute of
...
@@ -60,7 +60,8 @@ pagesComponent s = case s.currentRoute of
selectSpec (Corpus i) = layout0 $ cmapProps (const {nodeId: i}) $ noState Corpus.layout
selectSpec (Corpus i) = layout0 $ cmapProps (const {nodeId: i}) $ noState Corpus.layout
selectSpec AddCorpus = layout0 $ focus _addCorpusState _addCorpusAction AC.layoutAddcorpus
selectSpec AddCorpus = layout0 $ focus _addCorpusState _addCorpusAction AC.layoutAddcorpus
selectSpec SearchView = layout0 $ focus _searchState _searchAction S.searchSpec
selectSpec SearchView = layout0 $ focus _searchState _searchAction S.searchSpec
selectSpec (Document l i) = layout0 $ cmapProps (const {nodeId: i, listId: l}) $ noState Annotation.layout
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 (PGraphExplorer i)= layout1 $ focus _graphExplorerState _graphExplorerAction GE.specOld
selectSpec Dashboard = layout0 $ noState Dsh.layoutDashboard
selectSpec Dashboard = layout0 $ noState Dsh.layoutDashboard
selectSpec (Annuaire i) = layout0 $ cmapProps (const {annuaireId: i}) $ noState A.layout
selectSpec (Annuaire i) = layout0 $ cmapProps (const {annuaireId: i}) $ noState A.layout
...
@@ -96,7 +97,6 @@ layout0 layout =
...
@@ -96,7 +97,6 @@ layout0 layout =
]
]
ls = over _render \render d p s c -> [
ls = over _render \render d p s c -> [
div [ className "col-md-2", style {paddingTop: "60px"} ] $ render d p s c
div [ className "col-md-2", style {paddingTop: "60px"} ] $ render d p s c
]
]
rs = over _render \render d p s c -> [
rs = over _render \render d p s c -> [
div [ case (s.loginState.authData) of
div [ case (s.loginState.authData) of
...
...
src/Gargantext/Router.purs
View file @
b928fd92
...
@@ -21,6 +21,7 @@ data Routes
...
@@ -21,6 +21,7 @@ data Routes
| Corpus Int
| Corpus Int
| AddCorpus
| AddCorpus
| Document Int Int
| Document Int Int
| CorpusDocument Int Int Int
| PGraphExplorer Int
| PGraphExplorer Int
| Dashboard
| Dashboard
| Annuaire Int
| Annuaire Int
...
@@ -34,6 +35,7 @@ routing = oneOf
...
@@ -34,6 +35,7 @@ routing = oneOf
, AddCorpus <$ route "addCorpus"
, AddCorpus <$ route "addCorpus"
, Folder <$> (route "folder" *> int)
, Folder <$> (route "folder" *> int)
, Corpus <$> (route "corpus" *> int)
, Corpus <$> (route "corpus" *> int)
, CorpusDocument <$> (route "corpus" *> int) <*> (lit "list" *> int) <*> (lit "document" *> int)
, Document <$> (route "list" *> int) <*> (lit "document" *> int)
, Document <$> (route "list" *> int) <*> (lit "document" *> int)
, Dashboard <$ route "dashboard"
, Dashboard <$ route "dashboard"
, PGraphExplorer <$> (route "graph" *> int)
, PGraphExplorer <$> (route "graph" *> int)
...
@@ -55,6 +57,7 @@ instance showRoutes :: Show Routes where
...
@@ -55,6 +57,7 @@ instance showRoutes :: Show Routes where
show SearchView = "Search"
show SearchView = "Search"
show (UserPage i) = "User" <> show i
show (UserPage i) = "User" <> show i
show (ContactPage i) = "Contact" <> show i
show (ContactPage i) = "Contact" <> show i
show (CorpusDocument _ _ i) = "Document" <> show i
show (Document _ i) = "Document" <> show i
show (Document _ i) = "Document" <> show i
show (Corpus i) = "Corpus" <> show i
show (Corpus i) = "Corpus" <> show i
show (Annuaire i) = "Annuaire" <> show i
show (Annuaire i) = "Annuaire" <> show i
...
...
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