Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
128
Issues
128
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
purescript-gargantext
Commits
c237ff21
Commit
c237ff21
authored
Jul 13, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[simple-json] fix graph explorer json
parent
229f9ba3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
21 deletions
+33
-21
Types.purs
src/Gargantext/Components/GraphExplorer/Types.purs
+28
-13
Types.purs
src/Gargantext/Types.purs
+5
-8
No files found.
src/Gargantext/Components/GraphExplorer/Types.purs
View file @
c237ff21
...
...
@@ -36,6 +36,8 @@ cameraP = SProxy :: SProxy "camera"
mCameraP = SProxy :: SProxy "mCamera"
idP = SProxy :: SProxy "id"
id_P = SProxy :: SProxy "id_"
typeP = SProxy :: SProxy "type"
type_P = SProxy :: SProxy "type_"
derive instance Generic Node _
derive instance Newtype Node _
...
...
@@ -44,9 +46,17 @@ instance Ord Node where compare (Node n1) (Node n2) = compare n1.id_ n2.id_
instance JSON.ReadForeign Node where
readImpl f = do
inst <- JSON.readImpl f
pure $ Node $ Record.rename x_coordP xP $ Record.rename y_coordP yP inst
pure $ Node $
Record.rename idP id_P $
Record.rename typeP type_P $
Record.rename x_coordP xP $
Record.rename y_coordP yP inst
instance JSON.WriteForeign Node where
writeImpl (Node nd) = JSON.writeImpl $ Record.rename xP x_coordP $ Record.rename yP y_coordP nd
writeImpl (Node nd) = JSON.writeImpl $
Record.rename id_P idP $
Record.rename type_P typeP $
Record.rename xP x_coordP $
Record.rename yP y_coordP nd
newtype Cluster = Cluster { clustDefault :: Int }
...
...
@@ -110,15 +120,16 @@ instance JSON.ReadForeign GraphData where
readImpl f = do
inst :: { nodes :: Array Node
, edges :: Array Edge
, metadata :: Maybe MetaData
, corpusId :: Array CorpusId
, listId :: ListId } <- JSON.readImpl f
let side x = GraphSideCorpus { corpusId: x, corpusLabel: "Publications", listId : inst.listId}
let sides = side <$> inst.corpusId
, metadata :: MetaData } <- JSON.readImpl f
let (MetaData metadata) = inst.metadata
let side x = GraphSideCorpus { corpusId: x
, corpusLabel: "Publications"
, listId : metadata.list.listId }
let sides = side <$> metadata.corpusId
pure $ GraphData { nodes: inst.nodes
, edges: inst.edges
, sides
, metaData: inst.metadata }
, metaData:
Just
inst.metadata }
instance JSON.WriteForeign GraphData where
writeImpl (GraphData gd) = JSON.writeImpl { nodes: gd.nodes
, edges: gd.edges
...
...
@@ -127,9 +138,9 @@ instance JSON.WriteForeign GraphData where
newtype MetaData = MetaData
{ corpusId :: Array Int
, legend :: Array Legend
, list :: { listId
:: ListId
, version
:: Version
}
, list :: { listId :: ListId
, version
:: Version
}
, metric :: String -- dummy value
, startForceAtlas :: Boolean
, title :: String
...
...
@@ -188,8 +199,12 @@ derive instance Generic Legend _
derive instance Newtype Legend _
instance Eq Legend where eq (Legend l1) (Legend l2) = eq l1.id_ l2.id_
instance Ord Legend where compare (Legend l1) (Legend l2) = compare l1.id_ l2.id_
derive newtype instance JSON.ReadForeign Legend
derive newtype instance JSON.WriteForeign Legend
instance JSON.ReadForeign Legend where
readImpl f = do
inst <- JSON.readImpl f
pure $ Legend $ Record.rename idP id_P inst
instance JSON.WriteForeign Legend where
writeImpl (Legend l) = JSON.writeImpl $ Record.rename id_P idP l
getLegendData :: GraphData -> Array Legend
...
...
src/Gargantext/Types.purs
View file @
c237ff21
module Gargantext.Types where
import Data.Array as A
import Data.Either (Either(..))
import Data.Newtype (class Newtype)
import Data.String as S
import Data.Generic.Rep (class Generic)
...
...
@@ -9,7 +8,7 @@ import Data.Eq.Generic (genericEq)
import Data.Ord.Generic (genericCompare)
import Data.Show.Generic (genericShow)
import Data.Int (toNumber)
import Data.Maybe (Maybe(..), maybe
, fromMaybe
)
import Data.Maybe (Maybe(..), maybe)
import Effect.Aff (Aff)
import Foreign as F
import Prim.Row (class Union)
...
...
@@ -429,10 +428,10 @@ instance JSON.ReadForeign ApiVersion where
readImpl f = do
s <- JSON.readImpl f
case s of
"v0" -> pure V0
"v0"
-> pure V0
"v1.0" -> pure V10
"v1.1" -> pure V11
x -> F.fail $ F.ErrorAtProperty x $ F.ForeignError "unknown API value"
x
-> F.fail $ F.ErrorAtProperty x $ F.ForeignError "unknown API value"
instance JSON.WriteForeign ApiVersion where
writeImpl v = F.unsafeToForeign $ JSON.writeImpl $ show v
instance Show ApiVersion where
...
...
@@ -633,8 +632,7 @@ newtype AsyncTask =
derive instance Generic AsyncTask _
derive instance Newtype AsyncTask _
derive newtype instance JSON.ReadForeign AsyncTask
instance Eq AsyncTask where
eq = genericEq
instance Eq AsyncTask where eq = genericEq
newtype AsyncTaskWithType = AsyncTaskWithType {
task :: AsyncTask
...
...
@@ -687,8 +685,7 @@ prettyNodeType nt = S.replace (S.Pattern "Node") (S.Replacement " ")
data SidePanelState = InitialClosed | Opened | Closed
derive instance Generic SidePanelState _
instance Eq SidePanelState where
eq = genericEq
instance Eq SidePanelState where eq = genericEq
toggleSidePanelState :: SidePanelState -> SidePanelState
toggleSidePanelState InitialClosed = Opened
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment