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
133
Issues
133
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
81e21c97
Commit
81e21c97
authored
Jul 01, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[simple-json] code compiles now
parent
0f9d2064
Pipeline
#1566
failed with stage
Changes
35
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
972 additions
and
1347 deletions
+972
-1347
packages.dhall
packages.dhall
+2
-2
shell.nix
shell.nix
+1
-0
spago.dhall
spago.dhall
+39
-7
AsyncTasks.purs
src/Gargantext/AsyncTasks.purs
+10
-7
App.purs
src/Gargantext/Components/App.purs
+2
-0
Data.purs
src/Gargantext/Components/App/Data.purs
+5
-2
Series.purs
src/Gargantext/Components/Charts/Options/Series.purs
+20
-21
DocsTable.purs
src/Gargantext/Components/DocsTable.purs
+11
-13
FacetsTable.purs
src/Gargantext/Components/FacetsTable.purs
+5
-5
Tree.purs
src/Gargantext/Components/Forest/Tree.purs
+132
-7
Types.purs
...text/Components/Forest/Tree/Node/Tools/SubTree/Types.purs
+4
-9
Types.purs
src/Gargantext/Components/GraphExplorer/Types.purs
+85
-177
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+2
-2
Core.purs
src/Gargantext/Components/NgramsTable/Core.purs
+128
-202
Loader.purs
src/Gargantext/Components/NgramsTable/Loader.purs
+3
-3
Node.purs
src/Gargantext/Components/Node.purs
+26
-37
Annuaire.purs
src/Gargantext/Components/Nodes/Annuaire.purs
+21
-35
Types.purs
...antext/Components/Nodes/Annuaire/User/Contacts/Types.purs
+89
-215
Corpus.purs
src/Gargantext/Components/Nodes/Corpus.purs
+42
-38
Common.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Common.purs
+3
-3
Histo.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Histo.purs
+9
-22
Metrics.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Metrics.purs
+9
-25
Pie.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Pie.purs
+9
-22
Tree.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Tree.purs
+9
-13
Dashboard.purs
src/Gargantext/Components/Nodes/Corpus/Dashboard.purs
+13
-20
Document.purs
src/Gargantext/Components/Nodes/Corpus/Document.purs
+0
-5
Types.purs
src/Gargantext/Components/Nodes/Corpus/Document/Types.purs
+22
-111
Frame.purs
src/Gargantext/Components/Nodes/Frame.purs
+14
-21
Types.purs
src/Gargantext/Components/Nodes/Types.purs
+24
-22
Search.purs
src/Gargantext/Components/Search.purs
+106
-144
Loader.purs
src/Gargantext/Hooks/Loader.purs
+9
-17
Types.purs
src/Gargantext/Sessions/Types.purs
+36
-5
Types.purs
src/Gargantext/Types.purs
+60
-121
CacheAPI.purs
src/Gargantext/Utils/CacheAPI.purs
+10
-10
JSON.purs
src/Gargantext/Utils/JSON.purs
+12
-4
No files found.
packages.dhall
View file @
81e21c97
...
...
@@ -93,8 +93,8 @@ let additions =
}
, markdown-smolder =
{ dependencies = [ "markdown", "smolder" ]
, repo = "https://github.com/
poorscript
/purescript-markdown-smolder"
, version = "
2021-06-22
"
, repo = "https://github.com/
hgiasac
/purescript-markdown-smolder"
, version = "
v2.2.0
"
}
, precise =
{ dependencies = [ "prelude" ]
...
...
shell.nix
View file @
81e21c97
...
...
@@ -48,6 +48,7 @@ pkgs.mkShell {
build-purs
build
repl
pkgs
.
spago
pkgs
.
yarn
test-ps
];
...
...
spago.dhall
View file @
81e21c97
...
...
@@ -12,35 +12,59 @@ to generate this file without the comments in this block.
-}
{ name = "gargantext"
, dependencies =
[ "aff-promise"
[ "aff"
, "aff-promise"
, "affjax"
, "argonaut"
, "argonaut-codecs"
, "argonaut-core"
, "arrays"
, "bifunctors"
, "colors"
, "console"
, "control"
, "css"
, "datetime"
, "debug"
, "dom-filereader"
, "dom-simple"
, "effect"
, "foreign-generic"
, "either"
, "enums"
, "exceptions"
, "ffi-simple"
, "foldable-traversable"
, "foreign"
, "foreign-object"
, "form-urlencoded"
, "formula"
, "functions"
, "globals"
, "http-methods"
, "integers"
, "js-timers"
, "lists"
, "markdown"
, "markdown-smolder"
, "math"
, "maybe"
, "media-types"
, "milkis"
, "newtype"
, "nonempty"
, "now"
, "nullable"
, "numbers"
, "ordered-collections"
, "orders"
, "parallel"
, "partial"
, "prelude"
, "profunctor-lenses"
, "psci-support"
, "random"
, "react"
, "reactix"
, "re
a
d"
, "re
cor
d"
, "record-extra"
, "routing"
, "sequences"
...
...
@@ -48,18 +72,26 @@ to generate this file without the comments in this block.
, "simple-json-generics"
, "simplecrypto"
, "smolder"
, "spec"
, "spec-discovery"
, "spec-quickcheck"
, "string-parsers"
, "strings"
, "stringutils"
, "these"
, "toestand"
, "transformers"
, "tuples"
, "tuples-native"
, "typisch"
, "typelevel"
, "typelevel-prelude"
, "uint"
, "unfoldable"
, "unsafe-coerce"
, "uri"
, "
versions
"
, "
web-file
"
, "web-html"
, "web-storage"
, "web-xhr"
]
, packages = ./packages.dhall
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
...
...
src/Gargantext/AsyncTasks.purs
View file @
81e21c97
...
...
@@ -24,12 +24,15 @@ localStorageKey = "garg-async-tasks"
type TaskList = Array GT.AsyncTaskWithType
type Storage = Map.Map GT.NodeID TaskList
newtype Storage = Storage (Map.Map GT.NodeID TaskList)
instance JSON.ReadForeign Storage where readImpl = GUJ.readMap
instance JSON.ReadForeign Storage where
readImpl f = do
m <- GUJ.readMapInt f
pure $ Storage m
empty :: Storage
empty = Map.empty
empty =
Storage $
Map.empty
getAsyncTasks :: Effect Storage
getAsyncTasks = R2.getls >>= WSS.getItem localStorageKey >>= handleMaybe
...
...
@@ -44,10 +47,10 @@ getAsyncTasks = R2.getls >>= WSS.getItem localStorageKey >>= handleMaybe
parse s = GU.mapLeft (log2 "Error parsing serialised sessions:") (JSON.readJSON s)
getTasks :: GT.NodeID -> Storage -> TaskList
getTasks nodeId
storage
= fromMaybe [] $ Map.lookup nodeId storage
getTasks nodeId
(Storage storage)
= fromMaybe [] $ Map.lookup nodeId storage
setTasks :: GT.NodeID -> TaskList -> Storage -> Storage
setTasks id tasks
s =
Map.insert id tasks s
setTasks id tasks
(Storage s) = Storage $
Map.insert id tasks s
focus :: GT.NodeID -> T.Box Storage -> R.Hooks (T.Box TaskList)
focus id tasks = T.useFocused (getTasks id) (setTasks id) tasks
...
...
@@ -65,7 +68,7 @@ type ReductorProps = (
insert :: GT.NodeID -> GT.AsyncTaskWithType -> T.Box Storage -> Effect Unit
insert id task storage = T.modify_ newStorage storage
where
newStorage
s =
Map.alter (maybe (Just [task]) (\ts -> Just $ A.cons task ts)) id s
newStorage
(Storage s) = Storage $
Map.alter (maybe (Just [task]) (\ts -> Just $ A.cons task ts)) id s
finish :: GT.NodeID -> GT.AsyncTaskWithType -> T.Box Storage -> Effect Unit
finish id task storage = remove id task storage
...
...
@@ -73,7 +76,7 @@ finish id task storage = remove id task storage
remove :: GT.NodeID -> GT.AsyncTaskWithType -> T.Box Storage -> Effect Unit
remove id task storage = T.modify_ newStorage storage
where
newStorage
s =
Map.alter (maybe Nothing $ (\ts -> Just $ removeTaskFromList ts task)) id s
newStorage
(Storage s) = Storage $
Map.alter (maybe Nothing $ (\ts -> Just $ removeTaskFromList ts task)) id s
-- When a task is finished: which tasks cause forest or app reload
...
...
src/Gargantext/Components/App.purs
View file @
81e21c97
module Gargantext.Components.App (app) where
import Data.Set as Set
import Reactix as R
import Toestand as T
...
...
src/Gargantext/Components/App/Data.purs
View file @
81e21c97
...
...
@@ -4,6 +4,8 @@ import Data.Set as Set
import Data.Maybe (Maybe(..))
import Toestand as T
import Gargantext.Prelude
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.GraphExplorer.Sidebar.Types as GEST
import Gargantext.Components.Nodes.Lists.Types as ListsT
...
...
@@ -11,7 +13,8 @@ import Gargantext.Components.Nodes.Texts.Types as TextsT
import Gargantext.Ends (Backend)
import Gargantext.Routes (AppRoute(Home))
import Gargantext.Sessions as Sessions
import Gargantext.Sessions (OpenNodes, Session, Sessions)
import Gargantext.Sessions (Session, Sessions)
import Gargantext.Sessions.Types (OpenNodes(..))
import Gargantext.Types (Handed(RightHanded), SidePanelState(..))
import Gargantext.Utils.Toestand as T2
...
...
@@ -39,7 +42,7 @@ type App =
emptyApp :: App
emptyApp =
{ backend : Nothing
, forestOpen : Set.empty
, forestOpen :
OpenNodes $
Set.empty
, graphVersion : T2.newReload
, handed : RightHanded
, reloadForest : T2.newReload
...
...
src/Gargantext/Components/Charts/Options/Series.purs
View file @
81e21c97
module Gargantext.Components.Charts.Options.Series where
import Prelude (class Eq, class Show, bind, map, pure, show, ($), (+), (<<<), (<>), eq)
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, (.:), (~>), (:=))
import Data.Argonaut.Core (jsonEmptyObject)
import Data.Array (foldl)
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..), maybe)
import Data.Newtype (class Newtype)
import Data.Symbol (SProxy(..))
import Record as Record
import Record.Unsafe (unsafeSet)
import Simple.JSON as JSON
import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Prelude
import Gargantext.Types (class Optional)
import Gargantext.Components.Charts.Options.Font (ItemStyle, Tooltip)
import Gargantext.Components.Charts.Options.Data (DataD1, DataD2)
...
...
@@ -186,28 +188,20 @@ toJsTree maybeSurname (TreeNode x) =
where
name = maybe "" (\x' -> x' <> ">") maybeSurname <> x.name
data
TreeNode = TreeNode {
newtype
TreeNode = TreeNode {
children :: Array TreeNode
, name :: String
, value :: Int
}
derive instance Generic TreeNode _
instance Eq TreeNode where
eq (TreeNode n1) (TreeNode n2) = eq n1 n2
instance DecodeJson TreeNode where
decodeJson json = do
obj <- decodeJson json
children <- obj .: "children"
name <- obj .: "label"
value <- obj .: "value"
pure $ TreeNode { children, name, value }
instance EncodeJson TreeNode where
encodeJson (TreeNode { children, name, value }) =
"children" := encodeJson children
~> "label" := encodeJson name
~> "value" := encodeJson value
~> jsonEmptyObject
derive instance Newtype TreeNode _
derive instance Eq TreeNode
instance JSON.ReadForeign TreeNode where
readImpl f = do
inst <- JSON.readImpl f
pure $ TreeNode $ Record.rename labelP nameP inst
instance JSON.WriteForeign TreeNode where
writeImpl (TreeNode t) = JSON.writeImpl $ Record.rename nameP labelP t
treeNode :: String -> Int -> Array TreeNode -> TreeNode
treeNode n v ts = TreeNode {name : n, value:v, children:ts}
...
...
@@ -216,7 +210,12 @@ treeLeaf :: String -> Int -> TreeNode
treeLeaf n v = TreeNode { name : n, value : v, children : []}
nameP = SProxy :: SProxy "name"
labelP = SProxy :: SProxy "label"
-- | TODO
-- https://ecomfe.github.io/echarts-examples/public/data/asset/data/life-expectancy-table.json
-- https://ecomfe.github.io/echarts-examples/public/editor.html?c=scatter3D-dataset&gl=1
src/Gargantext/Components/DocsTable.purs
View file @
81e21c97
-- TODO: this module should be replaced by FacetsTable
module Gargantext.Components.DocsTable where
import Gargantext.Prelude
( class Ord, Unit, bind, const, discard, identity, mempty
, otherwise, pure, show, unit, ($), (/=), (<$>), (<<<), (<>), (==) )
import Data.Argonaut (class EncodeJson, jsonEmptyObject, (:=), (~>))
import Data.Array as A
import Data.Generic.Rep (class Generic)
import Data.Lens ((^.))
import Data.Lens.At (at)
import Data.Lens.Record (prop)
import Data.Maybe (Maybe(..), fromMaybe, isJust, maybe)
import Data.Map as Map
import Data.Newtype (class Newtype)
import Data.Ord.Down (Down(..))
import Data.Set (Set)
import Data.Set as Set
...
...
@@ -23,8 +22,11 @@ import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect)
import Reactix as R
import Reactix.DOM.HTML as H
import Simple.JSON as JSON
import Toestand as T
import Gargantext.Prelude
import Gargantext.Components.Category (rating)
import Gargantext.Components.Category.Types (Star(..))
import Gargantext.Components.DocsTable.Types
...
...
@@ -290,7 +292,7 @@ pageLayoutCpt = here.component "pageLayout" cpt where
, renderer: paint
}
NT.CacheOff -> do
localCategories <- T.useBox (
m
empty :: LocalUserScore)
localCategories <- T.useBox (
Map.
empty :: LocalUserScore)
paramsS <- T.useBox params
paramsS' <- T.useLive T.unequal paramsS
let loader p = do
...
...
@@ -338,7 +340,7 @@ pagePaintCpt = here.component "pagePaintCpt" cpt
cpt { documents, layout, params } _ = do
params' <- T.useLive T.unequal params
localCategories <- T.useBox (
m
empty :: LocalUserScore)
localCategories <- T.useBox (
Map.
empty :: LocalUserScore)
pure $ pagePaintRaw { documents: A.fromFoldable (filteredRows params')
, layout
, localCategories
...
...
@@ -505,13 +507,9 @@ newtype SearchQuery = SearchQuery {
parent_id :: Int
, query :: Array String
}
instance EncodeJson SearchQuery where
encodeJson (SearchQuery {query, parent_id})
= "query" := query
~> "parent_id" := parent_id
~> jsonEmptyObject
derive instance Generic SearchQuery _
derive instance Newtype SearchQuery _
derive newtype instance JSON.ReadForeign SearchQuery
documentsRoute :: Int -> SessionRoute
...
...
src/Gargantext/Components/FacetsTable.purs
View file @
81e21c97
...
...
@@ -3,11 +3,11 @@
-- has not been ported to this module yet.
module Gargantext.Components.FacetsTable where
import Data.Argonaut (class EncodeJson, jsonEmptyObject, (:=), (~>))
import Data.Generic.Rep (class Generic)
import Data.Eq.Generic (genericEq)
import Data.Show.Generic (genericShow)
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Newtype (class Newtype)
import Data.Sequence (Seq)
import Data.Sequence as Seq
import Data.Set (Set)
...
...
@@ -18,6 +18,7 @@ import Effect (Effect)
import Effect.Aff (Aff, launchAff_)
import Reactix as R
import Reactix.DOM.HTML as H
import Simple.JSON as JSON
import Toestand as T
import Gargantext.Prelude
...
...
@@ -412,10 +413,9 @@ publicationDate (DocumentsView {publication_year, publication_month, publication
---------------------------------------------------------
newtype DeleteDocumentQuery = DeleteDocumentQuery { documents :: Array Int }
instance EncodeJson DeleteDocumentQuery where
encodeJson (DeleteDocumentQuery {documents}) =
"documents" := documents ~> jsonEmptyObject
derive instance Generic DeleteDocumentQuery _
derive instance Newtype DeleteDocumentQuery _
derive newtype instance JSON.WriteForeign DeleteDocumentQuery
deleteDocuments :: Session -> Int -> DeleteDocumentQuery -> Aff (Array Int)
deleteDocuments session nodeId =
...
...
src/Gargantext/Components/Forest/Tree.purs
View file @
81e21c97
This diff is collapsed.
Click to expand it.
src/Gargantext/Components/Forest/Tree/Node/Tools/SubTree/Types.purs
View file @
81e21c97
...
...
@@ -5,16 +5,13 @@ import Data.Eq.Generic (genericEq)
import Data.Show.Generic (genericShow)
import Gargantext.Prelude (class Eq, class Show)
import Gargantext.Types as GT
import Reactix as R
data SubTreeOut = SubTreeOut { in :: GT.ID
, out :: GT.ID
}
derive instance Generic SubTreeOut _
instance Eq SubTreeOut where
eq = genericEq
instance Show SubTreeOut where
show = genericShow
instance Eq SubTreeOut where eq = genericEq
instance Show SubTreeOut where show = genericShow
------------------------------------------------------------------------
data SubTreeParams = SubTreeParams { showtypes :: Array GT.NodeType
...
...
@@ -22,10 +19,8 @@ data SubTreeParams = SubTreeParams { showtypes :: Array GT.NodeType
}
derive instance Generic SubTreeParams _
instance Eq SubTreeParams where
eq = genericEq
instance Show SubTreeParams where
show = genericShow
instance Eq SubTreeParams where eq = genericEq
instance Show SubTreeParams where show = genericShow
------------------------------------------------------------------------
src/Gargantext/Components/GraphExplorer/Types.purs
View file @
81e21c97
This diff is collapsed.
Click to expand it.
src/Gargantext/Components/NgramsTable.purs
View file @
81e21c97
...
...
@@ -74,7 +74,7 @@ type State =
initialState :: VersionedNgramsTable -> State
initialState (Versioned {version}) = {
ngramsChildren:
m
empty
ngramsChildren:
Map.
empty
, ngramsLocalPatch: mempty
, ngramsParent: Nothing
, ngramsSelection: mempty
...
...
@@ -444,7 +444,7 @@ mkDispatch { filteredRows
allNgramsSelected = allNgramsSelectedOnFirstPage ngramsSelection filteredRows
setParentResetChildren :: Maybe NgramsTerm -> State -> State
setParentResetChildren p = _ { ngramsParent = p, ngramsChildren =
m
empty }
setParentResetChildren p = _ { ngramsParent = p, ngramsChildren =
Map.
empty }
performAction :: Action -> Effect Unit
performAction (SetParentResetChildren p) =
...
...
src/Gargantext/Components/NgramsTable/Core.purs
View file @
81e21c97
This diff is collapsed.
Click to expand it.
src/Gargantext/Components/NgramsTable/Loader.purs
View file @
81e21c97
module Gargantext.Components.NgramsTable.Loader where
import Data.Argonaut (class DecodeJson)
import Data.Maybe (Maybe(..), maybe, isJust)
import Data.Tuple (fst)
import Data.Tuple.Nested ((/\))
...
...
@@ -8,6 +7,7 @@ import Effect.Aff (Aff, launchAff_, throwError)
import Effect.Class (liftEffect)
import Effect.Exception (error)
import Reactix as R
import Simple.JSON as JSON
import Toestand as T
import Gargantext.Prelude
...
...
@@ -34,7 +34,7 @@ type LoaderWithCacheAPIProps path res ret = (
)
useLoaderWithCacheAPI :: forall path res ret. Eq path =>
DecodeJso
n res => Eq ret =>
useLoaderWithCacheAPI :: forall path res ret. Eq path =>
JSON.ReadForeig
n res => Eq ret =>
Record (LoaderWithCacheAPIProps path res ret)
-> R.Hooks R.Element
useLoaderWithCacheAPI { cacheEndpoint, handleResponse, mkRequest, path, renderer } = do
...
...
@@ -56,7 +56,7 @@ type LoaderWithCacheAPIEffectProps path res ret = (
, state :: T.Box (Maybe ret)
)
useCachedAPILoaderEffect :: forall path res ret. Eq path =>
DecodeJso
n res => Eq ret =>
useCachedAPILoaderEffect :: forall path res ret. Eq path =>
JSON.ReadForeig
n res => Eq ret =>
Record (LoaderWithCacheAPIEffectProps path res ret)
-> R.Hooks Unit
useCachedAPILoaderEffect { cacheEndpoint
...
...
src/Gargantext/Components/Node.purs
View file @
81e21c97
module Gargantext.Components.Node
where
import Data.Argonaut (class DecodeJson, decodeJson, (.:), (.:?), (.!=))
import Data.Generic.Rep (class Generic)
import Data.Eq.Generic (genericEq)
import Data.Newtype (class Newtype)
import Simple.JSON as JSON
import Gargantext.Prelude
type NodePolyCommon a =
( id :: Int
, typename :: Int
, name :: String
, date :: String
, hyperdata :: a )
newtype NodePoly a =
NodePoly { id :: Int
, typename :: Int
, userId :: Int
NodePoly { userId :: Int
, parentId :: Int
, name :: String
, date :: String
, hyperdata :: a
| NodePolyCommon a
}
derive instance Generic (NodePoly a) _
instance Eq a => Eq (NodePoly a) where
eq = genericEq
instance (DecodeJson a)
=> DecodeJson (NodePoly a) where
decodeJson json = do
obj <- decodeJson json
id <- obj .: "id"
typename <- obj .: "typename"
userId <- obj .: "user_id"
parentId <- obj .: "parent_id"
name <- obj .: "name"
date <- obj .: "date"
hyperdata <- obj .: "hyperdata"
hyperdata' <- decodeJson hyperdata
pure $ NodePoly { id
, date
, hyperdata: hyperdata'
, name
, parentId
, typename
, userId
}
derive instance Newtype (NodePoly a) _
instance Eq a => Eq (NodePoly a) where eq = genericEq
instance JSON.ReadForeign a => JSON.ReadForeign (NodePoly a) where
readImpl f = do
inst :: { user_id :: Int, parent_id :: Int | NodePolyCommon a } <- JSON.readImpl f
pure $ NodePoly { id: inst.id
, typename: inst.typename
, userId: inst.user_id
, parentId: inst.parent_id
, name: inst.name
, date: inst.date
, hyperdata: inst.hyperdata }
newtype HyperdataList = HyperdataList { preferences :: String }
instance DecodeJson HyperdataList where
decodeJson json = do
obj <- decodeJson json
pref <- obj .:? "preferences" .!= ""
pure $ HyperdataList { preferences : pref }
derive instance Generic HyperdataList _
derive instance Newtype HyperdataList _
derive newtype instance JSON.ReadForeign HyperdataList
src/Gargantext/Components/Nodes/Annuaire.purs
View file @
81e21c97
...
...
@@ -2,17 +2,18 @@ module Gargantext.Components.Nodes.Annuaire
-- ( annuaire )
where
import Data.Argonaut (class DecodeJson, decodeJson, (.:), (.:?))
import Data.Array as A
import Data.Generic.Rep (class Generic)
import Data.Eq.Generic (genericEq)
import Data.Maybe (Maybe(..), maybe, fromMaybe)
import Data.Newtype (class Newtype)
import Data.Sequence as Seq
import Data.Tuple (fst, snd)
import Data.Tuple.Nested ((/\))
import Data.Symbol (SProxy(..))
import Effect.Aff (Aff, launchAff_)
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
import Simple.JSON as JSON
import Toestand as T
import Gargantext.Prelude
...
...
@@ -20,8 +21,8 @@ import Gargantext.Prelude
import Gargantext.Components.NgramsTable.Loader (clearCache)
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types as CT
import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Table as TT
import Gargantext.Components.Table.Types as TT
import Gargantext.Components.Table
(defaultContainer, initialParams, makeRow, table, tableHeaderLayout)
as TT
import Gargantext.Components.Table.Types
(ColumnName(..), Params)
as TT
import Gargantext.Ends (url, Frontends)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes (SessionRoute(..))
...
...
@@ -236,18 +237,13 @@ contactCellsCpt = here.component "contactCells" cpt where
contactWhereRole (CT.ContactWhere { role: Nothing }) = "Empty Role"
contactWhereRole (CT.ContactWhere { role: Just role }) = role
data
HyperdataAnnuaire = HyperdataAnnuaire
newtype
HyperdataAnnuaire = HyperdataAnnuaire
{ title :: Maybe String
, desc :: Maybe String }
derive instance Generic HyperdataAnnuaire _
instance Eq HyperdataAnnuaire where
eq = genericEq
instance DecodeJson HyperdataAnnuaire where
decodeJson json = do
obj <- decodeJson json
title <- obj .:? "title"
desc <- obj .:? "desc"
pure $ HyperdataAnnuaire { title, desc }
derive instance Newtype HyperdataAnnuaire _
instance Eq HyperdataAnnuaire where eq = genericEq
derive newtype instance JSON.ReadForeign HyperdataAnnuaire
------------------------------------------------------------------------------
newtype AnnuaireInfo =
...
...
@@ -261,27 +257,17 @@ newtype AnnuaireInfo =
, hyperdata :: HyperdataAnnuaire
}
derive instance Generic AnnuaireInfo _
instance Eq AnnuaireInfo where
eq = genericEq
instance DecodeJson AnnuaireInfo where
decodeJson json = do
obj <- decodeJson json
id <- obj .: "id"
typename <- obj .: "typename"
userId <- obj .: "user_id"
parentId <- obj .: "parent_id"
name <- obj .: "name"
date <- obj .: "date"
hyperdata <- obj .: "hyperdata"
pure $ AnnuaireInfo
{ id : id
, typename : typename
, userId : userId
, parentId : parentId
, name : name
, date : date
, hyperdata: hyperdata
}
derive instance Newtype AnnuaireInfo _
instance Eq AnnuaireInfo where eq = genericEq
instance JSON.ReadForeign AnnuaireInfo where
readImpl f = do
inst <- JSON.readImpl f
pure $ AnnuaireInfo $ Record.rename user_idP userIdP $ Record.rename parent_idP parentIdP inst
where
user_idP = SProxy :: SProxy "user_id"
userIdP = SProxy :: SProxy "userId"
parent_idP = SProxy :: SProxy "parent_id"
parentIdP = SProxy :: SProxy "parentId"
--newtype AnnuaireTable = AnnuaireTable { annuaireTable :: Array (Maybe Contact)}
...
...
src/Gargantext/Components/Nodes/Annuaire/User/Contacts/Types.purs
View file @
81e21c97
This diff is collapsed.
Click to expand it.
src/Gargantext/Components/Nodes/Corpus.purs
View file @
81e21c97
This diff is collapsed.
Click to expand it.
src/Gargantext/Components/Nodes/Corpus/Chart/Common.purs
View file @
81e21c97
module Gargantext.Components.Nodes.Corpus.Chart.Common where
import Data.Argonaut (class DecodeJson)
import Data.Tuple (fst)
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff)
import Reactix as R
import Simple.JSON as JSON
import Toestand as T
import Gargantext.Prelude
...
...
@@ -49,12 +49,12 @@ type MetricsWithCacheLoadViewProps res ret = (
)
metricsWithCacheLoadView :: forall res ret.
Eq ret =>
DecodeJso
n res =>
Eq ret =>
JSON.ReadForeig
n res =>
Record (MetricsWithCacheLoadViewProps res ret) -> R.Element
metricsWithCacheLoadView p = R.createElement metricsWithCacheLoadViewCpt p []
metricsWithCacheLoadViewCpt :: forall res ret.
Eq ret =>
DecodeJso
n res =>
Eq ret =>
JSON.ReadForeig
n res =>
R.Component (MetricsWithCacheLoadViewProps res ret)
metricsWithCacheLoadViewCpt = here.component "metricsWithCacheLoadView" cpt
where
...
...
src/Gargantext/Components/Nodes/Corpus/Chart/Histo.purs
View file @
81e21c97
module Gargantext.Components.Nodes.Corpus.Chart.Histo where
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, (.:), (~>), (:=))
import Data.Argonaut.Core (jsonEmptyObject)
import Data.Generic.Rep (class Generic)
import Data.Eq.Generic (genericEq)
import Data.Maybe (Maybe(..))
import Data.Newtype (class Newtype)
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff)
import Reactix as R
import Reactix.DOM.HTML as H
import Simple.JSON as JSON
import Toestand as T
import Gargantext.Prelude (class Eq, bind, map, pure, ($), (==))
...
...
@@ -35,29 +35,16 @@ newtype ChartMetrics = ChartMetrics {
"data" :: HistoMetrics
}
derive instance Generic ChartMetrics _
instance Eq ChartMetrics where
eq = genericEq
instance DecodeJson ChartMetrics where
decodeJson json = do
obj <- decodeJson json
d <- obj .: "data"
pure $ ChartMetrics { "data": d }
derive instance Newtype ChartMetrics _
instance Eq ChartMetrics where eq = genericEq
derive newtype instance JSON.ReadForeign ChartMetrics
newtype HistoMetrics = HistoMetrics { dates :: Array String, count :: Array Number }
derive instance Generic HistoMetrics _
instance Eq HistoMetrics where
eq = genericEq
instance DecodeJson HistoMetrics where
decodeJson json = do
obj <- decodeJson json
d <- obj .: "dates"
c <- obj .: "count"
pure $ HistoMetrics { dates : d , count: c}
instance EncodeJson HistoMetrics where
encodeJson (HistoMetrics { dates, count }) =
"count" := encodeJson count
~> "dates" := encodeJson dates
~> jsonEmptyObject
derive instance Newtype HistoMetrics _
instance Eq HistoMetrics where eq = genericEq
derive newtype instance JSON.ReadForeign HistoMetrics
derive newtype instance JSON.WriteForeign HistoMetrics
type Loaded = HistoMetrics
...
...
src/Gargantext/Components/Nodes/Corpus/Chart/Metrics.purs
View file @
81e21c97
module Gargantext.Components.Nodes.Corpus.Chart.Metrics where
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, (.:), (~>), (:=))
import Data.Argonaut.Core (jsonEmptyObject)
import Data.Generic.Rep (class Generic)
import Data.Eq.Generic (genericEq)
import Data.Map as Map
import Data.Map (Map)
import Data.Maybe (Maybe(..))
import Data.Newtype (class Newtype)
import Data.Tuple (Tuple(..))
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff)
import Reactix as R
import Reactix.DOM.HTML as H
import Simple.JSON as JSON
import Toestand as T
import Gargantext.Prelude (class Eq, bind, negate, pure, ($), (<$>), (<>))
...
...
@@ -43,33 +43,17 @@ newtype Metric = Metric
, cat :: TermList
}
derive instance Generic Metric _
instance Eq Metric where
eq = genericEq
instance DecodeJson Metric where
decodeJson json = do
obj <- decodeJson json
label <- obj .: "label"
x <- obj .: "x"
y <- obj .: "y"
cat <- obj .: "cat"
pure $ Metric { label, x, y, cat }
instance EncodeJson Metric where
encodeJson (Metric { label, x, y, cat }) =
"label" := encodeJson label
~> "x" := encodeJson x
~> "y" := encodeJson y
~> "cat" := encodeJson cat
~> jsonEmptyObject
derive instance Newtype Metric _
instance Eq Metric where eq = genericEq
derive newtype instance JSON.ReadForeign Metric
derive newtype instance JSON.WriteForeign Metric
newtype Metrics = Metrics {