Commit cd5c85f2 authored by James Laver's avatar James Laver

for seeg

parent 7ee27ee6
...@@ -4,6 +4,7 @@ import Data.Set as Set ...@@ -4,6 +4,7 @@ import Data.Set as Set
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Toestand as T import Toestand as T
import Gargantext.Ends (Backend)
import Gargantext.Sessions as Sessions import Gargantext.Sessions as Sessions
import Gargantext.Sessions (OpenNodes, Sessions) import Gargantext.Sessions (OpenNodes, Sessions)
import Gargantext.Routes (AppRoute(Home)) import Gargantext.Routes (AppRoute(Home))
...@@ -11,7 +12,8 @@ import Gargantext.Types (Handed(RightHanded)) ...@@ -11,7 +12,8 @@ import Gargantext.Types (Handed(RightHanded))
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
type App = type App =
{ handed :: Handed { backend :: Maybe Backend
, handed :: Handed
, forestOpen :: OpenNodes , forestOpen :: OpenNodes
, reloadRoot :: Int , reloadRoot :: Int
, reloadForest :: Int , reloadForest :: Int
...@@ -23,7 +25,8 @@ type App = ...@@ -23,7 +25,8 @@ type App =
emptyApp :: App emptyApp :: App
emptyApp = emptyApp =
{ handed: RightHanded { backend: Nothing
, handed: RightHanded
, route: Home , route: Home
, forestOpen: Set.empty , forestOpen: Set.empty
, reloadRoot: T2.newReload , reloadRoot: T2.newReload
...@@ -34,7 +37,8 @@ emptyApp = ...@@ -34,7 +37,8 @@ emptyApp =
} }
type Cursors = type Cursors =
{ handed :: T.Cursor Handed { backend :: T.Cursor (Maybe Backend)
, handed :: T.Cursor Handed
, forestOpen :: T.Cursor OpenNodes , forestOpen :: T.Cursor OpenNodes
, reloadRoot :: T.Cursor Int , reloadRoot :: T.Cursor Int
, reloadForest :: T.Cursor Int , reloadForest :: T.Cursor Int
......
...@@ -11,7 +11,7 @@ module Gargantext.Components.Forest ...@@ -11,7 +11,7 @@ module Gargantext.Components.Forest
import Data.Array as A import Data.Array as A
import Data.Maybe (Maybe(..), fromMaybe) import Data.Maybe (Maybe(..), fromMaybe)
import Data.Set as Set import Data.Set as Set
import Data.Tuple (fst, snd) import Data.Tuple (fst)
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
...@@ -25,7 +25,7 @@ import Gargantext.Ends (Frontends, Backend) ...@@ -25,7 +25,7 @@ import Gargantext.Ends (Frontends, Backend)
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Routes (AppRoute) import Gargantext.Routes (AppRoute)
import Gargantext.Sessions (Session(..), Sessions, OpenNodes, unSessions) import Gargantext.Sessions (Session(..), Sessions, OpenNodes, unSessions)
import Gargantext.Types (Handed(..), reverseHanded, switchHanded) import Gargantext.Types (Handed, reverseHanded, switchHanded)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
...@@ -42,7 +42,7 @@ type Common = ...@@ -42,7 +42,7 @@ type Common =
) )
type LayoutProps = type LayoutProps =
( backend :: T.Cursor Backend ( backend :: T.Cursor (Maybe Backend)
, reloadForest :: T.Cursor T2.Reload , reloadForest :: T.Cursor T2.Reload
, sessions :: T.Cursor Sessions , sessions :: T.Cursor Sessions
, showLogin :: T.Cursor Boolean , showLogin :: T.Cursor Boolean
...@@ -75,8 +75,7 @@ forestCpt = here.component "forest" cpt where ...@@ -75,8 +75,7 @@ forestCpt = here.component "forest" cpt where
, tasks } _ = do , tasks } _ = do
-- NOTE: this is a hack to reload the forest on demand -- NOTE: this is a hack to reload the forest on demand
tasks' <- GAT.useTasks reloadRoot reloadForest tasks' <- GAT.useTasks reloadRoot reloadForest
R.useEffect' $ do R.useEffect' $ T2.write_ (Just tasks') tasks
T2.write_ (Just tasks') tasks
handed' <- T.useLive T.unequal handed handed' <- T.useLive T.unequal handed
reloadForest' <- T.useLive T.unequal reloadForest reloadForest' <- T.useLive T.unequal reloadForest
reloadRoot' <- T.useLive T.unequal reloadRoot reloadRoot' <- T.useLive T.unequal reloadRoot
...@@ -108,7 +107,7 @@ forestCpt = here.component "forest" cpt where ...@@ -108,7 +107,7 @@ forestCpt = here.component "forest" cpt where
, session: s , session: s
, tasks } [] , tasks } []
plus :: Handed -> T.Cursor Boolean -> T.Cursor Backend -> R.Element plus :: Handed -> T.Cursor Boolean -> T.Cursor (Maybe Backend) -> R.Element
plus handed showLogin backend = H.div { className: "row" } plus handed showLogin backend = H.div { className: "row" }
[ H.button { className: buttonClass [ H.button { className: buttonClass
, on: { click } , on: { click }
...@@ -122,7 +121,7 @@ plus handed showLogin backend = H.div { className: "row" } ...@@ -122,7 +121,7 @@ plus handed showLogin backend = H.div { className: "row" }
-- [ H.i { className: "material-icons md-36"} [] ] -- [ H.i { className: "material-icons md-36"} [] ]
where where
click _ = do click _ = do
-- _ <- T.modify (const Nothing) backend -- _ <- T.write Nothing backend
T2.write_ true showLogin T2.write_ true showLogin
title = "Add or remove connections to the server(s)." title = "Add or remove connections to the server(s)."
divClass = "fa fa-universal-access" divClass = "fa fa-universal-access"
......
...@@ -44,8 +44,8 @@ import Gargantext.Utils.Toestand as T2 ...@@ -44,8 +44,8 @@ import Gargantext.Utils.Toestand as T2
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.GraphExplorer" here = R2.here "Gargantext.Components.GraphExplorer"
type LayoutProps = ( type LayoutProps =
backend :: T.Cursor Backend ( backend :: T.Cursor (Maybe Backend)
, frontends :: Frontends , frontends :: Frontends
, graphId :: GET.GraphId , graphId :: GET.GraphId
, handed :: T.Cursor Types.Handed , handed :: T.Cursor Types.Handed
...@@ -250,8 +250,8 @@ explorerCpt = here.component "explorer" cpt ...@@ -250,8 +250,8 @@ explorerCpt = here.component "explorer" cpt
Sidebar.sidebar (Record.merge props { metaData }) Sidebar.sidebar (Record.merge props { metaData })
type TreeProps = ( type TreeProps = (
backend :: T.Cursor Backend backend :: T.Cursor (Maybe Backend)
, forestOpen :: T.Cursor OpenNodes , forestOpen :: T.Cursor OpenNodes
, frontends :: Frontends , frontends :: Frontends
, handed :: T.Cursor Types.Handed , handed :: T.Cursor Types.Handed
, reload :: T.Cursor T2.Reload , reload :: T.Cursor T2.Reload
......
...@@ -3,6 +3,7 @@ module Gargantext.Components.Router (router) where ...@@ -3,6 +3,7 @@ module Gargantext.Components.Router (router) where
import Data.Array (fromFoldable) import Data.Array (fromFoldable)
import Data.Maybe (Maybe(..), maybe') import Data.Maybe (Maybe(..), maybe')
import Reactix as R import Reactix as R
import Record as Record
import Toestand as T import Toestand as T
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
...@@ -29,6 +30,7 @@ import Gargantext.Components.Nodes.Texts as Texts ...@@ -29,6 +30,7 @@ import Gargantext.Components.Nodes.Texts as Texts
import Gargantext.Components.SessionLoader (sessionWrapper) import Gargantext.Components.SessionLoader (sessionWrapper)
import Gargantext.Components.SimpleLayout (simpleLayout) import Gargantext.Components.SimpleLayout (simpleLayout)
import Gargantext.Config (defaultFrontends, defaultBackends, publicBackend) import Gargantext.Config (defaultFrontends, defaultBackends, publicBackend)
import Gargantext.Ends (Backend)
import Gargantext.Routes (AppRoute(..)) import Gargantext.Routes (AppRoute(..))
import Gargantext.Routes as GR import Gargantext.Routes as GR
import Gargantext.Types (CorpusId, ListId, NodeID, NodeType(..), SessionId(..)) import Gargantext.Types (CorpusId, ListId, NodeID, NodeType(..), SessionId(..))
...@@ -43,6 +45,8 @@ type Props = ( ...@@ -43,6 +45,8 @@ type Props = (
, tasks :: T.Cursor (Maybe GAT.Reductor) , tasks :: T.Cursor (Maybe GAT.Reductor)
) )
type Props' = ( route' :: AppRoute, backend :: Backend | Props )
router :: R2.Leaf Props router :: R2.Leaf Props
router props = R.createElement routerCpt props [] router props = R.createElement routerCpt props []
...@@ -51,85 +55,86 @@ routerCpt = here.component "root" cpt where ...@@ -51,85 +55,86 @@ routerCpt = here.component "root" cpt where
cpt props@{ cursors, ws, tasks } _ = do cpt props@{ cursors, ws, tasks } _ = do
let session = R.createContext (unsafeCoerce {}) let session = R.createContext (unsafeCoerce {})
showLogin <- T.useLive T.unequal cursors.showLogin showLogin <- T.useLive T.unequal cursors.showLogin
route <- T.useLive (T.changed notEq) cursors.route route' <- T.useLive (T.changed notEq) cursors.route
let props' = Record.merge props { route' }
if showLogin then login' cursors if showLogin then login' cursors
else case route of else case route' of
GR.Annuaire s n -> annuaire props s n GR.Annuaire s n -> annuaire props' s n
GR.Corpus s n -> corpus props s n GR.Corpus s n -> corpus props' s n
GR.CorpusDocument s c l n -> corpusDocument props s c l n GR.CorpusDocument s c l n -> corpusDocument props' s c l n
GR.Dashboard s n -> dashboard props s n GR.Dashboard s n -> dashboard props' s n
GR.Document s l n -> document props s l n GR.Document s l n -> document props' s l n
GR.Folder s n -> corpus props s n GR.Folder s n -> corpus props' s n
GR.FolderPrivate s n -> corpus props s n GR.FolderPrivate s n -> corpus props' s n
GR.FolderPublic s n -> corpus props s n GR.FolderPublic s n -> corpus props' s n
GR.FolderShared s n -> corpus props s n GR.FolderShared s n -> corpus props' s n
GR.Home -> home props GR.Home -> home props'
GR.Lists s n -> lists props s n GR.Lists s n -> lists props' s n
GR.Login -> login' cursors GR.Login -> login' cursors
GR.PGraphExplorer s g -> graphExplorer props s g GR.PGraphExplorer s g -> graphExplorer props' s g
GR.RouteFile s n -> routeFile props s n GR.RouteFile s n -> routeFile props' s n
GR.RouteFrameCalc s n -> routeFrame props s n NodeFrameCalc GR.RouteFrameCalc s n -> routeFrame props' s n NodeFrameCalc
GR.RouteFrameCode s n -> routeFrame props s n NodeFrameNotebook GR.RouteFrameCode s n -> routeFrame props' s n NodeFrameNotebook
GR.RouteFrameWrite s n -> routeFrame props s n NodeFrameWrite GR.RouteFrameWrite s n -> routeFrame props' s n NodeFrameWrite
GR.Team s n -> team props s n GR.Team s n -> team props' s n
GR.Texts s n -> texts props s n GR.Texts s n -> texts props' s n
GR.UserPage s n -> user props s n GR.UserPage s n -> user props' s n
GR.ContactPage s a n -> contact props s a n GR.ContactPage s a n -> contact props' s a n
forested :: Record Props -> Array R.Element -> R.Element forested :: Record Props' -> Array R.Element -> R.Element
forested { tasks, cursors: { route, handed, sessions, backend, reloadForest, reloadRoot, showLogin } } = forested { route', tasks, cursors: { handed, sessions, backend, reloadForest, reloadRoot, showLogin } } =
forestLayout forestLayout
{ tasks, frontends, route, handed, sessions { tasks, frontends, handed, sessions, route: route'
, backend, reloadForest, reloadRoot, showLogin , backend, reloadForest, reloadRoot, showLogin
} where frontends = defaultFrontends } where frontends = defaultFrontends
authed :: Record Props -> SessionId -> R.Element -> R.Element authed :: Record Props' -> SessionId -> R.Element -> R.Element
authed props@{ cursors: { session, sessions } , tasks } sessionId content = authed props@{ cursors: { sessions }, tasks } sessionId content =
sessionWrapper { sessionId, session, sessions, fallback: home props } sessionWrapper { sessionId, sessions, fallback: home props }
[ content, footer { session } ] [ content, footer { session } ]
annuaire :: Record Props -> SessionId -> NodeID -> R.Element annuaire :: Record Props' -> SessionId -> NodeID -> R.Element
annuaire props@{ tasks, cursors: { session } } sessionId nodeId = annuaire props@{ tasks, cursors: { session } } sessionId nodeId =
authed props sessionId $ authed props sessionId $
forested props [ annuaireLayout { nodeId, frontends, session } ] forested props [ annuaireLayout { nodeId, frontends, session } ]
where frontends = defaultFrontends where frontends = defaultFrontends
corpus :: Record Props -> SessionId -> NodeID -> R.Element corpus :: Record Props' -> SessionId -> NodeID -> R.Element
corpus props@{ tasks, cursors: session } sessionId nodeId = corpus props@{ tasks, cursors: session } sessionId nodeId =
authed props sessionId $ authed props sessionId $
forested props forested props
[ corpusLayout { nodeId, session } ] [ corpusLayout { nodeId, session } ]
corpusDocument :: Record Props -> SessionId -> CorpusId -> ListId -> NodeID -> R.Element corpusDocument :: Record Props' -> SessionId -> CorpusId -> ListId -> NodeID -> R.Element
corpusDocument props@{ tasks, cursors: session } sessionId corpusId' listId nodeId = corpusDocument props@{ tasks, cursors: session } sessionId corpusId' listId nodeId =
authed props sessionId $ authed props sessionId $
forested props forested props
[ documentMainLayout { listId, nodeId, corpusId, sessionId, session } [] ] [ documentMainLayout { listId, nodeId, corpusId, sessionId, session } [] ]
where corpusId = Just corpusId' where corpusId = Just corpusId'
dashboard :: Record Props -> SessionId -> NodeID -> R.Element dashboard :: Record Props' -> SessionId -> NodeID -> R.Element
dashboard props@{ tasks, cursors: { session } } sessionId nodeId = dashboard props@{ tasks, cursors: { session } } sessionId nodeId =
authed props sessionId $ authed props sessionId $
forested props [ dashboardLayout { nodeId, session } [] ] forested props [ dashboardLayout { nodeId, session } [] ]
document :: Record Props -> SessionId -> ListId -> NodeID -> R.Element document :: Record Props' -> SessionId -> ListId -> NodeID -> R.Element
document props@{ tasks, cursors: { session } } sessionId listId nodeId = document props@{ tasks, cursors: { session } } sessionId listId nodeId =
authed props sessionId $ authed props sessionId $
forested props forested props
[ documentMainLayout { listId, nodeId, corpusId, session } [] ] [ documentMainLayout { listId, nodeId, corpusId, session } [] ]
where corpusId = Nothing where corpusId = Nothing
home :: Record Props -> R.Element home :: Record Props' -> R.Element
home props@{ cursors: { backend, showLogin, sessions } } = home props@{ cursors: { showLogin, sessions } } =
forested props [ homeLayout { sessions, backend, showLogin, lang: LL_EN } ] forested props [ homeLayout { sessions, showLogin, lang: LL_EN } ]
lists :: Record Props -> SessionId -> NodeID -> R.Element lists :: Record Props' -> SessionId -> NodeID -> R.Element
lists props@{ cursors: { backend, route, handed, sessions lists props@{ cursors: { backend, route, handed, sessions
, reloadForest, reloadRoot, session, showLogin } , reloadForest, reloadRoot, session, showLogin }
, tasks } sessionId nodeId = , tasks } sessionId nodeId =
authed props sessionId $ authed props sessionId $
Lists.listsWithForest Lists.listsWithForest
{ forestProps: { backend { forestProps': { backend
, frontends , frontends
, handed , handed
, reloadForest , reloadForest
...@@ -138,7 +143,7 @@ lists props@{ cursors: { backend, route, handed, sessions ...@@ -138,7 +143,7 @@ lists props@{ cursors: { backend, route, handed, sessions
, sessions , sessions
, showLogin , showLogin
, tasks } , tasks }
, listsProps: { tasks, reloadRoot, reloadForest, nodeId, session } , listsProps': { tasks, reloadRoot, reloadForest, nodeId, session }
} [] } []
where frontends = defaultFrontends where frontends = defaultFrontends
...@@ -147,7 +152,7 @@ login' { backend, sessions, showLogin: visible } = ...@@ -147,7 +152,7 @@ login' { backend, sessions, showLogin: visible } =
login { backend, sessions, visible login { backend, sessions, visible
, backends: fromFoldable defaultBackends } , backends: fromFoldable defaultBackends }
graphExplorer :: Record Props -> SessionId -> Int -> R.Element graphExplorer :: Record Props' -> SessionId -> Int -> R.Element
graphExplorer props@{ views: { backend, route, handed, session, sessions, showLogin } graphExplorer props@{ views: { backend, route, handed, session, sessions, showLogin }
, tasks } sessionId graphId = , tasks } sessionId graphId =
authed props sessionId $ authed props sessionId $
...@@ -156,36 +161,36 @@ graphExplorer props@{ views: { backend, route, handed, session, sessions, showLo ...@@ -156,36 +161,36 @@ graphExplorer props@{ views: { backend, route, handed, session, sessions, showLo
, handed, session, sessions, showLogin } ] , handed, session, sessions, showLogin } ]
where frontends = defaultFrontends where frontends = defaultFrontends
routeFile :: Record Props -> SessionId -> NodeID -> R.Element routeFile :: Record Props' -> SessionId -> NodeID -> R.Element
routeFile props@{ cursors: { session } } sessionId nodeId = routeFile props@{ cursors: { session } } sessionId nodeId =
authed props sessionId $ forested props [ fileLayout { nodeId, session } ] authed props sessionId $ forested props [ fileLayout { nodeId, session } ]
routeFrame :: Record Props -> SessionId -> NodeID -> NodeType -> R.Element routeFrame :: Record Props' -> SessionId -> NodeID -> NodeType -> R.Element
routeFrame props@{ cursors: { session } } sessionId nodeId nodeType = routeFrame props@{ cursors: { session } } sessionId nodeId nodeType =
authed props sessionId $ forested props [ frameLayout { nodeId, nodeType, session } ] authed props sessionId $ forested props [ frameLayout { nodeId, nodeType, session } ]
team :: Record Props -> SessionId -> NodeID -> R.Element team :: Record Props' -> SessionId -> NodeID -> R.Element
team props@{ tasks, cursors: { session } } sessionId nodeId = team props@{ tasks, cursors: { session } } sessionId nodeId =
authed props sessionId $ forested props [ corpusLayout { nodeId, session } ] authed props sessionId $ forested props [ corpusLayout { nodeId, session } ]
texts :: Record Props -> SessionId -> NodeID -> R.Element texts :: Record Props' -> SessionId -> NodeID -> R.Element
texts props@{ cursors: { backend, reloadForest, reloadRoot, showLogin, route, handed, session, sessions } texts props@{ cursors: { backend, reloadForest, reloadRoot, showLogin, route, handed, session, sessions }
, tasks } sessionId nodeId = , tasks } sessionId nodeId =
authed props sessionId $ authed props sessionId $
Texts.textsWithForest Texts.textsWithForest
{ forestProps: { frontends, tasks, route, handed, sessions { forestProps': { frontends, tasks, route, handed, sessions
, backend, reloadForest, reloadRoot, showLogin } , backend, reloadForest, reloadRoot, showLogin }
, textsProps: { frontends, nodeId, session } } , textsProps': { frontends, nodeId, session } }
[] where frontends = defaultFrontends [] where frontends = defaultFrontends
user :: Record Props -> SessionId -> NodeID -> R.Element user :: Record Props' -> SessionId -> NodeID -> R.Element
user props@{ cursors: { reloadRoot, session }, tasks } sessionId nodeId = user props@{ cursors: { reloadRoot, session }, tasks } sessionId nodeId =
authed props sessionId $ authed props sessionId $
forested props forested props
[ userLayout { tasks, nodeId, session, reloadRoot, frontends } ] [ userLayout { tasks, nodeId, session, reloadRoot, frontends } ]
where frontends = defaultFrontends where frontends = defaultFrontends
contact :: Record Props -> SessionId -> NodeID -> R.Element contact :: Record Props' -> SessionId -> NodeID -> R.Element
contact props@{ tasks, cursors: { reloadRoot } } sessionId annuaireId nodeId = contact props@{ tasks, cursors: { reloadRoot } } sessionId annuaireId nodeId =
authed props sessionId $ authed props sessionId $
forested props forested props
......
...@@ -15,16 +15,16 @@ import Gargantext.Utils.Reactix as R2 ...@@ -15,16 +15,16 @@ import Gargantext.Utils.Reactix as R2
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.SessionWrapper" here = R2.here "Gargantext.Components.SessionWrapper"
type Props sessions = type Props =
( sessionId :: SessionId ( sessionId :: SessionId
, sessions :: sessions , sessions :: T.Cursor Sessions
, provider :: R.Provider Session , provider :: R.Provider Session
, fallback :: R.Element ) , fallback :: R.Element )
sessionWrapper :: forall s. T.Read s Sessions => R2.Component (Props s) sessionWrapper :: R2.Component Props
sessionWrapper = R.createElement sessionWrapperCpt sessionWrapper = R.createElement sessionWrapperCpt
sessionWrapperCpt :: forall s. T.Read s Sessions => R.Component (Props s) sessionWrapperCpt :: R.Component Props
sessionWrapperCpt = here.component "sessionWrapper" cpt where sessionWrapperCpt = here.component "sessionWrapper" cpt where
cpt { sessionId, sessions, provider, fallback } content = cpt { sessionId, sessions, provider, fallback } content =
cp <$> T.useLive T.unequal sessions where cp <$> T.useLive T.unequal sessions where
......
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