Commit 8e0b5f8d authored by Alexandre Delanoë's avatar Alexandre Delanoë

[READING+FEAT] Forest in Graph Explorer.

parent b7e624dc
......@@ -43,10 +43,12 @@ appCpt = R.hooksComponent "G.C.App.app" cpt where
cpt _ _ = do
sessions <- useSessions
route <- useHashRouter router Home
showLogin <- R.useState' false
showCorpus <- R.useState' false
let tree = forestLayout frontends (fst sessions) (fst route) (snd showLogin)
let mCurrentRoute = Just $ fst route
let mCurrentRoute = fst route
let backends = fromFoldable defaultBackends
pure $ case fst showLogin of
true -> tree $ login { sessions, backends, visible: showLogin }
......@@ -61,8 +63,8 @@ appCpt = R.hooksComponent "G.C.App.app" cpt where
Corpus nodeId -> tree $ corpusLayout { nodeId }
Texts nodeId -> tree $ textsLayout { nodeId, session }
Lists nodeId -> tree $ listsLayout { nodeId, session }
Dashboard -> tree $ dashboardLayout {}
Annuaire annuaireId -> tree $ annuaireLayout { annuaireId, session }
Dashboard _nodeId -> tree $ dashboardLayout {}
Annuaire nodeId -> tree $ annuaireLayout { nodeId, session }
UserPage nodeId -> tree $ userLayout { nodeId, session }
ContactPage nodeId -> tree $ userLayout { nodeId, session }
CorpusDocument corpusId listId nodeId ->
......@@ -71,7 +73,7 @@ appCpt = R.hooksComponent "G.C.App.app" cpt where
tree $ documentLayout { nodeId, listId, session, corpusId: Nothing }
PGraphExplorer graphId ->
simpleLayout (fst sessions) $
explorerLayout { graphId, mCurrentRoute, session, treeId: Nothing, frontends }
explorerLayout { graphId, mCurrentRoute, session, treeId: Nothing, frontends}
forestLayout :: Frontends -> Sessions -> AppRoute -> R2.Setter Boolean -> R.Element -> R.Element
forestLayout frontends sessions route showLogin child =
......@@ -82,7 +84,8 @@ forestLayout frontends sessions route showLogin child =
R.fragment
[ H.div {className: "col-md-2", style: {paddingTop: "60px"}}
[ forest {sessions, route, frontends, showLogin} ]
, mainPage child ]
, mainPage child
]
-- Simple layout does not accommodate the tree
simpleLayout :: Sessions -> R.Element -> R.Element
......
module Gargantext.Components.Forest where
import Prelude (const, show, discard)
import Prelude (const, show)
import Data.Maybe (Maybe(..))
import DOM.Simple.Console (log)
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Ends (Frontends)
......@@ -31,7 +30,11 @@ forestCpt = R.staticComponent "G.C.Forest.forest" cpt where
Just s@(Session {treeId}) ->
R.fragment
[ H.text (show s)
, treeView { root: treeId, frontends, mCurrentRoute: Just route, session: s } ]
, treeView { root: treeId
, frontends
, mCurrentRoute: Just route
, session: s }
]
plus :: R2.Setter Boolean -> R.Element
plus showLogin = H.button {on: {click}} [ H.text "+" ]
......
......@@ -7,7 +7,7 @@ import Data.Foldable (foldMap)
import Data.Int (toNumber)
import Data.Maybe (Maybe(..))
import Data.Sequence as Seq
import Data.Tuple (fst)
import Data.Tuple (fst,snd)
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff)
import Reactix as R
......@@ -21,25 +21,27 @@ import Gargantext.Components.GraphExplorer.Sidebar as Sidebar
import Gargantext.Components.GraphExplorer.ToggleButton as Toggle
import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Components.Graph as Graph
import Gargantext.Components.Tree as Tree
import Gargantext.Components.Forest (forest)
import Gargantext.Config.REST (get)
import Gargantext.Ends (Frontends, url)
import Gargantext.Routes (SessionRoute(NodeAPI), AppRoute)
import Gargantext.Sessions (Session)
import Gargantext.Sessions (Session, Sessions(..))
import Gargantext.Types (NodeType(Graph))
type GraphId = Int
type LayoutProps =
( graphId :: GraphId
, mCurrentRoute :: Maybe AppRoute
, mCurrentRoute :: AppRoute
, treeId :: Maybe Int
, session :: Session
, frontends :: Frontends )
, frontends :: Frontends
)
type Props = ( graph :: Maybe Graph.Graph | LayoutProps )
--------------------------------------------------------------
explorerLayout :: Record LayoutProps -> R.Element
explorerLayout props = R.createElement explorerLayoutCpt props []
......@@ -52,6 +54,7 @@ explorerLayoutCpt = R.hooksComponent "G.C.GraphExplorer.explorerLayout" cpt
handler loaded = explorer {graphId, mCurrentRoute, treeId, session, graph, frontends}
where graph = Just (convert loaded)
--------------------------------------------------------------
explorer :: Record Props -> R.Element
explorer props = R.createElement explorerCpt props []
......@@ -61,13 +64,12 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
cpt {session, graphId, mCurrentRoute, treeId, graph, frontends} _ = do
controls <- Controls.useGraphControls
state <- useExplorerState
showLogin <- snd <$> R.useState' true
pure $
RH.div
{ id: "graph-explorer" }
[
row
[
outer
[ row
[ outer
[ inner
[ row1
[ col [ pullLeft [ Toggle.treeToggleButton controls.showTree ] ]
......@@ -75,7 +77,7 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
, col [ pullRight [ Toggle.sidebarToggleButton controls.showSidePanel ] ]
]
, row [ Controls.controls controls ]
, row [ tree {mCurrentRoute, treeId} controls
, row [ tree {mCurrentRoute, treeId} controls showLogin
, mGraph controls.sigmaRef {graphId, graph}
, Sidebar.sidebar {showSidePanel: fst controls.showSidePanel} ]
, row [ ]
......@@ -84,11 +86,11 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
]
]
where
tree {treeId: Nothing} _ = RH.div { id: "tree" } []
tree _ {showTree: false /\ _} = RH.div { id: "tree" } []
tree {mCurrentRoute: m, treeId: Just root} _ =
RH.div { id: "tree", className: "col-md-2" }
[ Tree.treeView {frontends, root, mCurrentRoute: m, session: session} ]
-- tree {treeId: Nothing} _ _ = RH.div { id: "tree" } []
tree _ {showTree: false /\ _} _ = RH.div { id: "tree" } []
tree {mCurrentRoute: m, treeId: root} _ showLogin=
RH.div {className: "col-md-2", style: {paddingTop: "60px"}}
[forest {sessions: Sessions (Just session), route:m, frontends, showLogin}]
outer = RH.div { className: "col-md-12" }
inner = RH.div { className: "container-fluid", style: { paddingTop: "90px" } }
row1 = RH.div { className: "row", style: { paddingBottom: "10px", marginTop: "-24px" } }
......
......@@ -107,8 +107,7 @@ useGraphControls = do
showTree <- R.useState' false
sigmaRef <- R2.nothingRef
pure {
cursorSize
pure { cursorSize
, multiNodeSelect
, showControls
, showSidePanel
......@@ -138,7 +137,7 @@ setShowSidePanel :: Record Controls -> Boolean -> Effect Unit
setShowSidePanel { showSidePanel: ( _ /\ set ) } v = set $ const v
setShowTree :: Record Controls -> Boolean -> Effect Unit
setShowTree { showTree: ( _ /\ set ) } v = set $ const v
setShowTree { showTree: ( _ /\ set ) } v = set $ not <<< const v
setCursorSize :: Record Controls -> Number -> Effect Unit
setCursorSize { cursorSize: ( _ /\ setSize ) } v = setSize $ const v
......
......@@ -7,7 +7,7 @@ Maintainer : alexandre.delanoe@iscpif.fr
Stability : experimental
Portability : POSIX
How semantic emerge from contextualized randomness can be experimented
How semantic emerges from contextualized randomness can be experimented
with these simple functions;
randomSentences: randomizes sentences in a paragraph.
......
......@@ -44,13 +44,17 @@ type Reload = Int
data NodePopup = CreatePopup | NodePopup
type Props = ( root :: ID, mCurrentRoute :: Maybe AppRoute, session :: Session, frontends :: Frontends )
type Props = ( root :: ID
, mCurrentRoute :: Maybe AppRoute
, session :: Session
, frontends :: Frontends
)
type TreeViewProps =
( tree :: FTree
type TreeViewProps = ( tree :: FTree
, mCurrentRoute :: Maybe AppRoute
, frontends :: Frontends
, session :: Session )
, session :: Session
)
data NTree a = NTree a (Array (NTree a))
......@@ -203,7 +207,8 @@ type NodeMainSpanProps =
( id :: ID
, name :: Name
, nodeType :: NodeType
, mCurrentRoute :: Maybe AppRoute)
, mCurrentRoute :: Maybe AppRoute
)
nodeMainSpan :: (Action -> Aff Unit)
-> Record NodeMainSpanProps
......@@ -270,10 +275,14 @@ nodeMainSpan d p folderOpen session frontends = R.createElement el p []
fldr :: Boolean -> String
fldr open = if open then "glyphicon glyphicon-folder-open" else "glyphicon glyphicon-folder-close"
childNodes :: Session -> Frontends -> R.State Reload -> R.State Boolean -> Maybe AppRoute -> Array FTree -> Array R.Element
fldr open = if open
then "glyphicon glyphicon-folder-open"
else "glyphicon glyphicon-folder-close"
childNodes :: Session -> Frontends
-> R.State Reload -> R.State Boolean
-> Maybe AppRoute -> Array FTree
-> Array R.Element
childNodes _ _ _ _ _ [] = []
childNodes _ _ _ (false /\ _) _ _ = []
childNodes session frontends reload (true /\ _) mCurrentRoute ary = map (\ctree -> childNode {tree: ctree}) ary
......
......@@ -5,21 +5,21 @@ import Gargantext.Ends
import Gargantext.Types (ApiVersion(..))
defaultBackends :: NonEmpty Array Backend
defaultBackends = prod :| [dev, demo, local]
defaultBackends = local :| [dev, demo]
where
prod = backend V10 "/api/" "https://gargantext.org" "gargantext.org"
-- prod = backend V10 "/api/" "https://gargantext.org" "gargantext.org"
dev = backend V10 "/api/" "https://dev.gargantext.org" "dev.gargantext.org"
demo = backend V10 "/api/" "https://demo.gargantext.org" "demo.gargantext.org"
local = backend V10 "/api/" "http://localhost:8008" "localhost"
defaultApps :: NonEmpty Array Frontend
defaultApps = relative :| [prod, dev, demo, haskell, caddy]
defaultApps = relative :| [dev, demo, haskell, caddy]
where
relative = frontend "/#/" "" "Relative"
prod = frontend "/#/" "https://gargantext.org" "gargantext.org"
-- prod = frontend "/#/" "https://gargantext.org" "gargantext.org"
dev = frontend "/#/" "https://dev.gargantext.org" "gargantext.org (dev)"
demo = frontend "/#/" "https://demo.gargantext.org" "gargantext.org (demo)"
haskell = frontend "/#/" "http://localhost:8008" "localhost.gargantext)"
haskell = frontend "/#/" "http://localhost:8008" "localhost.gargantext"
python = frontend "/#/" "http://localhost:8000" "localhost.python"
caddy = frontend "/#/" "http://localhost:2015" "localhost.caddy"
......
......@@ -10,7 +10,8 @@ import Reactix as R
import Gargantext.Utils.Reactix as R2
import Gargantext.Components.LoadingSpinner (loadingSpinner)
useAff :: forall st. Aff st -> R.Hooks (Maybe st)
useAff :: forall st.
Aff st -> R.Hooks (Maybe st)
useAff loader = do
(loaded /\ setLoaded) <- R.useState' Nothing
R.useEffect1 loader $ do
......@@ -20,36 +21,44 @@ useAff loader = do
else pure R.nothing
pure loaded
useLoader :: forall path st. path -> (path -> Aff st) -> (st -> R.Element) -> R.Hooks R.Element
useLoader :: forall path st.
path -> (path -> Aff st) -> (st -> R.Element) -> R.Hooks R.Element
useLoader path loader render
= maybe' (\_ -> loadingSpinner {}) render
<$> (useAff =<< R.useMemo2 path loader (\_ -> loader path))
useLoader2 :: forall path st. R.State path -> (path -> Aff st) -> (st -> R.Element) -> R.Hooks R.Element
useLoader2 :: forall path st.
R.State path -> (path -> Aff st)
-> (st -> R.Element) -> R.Hooks R.Element
useLoader2 path loader render = do
state <- R.useState' Nothing
useLoaderEffect2 path state loader
pure $ maybe (loadingSpinner {}) render (fst state)
useLoaderEffect :: forall state. Aff state -> R.State (Maybe state) -> R.Hooks Unit
useLoaderEffect :: forall state.
Aff state -> R.State (Maybe state) -> R.Hooks Unit
useLoaderEffect loader (state /\ setState) = do
R.useEffect2 state loader $ do
if isNothing state then
R2.affEffect "G.H.Loader.useLoader" $ loader >>= (liftEffect <<< setState <<< const <<< Just)
else pure R.nothing
useLoaderEffect' :: forall state. Aff state -> R.Hooks (R.State (Maybe state))
useLoaderEffect' :: forall state.
Aff state -> R.Hooks (R.State (Maybe state))
useLoaderEffect' aff = do
state <- R.useState' Nothing
useLoaderEffect aff state
pure state
useLoaderEffect2 :: forall st path. R.State path -> R.State (Maybe st) -> (path -> Aff st) -> R.Hooks Unit
useLoaderEffect2 :: forall st path.
R.State path -> R.State (Maybe st)
-> (path -> Aff st) -> R.Hooks Unit
useLoaderEffect2 path state loader = do
aff <- useRepointer path loader
useLoaderEffect aff state
useRepointer :: forall path st. R.State path -> (path -> Aff st) -> R.Hooks (Aff st)
useRepointer :: forall path st.
R.State path -> (path -> Aff st) -> R.Hooks (Aff st)
useRepointer path@(path' /\ _) loader = R.useMemo2 loader path' (\_ -> loader path')
module Gargantext.Pages.Annuaire where
import Prelude (bind, const, identity, pure, ($), (<$>), (<>))
import Data.Argonaut (class DecodeJson, decodeJson, (.:), (.??))
import Data.Argonaut (class DecodeJson, decodeJson, (.:), (.:?))
import Data.Array (head)
import Data.Maybe (Maybe(..), maybe)
import Data.Tuple (fst, snd)
......@@ -29,7 +29,7 @@ toRows (AnnuaireTable a) = a.annuaireTable
-- | Top level layout component. Loads an annuaire by id and renders
-- | the annuaire using the result
type LayoutProps = ( annuaireId :: Int, session :: Session )
type LayoutProps = ( nodeId :: Int, session :: Session )
annuaireLayout :: Record LayoutProps -> R.Element
annuaireLayout props = R.createElement annuaireLayoutCpt props []
......@@ -37,8 +37,8 @@ annuaireLayout props = R.createElement annuaireLayoutCpt props []
annuaireLayoutCpt :: R.Component LayoutProps
annuaireLayoutCpt = R.hooksComponent "G.P.Annuaire.annuaireLayout" cpt
where
cpt {annuaireId, session} _ = do
path <- R.useState' annuaireId
cpt {nodeId, session} _ = do
path <- R.useState' nodeId
useLoader (fst path) (getAnnuaireInfo session) $
\info -> annuaire {session, path, info}
......@@ -138,8 +138,8 @@ data HyperdataAnnuaire = HyperdataAnnuaire
instance decodeHyperdataAnnuaire :: DecodeJson HyperdataAnnuaire where
decodeJson json = do
obj <- decodeJson json
title <- obj .?? "title"
desc <- obj .?? "desc"
title <- obj .:? "title"
desc <- obj .:? "desc"
pure $ HyperdataAnnuaire { title, desc }
------------------------------------------------------------------------------
......
module Gargantext.Pages.Corpus.Document where
import Prelude (class Show, bind, identity, mempty, pure, ($), (<<<))
import Data.Argonaut (class DecodeJson, decodeJson, (.:), (.??))
import Data.Argonaut (class DecodeJson, decodeJson, (.:), (.:?))
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..), maybe)
......@@ -203,7 +203,7 @@ instance decodeDocumentV3 :: DecodeJson DocumentV3
where
decodeJson json = do
obj <- decodeJson json
abstract <- obj .?? "abstract"
abstract <- obj .:? "abstract"
authors <- obj .: "authors"
--error <- obj .: "error"
language_iso2 <- obj .: "language_iso2"
......@@ -243,23 +243,23 @@ instance decodeDocument :: DecodeJson Document
where
decodeJson json = do
obj <- decodeJson json
abstract <- obj .?? "abstract"
authors <- obj .?? "authors"
bdd <- obj .?? "bdd"
doi <- obj .?? "doi"
language_iso2 <- obj .?? "language_iso2"
-- page <- obj .?? "page"
publication_date <- obj .?? "publication_date"
--publication_second <- obj .?? "publication_second"
--publication_minute <- obj .?? "publication_minute"
--publication_hour <- obj .?? "publication_hour"
publication_day <- obj .?? "publication_day"
publication_month <- obj .?? "publication_month"
publication_year <- obj .?? "publication_year"
source <- obj .?? "sources"
institutes <- obj .?? "institutes"
title <- obj .?? "title"
uniqId <- obj .?? "uniqId"
abstract <- obj .:? "abstract"
authors <- obj .:? "authors"
bdd <- obj .:? "bdd"
doi <- obj .:? "doi"
language_iso2 <- obj .:? "language_iso2"
-- page <- obj .:? "page"
publication_date <- obj .:? "publication_date"
--publication_second <- obj .:? "publication_second"
--publication_minute <- obj .:? "publication_minute"
--publication_hour <- obj .:? "publication_hour"
publication_day <- obj .:? "publication_day"
publication_month <- obj .:? "publication_month"
publication_year <- obj .:? "publication_year"
source <- obj .:? "sources"
institutes <- obj .:? "institutes"
title <- obj .:? "title"
uniqId <- obj .:? "uniqId"
--url <- obj .: "url"
--text <- obj .: "text"
pure $ Document { abstract
......
......@@ -8,7 +8,8 @@ import Reactix.DOM.HTML as H
import Routing.Hash (setHash)
import Gargantext.Components.Lang.Landing.EnUS as En
import Gargantext.Components.Lang.Landing.FrFR as Fr
import Gargantext.Components.Data.Landing (BlockText(..), BlockTexts(..), Button(..), LandingData(..))
import Gargantext.Components.Data.Landing
(BlockText(..), BlockTexts(..), Button(..), LandingData(..))
import Gargantext.Components.Data.Lang (Lang(..))
type Props = ()
......
......@@ -30,7 +30,7 @@ textsLayout props = R.createElement textsLayoutCpt props []
textsLayoutCpt :: R.Component Props
textsLayoutCpt = R.hooksComponent "TextsLoader" cpt
where
cpt {nodeId,session} _ =
cpt {session,nodeId} _ =
useLoader nodeId (getCorpus session) $
\corpusData@{corpusId, corpusNode, defaultListId} ->
let
......
......@@ -10,10 +10,13 @@ router :: Match AppRoute
router = oneOf
[ Login <$ route "login"
, Folder <$> (route "folder" *> int)
, CorpusDocument <$> (route "corpus" *> int) <*> (lit "list" *> int) <*> (lit "document" *> int)
, CorpusDocument <$> (route "corpus" *> int)
<*> (lit "list" *> int)
<*> (lit "document" *> int)
, Corpus <$> (route "corpus" *> int)
, Document <$> (route "list" *> int) <*> (lit "document" *> int)
, Dashboard <$ route "dashboard"
, Document <$> (route "list" *> int)
<*> (lit "document" *> int)
, Dashboard <$> (route "dashboard" *> int)
, PGraphExplorer <$> (route "graph" *> int)
, Texts <$> (route "texts" *> int)
, Lists <$> (route "lists" *> int)
......
......@@ -12,7 +12,7 @@ data AppRoute
| Document Int Int
| CorpusDocument Int Int Int
| PGraphExplorer Int
| Dashboard
| Dashboard Int
| Texts Int
| Lists Int
| Annuaire Int
......@@ -39,7 +39,7 @@ instance showAppRoute :: Show AppRoute where
show (Document _ i) = "Document" <> show i
show (CorpusDocument _ _ i) = "Document" <> show i
show (PGraphExplorer i) = "graphExplorer" <> show i
show Dashboard = "Dashboard"
show (Dashboard i) = "Dashboard" <> show i
show (Texts i) = "texts" <> show i
show (Lists i) = "lists" <> show i
show (Annuaire i) = "Annuaire" <> show i
......@@ -53,7 +53,7 @@ appPath (Folder i) = "folder/" <> show i
appPath (CorpusDocument c l i) = "corpus/" <> show c <> "/list/" <> show l <> "/document/" <> show i
appPath (Corpus i) = "corpus/" <> show i
appPath (Document l i) = "list/" <> show l <> "/document/" <> show i
appPath Dashboard = "dashboard"
appPath (Dashboard i) = "dashboard/" <> show i
appPath (PGraphExplorer i) = "graph/" <> show i
appPath (Texts i) = "texts/" <> show i
appPath (Lists i) = "lists/" <> show i
......
module Gargantext.Components.NgramsTable.Spec where
import Prelude
import Gargantext.Config (CTabNgramType(..))
import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..))
import Gargantext.Components.NgramsTable.Core (highlightNgrams, NgramsElement(..), NgramsTable(..))
import Gargantext.Config (CTabNgramType(..))
import Gargantext.Types (TermList(..))
import Test.Spec (Spec, describe, it)
import Test.Spec.Assertions (shouldEqual)
......@@ -13,6 +11,7 @@ import Test.Spec.Assertions (shouldEqual)
import Data.Map as Map
import Data.Set as Set
{-
spec :: Spec Unit
spec = do
let ne ngrams list =
......@@ -93,3 +92,4 @@ spec = do
,Tuple ", after" Nothing
]
highlightNgrams CTabTerms table input `shouldEqual` output
-}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment