Commit c405a828 authored by Karen Konou's avatar Karen Konou

[Refactor] Move graph types to graph modules

parent 3892af4e
Pipeline #7541 passed with stages
in 22 minutes and 7 seconds
...@@ -11,11 +11,12 @@ import Gargantext.AsyncTasks as GAT ...@@ -11,11 +11,12 @@ import Gargantext.AsyncTasks as GAT
import Gargantext.Components.Bootstrap as B import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (ComponentStatus(..)) import Gargantext.Components.Bootstrap.Types (ComponentStatus(..))
import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..)) import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..))
import Gargantext.Components.Forest.Tree.Node.Action.Update.Types (BridgenessMethod(..), Charts(..), Granularity(..), GraphMetric(..), Method(..), Strength(..), UpdateNodeConfigGraph(..), UpdateNodeParams(..)) import Gargantext.Components.Forest.Tree.Node.Action.Update.Types (Charts(..), Granularity(..), Method(..), UpdateNodeParams(..), UpdateNodeConfigGraph(..))
import Gargantext.Components.Forest.Tree.Node.Tools as Tools import Gargantext.Components.Forest.Tree.Node.Tools as Tools
import Gargantext.Components.PhyloExplorer.API as Phylo import Gargantext.Components.PhyloExplorer.API as Phylo
import Gargantext.Components.PhyloExplorer.Config.ConfigForm as PhyloForm import Gargantext.Components.PhyloExplorer.Config.ConfigForm as PhyloForm
import Gargantext.Components.PhyloExplorer.ConfigFormParser as PhyloHook import Gargantext.Components.PhyloExplorer.ConfigFormParser as PhyloHook
import Gargantext.Components.GraphExplorer.Types (GraphMetric(..), Strength(..), PartitionMethod(..), BridgenessMethod(..))
import Gargantext.Config.REST (AffRESTError) import Gargantext.Config.REST (AffRESTError)
import Gargantext.Routes as GR import Gargantext.Routes as GR
import Gargantext.Sessions (Session, post) import Gargantext.Sessions (Session, post)
......
...@@ -5,6 +5,7 @@ import Gargantext.Prelude ...@@ -5,6 +5,7 @@ import Gargantext.Prelude
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Show.Generic (genericShow) import Data.Show.Generic (genericShow)
import Gargantext.Components.GraphExplorer.Types (BridgenessMethod, GraphMetric, Strength)
import Gargantext.Components.PhyloExplorer.API as Phylo import Gargantext.Components.PhyloExplorer.API as Phylo
import Gargantext.Types as GT import Gargantext.Types as GT
import Simple.JSON as JSON import Simple.JSON as JSON
...@@ -105,63 +106,6 @@ instance Read Method where ...@@ -105,63 +106,6 @@ instance Read Method where
read "WithModel" = Just WithModel read "WithModel" = Just WithModel
read _ = Nothing read _ = Nothing
----------------------------------------------------------------------
data GraphMetric = Order1 | Order2
derive instance Generic GraphMetric _
derive instance Eq GraphMetric
instance Show GraphMetric where
show = genericShow
instance Read GraphMetric where
read "Order1" = Just Order1
read "Order2" = Just Order2
read _ = Nothing
instance JSON.ReadForeign GraphMetric where
readImpl = JSONG.enumSumRep
instance JSON.WriteForeign GraphMetric where
writeImpl = JSON.writeImpl <<< show
data Strength = Strong | Weak
derive instance Generic Strength _
derive instance Eq Strength
instance Show Strength where
show = genericShow
instance Read Strength where
read "Strong" = Just Strong
read "Weak" = Just Weak
read _ = Nothing
instance JSON.ReadForeign Strength where
readImpl = JSONG.enumSumRep
instance JSON.WriteForeign Strength where
writeImpl = JSON.writeImpl <<< show
data BridgenessMethod
= BridgenessBasic
| BridgenessAdvanced
derive instance Generic BridgenessMethod _
derive instance Eq BridgenessMethod
instance Show BridgenessMethod where
show = genericShow
instance Read BridgenessMethod where
read "BridgenessBasic" = Just BridgenessBasic
read "BridgenessAdvanced" = Just BridgenessAdvanced
read _ = Nothing
instance JSON.ReadForeign BridgenessMethod where
readImpl = JSONG.enumSumRep
instance JSON.WriteForeign BridgenessMethod where
writeImpl = JSON.writeImpl <<< show
---------------------------------------------------------------------- ----------------------------------------------------------------------
data Granularity = NewNgrams | NewTexts | Both data Granularity = NewNgrams | NewTexts | Both
......
...@@ -29,6 +29,7 @@ import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), Variant(..)) ...@@ -29,6 +29,7 @@ import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), Variant(..))
import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadArbitraryData) import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadArbitraryData)
import Gargantext.Components.Forest.Tree.Node.Action.Upload.Types (FileFormat(..)) import Gargantext.Components.Forest.Tree.Node.Action.Upload.Types (FileFormat(..))
import Gargantext.Components.GraphExplorer.API (cloneGraph) import Gargantext.Components.GraphExplorer.API (cloneGraph)
import Gargantext.Components.GraphExplorer.Types (GraphMetric(..))
import Gargantext.Components.GraphExplorer.Types as GET import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Components.GraphExplorer.Utils as GEU import Gargantext.Components.GraphExplorer.Utils as GEU
import Gargantext.Data.Louvain as DLouvain import Gargantext.Data.Louvain as DLouvain
...@@ -235,9 +236,12 @@ louvainButtonCpt = here.component "louvainButton" cpt ...@@ -235,9 +236,12 @@ louvainButtonCpt = here.component "louvainButton" cpt
{ corpusId: [] { corpusId: []
, legend: legend' , legend: legend'
, list: { listId: 0, version: 0 } , list: { listId: 0, version: 0 }
, metric: "Order1" , metric: Order1
, startForceAtlas: true , startForceAtlas: true
, title: "" , title: ""
, edgesStrength: Nothing
, partitionMethod: Nothing
, bridgenessMethod: Nothing
} }
T.write_ mMetaData'' mMetaData T.write_ mMetaData'' mMetaData
T.write_ lgraph transformedGraph T.write_ lgraph transformedGraph
......
module Gargantext.Components.GraphExplorer.Types where module Gargantext.Components.GraphExplorer.Types where
import Gargantext.Components.GraphExplorer.GraphTypes
import Gargantext.Prelude
import Data.Array ((!!), length) import Data.Array ((!!), length)
import Data.Eq.Generic (genericEq) import Data.Eq.Generic (genericEq)
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
...@@ -7,12 +10,11 @@ import Data.Maybe (Maybe(..), fromJust) ...@@ -7,12 +10,11 @@ import Data.Maybe (Maybe(..), fromJust)
import Data.Newtype (class Newtype) import Data.Newtype (class Newtype)
import Data.Ord.Generic (genericCompare) import Data.Ord.Generic (genericCompare)
import Data.Show.Generic (genericShow) import Data.Show.Generic (genericShow)
import Gargantext.Components.GraphExplorer.GraphTypes
import Gargantext.Hooks.Sigmax.Camera (Camera) import Gargantext.Hooks.Sigmax.Camera (Camera)
import Gargantext.Prelude
import Partial.Unsafe (unsafePartial) import Partial.Unsafe (unsafePartial)
import Record as Record import Record as Record
import Simple.JSON as JSON import Simple.JSON as JSON
import Simple.JSON.Generics as JSONG
type GraphId = Int type GraphId = Int
...@@ -94,9 +96,12 @@ newtype MetaData = MetaData ...@@ -94,9 +96,12 @@ newtype MetaData = MetaData
{ listId :: ListId { listId :: ListId
, version :: Version , version :: Version
} }
, metric :: String -- dummy value , metric :: GraphMetric -- dummy value
, startForceAtlas :: Boolean , startForceAtlas :: Boolean
, title :: String , title :: String
, edgesStrength :: Maybe Strength
, partitionMethod :: Maybe PartitionMethod
, bridgenessMethod :: Maybe BridgenessMethod
} }
derive instance Generic MetaData _ derive instance Generic MetaData _
...@@ -147,12 +152,92 @@ initialGraphData = GraphData ...@@ -147,12 +152,92 @@ initialGraphData = GraphData
{ corpusId: [] { corpusId: []
, legend: [] , legend: []
, list: { listId: 0, version: 0 } , list: { listId: 0, version: 0 }
, metric: "Order1" , metric: Order1
, startForceAtlas: true , startForceAtlas: true
, title: "" , title: ""
, edgesStrength: Nothing
, partitionMethod: Nothing
, bridgenessMethod: Nothing
} }
} }
----------------------------------------------------------------------
data GraphMetric = Order1 | Order2
derive instance Generic GraphMetric _
derive instance Eq GraphMetric
instance Show GraphMetric where
show = genericShow
instance Read GraphMetric where
read "Order1" = Just Order1
read "Order2" = Just Order2
read _ = Nothing
instance JSON.ReadForeign GraphMetric where
readImpl = JSONG.enumSumRep
instance JSON.WriteForeign GraphMetric where
writeImpl = JSON.writeImpl <<< show
data Strength = Strong | Weak
derive instance Generic Strength _
derive instance Eq Strength
instance Show Strength where
show = genericShow
instance Read Strength where
read "Strong" = Just Strong
read "Weak" = Just Weak
read _ = Nothing
instance JSON.ReadForeign Strength where
readImpl = JSONG.enumSumRep
instance JSON.WriteForeign Strength where
writeImpl = JSON.writeImpl <<< show
data PartitionMethod = Spinglass | Infomap | Confluence
derive instance Generic PartitionMethod _
derive instance Eq PartitionMethod
instance Show PartitionMethod where
show = genericShow
instance Read PartitionMethod where
read "Spinglass" = Just Spinglass
read "Confluence" = Just Confluence
read "Infomap" = Just Infomap
read _ = Nothing
instance JSON.ReadForeign PartitionMethod where
readImpl = JSONG.enumSumRep
instance JSON.WriteForeign PartitionMethod where
writeImpl = JSON.writeImpl <<< show
data BridgenessMethod
= BridgenessBasic
| BridgenessAdvanced
derive instance Generic BridgenessMethod _
derive instance Eq BridgenessMethod
instance Show BridgenessMethod where
show = genericShow
instance Read BridgenessMethod where
read "BridgenessBasic" = Just BridgenessBasic
read "BridgenessAdvanced" = Just BridgenessAdvanced
read _ = Nothing
instance JSON.ReadForeign BridgenessMethod where
readImpl = JSONG.enumSumRep
instance JSON.WriteForeign BridgenessMethod where
writeImpl = JSON.writeImpl <<< show
----------------------------------------------------------------------
newtype Legend = Legend { id_ :: Int, color :: String, label :: String } newtype Legend = Legend { id_ :: Int, color :: String, label :: String }
derive instance Generic Legend _ derive instance Generic Legend _
......
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