Commit 308c0a8f authored by arturo's avatar arturo

>>> BEGIN 219

parent 0b5b7644
...@@ -206,6 +206,26 @@ let additions = ...@@ -206,6 +206,26 @@ let additions =
, repo = "https://github.com/natefaubion/purescript-convertable-options" , repo = "https://github.com/natefaubion/purescript-convertable-options"
, version = "v1.0.0" , version = "v1.0.0"
} }
, d3 =
{ dependencies =
[ "aff"
, "aff-promise"
, "dom-simple"
, "easy-ffi"
, "effect"
, "exceptions"
, "foreign"
, "functions"
, "js-date"
, "maybe"
, "prelude"
, "psci-support"
, "tuples"
, "web-dom"
]
, repo = "https://github.com/cgenie/purescript-d3"
, version = "v0.9.1"
}
} }
in upstream // overrides // additions in upstream // overrides // additions
...@@ -26,6 +26,7 @@ to generate this file without the comments in this block. ...@@ -26,6 +26,7 @@ to generate this file without the comments in this block.
, "control" , "control"
, "convertable-options" , "convertable-options"
, "css" , "css"
, "d3"
, "datetime" , "datetime"
, "dom-filereader" , "dom-filereader"
, "dom-simple" , "dom-simple"
......
module Gargantext.Components.Nodes.Corpus.Phylo where module Gargantext.Components.Nodes.Corpus.Phylo
( phyloLayout
) where
import Gargantext.Prelude import Gargantext.Prelude
( pure, ($) )
-- import Gargantext.Utils.Toestand as T2 import Affjax (Error)
-- import Toestand as T import Affjax as AX
import Affjax.ResponseFormat as ResponseFormat
import DOM.Simple.Console (log2)
import Data.Either (Either(..))
import Data.HTTP.Method (Method(..))
import Data.List.Types (NonEmptyList)
import Data.Maybe (Maybe(..))
import Effect.Aff (Aff, launchAff_, throwError)
import Effect.Class (liftEffect)
import Foreign (ForeignError)
import Gargantext.Components.PhyloExplorer.Types (PhyloDataSet)
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (NodeID) import Gargantext.Types (NodeID)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Simple.JSON (class ReadForeign)
import Simple.JSON as JSON
import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Corpus.Phylo" here = R2.here "Gargantext.Components.Nodes.Corpus.Phylo"
type Props = ( nodeId :: NodeID, session :: Session ) type Props =
( nodeId :: NodeID
, session :: Session
)
phyloLayout :: R2.Component Props phyloLayout :: R2.Component Props
phyloLayout = R.createElement phyloLayoutCpt phyloLayout = R.createElement phyloLayoutCpt
phyloLayoutCpt :: R.Component Props phyloLayoutCpt :: R.Component Props
phyloLayoutCpt = here.component "phyloLayout" cpt where phyloLayoutCpt = here.component "phyloLayout" cpt where
cpt { nodeId, session } content = do cpt _ _ = do
pure $ H.h1 {} [ H.text "Hello Phylo" ]
isFetchedBox <- T.useBox false
isFetched <- T.useLive T.unequal isFetchedBox
R.useEffect' $ launchAff_ $ fetchPhyloJSON
pure $
H.div
{ className: "page-phylo" }
[
H.h1 {} [ H.text "hello" ]
-- ,
-- infoCorpusR
-- ,
-- infoPhyloR
-- ,
-- timelineR
-- ,
-- isolineR
-- ,
-- wordcloudR
-- ,
-- phyloR
]
-- fetchPhyloJSON :: forall res. Aff (Either Error res)
fetchPhyloJSON :: ReadForeign PhyloDataSet => Aff Unit
fetchPhyloJSON =
let
request = AX.defaultRequest
-- @WIP remove dumb data
{ url = "http://localhost:5000/js/knowledge-phylomemy.json"
, method = Left GET
, responseFormat = ResponseFormat.string
}
in do
result <- request # AX.request
liftEffect $ case result of
Left err -> log2 "error" $ AX.printError err
Right response -> case JSON.readJSON response.body of
Left err -> log2 "error" $ show err
Right (res :: PhyloDataSet) -> log2 "success" $ show res
module Gargantext.Components.PhyloExplorer.Types where
import Gargantext.Prelude
import Prelude
import Data.Eq.Generic (genericEq)
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..))
import Data.Newtype (class Newtype)
import Data.Nullable (Nullable)
import Data.Show.Generic (genericShow)
import Simple.JSON as JSON
import Simple.JSON.Generics (enumSumRep)
import Simple.JSON.Generics as JSONG
-- // Generics
--------------------------------------------------
-- type PhyloJSON =
-- { name :: String
-- , phyloDocs :: String
-- , phyloFoundations :: String
-- , phyloPeriods :: String
-- , phyloTerms :: String
-- , phyloGroups :: String
-- , phyloBranches :: String
-- , objects :: Array PhyloObject
-- , edges :: Array PhyloEdge
-- }
newtype PhyloDataSet = PhyloDataSet
{ name :: String
, edges :: Array PhyloEdge
}
derive instance Generic PhyloDataSet _
derive instance Newtype PhyloDataSet _
instance Show PhyloDataSet where show = genericShow
derive newtype instance JSON.ReadForeign PhyloDataSet
--------------------------------------------------
-- data PhyloObject =
-- PhyloBranch
-- { _gvid :: Int
-- , bId :: String
-- , branch_x :: String
-- , branch_y :: String
-- , label :: String
-- , nodeType :: String
-- , pos :: String
-- }
-- | PhyloGroup
-- { _gvid :: Int
-- , bId :: String
-- , foundation :: String
-- , from :: String
-- , lbl :: String
-- , nodeType :: String
-- , pos :: String
-- , role :: String
-- , support :: String
-- , to :: String
-- , weight :: String
-- }
-- | PhyloPeriod
-- { _gvid :: Int
-- , nodeType :: String
-- }
-- | DefaultObject
-- { _gvid :: Int
-- }
-- derive instance Generic PhyloObject _
-- instance Eq PhyloObject where eq = genericEq
-- instance showPhyloObject :: Show PhyloObject where
-- show (PhyloBranch { nodeType }) = nodeType
-- show (PhyloGroup { nodeType }) = nodeType
-- show (PhyloPeriod { nodeType }) = nodeType
-- show (DefaultObject { _gvid }) = "DefaultNode"
--------------------------------------------------
data EdgeType = Link | BranchLink | AncestorLink | DefaultEdge
derive instance Generic EdgeType _
instance Eq EdgeType where eq = genericEq
instance Show EdgeType where show = genericShow
-- @TODO use `enumSumRep` -> input value with lowercased first char
instance JSON.ReadForeign EdgeType where
readImpl v = JSON.readImpl v >>= pure <<< case _ of
Just "link" -> Link
Just "branchLink" -> BranchLink
Just "ancestorLink" -> AncestorLink
_ -> DefaultEdge
newtype PhyloEdge = PhyloEdge
{ _gvid :: Int
, color :: String
, edgeType :: EdgeType
, head :: Int
, pos :: String
, tail :: Int
, width :: String
, arrowhead :: Maybe String
, constraint :: Maybe String
, lbl :: Maybe String
, penwidth :: Maybe String
}
derive instance Generic PhyloEdge _
derive instance Newtype PhyloEdge _
instance Show PhyloEdge where show = genericShow
derive newtype instance JSON.ReadForeign PhyloEdge
-- arrowhead: "rdot"
-- color: "black"
-- edgeType: "branchLink"
-- head: 309
-- pos: "e,63066,5862.7 62942,34687 62953,34667 62967,34640 62975,34615 63059,34351 63066,34275 63066,33998 63066,33998 63066,33998 63066,7485.5 63066,6917.8 63066,6256.7 63066,5870.9"
-- tail: 86
-- width: "3"
-- _gvid: 49
-- color: "black"
-- head: 90
-- pos: "e,64286,35436 64286,35508 64286,35489 64286,35466 64286,35446"
-- tail: 87
-- width: "5"
-- _gvid: 50
-- color: "black"
-- constraint: "true"
-- edgeType: "link"
-- head: 101
-- lbl: "1.0"
-- penwidth: "4"
-- pos: "e,22565,33307 22565,33379 22565,33358 22565,33338 22565,33317"
-- tail: 89
-- width: "3"
-- _gvid: 52
This diff is collapsed.
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