Commit 8f3db1e3 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch '219-memiescape-rc1.x' of...

Merge branch '219-memiescape-rc1.x' of ssh://gitlab.iscpif.fr:20022/gargantext/purescript-gargantext into dev-merge
parents c9eee335 3b6bb6fe
...@@ -55,8 +55,8 @@ fetchPhyloJSON :: Aff (Either String PhyloDataSet) ...@@ -55,8 +55,8 @@ fetchPhyloJSON :: Aff (Either String PhyloDataSet)
fetchPhyloJSON = fetchPhyloJSON =
let let
-- @WIP remove dumb data -- @WIP remove dumb data
url = "http://localhost:5000/js/knowledge-phylomemy.json" -- url = "http://localhost:5000/js/knowledge-phylomemy.json"
-- url = "http://localhost:5000/js/vaccines_countries_06_2021.json" url = "http://localhost:5000/js/vaccines_countries_06_2021.json"
request = AX.defaultRequest request = AX.defaultRequest
{ url = url { url = url
, method = Left GET , method = Left GET
......
...@@ -77,7 +77,9 @@ data RawObject ...@@ -77,7 +77,9 @@ data RawObject
, lbl :: String , lbl :: String
, penwidth :: String , penwidth :: String
, role :: String , role :: String
, seaLvl :: String -- @WIP: not in API; but present in certain data (eg. "Knowledge
-- visualisation")
, seaLvl :: Maybe String
, source :: String , source :: String
, strFrom :: Maybe String , strFrom :: Maybe String
, strTo :: Maybe String , strTo :: Maybe String
......
...@@ -5,14 +5,15 @@ module Gargantext.Components.PhyloExplorer.Layout ...@@ -5,14 +5,15 @@ module Gargantext.Components.PhyloExplorer.Layout
import Gargantext.Prelude import Gargantext.Prelude
import DOM.Simple (document, window) import DOM.Simple (document, window)
import Data.Array as Array import Data.Tuple.Nested ((/\))
import Gargantext.Components.PhyloExplorer.Draw (drawPhylo, highlightSource, setGlobalD3Reference, setGlobalDependencies, unhide) import Gargantext.Components.PhyloExplorer.Draw (drawPhylo, highlightSource, setGlobalD3Reference, setGlobalDependencies, unhide)
import Gargantext.Components.PhyloExplorer.Types (PhyloDataSet(..)) import Gargantext.Components.PhyloExplorer.Types (PhyloDataSet(..), Source(..), sortSources)
import Gargantext.Utils (nbsp) import Gargantext.Utils (nbsp)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Graphics.D3.Base (d3) import Graphics.D3.Base (d3)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.PhyloExplorer" here = R2.here "Gargantext.Components.PhyloExplorer"
...@@ -28,7 +29,10 @@ layoutCpt = here.component "layout" cpt where ...@@ -28,7 +29,10 @@ layoutCpt = here.component "layout" cpt where
cpt { phyloDataSet: (PhyloDataSet o) cpt { phyloDataSet: (PhyloDataSet o)
} _ = do } _ = do
-- States -- States
sources /\ sourcesBox <- R2.useBox' (mempty :: Array Source)
R.useEffectOnce' $ do R.useEffectOnce' $ do
(sortSources >>> flip T.write_ sourcesBox) o.sources
unhide document o.name unhide document o.name
setGlobalD3Reference window d3 setGlobalD3Reference window d3
setGlobalDependencies window (PhyloDataSet o) setGlobalDependencies window (PhyloDataSet o)
...@@ -108,11 +112,11 @@ layoutCpt = here.component "layout" cpt where ...@@ -108,11 +112,11 @@ layoutCpt = here.component "layout" cpt where
[ H.text "unselect source ✕" ] [ H.text "unselect source ✕" ]
] ]
<> <>
flip Array.mapWithIndex o.sources flip map sources
( \idx val -> ( \(Source { id, label }) ->
H.option H.option
{ value: idx } { value: id }
[ H.text val ] [ H.text label ]
) )
, ,
......
module Gargantext.Components.PhyloExplorer.Types module Gargantext.Components.PhyloExplorer.Types
( PhyloDataSet(..) ( PhyloDataSet(..)
, parsePhyloJSONSet
, Branch(..), Period(..), Group(..) , Branch(..), Period(..), Group(..)
, Link(..), AncestorLink(..), BranchLink(..) , Link(..), AncestorLink(..), BranchLink(..)
, GlobalTerm(..) , GlobalTerm(..)
, parsePhyloJSONSet , Source(..)
, sortSources
) where ) where
import Gargantext.Prelude import Gargantext.Prelude
...@@ -61,7 +63,8 @@ parsePhyloJSONSet (PhyloJSONSet o) = PhyloDataSet ...@@ -61,7 +63,8 @@ parsePhyloJSONSet (PhyloJSONSet o) = PhyloDataSet
, links , links
, name : o.name , name : o.name
, nbBranches : parseInt o.phyloBranches , nbBranches : parseInt o.phyloBranches
, nbDocs : parseInt o.phyloDocs -- @WIP remotely stringify as a Double instead of an Int (?)
, nbDocs : (parseFloat >>> parseInt') o.phyloDocs
, nbFoundations : parseInt o.phyloFoundations , nbFoundations : parseInt o.phyloFoundations
, nbGroups : parseInt o.phyloGroups , nbGroups : parseInt o.phyloGroups
, nbPeriods : parseInt o.phyloPeriods , nbPeriods : parseInt o.phyloPeriods
...@@ -217,7 +220,7 @@ parseLinks ...@@ -217,7 +220,7 @@ parseLinks
, label : "" , label : ""
, to : o.head , to : o.head
} }
parse _ = Nothing parse _ = Nothing
----------------------------------------------------------- -----------------------------------------------------------
...@@ -252,7 +255,7 @@ parseAncestorLinks ...@@ -252,7 +255,7 @@ parseAncestorLinks
, label : "" , label : ""
, to : o.head , to : o.head
} }
parse _ = Nothing parse _ = Nothing
----------------------------------------------------------- -----------------------------------------------------------
...@@ -276,14 +279,14 @@ parseBranchLinks ...@@ -276,14 +279,14 @@ parseBranchLinks
-- bc. BranchToGroup as 1-1 relation with "edgeType=branchLink" -- bc. BranchToGroup as 1-1 relation with "edgeType=branchLink"
filter :: RawEdge -> Boolean filter :: RawEdge -> Boolean
filter (BranchToGroup o) = o.edgeType == "branchLink" filter (BranchToGroup o) = o.edgeType == "branchLink"
filter _ = false filter _ = false
parse :: RawEdge -> Maybe BranchLink parse :: RawEdge -> Maybe BranchLink
parse (BranchToGroup o) = Just $ BranchLink parse (BranchToGroup o) = Just $ BranchLink
{ from : o.tail { from : o.tail
, to : o.head , to : o.head
} }
parse _ = Nothing parse _ = Nothing
----------------------------------------------------------- -----------------------------------------------------------
...@@ -296,6 +299,40 @@ derive instance Generic GlobalTerm _ ...@@ -296,6 +299,40 @@ derive instance Generic GlobalTerm _
derive instance Eq GlobalTerm derive instance Eq GlobalTerm
instance Show GlobalTerm where show = genericShow instance Show GlobalTerm where show = genericShow
-----------------------------------------------------------
newtype Source = Source
{ label :: String
, id :: Int
}
derive instance Generic Source _
derive instance Eq Source
instance Show Source where show = genericShow
parseSources :: String -> Array String
parseSources
= String.replaceAll (String.Pattern "[") (String.Replacement "")
>>> String.replaceAll (String.Pattern "]") (String.Replacement "")
>>> String.replaceAll (String.Pattern "\"") (String.Replacement "")
>>> String.split (String.Pattern ",")
>>> Array.filter (\s -> not eq 0 $ String.length s)
-- @WIP: as some "Draw.js" business's methods still use `source` as an unsorted
-- `Array String`, we have to dissociate the parsing and sorting
-- computation (hence this second method to use for sorting purposes)
sortSources :: Array String -> Array Source
sortSources
= Array.mapWithIndex setSource
>>> Array.sortWith getLabel
where
setSource :: Int -> String -> Source
setSource id label = Source { id, label }
getLabel :: Source -> String
getLabel (Source { label }) = label
----------------------------------------------------------- -----------------------------------------------------------
...@@ -308,15 +345,6 @@ parseInt' n = maybe 0 identity $ Int.fromNumber n ...@@ -308,15 +345,6 @@ parseInt' n = maybe 0 identity $ Int.fromNumber n
parseFloat :: String -> Number parseFloat :: String -> Number
parseFloat s = maybe 0.0 identity $ Number.fromString s parseFloat s = maybe 0.0 identity $ Number.fromString s
parseSources :: String -> Array String
parseSources
= String.replace (String.Pattern "[") (String.Replacement "")
>>> String.replace (String.Pattern "]") (String.Replacement "")
>>> String.split (String.Pattern ",")
>>> Array.filter (\s -> not eq 0 $ String.length s)
>>> Array.sort
parseBB :: String -> Array Number parseBB :: String -> Array Number
parseBB parseBB
= String.split (String.Pattern ",") = String.split (String.Pattern ",")
......
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