Commit 36b78810 authored by Ali El Amrani's avatar Ali El Amrani

[add cpt loaded]

parent 4b95229f
......@@ -5,10 +5,12 @@ import Prelude
import DOM.Simple.Console (log, log2)
import Data.Array (length)
import Data.Int (toNumber, round)
import Data.Maybe (Maybe(..), fromMaybe, maybe)
import Data.Maybe (Maybe(..), isJust, maybe)
import Data.Nullable (null, toMaybe)
import Effect.Aff (Aff, launchAff_)
import Effect (Effect)
import Effect.Aff (Aff, killFiber, launchAff, launchAff_)
import Effect.Class (liftEffect)
import Effect.Exception (error)
import FFI.Simple (delay)
import Graphics.D3.Base (D3Eff)
import Graphics.D3.Contour as Contour
......@@ -23,42 +25,18 @@ type InfoCorpus =
, nbFondations :: Int
, nbPeriods :: Int
)
--getPhyloName =
-- launchAff_ $ do
-- mr <- PTE.fetchPhyloJSON
-- liftEffect $ do
-- case mr of
-- Nothing -> log "Nothing"
-- Just r -> log2 "r" r.name
-- pure $ maybe mr.name
intToString :: Int -> String
intToString x = show x
infoCorpusR :: R.Element
infoCorpusR = infoCorpus {nbDocs : 0
,nbFondations : 0
,nbPeriods : 0}
infoCorpus :: Record InfoCorpus -> R.Element
infoCorpus props = R.createElement infoCorpusCpt props []
infoCorpusCpt :: R.Component InfoCorpus
infoCorpusCpt = R.hooksComponent "infoCorpus" cpt where
cpt { } _children = do
-- R.useEffect'
-- launchAff_ $ do
-- mr <- PTE.fetchPhyloJSON
-- liftEffect $ do
pure $ H.div {className:"phyloCorpus"} [H.text "Here lies Corpus-info",
-- H.div {className:"phyloCorpus-info"}[H.text "0"]]
H.div {className:"phyloCorpus-info"}[H.text "Infos"]]
type InfoPhylo =
( nbTerms :: Int
, nbGroups :: Int
, nbBranches :: Int
)
infoCorpusR :: R.Element
infoCorpusR = infoCorpus {nbDocs : 0
,nbFondations : 0
,nbPeriods : 0}
infoPhyloR :: R.Element
infoPhyloR = infoPhylo {nbTerms : 0
,nbGroups : 0
......@@ -71,4 +49,53 @@ infoPhyloCpt :: R.Component InfoPhylo
infoPhyloCpt = R.hooksComponent "infoPhylo" cpt where
cpt { } _children = do
pure $ H.div {className:"phyloInfos"} [H.text "Here lies Phylo-info",
H.div {className:"phyloInfos-info"}[H.text "0"]]
\ No newline at end of file
H.div {className:"phyloInfos-info"}[H.text "0"]]
infoCorpus :: Record InfoCorpus -> R.Element
infoCorpus props = R.createElement infoCorpusCpt props []
--infoCorpusCpt :: R.Component InfoCorpus
--infoCorpusCpt = R.hooksComponent "infoCorpus" cpt where
-- cpt { } _children = do
-- pure $ H.div {className:"phyloCorpus"} [H.text "Here lies Corpus-info",
-- H.div {className:"phyloCorpus-info"}[H.text $ "Corpus Info here"]
type InfoCorpusLoaded =
( fetched :: T.Box (Maybe PTE.PhyloJSON) )
infoCorpusCpt :: R.Component InfoCorpus
infoCorpusCpt = R.hooksComponent "infoCorpus" cpt where
cpt { } _children = do
fetched <- T.useBox Nothing
R.useEffect' $ do
launchAff_ $ do
mr <- PTE.fetchPhyloJSON
liftEffect $ do
case mr of
Nothing -> log "Nothing"
Just r -> T.write_ (Just r) fetched
pure $ infoCorpusLoaded { fetched } []
infoCorpusLoaded = R.createElement infoCorpusLoadedCpt
infoCorpusLoadedCpt :: R.Component InfoCorpusLoaded
infoCorpusLoadedCpt = R.hooksComponent "infoCorpusLoaded" cpt where
cpt { fetched } _ = do
fetched' <- T.useLive T.unequal fetched
case fetched' of
Nothing -> pure $ H.div {}[]
Just mr -> pure $ H.div {className:"phyloCorpus"}
[H.text "Here lies Corpus-info",
H.div {className:"phyloCorpus-info"}[H.text mr.name]]
--getPhyloName =
-- launchAff_ $ do
-- mr <- PTE.fetchPhyloJSON
-- liftEffect $ do
-- case mr of
-- Nothing -> log "Nothing"
-- Just r -> log2 "r" r.name
-- pure $ maybe mr.name
\ No newline at end of file
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