Commit f805b5c2 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] public url

parent 62014c06
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.Tuple (fst) import Data.Array as Array
import Data.Argonaut as Argonaut import Data.Argonaut as Argonaut
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow) import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.NonEmpty (head)
import Data.String (take) import Data.String (take)
import Data.Tuple (fst)
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Gargantext.Config (publicBackend) import Gargantext.Config (defaultBackends)
import Gargantext.Config.REST (get) import Gargantext.Config.REST (get)
import Gargantext.Ends (backendUrl) import Gargantext.Ends (backendUrl, Backend(..))
import Gargantext.Prelude
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude
import Gargantext.Utils.Argonaut (genericSumDecodeJson, genericSumEncodeJson) 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
import Data.Traversable (traverse)
type PublicProps = (publicDatas :: (Array PublicData) type PublicProps = (publicDatas :: (Array PublicData)
-- , session :: Session -- , session :: Session
...@@ -47,16 +49,23 @@ instance encodeJsonPublicData :: Argonaut.EncodeJson PublicData where ...@@ -47,16 +49,23 @@ instance encodeJsonPublicData :: Argonaut.EncodeJson PublicData where
encodeJson = genericSumEncodeJson encodeJson = genericSumEncodeJson
------------------------------------------------------------------------ ------------------------------------------------------------------------
type LoadData = () type LoadData = ()
type LoadProps = (reload :: Int) type LoadProps = (reload :: Int)
loadPublicData :: Record LoadProps -> Aff (Array PublicData) loadPublicData :: Record LoadProps -> Aff (Array PublicData)
loadPublicData _l = do loadPublicData _l = do
backend <- liftEffect publicBackend --backend <- liftEffect publicBackend
_ <- liftEffect (log backend) let backend = head defaultBackends
get Nothing (backendUrl backend "public") get Nothing (backendUrl backend "public")
{-
let
ok = ["local.cnrs", "devel.inshs.cnrs"]
backends = Array.filter (\(Backend {name}) -> Array.elem name ok) (toArray defaultBackends)
Array.concat <$> traverse (\backend -> get Nothing (backendUrl backend "public")) backends
-}
renderPublic :: R.Element renderPublic :: R.Element
renderPublic = R.createElement renderPublicCpt {} [] renderPublic = R.createElement renderPublicCpt {} []
...@@ -65,18 +74,6 @@ renderPublicCpt = R.hooksComponent "G.C.N.Home.Public.renderPublic" cpt ...@@ -65,18 +74,6 @@ renderPublicCpt = R.hooksComponent "G.C.N.Home.Public.renderPublic" cpt
where where
cpt {} _ = do cpt {} _ = do
reload <- R.useState' 0 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}) useLoader { reload: fst reload } loadPublicData (\pd -> publicLayout {publicDatas: pd})
......
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