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
d9c283e7
Commit
d9c283e7
authored
Sep 24, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] Login on uniq server for Join main button at Home page
parent
95861d14
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
150 additions
and
85 deletions
+150
-85
App.purs
src/Gargantext/Components/App.purs
+25
-10
Forest.purs
src/Gargantext/Components/Forest.purs
+15
-14
GraphExplorer.purs
src/Gargantext/Components/GraphExplorer.purs
+8
-4
Login.purs
src/Gargantext/Components/Login.purs
+42
-36
Home.purs
src/Gargantext/Components/Nodes/Home.purs
+23
-6
Public.purs
src/Gargantext/Components/Nodes/Home/Public.purs
+37
-15
No files found.
src/Gargantext/Components/App.purs
View file @
d9c283e7
...
@@ -10,6 +10,7 @@ import Reactix.DOM.HTML as H
...
@@ -10,6 +10,7 @@ import Reactix.DOM.HTML as H
import Gargantext.Prelude
import Gargantext.Prelude
import Gargantext.Config (publicBackend)
import Gargantext.Components.Forest (forest)
import Gargantext.Components.Forest (forest)
import Gargantext.Components.GraphExplorer (explorerLayout)
import Gargantext.Components.GraphExplorer (explorerLayout)
import Gargantext.Components.Lang (LandingLang(..))
import Gargantext.Components.Lang (LandingLang(..))
...
@@ -25,7 +26,7 @@ import Gargantext.Components.Nodes.Home (homeLayout)
...
@@ -25,7 +26,7 @@ import Gargantext.Components.Nodes.Home (homeLayout)
import Gargantext.Components.Nodes.Lists (listsLayout)
import Gargantext.Components.Nodes.Lists (listsLayout)
import Gargantext.Components.Nodes.Texts (textsLayout)
import Gargantext.Components.Nodes.Texts (textsLayout)
import Gargantext.Config (defaultFrontends, defaultBackends)
import Gargantext.Config (defaultFrontends, defaultBackends)
import Gargantext.Ends (Frontends)
import Gargantext.Ends (Frontends
, Backend
)
import Gargantext.Hooks.Router (useHashRouter)
import Gargantext.Hooks.Router (useHashRouter)
import Gargantext.License (license)
import Gargantext.License (license)
import Gargantext.Router (router)
import Gargantext.Router (router)
...
@@ -51,6 +52,8 @@ appCpt = R2.hooksComponent thisModule "app" cpt where
...
@@ -51,6 +52,8 @@ appCpt = R2.hooksComponent thisModule "app" cpt where
route <- useHashRouter router Home
route <- useHashRouter router Home
showLogin <- R.useState' false
showLogin <- R.useState' false
backend <- R.useState' Nothing
showCorpus <- R.useState' false
showCorpus <- R.useState' false
treeReload <- R.useState' 0
treeReload <- R.useState' 0
...
@@ -65,18 +68,28 @@ appCpt = R2.hooksComponent thisModule "app" cpt where
...
@@ -65,18 +68,28 @@ appCpt = R2.hooksComponent thisModule "app" cpt where
, reload: treeReload
, reload: treeReload
, route: fst route
, route: fst route
, sessions: fst sessions
, sessions: fst sessions
, showLogin: snd showLogin }
, showLogin: snd showLogin
, backend
}
let mCurrentRoute = fst route
let mCurrentRoute = fst route
let withSession sid f =
let withSession sid f = maybe' ( const $ forested
maybe' (const $ forested $ homeLayout LL_EN) (ff f) $ Sessions.lookup sid (fst sessions)
$ homeLayout { lang: LL_EN
, backend
, publicBackend
, sessions
, visible:showLogin
}
)
(ff f)
(Sessions.lookup sid (fst sessions))
pure $ case fst showLogin of
pure $ case fst showLogin of
true -> forested $ login { backends, sessions, visible: showLogin }
true -> forested $ login { backend
, backend
s, sessions, visible: showLogin }
false ->
false ->
case fst route of
case fst route of
Home -> forested $ homeLayout
LL_EN
Home -> forested $ homeLayout
{lang:LL_EN, backend, publicBackend, sessions, visible:showLogin}
Login -> login { backends, sessions, visible: showLogin
}
Login -> login { backends, sessions, visible: showLogin
, backend
}
Folder sid nodeId
-> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
Folder sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
FolderPrivate sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
FolderPrivate sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
FolderPublic sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
FolderPublic sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
FolderShared sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
FolderShared sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
...
@@ -106,6 +119,7 @@ appCpt = R2.hooksComponent thisModule "app" cpt where
...
@@ -106,6 +119,7 @@ appCpt = R2.hooksComponent thisModule "app" cpt where
, session
, session
, sessions: (fst sessions)
, sessions: (fst sessions)
, showLogin
, showLogin
, backend
--, treeReload
--, treeReload
}
}
...
@@ -117,6 +131,7 @@ type ForestLayoutProps =
...
@@ -117,6 +131,7 @@ type ForestLayoutProps =
, route :: AppRoute
, route :: AppRoute
, sessions :: Sessions
, sessions :: Sessions
, showLogin :: R2.Setter Boolean
, showLogin :: R2.Setter Boolean
, backend :: R.State (Maybe Backend)
)
)
forestLayout :: Record ForestLayoutProps -> R.Element
forestLayout :: Record ForestLayoutProps -> R.Element
...
@@ -134,7 +149,7 @@ forestLayoutMain props = R.createElement forestLayoutMainCpt props []
...
@@ -134,7 +149,7 @@ forestLayoutMain props = R.createElement forestLayoutMainCpt props []
forestLayoutMainCpt :: R.Component ForestLayoutProps
forestLayoutMainCpt :: R.Component ForestLayoutProps
forestLayoutMainCpt = R2.hooksComponent thisModule "forestLayoutMain" cpt
forestLayoutMainCpt = R2.hooksComponent thisModule "forestLayoutMain" cpt
where
where
cpt { child, frontends, handed, reload, route, sessions, showLogin
} _ = do
cpt { child, frontends, handed, reload, route, sessions, showLogin
, backend
} _ = do
let ordering =
let ordering =
case fst handed of
case fst handed of
GT.LeftHanded -> reverse
GT.LeftHanded -> reverse
...
@@ -142,7 +157,7 @@ forestLayoutMainCpt = R2.hooksComponent thisModule "forestLayoutMain" cpt
...
@@ -142,7 +157,7 @@ forestLayoutMainCpt = R2.hooksComponent thisModule "forestLayoutMain" cpt
pure $ R2.row $ ordering [
pure $ R2.row $ ordering [
H.div { className: "col-md-2", style: { paddingTop: "60px" } }
H.div { className: "col-md-2", style: { paddingTop: "60px" } }
[ forest { frontends, handed: fst handed, reload, route, sessions, showLogin
} ]
[ forest { frontends, handed: fst handed, reload, route, sessions, showLogin
, backend
} ]
, mainPage child
, mainPage child
]
]
...
...
src/Gargantext/Components/Forest.purs
View file @
d9c283e7
module Gargantext.Components.Forest where
module Gargantext.Components.Forest where
import
Gargantext.Prelude
import
DOM.Simple.Console (log)
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..))
import Data.Set as Set
import Data.Set as Set
import Data.Tuple (fst)
import Data.Tuple (fst
, snd
)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.AsyncTasks as GAT
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.Forest.Tree (treeView)
import Gargantext.Components.Forest.Tree (treeView)
import Gargantext.Ends (Frontends)
import Gargantext.Ends (Frontends, Backend(..))
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 (Reload, Handed(..))
import Gargantext.Types (Reload, Handed(..))
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
thisModule = "Gargantext.Components.Forest"
thisModule = "Gargantext.Components.Forest"
...
@@ -26,6 +26,7 @@ type Props =
...
@@ -26,6 +26,7 @@ type Props =
, route :: AppRoute
, route :: AppRoute
, sessions :: Sessions
, sessions :: Sessions
, showLogin :: R2.Setter Boolean
, showLogin :: R2.Setter Boolean
, backend :: R.State (Maybe Backend)
)
)
forest :: Record Props -> R.Element
forest :: Record Props -> R.Element
...
@@ -33,7 +34,7 @@ forest props = R.createElement forestCpt props []
...
@@ -33,7 +34,7 @@ forest props = R.createElement forestCpt props []
forestCpt :: R.Component Props
forestCpt :: R.Component Props
forestCpt = R2.hooksComponent thisModule "forest" cpt where
forestCpt = R2.hooksComponent thisModule "forest" cpt where
cpt { frontends, handed, reload: extReload, route, sessions, showLogin
} _ = do
cpt { frontends, handed, reload: extReload, route, sessions, showLogin
, backend
} _ = do
-- NOTE: this is a hack to reload the tree view on demand
-- NOTE: this is a hack to reload the tree view on demand
reload <- R.useState' (0 :: Reload)
reload <- R.useState' (0 :: Reload)
openNodes <- R2.useLocalStorageState R2.openNodesKey (Set.empty :: OpenNodes)
openNodes <- R2.useLocalStorageState R2.openNodesKey (Set.empty :: OpenNodes)
...
@@ -48,9 +49,9 @@ forestCpt = R2.hooksComponent thisModule "forest" cpt where
...
@@ -48,9 +49,9 @@ forestCpt = R2.hooksComponent thisModule "forest" cpt where
/\ fst asyncTasks
/\ fst asyncTasks
/\ handed
/\ handed
)
)
(cpt' openNodes asyncTasks reload showLogin)
(cpt' openNodes asyncTasks reload showLogin
backend
)
cpt' openNodes asyncTasks reload showLogin (frontends /\ route /\ sessions /\ _ /\ _ /\ _ /\ _ /\ handed) = do
cpt' openNodes asyncTasks reload showLogin
backend
(frontends /\ route /\ sessions /\ _ /\ _ /\ _ /\ _ /\ handed) = do
pure $ R2.row $ [plus handed showLogin] <> trees
pure $ R2.row $ [plus handed showLogin
backend
] <> trees
where
where
trees = tree <$> unSessions sessions
trees = tree <$> unSessions sessions
tree s@(Session {treeId}) =
tree s@(Session {treeId}) =
...
@@ -64,8 +65,8 @@ forestCpt = R2.hooksComponent thisModule "forest" cpt where
...
@@ -64,8 +65,8 @@ forestCpt = R2.hooksComponent thisModule "forest" cpt where
, session: s
, session: s
}
}
plus :: Handed -> R2.Setter Boolean -> R.Element
plus :: Handed -> R2.Setter Boolean -> R.
State (Maybe Backend) -> R.
Element
plus handed showLogin = H.div {className: if handed == RightHanded
plus handed showLogin
backend
= H.div {className: if handed == RightHanded
then "flex-start" -- TODO we should use lefthanded SASS class here
then "flex-start" -- TODO we should use lefthanded SASS class here
else "flex-end"
else "flex-end"
} [
} [
...
@@ -84,5 +85,5 @@ plus handed showLogin = H.div {className: if handed == RightHanded
...
@@ -84,5 +85,5 @@ plus handed showLogin = H.div {className: if handed == RightHanded
-- TODO same as the one in the Login Modal (same CSS)
-- TODO same as the one in the Login Modal (same CSS)
-- [ H.i { className: "material-icons md-36"} [] ]
-- [ H.i { className: "material-icons md-36"} [] ]
where
where
click _ =
do
click _ =
(snd backend) (const Nothing)
showLogin $ const true
*> showLogin (const true)
src/Gargantext/Components/GraphExplorer.purs
View file @
d9c283e7
...
@@ -27,7 +27,7 @@ import Gargantext.Components.GraphExplorer.Sidebar as Sidebar
...
@@ -27,7 +27,7 @@ import Gargantext.Components.GraphExplorer.Sidebar as Sidebar
import Gargantext.Components.GraphExplorer.ToggleButton as Toggle
import Gargantext.Components.GraphExplorer.ToggleButton as Toggle
import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Data.Louvain as Louvain
import Gargantext.Data.Louvain as Louvain
import Gargantext.Ends (Frontends)
import Gargantext.Ends (Frontends
, Backend
)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.Sigmax as Sigmax
import Gargantext.Hooks.Sigmax as Sigmax
import Gargantext.Hooks.Sigmax.Types as SigmaxT
import Gargantext.Hooks.Sigmax.Types as SigmaxT
...
@@ -48,6 +48,7 @@ type LayoutProps =
...
@@ -48,6 +48,7 @@ type LayoutProps =
, session :: Session
, session :: Session
, sessions :: Sessions
, sessions :: Sessions
, showLogin :: R.State Boolean
, showLogin :: R.State Boolean
, backend :: R.State (Maybe Backend)
)
)
type Props =
type Props =
...
@@ -100,6 +101,7 @@ explorerCpt = R2.hooksComponent thisModule "explorer" cpt
...
@@ -100,6 +101,7 @@ explorerCpt = R2.hooksComponent thisModule "explorer" cpt
, session
, session
, sessions
, sessions
, showLogin
, showLogin
, backend
} _ = do
} _ = do
let startForceAtlas = maybe true (\(GET.MetaData { startForceAtlas }) -> startForceAtlas) mMetaData
let startForceAtlas = maybe true (\(GET.MetaData { startForceAtlas }) -> startForceAtlas) mMetaData
...
@@ -158,7 +160,8 @@ explorerCpt = R2.hooksComponent thisModule "explorer" cpt
...
@@ -158,7 +160,8 @@ explorerCpt = R2.hooksComponent thisModule "explorer" cpt
, reload: treeReload
, reload: treeReload
, sessions
, sessions
, show: fst controls.showTree
, show: fst controls.showTree
, showLogin: snd showLogin }
, showLogin: snd showLogin
, backend}
/\
/\
RH.div { ref: graphRef, id: "graph-view", className: "col-md-12" } []
RH.div { ref: graphRef, id: "graph-view", className: "col-md-12" } []
/\
/\
...
@@ -205,9 +208,9 @@ explorerCpt = R2.hooksComponent thisModule "explorer" cpt
...
@@ -205,9 +208,9 @@ explorerCpt = R2.hooksComponent thisModule "explorer" cpt
tree :: Record TreeProps -> R.Element
tree :: Record TreeProps -> R.Element
tree { show: false } = RH.div { id: "tree" } []
tree { show: false } = RH.div { id: "tree" } []
tree { frontends, handed, mCurrentRoute: route, reload, sessions, showLogin
} =
tree { frontends, handed, mCurrentRoute: route, reload, sessions, showLogin
, backend
} =
RH.div {className: "col-md-2 graph-tree"} [
RH.div {className: "col-md-2 graph-tree"} [
forest { frontends, handed, reload, route, sessions, showLogin
}
forest { frontends, handed, reload, route, sessions, showLogin
, backend
}
]
]
mSidebar :: Maybe GET.MetaData
mSidebar :: Maybe GET.MetaData
...
@@ -226,6 +229,7 @@ type TreeProps =
...
@@ -226,6 +229,7 @@ type TreeProps =
, sessions :: Sessions
, sessions :: Sessions
, show :: Boolean
, show :: Boolean
, showLogin :: R2.Setter Boolean
, showLogin :: R2.Setter Boolean
, backend :: R.State (Maybe Backend)
)
)
type MSidebarProps =
type MSidebarProps =
...
...
src/Gargantext/Components/Login.purs
View file @
d9c283e7
...
@@ -29,15 +29,33 @@ import Gargantext.Utils.Reactix as R2
...
@@ -29,15 +29,33 @@ import Gargantext.Utils.Reactix as R2
thisModule = "Gargantext.Components.Login"
thisModule = "Gargantext.Components.Login"
-- TODO: ask for login (modal) or account creation after 15 mn when user
-- TODO
-- is not logged and has made one search at least
-- enable anonymous login for first map
-- and ask for login (modal) or account creation after 15 mn when user
-- if not logged user can not save his work
type Props =
type
Login
Props =
( backends :: Array Backend
( backends :: Array Backend
, sessions :: R2.Reductor Sessions Sessions.Action
, sessions :: R2.Reductor Sessions Sessions.Action
, visible :: R.State Boolean
, visible :: R.State Boolean
, backend :: R.State (Maybe Backend)
)
)
login :: Record LoginProps -> R.Element
login props = R.createElement loginCpt props []
loginCpt :: R.Component LoginProps
loginCpt = R2.hooksComponent thisModule "login" cpt
where
cpt props@{backends, sessions, visible, backend} _ = do
pure $
modal {visible} $
case fst backend of
Nothing -> chooser { backends, backend, sessions, visible }
Just b -> form { sessions, visible, backend: b }
------------------------------------------------------------------------
type ModalProps = ( visible :: R.State Boolean )
type ModalProps = ( visible :: R.State Boolean )
modal :: Record ModalProps -> R.Element -> R.Element
modal :: Record ModalProps -> R.Element -> R.Element
...
@@ -76,45 +94,33 @@ modalCpt = R2.hooksComponent thisModule "modal" cpt where
...
@@ -76,45 +94,33 @@ modalCpt = R2.hooksComponent thisModule "modal" cpt where
]
]
------------------------------------------------------------------------
login :: Record Props -> R.Element
chooser :: Record LoginProps -> R.Element
login props = R.createElement loginCpt props []
loginCpt :: R.Component Props
loginCpt = R2.hooksComponent thisModule "login" cpt
where
cpt props@{backends, sessions, visible} _ = do
backend <- R.useState' Nothing
pure $
modal {visible} $
case fst backend of
Nothing -> chooser { backends, backend, sessions, visible }
Just b -> form { sessions, visible, backend: b }
type ChooserProps = ( backend :: R.State (Maybe Backend) | Props )
chooser :: Record ChooserProps -> R.Element
chooser props = R.createElement chooserCpt props []
chooser props = R.createElement chooserCpt props []
chooserCpt :: R.Component
Chooser
Props
chooserCpt :: R.Component
Login
Props
chooserCpt = R.staticComponent "G.C.Login.chooser" cpt where
chooserCpt = R.staticComponent "G.C.Login.chooser" cpt where
cpt :: Record
Chooser
Props -> Array R.Element -> R.Element
cpt :: Record
Login
Props -> Array R.Element -> R.Element
cpt {backend, backends, sessions} _ =
cpt {backend, backends, sessions} _ =
R.fragment $ title <> active <> new <> search
R.fragment $ title <> active <> new <> search
where
where
title = [H.h2 { className: "center modal-title" } [H.text "Instances manager"]]
title = [H.h2 { className: "center modal-title" } [H.text "Instances manager"]]
active = if DS.length ss > 0 then [ H.h3 {} [H.text "Active connection(s)"]
active = if DS.length ss > 0
, H.ul {} [ renderSessions sessions]
then [ H.h3 {} [H.text "Active connection(s)"]
] else [] where
, H.ul {} [ renderSessions sessions]
Sessions {sessions:ss} = fst sessions
]
else []
where
Sessions {sessions:ss} = fst sessions
search = [ H.input {className: "form-control", type:"text", placeholder: "Search for your institute"}]
search = [ H.input {className: "form-control", type:"text", placeholder: "Search for your institute"}]
new = [ H.h3 {} [H.text "Last connection(s)"]
new = [ H.h3 {} [ H.text "Last connection(s)" ]
, H.table {className : "table"}
, H.table { className : "table" }
[ H.thead {className: "thead-dark"} [ H.tr {} [ H.th {} [ H.text ""]
[ H.thead { className: "thead-dark" }
, H.th {} [H.text "Label of instance"]
[ H.tr {} [ H.th {} [ H.text "" ]
, H.th {} [H.text "Gargurl"]
, H.th {} [ H.text "Label of instance" ]
]
, H.th {} [ H.text "Gargurl" ]
]
]
]
, H.tbody {} (map (renderBackend backend) backends)
, H.tbody {} (map (renderBackend backend) backends)
]
]
]
]
...
@@ -205,8 +211,8 @@ formCpt = R2.hooksComponent thisModule "form" cpt where
...
@@ -205,8 +211,8 @@ formCpt = R2.hooksComponent thisModule "form" cpt where
Left message -> liftEffect $ (snd error) (const message)
Left message -> liftEffect $ (snd error) (const message)
Right sess -> liftEffect $ do
Right sess -> liftEffect $ do
(snd sessions) (Sessions.Login sess)
(snd sessions) (Sessions.Login sess)
(snd error) (const "")
(snd error
) (const "")
(snd visible) (const false)
(snd visible
) (const false)
csrfTokenInput :: {} -> R.Element
csrfTokenInput :: {} -> R.Element
csrfTokenInput _ =
csrfTokenInput _ =
...
...
src/Gargantext/Components/Nodes/Home.purs
View file @
d9c283e7
module Gargantext.Components.Nodes.Home where
module Gargantext.Components.Nodes.Home where
import Data.Maybe (Maybe(..))
import Data.Newtype (class Newtype)
import Data.Newtype (class Newtype)
import Effect (Effect)
import Effect (Effect)
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
import Routing.Hash (setHash)
import Routing.Hash (setHash)
import Gargantext.Ends (Backend(..))
import Gargantext.Sessions (Sessions(..))
import Gargantext.Sessions as Sessions
import Gargantext.Components.Data.Landing (BlockText(..), BlockTexts(..), Button(..), LandingData(..))
import Gargantext.Components.Data.Landing (BlockText(..), BlockTexts(..), Button(..), LandingData(..))
import Gargantext.Components.Lang (LandingLang(..))
import Gargantext.Components.Lang (LandingLang(..))
import Gargantext.Components.Lang.Landing.EnUS as En
import Gargantext.Components.Lang.Landing.EnUS as En
...
@@ -47,19 +52,31 @@ langLandingData LL_EN = En.landingData
...
@@ -47,19 +52,31 @@ langLandingData LL_EN = En.landingData
------------------------------------------------------------------------
------------------------------------------------------------------------
homeLayout :: LandingLang -> R.Element
type HomeProps = ( lang :: LandingLang
homeLayout lang = R.createElement homeLayoutCpt {landingData} []
, publicBackend :: Backend
where landingData = langLandingData lang
, backend :: R.State (Maybe Backend)
, sessions :: R2.Reductor Sessions Sessions.Action
, visible :: R.State Boolean
)
homeLayout :: Record HomeProps -> R.Element
homeLayout props = R.createElement homeLayoutCpt props []
homeLayoutCpt :: R.Component
( landingData :: LandingData )
homeLayoutCpt :: R.Component
HomeProps
homeLayoutCpt = R2.hooksComponent thisModule "homeLayout" cpt
homeLayoutCpt = R2.hooksComponent thisModule "homeLayout" cpt
where
where
cpt {landingData} _ = do
cpt {lang, backend, publicBackend, sessions, visible} _ = do
let landingData = langLandingData lang
pure $ H.span {}
pure $ H.span {}
[ H.div { className: "container1" } [ jumboTitle landingData false ]
[ H.div { className: "container1" } [ jumboTitle landingData false ]
, H.div { className: "container1" } [] -- TODO put research form
, H.div { className: "container1" } [] -- TODO put research form
, H.div { className: "container1" } [ blocksRandomText' landingData ]
, H.div { className: "container1" } [ blocksRandomText' landingData ]
, H.div { className: "container1" } [ renderPublic ]
, H.div { className: "container1" } [ renderPublic { backend
, publicBackend
, sessions
, visible
}
]
, license
, license
]
]
...
...
src/Gargantext/Components/Nodes/Home/Public.purs
View file @
d9c283e7
module Gargantext.Components.Nodes.Home.Public where
module Gargantext.Components.Nodes.Home.Public where
import DOM.Simple.Console (log)
import Data.Array.NonEmpty (toArray)
import Data.Array.NonEmpty (toArray)
import Data.Array as Array
import Data.Array as Array
import Data.Argonaut as Argonaut
import Data.Argonaut as Argonaut
...
@@ -9,12 +10,13 @@ import Data.Maybe (Maybe(..))
...
@@ -9,12 +10,13 @@ import Data.Maybe (Maybe(..))
import Data.NonEmpty (head)
import Data.NonEmpty (head)
import Data.String (take)
import Data.String (take)
import Data.Traversable (traverse)
import Data.Traversable (traverse)
import Data.Tuple (fst)
import Data.Tuple (fst
, snd
)
import Effect.Aff (Aff)
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
import Gargantext.Components.Login (login)
import Gargantext.Config (publicBackend)
import Gargantext.Config (publicBackend)
import Gargantext.Config.REST (get)
import Gargantext.Config.REST (get)
import Gargantext.Ends (backendUrl, Backend(..))
import Gargantext.Ends (backendUrl, Backend(..))
...
@@ -23,12 +25,24 @@ import Gargantext.Prelude
...
@@ -23,12 +25,24 @@ import Gargantext.Prelude
import Gargantext.Utils.Argonaut (genericSumDecodeJson, genericSumEncodeJson)
import Gargantext.Utils.Argonaut (genericSumDecodeJson, genericSumEncodeJson)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Gargantext.Ends (Backend(..))
import Gargantext.Sessions (Sessions(..))
import Gargantext.Sessions as Sessions
thisModule = "Gargantext.Components.Nodes.Home.Public"
thisModule = "Gargantext.Components.Nodes.Home.Public"
type PublicProps = (publicDatas :: (Array PublicData)
type PublicProps = ( backend :: R.State (Maybe Backend)
-- , session :: Session
, publicBackend :: Backend
, sessions :: R2.Reductor Sessions Sessions.Action
, visible :: R.State Boolean
)
)
type PublicDataProps =
( publicDatas :: (Array PublicData)
| PublicProps
)
data PublicData = PublicData
data PublicData = PublicData
{ title :: String
{ title :: String
, abstract :: String
, abstract :: String
...
@@ -75,25 +89,28 @@ loadPublicData _l = do
...
@@ -75,25 +89,28 @@ loadPublicData _l = do
Array.concat <$> traverse (\backend -> get Nothing (backendUrl backend "public")) backends
Array.concat <$> traverse (\backend -> get Nothing (backendUrl backend "public")) backends
-}
-}
renderPublic :: R.Element
renderPublic :: R
ecord PublicProps -> R
.Element
renderPublic
= R.createElement renderPublicCpt {}
[]
renderPublic
props = R.createElement renderPublicCpt props
[]
renderPublicCpt :: R.Component
LoadData
renderPublicCpt :: R.Component
PublicProps
renderPublicCpt = R2.hooksComponent thisModule "renderPublic" cpt
renderPublicCpt = R2.hooksComponent thisModule "renderPublic" cpt
where
where
cpt {} _ = do
cpt {
backend, publicBackend, sessions, visible
} _ = do
reload <- R.useState' 0
reload <- R.useState' 0
useLoader { reload: fst reload } loadPublicData (\pd -> publicLayout {publicDatas: pd})
showLogin <- R.useState' false
useLoader { reload: fst reload }
loadPublicData
(\pd -> publicLayout {publicDatas: pd, backend, publicBackend, sessions, visible})
------------------------------------------------------------------------
------------------------------------------------------------------------
publicLayout :: Record PublicProps -> R.Element
publicLayout :: Record Public
Data
Props -> R.Element
publicLayout props = R.createElement publicLayoutCpt props []
publicLayout props = R.createElement publicLayoutCpt props []
publicLayoutCpt :: R.Component PublicProps
publicLayoutCpt :: R.Component Public
Data
Props
publicLayoutCpt = R2.hooksComponent thisModule "publicLayout" cpt
publicLayoutCpt = R2.hooksComponent thisModule "publicLayout" cpt
where
where
cpt {publicDatas} _ = do
cpt {publicDatas
, visible, backend, publicBackend, sessions
} _ = do
pure $ H.span {}
pure $ H.span {}
[ H.div { className: "text-center" }
[ H.div { className: "text-center" }
[ H.div { className:"container1" }
[ H.div { className:"container1" }
...
@@ -102,10 +119,12 @@ publicLayoutCpt = R2.hooksComponent thisModule "publicLayout" cpt
...
@@ -102,10 +119,12 @@ publicLayoutCpt = R2.hooksComponent thisModule "publicLayout" cpt
[ H.text "Discover maps made with "
[ H.text "Discover maps made with "
, H.span {className: "fa fa-heart"} []
, H.span {className: "fa fa-heart"} []
]
]
, H.p { className:"flex-space-around" }
, H.div { className:"flex-space-around" }
[ H.a { className: "btn btn-primary my-2"
[ H.button { className: "btn btn-primary my-2"
, href :"https://gargantext.org"
, on : { click }
} [H.text "Join"]
, title: "Connect to the server"
} [ H.text "Join"
]
]
]
]
]
]
]
...
@@ -113,6 +132,9 @@ publicLayoutCpt = R2.hooksComponent thisModule "publicLayout" cpt
...
@@ -113,6 +132,9 @@ publicLayoutCpt = R2.hooksComponent thisModule "publicLayout" cpt
-- | TODO random maps
-- | TODO random maps
, album publicDatas
, album publicDatas
]
]
where
click _ = log "click!" *> (snd backend) (const $ Just publicBackend)
*> (snd visible) (const true)
album :: Array PublicData -> R.Element
album :: Array PublicData -> R.Element
album pds = H.div {className: "album py-5 bg-light"}
album pds = H.div {className: "album py-5 bg-light"}
...
...
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