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
f8dd0be6
Commit
f8dd0be6
authored
Jan 25, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into dev-markdown
parents
bcd49e56
6ec86879
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
22 deletions
+68
-22
Corpus.purs
src/Gargantext/Components/Nodes/Corpus.purs
+22
-2
Types.purs
src/Gargantext/Components/Nodes/Corpus/Types.purs
+28
-3
Lists.purs
src/Gargantext/Components/Nodes/Lists.purs
+11
-10
Texts.purs
src/Gargantext/Components/Nodes/Texts.purs
+7
-7
No files found.
src/Gargantext/Components/Nodes/Corpus.purs
View file @
f8dd0be6
...
@@ -333,8 +333,9 @@ loadCorpus :: Record LoadProps -> Aff CorpusData
...
@@ -333,8 +333,9 @@ loadCorpus :: Record LoadProps -> Aff CorpusData
loadCorpus {nodeId, session} = do
loadCorpus {nodeId, session} = do
-- fetch corpus via lists parentId
-- fetch corpus via lists parentId
(NodePoly {parentId: corpusId} :: NodePoly {}) <- get session nodePolyRoute
(NodePoly {parentId: corpusId} :: NodePoly {}) <- get session nodePolyRoute
corpusNode <- get session $ corpusNodeRoute corpusId ""
corpusNode <- get session $ corpusNodeRoute corpusId ""
defaultListIds <- (get session $ defaultListIdsRoute corpusId) :: forall a. DecodeJson a => AffTableResult (NodePoly a)
defaultListIds <- (get session $ defaultListIdsRoute corpusId)
:: forall a. DecodeJson a => AffTableResult (NodePoly a)
case (A.head defaultListIds.docs :: Maybe (NodePoly HyperdataList)) of
case (A.head defaultListIds.docs :: Maybe (NodePoly HyperdataList)) of
Just (NodePoly { id: defaultListId }) ->
Just (NodePoly { id: defaultListId }) ->
pure {corpusId, corpusNode, defaultListId}
pure {corpusId, corpusNode, defaultListId}
...
@@ -344,3 +345,22 @@ loadCorpus {nodeId, session} = do
...
@@ -344,3 +345,22 @@ loadCorpus {nodeId, session} = do
nodePolyRoute = NodeAPI Corpus (Just nodeId) ""
nodePolyRoute = NodeAPI Corpus (Just nodeId) ""
corpusNodeRoute = NodeAPI Corpus <<< Just
corpusNodeRoute = NodeAPI Corpus <<< Just
defaultListIdsRoute = Children NodeList 0 1 Nothing <<< Just
defaultListIdsRoute = Children NodeList 0 1 Nothing <<< Just
loadCorpusWithChild :: Record LoadProps -> Aff CorpusData
loadCorpusWithChild {nodeId:childId, session} = do
-- fetch corpus via lists parentId
(NodePoly {parentId: corpusId} :: NodePoly {}) <- get session $ listNodeRoute childId ""
corpusNode <- get session $ corpusNodeRoute corpusId ""
defaultListIds <- (get session $ defaultListIdsRoute corpusId)
:: forall a. DecodeJson a => AffTableResult (NodePoly a)
case (A.head defaultListIds.docs :: Maybe (NodePoly HyperdataList)) of
Just (NodePoly { id: defaultListId }) ->
pure {corpusId, corpusNode, defaultListId}
Nothing ->
throwError $ error "Missing default list"
where
corpusNodeRoute = NodeAPI Corpus <<< Just
listNodeRoute = NodeAPI Node <<< Just
defaultListIdsRoute = Children NodeList 0 1 Nothing <<< Just
src/Gargantext/Components/Nodes/Corpus/Types.purs
View file @
f8dd0be6
module Gargantext.Components.Nodes.Corpus.Types where
module Gargantext.Components.Nodes.Corpus.Types where
import Data.Maybe (Maybe(..))
import Data.Array (head)
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, (.:), (.:?), (:=), (~>), jsonEmptyObject)
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, (.:), (.:?), (:=), (~>), jsonEmptyObject)
import Data.Either (Either(..))
import Data.Either (Either(..))
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep (class Generic)
...
@@ -63,6 +65,29 @@ data FieldType =
...
@@ -63,6 +65,29 @@ data FieldType =
tag :: Tag
tag :: Tag
, text :: MarkdownText
, text :: MarkdownText
}
}
isJSON :: FieldType -> Boolean
isJSON (JSON _) = true
isJSON _ = false
getCorpusInfo :: Array (Field FieldType) -> CorpusInfo
getCorpusInfo as = case head as of
Just (Field {typ: JSON {authors, desc,query,title}}) -> CorpusInfo { title
, desc
, query
, authors
, chart:Nothing
, totalRecords:0
}
_ -> CorpusInfo { title:"Empty"
, desc:""
, query:""
, authors:""
, chart:Nothing
, totalRecords:0
}
derive instance genericFieldType :: Generic FieldType _
derive instance genericFieldType :: Generic FieldType _
instance eqFieldType :: Eq FieldType where
instance eqFieldType :: Eq FieldType where
eq = genericEq
eq = genericEq
...
@@ -99,8 +124,8 @@ instance encodeFTField :: EncodeJson (Field FieldType) where
...
@@ -99,8 +124,8 @@ instance encodeFTField :: EncodeJson (Field FieldType) where
~> "type" := typ' typ
~> "type" := typ' typ
~> jsonEmptyObject
~> jsonEmptyObject
where
where
typ' (Haskell _) = "Haskell"
typ' (Haskell _)
= "Haskell"
typ' (JSON _) = "JSON"
typ' (JSON _)
= "JSON"
typ' (Markdown _) = "Markdown"
typ' (Markdown _) = "Markdown"
instance encodeFieldType :: EncodeJson FieldType where
instance encodeFieldType :: EncodeJson FieldType where
encodeJson (Haskell {haskell}) =
encodeJson (Haskell {haskell}) =
...
@@ -170,5 +195,5 @@ instance decodeCorpusInfo :: DecodeJson CorpusInfo where
...
@@ -170,5 +195,5 @@ instance decodeCorpusInfo :: DecodeJson CorpusInfo where
pure $ CorpusInfo {title, desc, query, authors, chart, totalRecords}
pure $ CorpusInfo {title, desc, query, authors, chart, totalRecords}
type CorpusData = { corpusId :: Int
type CorpusData = { corpusId :: Int
, corpusNode :: NodePoly CorpusInfo
, corpusNode :: NodePoly
Hyperdata --
CorpusInfo
, defaultListId :: Int}
, defaultListId :: Int}
src/Gargantext/Components/Nodes/Lists.purs
View file @
f8dd0be6
module Gargantext.Components.Nodes.Lists where
module Gargantext.Components.Nodes.Lists where
import Reactix as R
import Reactix as R
--------------------------------------------------------
------------------------------------------------------------------------
import Gargantext.Prelude
import Gargantext.Components.Nodes.Corpus (loadCorpus)
import Gargantext.Components.Nodes.Corpus.Types (CorpusInfo(..))
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.Nodes.Corpus (loadCorpusWithChild)
import Gargantext.Components.Nodes.Corpus.Types (getCorpusInfo, CorpusInfo(..), Hyperdata(..))
import Gargantext.Components.Nodes.Lists.Tabs as Tabs
import Gargantext.Components.Table as Table
import Gargantext.Components.Table as Table
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.
Components.Nodes.Lists.Tabs as Tabs
import Gargantext.
Prelude
import Gargantext.Sessions (Session)
import Gargantext.Sessions (Session)
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
type Props = ( session :: Session, nodeId :: Int )
type Props = ( session :: Session, nodeId :: Int )
...
@@ -22,12 +22,13 @@ listsLayoutCpt :: R.Component Props
...
@@ -22,12 +22,13 @@ listsLayoutCpt :: R.Component Props
listsLayoutCpt = R.hooksComponent "G.P.Lists.listsLayout" cpt
listsLayoutCpt = R.hooksComponent "G.P.Lists.listsLayout" cpt
where
where
cpt path@{session} _ =
cpt path@{session} _ =
useLoader path loadCorpus $
useLoader path loadCorpus
WithChild
$
\corpusData@{corpusId, defaultListId, corpusNode: NodePoly poly} ->
\corpusData@{corpusId, defaultListId, corpusNode: NodePoly poly} ->
let { name, date, hyperdata: CorpusInfo corpus } = poly
let { name, date, hyperdata : Hyperdata h} = poly
{ desc, query, authors: user } = corpus in
CorpusInfo {desc,query,authors} = getCorpusInfo h.fields
in
R.fragment
R.fragment
[ Table.tableHeaderLayout
[ Table.tableHeaderLayout
{ title: "Corpus " <> name, desc, query, user, date }
{ title: "Corpus " <> name, desc, query, user
:authors
, date }
, Tabs.tabs {session, corpusId, corpusData}]
, Tabs.tabs {session, corpusId, corpusData}]
------------------------------------------------------------------------
------------------------------------------------------------------------
src/Gargantext/Components/Nodes/Texts.purs
View file @
f8dd0be6
...
@@ -7,19 +7,19 @@ import Data.Maybe (Maybe(..))
...
@@ -7,19 +7,19 @@ import Data.Maybe (Maybe(..))
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
--------------------------------------------------------
--------------------------------------------------------
import Gargantext.Components.DocsTable as DT
import Gargantext.Components.DocsTable as DT
import Gargantext.Components.Loader (loader)
import Gargantext.Components.Loader (loader)
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.Nodes.Corpus (loadCorpus)
import Gargantext.Components.Nodes.Corpus (loadCorpusWithChild)
import Gargantext.Components.Nodes.Corpus.Types (CorpusData, CorpusInfo(..))
import Gargantext.Components.Nodes.Corpus.Chart.Histo (histo)
import Gargantext.Components.Nodes.Corpus.Chart.Histo (histo)
import Gargantext.Components.Nodes.Corpus.Types (CorpusData, Hyperdata(..), getCorpusInfo, CorpusInfo(..))
import Gargantext.Components.Tab as Tab
import Gargantext.Components.Tab as Tab
import Gargantext.Components.Table as Table
import Gargantext.Components.Table as Table
import Gargantext.Ends (Frontends)
import Gargantext.Ends (Frontends)
import Gargantext.Sessions (Session)
import Gargantext.Sessions (Session)
import Gargantext.Types (CTabNgramType(..), TabSubType(..), TabType(..))
import Gargantext.Types (CTabNgramType(..), TabSubType(..), TabType(..))
--------------------------------------------------------
type Props = ( frontends :: Frontends, session :: Session, nodeId :: Int )
type Props = ( frontends :: Frontends, session :: Session, nodeId :: Int )
...
@@ -30,16 +30,16 @@ textsLayout props = R.createElement textsLayoutCpt props []
...
@@ -30,16 +30,16 @@ textsLayout props = R.createElement textsLayoutCpt props []
textsLayoutCpt :: R.Component Props
textsLayoutCpt :: R.Component Props
textsLayoutCpt = R.hooksComponent "G.C.Nodes.Texts.textsLayout" cpt where
textsLayoutCpt = R.hooksComponent "G.C.Nodes.Texts.textsLayout" cpt where
cpt {session,nodeId,frontends} _ = do
cpt {session,nodeId,frontends} _ = do
pure $ loader {session, nodeId} loadCorpus paint
pure $ loader {session, nodeId} loadCorpus
WithChild
paint
where
where
paint corpusData@{corpusId, corpusNode, defaultListId} =
paint corpusData@{corpusId, corpusNode, defaultListId} =
R.fragment [ Table.tableHeaderLayout headerProps, tabs' ]
R.fragment [ Table.tableHeaderLayout headerProps, tabs' ]
where
where
NodePoly { name, date, hyperdata:
CorpusInfo corpus
} = corpusNode
NodePoly { name, date, hyperdata:
Hyperdata h
} = corpusNode
{desc, query, authors: user} = corpu
s
CorpusInfo {desc,query,authors} = getCorpusInfo h.field
s
tabs' = tabs {session, corpusId, corpusData, frontends}
tabs' = tabs {session, corpusId, corpusData, frontends}
title = "Corpus " <> name
title = "Corpus " <> name
headerProps = { title, desc, query, date, user }
headerProps = { title, desc, query, date, user
:authors
}
data Mode = MoreLikeFav | MoreLikeTrash
data Mode = MoreLikeFav | MoreLikeTrash
...
...
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