Commit 28ccc767 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[PUBLIC] API connected

parent 353645de
...@@ -29,17 +29,16 @@ import Gargantext.Types (NodeType(..), AffTableResult) ...@@ -29,17 +29,16 @@ import Gargantext.Types (NodeType(..), AffTableResult)
import Gargantext.Utils.Crypto as GUC import Gargantext.Utils.Crypto as GUC
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
type Props = ( type Props =
nodeId :: Int ( nodeId :: Int
, session :: Session , session :: Session
) )
type Reload = R.State Int type Reload = R.State Int
type KeyProps = type KeyProps =
( ( key :: String
key :: String | Props
| Props
) )
corpusLayout :: Record KeyProps -> R.Element corpusLayout :: Record KeyProps -> R.Element
...@@ -54,8 +53,8 @@ corpusLayoutCpt = R.hooksComponent "G.C.N.C.corpusLayout" cpt ...@@ -54,8 +53,8 @@ corpusLayoutCpt = R.hooksComponent "G.C.N.C.corpusLayout" cpt
useLoader {nodeId, reload: fst reload, session} loadCorpusWithReload $ useLoader {nodeId, reload: fst reload, session} loadCorpusWithReload $
\corpus -> corpusLayoutView {corpus, nodeId, reload, session} \corpus -> corpusLayoutView {corpus, nodeId, reload, session}
type ViewProps = ( type ViewProps =
corpus :: NodePoly Hyperdata ( corpus :: NodePoly Hyperdata
, reload :: Reload , reload :: Reload
| Props | Props
) )
...@@ -345,8 +344,8 @@ changeCode onc (Markdown md) CE.Haskell c = onc $ Haskell $ defaultHaskell' { ha ...@@ -345,8 +344,8 @@ changeCode onc (Markdown md) CE.Haskell c = onc $ Haskell $ defaultHaskell' { ha
changeCode onc (Markdown md) CE.JSON c = onc $ Markdown $ defaultMarkdown' { text = c } changeCode onc (Markdown md) CE.JSON c = onc $ Markdown $ defaultMarkdown' { text = c }
changeCode onc (Markdown md) CE.Markdown c = onc $ Markdown $ md { text = c } changeCode onc (Markdown md) CE.Markdown c = onc $ Markdown $ md { text = c }
type LoadProps = ( type LoadProps =
nodeId :: Int ( nodeId :: Int
, session :: Session , session :: Session
) )
......
module Gargantext.Components.Nodes.Home where module Gargantext.Components.Nodes.Home where
import Data.Array (replicate)
import Data.Foldable (foldl)
import Data.Newtype (class Newtype) import Data.Newtype (class Newtype)
import Effect (Effect) import Effect (Effect)
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
import Gargantext.Components.Lang.Landing.FrFR as Fr import Gargantext.Components.Lang.Landing.FrFR as Fr
import Gargantext.Components.Nodes.Home.Public (PublicData(..), publicLayout) import Gargantext.Components.Nodes.Home.Public (renderPublic)
import Gargantext.License (license) import Gargantext.License (license)
import Gargantext.Prelude (Unit, bind, map, pure, unit, void, ($), (<>)) import Gargantext.Prelude (Unit, map, pure, unit, void, ($), (<>))
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)
...@@ -53,22 +51,11 @@ homeLayoutCpt :: R.Component ( landingData :: LandingData ) ...@@ -53,22 +51,11 @@ homeLayoutCpt :: R.Component ( landingData :: LandingData )
homeLayoutCpt = R.hooksComponent "LayoutLanding" cpt homeLayoutCpt = R.hooksComponent "LayoutLanding" cpt
where where
cpt {landingData} _ = do cpt {landingData} _ = do
pds <- R.useState' ( replicate 6 (PublicData { title: "Title"
, abstract : foldl (<>) "" $ replicate 100 "abstract "
, img: "images/Gargantextuel-212x300.jpg"
, url : "https://.."
, date: "YY/MM/DD"
, database: "database"
, author : "Author"
}
)
)
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" } [ publicLayout {publicDatas:pds} ] , H.div { className: "container1" } [ renderPublic ]
, license , license
] ]
......
module Gargantext.Components.Nodes.Home.Public where module Gargantext.Components.Nodes.Home.Public where
import Data.Tuple (fst)
import Data.Argonaut as Argonaut
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..))
import Data.NonEmpty (head)
import Data.String (take) import Data.String (take)
import Effect.Aff (Aff)
import Gargantext.Config (defaultBackends)
import Gargantext.Config.REST (get)
import Gargantext.Ends (backendUrl)
import Gargantext.Prelude import Gargantext.Prelude
import Data.Tuple.Nested ((/\)) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Utils.Argonaut (genericSumDecodeJson, genericSumEncodeJson)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
type PublicProps = (publicDatas :: R.State (Array PublicData) type PublicProps = (publicDatas :: (Array PublicData)
-- , session :: Session -- , session :: Session
) )
newtype PublicData = PublicData data PublicData = PublicData
{ title :: String { title :: String
, abstract :: String , abstract :: String
, img :: String , img :: String
...@@ -19,22 +30,70 @@ newtype PublicData = PublicData ...@@ -19,22 +30,70 @@ newtype PublicData = PublicData
, date :: String , date :: String
, database :: String , database :: String
, author :: String , author :: String
} } | NoData { nodata :: String }
derive instance eqPublicData :: Eq PublicData
derive instance genericPublicData :: Generic PublicData _
instance showPublicData :: Show PublicData where
show = genericShow
instance decodeJsonPublicData :: Argonaut.DecodeJson PublicData where
decodeJson = genericSumDecodeJson
instance encodeJsonPublicData :: Argonaut.EncodeJson PublicData where
encodeJson = genericSumEncodeJson
------------------------------------------------------------------------
type LoadData = ()
type LoadProps = (reload :: Int)
loadPublicData :: Record LoadProps -> Aff (Array PublicData)
loadPublicData _l = get Nothing (backendUrl backend "public")
where
backend = head defaultBackends
renderPublic :: R.Element
renderPublic = R.createElement renderPublicCpt {} []
renderPublicCpt :: R.Component LoadData
renderPublicCpt = R.hooksComponent "G.C.N.Home.Public.renderPublic" cpt
where
cpt {} _ = do
reload <- R.useState' 0
{-
(pds /\ setPds) :: R.State PublicProps <- R.useState' ( replicate 6 (PublicData { title: "Title"
, abstract : foldl (<>) "" $ replicate 100 "abstract "
, img: "images/Gargantextuel-212x300.jpg"
, url : "https://.."
, date: "YY/MM/DD"
, database: "database"
, author : "Author"
}
)
)
-}
useLoader { reload: fst reload } loadPublicData (\pd -> publicLayout {publicDatas: pd})
------------------------------------------------------------------------
publicLayout :: Record PublicProps -> R.Element publicLayout :: Record PublicProps -> R.Element
publicLayout props = R.createElement publicLayoutCpt props [] publicLayout props = R.createElement publicLayoutCpt props []
publicLayoutCpt :: R.Component PublicProps publicLayoutCpt :: R.Component PublicProps
publicLayoutCpt = R.staticComponent "[G.C.N.H.Public.publicLayout" cpt publicLayoutCpt = R.hooksComponent "[G.C.N.H.Public.publicLayout" cpt
where where
cpt {publicDatas} _ = cpt {publicDatas} _ = do
H.span {} pure $ H.span {}
[ H.div { className: "text-center" } [ H.div { className: "text-center" }
[ H.div { className:"container1" } [ H.div { className:"container1" }
[ H.h2 {} [H.text "Public Maps"] [ H.h2 {} [H.text "Public Maps"]
, H.p {className: "lead text-muted"} [H.text "Discover maps made with " , H.p { className: "lead text-muted"}
, H.div {className: "fa fa-heart"} []] [ H.text "Discover maps made with "
, H.div {className: "fa fa-heart"} []
]
, H.p { className:"flex-space-around" } , H.p { className:"flex-space-around" }
[ H.a { className: "btn btn-primary my-2" [ H.a { className: "btn btn-primary my-2"
, href :"https://gargantext.org" , href :"https://gargantext.org"
...@@ -44,30 +103,19 @@ publicLayoutCpt = R.staticComponent "[G.C.N.H.Public.publicLayout" cpt ...@@ -44,30 +103,19 @@ publicLayoutCpt = R.staticComponent "[G.C.N.H.Public.publicLayout" cpt
] ]
-- | TODO browse maps -- | TODO browse maps
-- | TODO random maps -- | TODO random maps
, album pds , album publicDatas
] ]
where
(pds /\ _setPublicData) = publicDatas
{-
<section class="jumbotron text-center">
<div class="container" >
<h1 class="jumbotron-heading">Gargantext Maps</h1>
<p class="lead text-muted">Discover maps made with love</p>
<p>
<a href="http://gargantext.org" target="blank" class="btn btn-primary my-2">More about Gargantext</a>
<a href="http://iscpif.fr" target="blank" class="btn btn-secondary my-2">CNRS/ISC-PIF</a>
</p>
</div>
</section>
-}
album :: Array PublicData -> R.Element album :: Array PublicData -> R.Element
album pd = H.div {className: "album py-5 bg-light"} album pds = H.div {className: "album py-5 bg-light"}
[ H.div { className: "container" } [ H.div { className: "container" }
[ H.div { className : "row" } [ H.div { className : "row" }
(map (\tab -> H.div {className : "col-md-6 content"} [tableau tab]) pd ) (map (\tab -> H.div {className : "col-md-6 content"}
] [tableau tab]
] ) pds
)
]
]
tableau :: PublicData -> R.Element tableau :: PublicData -> R.Element
...@@ -102,3 +150,4 @@ tableau (PublicData {title, abstract, img, url, date, database, author}) = ...@@ -102,3 +150,4 @@ tableau (PublicData {title, abstract, img, url, date, database, author}) =
] ]
] ]
] ]
tableau (NoData {nodata}) = H.div {className : "center"} [H.h2 {} [H.text "Create a corpus and publicize it"]]
...@@ -24,11 +24,11 @@ import Gargantext.Utils.CacheAPI as GUC ...@@ -24,11 +24,11 @@ import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
useLoader :: forall path st. Eq path => useLoader :: forall path st. Eq path
path => path
-> (path -> Aff st) -> (path -> Aff st)
-> (st -> R.Element) -> (st -> R.Element)
-> R.Hooks R.Element -> R.Hooks R.Element
useLoader path loader render = do useLoader path loader render = do
state <- R.useState' Nothing state <- R.useState' Nothing
useLoaderEffect path state loader useLoaderEffect path state loader
......
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