Commit a1226e38 authored by aelamrani's avatar aelamrani

filtered & begin d3/graph

parent 80b8d4be
...@@ -11,7 +11,7 @@ import Data.Nullable (toMaybe) ...@@ -11,7 +11,7 @@ import Data.Nullable (toMaybe)
import Effect (Effect) import Effect (Effect)
import FFI.Simple ((...), delay, args2) import FFI.Simple ((...), delay, args2)
import Phylo.Graph (phyloR, timelineR, wordcloudR) import Phylo.Graph (phyloR, timelineR, wordcloudR)
import Phylo.Infos (infoCorpusR) import Phylo.Infos (infoCorpusR,infoPhyloR)
import Phylo.Isoline (isolineR) import Phylo.Isoline (isolineR)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
...@@ -23,5 +23,5 @@ app = R.createElement appCpt ...@@ -23,5 +23,5 @@ app = R.createElement appCpt
appCpt :: R.Component() appCpt :: R.Component()
appCpt = R.hooksComponent "app" cpt where appCpt = R.hooksComponent "app" cpt where
cpt _ _ = do cpt _ _ = do
pure $ H.div {className:"mèmiscape"} [infoCorpusR, timelineR,isolineR, wordcloudR, phyloR] pure $ H.div {className:"mèmiscape"} [infoCorpusR,infoPhyloR, timelineR,isolineR, wordcloudR, phyloR]
...@@ -20,32 +20,33 @@ import Reactix as R ...@@ -20,32 +20,33 @@ import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Toestand as T import Toestand as T
-- type InfoPhylo =
-- ( nbTerms :: Int
-- , nbGroups :: Int
-- , nbBranches :: Int
-- )
type Props = () type Props = ()
infoCorpusR :: R.Element infoCorpusR :: R.Element
infoCorpusR = infoCorpus {} infoCorpusR = infoCorpus {}
-- infoPhyloR :: R.Element infoPhyloR :: R.Element
-- infoPhyloR = infoPhylo {nbTerms : 0 infoPhyloR = infoPhylo {}
-- ,nbGroups : 0
-- ,nbBranches : 0}
--
-- infoPhylo :: Record InfoPhylo -> R.Element
-- infoPhylo props = R.createElement infoPhyloCpt props []
--
-- 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"]]
infoCorpus :: Record Props -> R.Element --infoPhyloCpt :: R.Component Props
infoCorpus props = R.createElement infoCorpusCpt props [] --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"]]
infoPhyloCpt :: R.Component Props
infoPhyloCpt = 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 $ infoPhyloLoaded { fetched } []
--infoCorpusCpt :: R.Component InfoCorpus --infoCorpusCpt :: R.Component InfoCorpus
--infoCorpusCpt = R.hooksComponent "infoCorpus" cpt where --infoCorpusCpt = R.hooksComponent "infoCorpus" cpt where
...@@ -53,6 +54,12 @@ infoCorpus props = R.createElement infoCorpusCpt props [] ...@@ -53,6 +54,12 @@ infoCorpus props = R.createElement infoCorpusCpt props []
-- pure $ H.div {className:"phyloCorpus"} [H.text "Here lies Corpus-info", -- pure $ H.div {className:"phyloCorpus"} [H.text "Here lies Corpus-info",
-- H.div {className:"phyloCorpus-info"}[H.text $ "Corpus Info here"] -- H.div {className:"phyloCorpus-info"}[H.text $ "Corpus Info here"]
infoCorpus :: Record Props -> R.Element
infoCorpus props = R.createElement infoCorpusCpt props []
infoPhylo :: Record Props -> R.Element
infoPhylo props = R.createElement infoPhyloCpt props []
type InfoCorpusLoaded = type InfoCorpusLoaded =
( fetched :: T.Box (Maybe PTE.PhyloJSON) ) ( fetched :: T.Box (Maybe PTE.PhyloJSON) )
...@@ -73,6 +80,9 @@ infoCorpusCpt = R.hooksComponent "infoCorpus" cpt where ...@@ -73,6 +80,9 @@ infoCorpusCpt = R.hooksComponent "infoCorpus" cpt where
infoCorpusLoaded :: Record InfoCorpusLoaded -> Array R.Element -> R.Element infoCorpusLoaded :: Record InfoCorpusLoaded -> Array R.Element -> R.Element
infoCorpusLoaded = R.createElement infoCorpusLoadedCpt infoCorpusLoaded = R.createElement infoCorpusLoadedCpt
infoPhyloLoaded :: Record InfoCorpusLoaded -> Array R.Element -> R.Element
infoPhyloLoaded = R.createElement infoPhyloLoadedCpt
infoCorpusLoadedCpt :: R.Component InfoCorpusLoaded infoCorpusLoadedCpt :: R.Component InfoCorpusLoaded
infoCorpusLoadedCpt = R.hooksComponent "infoCorpusLoaded" cpt where infoCorpusLoadedCpt = R.hooksComponent "infoCorpusLoaded" cpt where
cpt { fetched } _ = do cpt { fetched } _ = do
...@@ -82,10 +92,22 @@ infoCorpusLoadedCpt = R.hooksComponent "infoCorpusLoaded" cpt where ...@@ -82,10 +92,22 @@ infoCorpusLoadedCpt = R.hooksComponent "infoCorpusLoaded" cpt where
Nothing -> pure $ H.div {}[] Nothing -> pure $ H.div {}[]
Just mr -> pure $ H.div {className:"phyloCorpus"} Just mr -> pure $ H.div {className:"phyloCorpus"}
[H.text "Corpus", [H.text "Corpus",
H.div {className:"phyloCorpus-info"}[H.span {}[H.text $ mr.phyloDocs <> " docs"], H.div {className:"phyloInfos-info"}[H.span {}[H.text $ mr.phyloDocs <> " docs"],
H.span {}[H.text $ mr.phyloFoundations <> " foundations"], H.span {}[H.text $ mr.phyloFoundations <> " foundations"],
H.span {}[H.text $ mr.phyloPeriods <> " periods"]]] H.span {}[H.text $ mr.phyloPeriods <> " periods"]]]
infoPhyloLoadedCpt :: R.Component InfoCorpusLoaded
infoPhyloLoadedCpt = 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:"phyloInfos"}
[H.text "Phylo",
H.div {className:"phyloCorpus-info"}[H.span {}[H.text $ mr.phyloTerms <> " Termes"],
H.span {}[H.text $ mr.phyloBranches <> " Branches"],
H.span {}[H.text $ mr.phyloGroups <> " Groupes"]]]
--getPhyloName = --getPhyloName =
-- launchAff_ $ do -- launchAff_ $ do
-- mr <- PTE.fetchPhyloJSON -- mr <- PTE.fetchPhyloJSON
......
...@@ -14,6 +14,7 @@ import Data.Maybe (Maybe(..), fromMaybe, maybe) ...@@ -14,6 +14,7 @@ import Data.Maybe (Maybe(..), fromMaybe, maybe)
import Effect (Effect) import Effect (Effect)
import Effect.Aff (Aff, launchAff, launchAff_) import Effect.Aff (Aff, launchAff, launchAff_)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Effect.Class.Console (logShow)
import Simple.JSON as JSON import Simple.JSON as JSON
type PhyloJSON = type PhyloJSON =
...@@ -61,13 +62,17 @@ type PhyloJSON = ...@@ -61,13 +62,17 @@ type PhyloJSON =
derive instance Generic PhyloObject _ derive instance Generic PhyloObject _
instance Eq PhyloObject where eq = genericEq instance Eq PhyloObject where eq = genericEq
instance showPhyloObject :: Show PhyloObject where
show (PhyloBranch {nodeType}) = nodeType
show (PhyloGroup {nodeType}) = nodeType
show (PhyloPeriod {nodeType}) = nodeType
show (Default {_gvid}) = "DefaultNode"
data PhyloObject = PhyloBranch data PhyloObject = PhyloBranch
{ _gvid :: Int { _gvid :: Int
, bId :: String
, nodeType :: String , nodeType :: String
} | PhyloGroup } | PhyloGroup
{ _gvid :: Int { _gvid :: Int
, bId :: String
, nodeType :: String , nodeType :: String
} | PhyloPeriod } | PhyloPeriod
{ _gvid :: Int { _gvid :: Int
...@@ -77,25 +82,33 @@ data PhyloObject = PhyloBranch ...@@ -77,25 +82,33 @@ data PhyloObject = PhyloBranch
_gvid :: Int _gvid :: Int
} }
isolate :: PhyloObject -> String -> PhyloObject --instance JSON.ReadForeign PhyloObject where
isolate obj s = case s of -- readImpl f = do
"branch" -> -- { _gvid, nodeType: mNodeType } :: { _gvid :: Int, nodeType :: Maybe String } <- JSON.readImpl f
-- case mNodeType of
-- Nothing -> pure $ Default { _gvid }
-- Just nodeType -> do
-- { bId: mBId } :: { bId :: Maybe String } <- JSON.readImpl f
-- case mBId of
-- Nothing -> pure $ Default { _gvid }
-- Just bId ->
-- case nodeType of
-- "branch" -> pure $ PhyloBranch { _gvid, bId, nodeType }
-- "group" -> pure $ PhyloGroup { _gvid, bId, nodeType }
-- "period" -> pure $ PhyloPeriod { _gvid, nodeType }
-- _ -> pure $ Default { _gvid }
instance JSON.ReadForeign PhyloObject where instance JSON.ReadForeign PhyloObject where
readImpl f = do readImpl f = do
{ _gvid, nodeType: mNodeType } :: { _gvid :: Int, nodeType :: Maybe String } <- JSON.readImpl f { _gvid, nodeType: mNodeType} :: { _gvid :: Int, nodeType :: Maybe String } <- JSON.readImpl f
case mNodeType of case mNodeType of
Nothing -> pure $ Default { _gvid } Nothing -> pure $ Default { _gvid }
Just nodeType -> do Just nodeType ->
{ bId: mBId } :: { bId :: Maybe String } <- JSON.readImpl f case nodeType of
case mBId of "branch" -> pure $ PhyloBranch { _gvid, nodeType }
Nothing -> pure $ Default { _gvid } "group" -> pure $ PhyloGroup { _gvid, nodeType }
Just bId -> "period" -> pure $ PhyloPeriod { _gvid, nodeType }
case nodeType of _ -> pure $ Default { _gvid }
"branch" -> pure $ PhyloBranch { _gvid, bId, nodeType }
"group" -> pure $ PhyloGroup { _gvid, bId, nodeType }
"period" -> pure $ PhyloPeriod { _gvid, nodeType }
_ -> pure $ Default { _gvid }
derive instance Generic PhyloEdge _ derive instance Generic PhyloEdge _
instance Eq PhyloEdge where eq = genericEq instance Eq PhyloEdge where eq = genericEq
...@@ -139,27 +152,27 @@ instance JSON.ReadForeign PhyloEdge where ...@@ -139,27 +152,27 @@ instance JSON.ReadForeign PhyloEdge where
, edgeType } , edgeType }
_ -> pure $ DefaultLink { _gvid } _ -> pure $ DefaultLink { _gvid }
newtype PhyloData = PhyloData --newtype PhyloData = PhyloData
{ name :: String -- { name :: String
, phyloDocs :: Int -- , phyloDocs :: Int
, phyloFoundations :: Int -- , phyloFoundations :: Int
, phyloPeriods :: Int -- , phyloPeriods :: Int
, phyloTerms :: Int -- , phyloTerms :: Int
, phyloGroups :: Int -- , phyloGroups :: Int
, phyloBranches :: Int -- , phyloBranches :: Int
, phyloOBranches :: Array PhyloObject -- , phyloOBranches :: Array PhyloObject
, phyloOGroups :: Array PhyloObject -- , phyloOGroups :: Array PhyloObject
, phyloOPeriods :: Array PhyloObject -- , phyloOPeriods :: Array PhyloObject
, phyloOLinks :: Array PhyloEdge -- , phyloOLinks :: Array PhyloEdge
, phyloOAncestorLinks :: Array PhyloEdge -- , phyloOAncestorLinks :: Array PhyloEdge
, phyloOBrancheLinks :: Array PhyloEdge -- , phyloOBrancheLinks :: Array PhyloEdge
} -- }
--
--
type PhyloConfig = --type PhyloConfig =
{ -- {
--
} -- }
-- getBranch :: -- getBranch ::
-- type PhyloObjects = -- type PhyloObjects =
-- { _gvid :: Int -- { _gvid :: Int
...@@ -220,13 +233,38 @@ fetchPhyloJSON = do ...@@ -220,13 +233,38 @@ fetchPhyloJSON = do
pure Nothing pure Nothing
Right (r :: PhyloJSON) -> do Right (r :: PhyloJSON) -> do
log $ "name of phylo is : " <> show r.name log $ "name of phylo is : " <> show r.name
log $ getBranches r.objects
log $ getGroups r.objects
log $ getPeriods r.objects
pure $ Just r pure $ Just r
-- phylo :: PhyloJSON -> PhyloJSON isBranch :: PhyloObject -> Boolean
isBranch (PhyloBranch _) = true
isBranch _ = false
getBranches :: Array PhyloObject -> Array PhyloObject
getBranches x = filter isBranch x
isGroup :: PhyloObject -> Boolean
isGroup (PhyloGroup _) = true
isGroup _ = false
getGroups :: Array PhyloObject -> Array PhyloObject
getGroups x = filter isGroup x
isPeriod :: PhyloObject -> Boolean
isPeriod (PhyloPeriod _) = true
isPeriod _ = false
getPeriods :: Array PhyloObject -> Array PhyloObject
getPeriods x = filter isPeriod x
isBranch' :: String -> Boolean
isBranch' "branch" = true
isBranch' _ = false
doStuff = do getBranches' :: Array PhyloObject -> Array PhyloObject
mPhy <- fetchPhyloJSON getBranches' x = filter (isBranch) x
pure $ maybe mPhy
-- fetchmyJSON = do -- fetchmyJSON = do
-- result <- AX.request (AX.defaultRequest { url = "http://localhost:5501/data/myJSON.json", method = Left GET, -- responseFormat = ResponseFormat.string }) -- result <- AX.request (AX.defaultRequest { url = "http://localhost:5501/data/myJSON.json", method = Left GET, -- responseFormat = ResponseFormat.string })
......
...@@ -22,15 +22,15 @@ $white: #ffffff ...@@ -22,15 +22,15 @@ $white: #ffffff
color: $black color: $black
.phyloCorpus .phyloCorpus
grid-row: 1 / 2 grid-row: 1 / 4
grid-column: 1 / 4 grid-column: 1 / 2
display: flex display: flex
align-items: center align-items: center
justify-content: center justify-content: center
background-color: $testcolor3 background-color: $testcolor3
.phyloInfos .phyloInfos
grid-row: 1 grid-row: 1 / 4
grid-column: 3 / 4 grid-column: 3 / 4
font-size: 14px font-size: 14px
display: flex display: flex
...@@ -46,7 +46,7 @@ $white: #ffffff ...@@ -46,7 +46,7 @@ $white: #ffffff
background-color: $testcolor4 background-color: $testcolor4
.phyloInfos-info .phyloInfos-info
grid-row: 2 / 4 grid-row: 1 / 4
grid-column: 6 / 8 grid-column: 6 / 8
font-size: 14px font-size: 14px
display: flex display: flex
......
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