Commit 5006bca0 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski
parent d576e672
...@@ -6,7 +6,7 @@ import Record.Unsafe (unsafeSet) ...@@ -6,7 +6,7 @@ import Record.Unsafe (unsafeSet)
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
import Prelude import Prelude
import Data.Argonaut (class DecodeJson, decodeJson, (.?)) import Data.Argonaut (class DecodeJson, decodeJson, (.:))
import Gargantext.Types (class Optional) import Gargantext.Types (class Optional)
import Gargantext.Components.Charts.Options.Font (ItemStyle, Tooltip) import Gargantext.Components.Charts.Options.Font (ItemStyle, Tooltip)
import Gargantext.Components.Charts.Options.Data (DataD1, DataD2) import Gargantext.Components.Charts.Options.Data (DataD1, DataD2)
...@@ -192,9 +192,9 @@ data TreeNode = TreeNode { name :: String ...@@ -192,9 +192,9 @@ data TreeNode = TreeNode { name :: String
instance decodeTreeNode :: DecodeJson TreeNode where instance decodeTreeNode :: DecodeJson TreeNode where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
name <- obj .? "label" name <- obj .: "label"
value <- obj .? "value" value <- obj .: "value"
children <- obj .? "children" children <- obj .: "children"
pure $ TreeNode {name, value, children} pure $ TreeNode {name, value, children}
......
-- TODO: this module should be replaced by FacetsTable -- TODO: this module should be replaced by FacetsTable
module Gargantext.Components.DocsTable where module Gargantext.Components.DocsTable where
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, jsonEmptyObject, (.?), (:=), (~>)) import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, jsonEmptyObject, (.:), (:=), (~>))
import Data.Array (drop, take) import Data.Array (drop, take)
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow) import Data.Generic.Rep.Show (genericShow)
...@@ -102,18 +102,18 @@ newtype Hyperdata = Hyperdata ...@@ -102,18 +102,18 @@ newtype Hyperdata = Hyperdata
instance decodeHyperdata :: DecodeJson Hyperdata where instance decodeHyperdata :: DecodeJson Hyperdata where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
title <- obj .? "title" title <- obj .: "title"
source <- obj .? "source" source <- obj .: "source"
pub_year <- obj .? "publication_year" pub_year <- obj .: "publication_year"
pure $ Hyperdata { title,source, pub_year} pure $ Hyperdata { title,source, pub_year}
instance decodeResponse :: DecodeJson Response where instance decodeResponse :: DecodeJson Response where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
cid <- obj .? "id" cid <- obj .: "id"
favorite <- obj .? "favorite" favorite <- obj .: "favorite"
ngramCount <- obj .? "id" ngramCount <- obj .: "id"
hyperdata <- obj .? "hyperdata" hyperdata <- obj .: "hyperdata"
pure $ Response { cid, category: decodeCategory favorite, ngramCount, hyperdata } pure $ Response { cid, category: decodeCategory favorite, ngramCount, hyperdata }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
module Gargantext.Components.FacetsTable where module Gargantext.Components.FacetsTable where
import Control.Monad.Cont.Trans (lift) import Control.Monad.Cont.Trans (lift)
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, jsonEmptyObject, (.?), (:=), (~>)) import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, jsonEmptyObject, (.:), (:=), (~>))
import Data.Array (filter, (!!)) import Data.Array (filter, (!!))
import Data.Foldable (intercalate) import Data.Foldable (intercalate)
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
...@@ -54,7 +54,7 @@ newtype SearchResults = SearchResults { results :: Array Response } ...@@ -54,7 +54,7 @@ newtype SearchResults = SearchResults { results :: Array Response }
instance decodeSearchResults :: DecodeJson SearchResults where instance decodeSearchResults :: DecodeJson SearchResults where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
results <- obj .? "results" results <- obj .: "results"
pure $ SearchResults {results} pure $ SearchResults {results}
type Props = type Props =
...@@ -129,16 +129,16 @@ newtype Hyperdata = Hyperdata ...@@ -129,16 +129,16 @@ newtype Hyperdata = Hyperdata
--instance decodeHyperdata :: DecodeJson Hyperdata where --instance decodeHyperdata :: DecodeJson Hyperdata where
-- decodeJson json = do -- decodeJson json = do
-- obj <- decodeJson json -- obj <- decodeJson json
-- title <- obj .? "title" -- title <- obj .: "title"
-- source <- obj .? "source" -- source <- obj .: "source"
-- pure $ Hyperdata { title,source } -- pure $ Hyperdata { title,source }
instance decodePair :: DecodeJson Pair where instance decodePair :: DecodeJson Pair where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
id <- obj .? "id" id <- obj .: "id"
label <- obj .? "label" label <- obj .: "label"
pure $ Pair { id, label } pure $ Pair { id, label }
instance decodeHyperdata :: DecodeJson Hyperdata where instance decodeHyperdata :: DecodeJson Hyperdata where
...@@ -152,23 +152,23 @@ instance decodeHyperdata :: DecodeJson Hyperdata where ...@@ -152,23 +152,23 @@ instance decodeHyperdata :: DecodeJson Hyperdata where
instance decodeResponse :: DecodeJson Response where instance decodeResponse :: DecodeJson Response where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
id <- obj .? "id" id <- obj .: "id"
-- date <- obj .? "date" -- TODO -- date <- obj .: "date" -- TODO
date <- pure "2018" date <- pure "2018"
score <- obj .? "score" score <- obj .: "score"
hyperdata <- obj .? "hyperdata" hyperdata <- obj .: "hyperdata"
pairs <- obj .? "pairs" pairs <- obj .: "pairs"
pure $ Response { id, date, score, hyperdata, pairs } pure $ Response { id, date, score, hyperdata, pairs }
-} -}
instance decodeResponse :: DecodeJson Response where instance decodeResponse :: DecodeJson Response where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
id <- obj .? "id" id <- obj .: "id"
created <- obj .? "created" created <- obj .: "created"
hyperdata <- obj .? "hyperdata" hyperdata <- obj .: "hyperdata"
favorite <- obj .? "favorite" favorite <- obj .: "favorite"
--ngramCount <- obj .? "ngramCount" --ngramCount <- obj .: "ngramCount"
let ngramCount = 1 let ngramCount = 1
pure $ Response { id, created, hyperdata, category: decodeCategory favorite, ngramCount} pure $ Response { id, created, hyperdata, category: decodeCategory favorite, ngramCount}
......
...@@ -8,7 +8,7 @@ import Data.Sequence (Seq) ...@@ -8,7 +8,7 @@ import Data.Sequence (Seq)
import Data.Traversable (foldMap) import Data.Traversable (foldMap)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as RH import Reactix.DOM.HTML as RH
import Gargantext.Components.GraphExplorer.Types (Cluster(..), MetaData(..), Edge(..), GraphData(..), Legend(..), Node(..), getLegendData, intColor) import Gargantext.Components.GraphExplorer.Types (Legend(..), intColor)
type Props = ( items :: Seq Legend ) type Props = ( items :: Seq Legend )
......
...@@ -3,7 +3,7 @@ module Gargantext.Components.GraphExplorer.Types where ...@@ -3,7 +3,7 @@ module Gargantext.Components.GraphExplorer.Types where
import Prelude import Prelude
import Partial.Unsafe (unsafePartial) import Partial.Unsafe (unsafePartial)
import Data.Argonaut (class DecodeJson, decodeJson, (.?)) import Data.Argonaut (class DecodeJson, decodeJson, (.:))
import Data.Array ((!!), length) import Data.Array ((!!), length)
import Data.Maybe (Maybe(..), fromJust) import Data.Maybe (Maybe(..), fromJust)
import Data.Newtype (class Newtype) import Data.Newtype (class Newtype)
...@@ -152,13 +152,13 @@ initialState = fromStateGlue initialStateGlue ...@@ -152,13 +152,13 @@ initialState = fromStateGlue initialStateGlue
instance decodeJsonGraphData :: DecodeJson GraphData where instance decodeJsonGraphData :: DecodeJson GraphData where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
nodes <- obj .? "nodes" nodes <- obj .: "nodes"
edges <- obj .? "edges" edges <- obj .: "edges"
-- TODO: sides -- TODO: sides
metadata <- obj .? "metadata" metadata <- obj .: "metadata"
corpusIds <- metadata .? "corpusId" corpusIds <- metadata .: "corpusId"
listId' <- metadata .? "listId" listId' <- metadata .: "listId"
metaData <- obj .? "metadata" metaData <- obj .: "metadata"
let side x = GraphSideCorpus { corpusId: x, corpusLabel: "Publications", listId : listId'} let side x = GraphSideCorpus { corpusId: x, corpusLabel: "Publications", listId : listId'}
let sides = side <$> corpusIds let sides = side <$> corpusIds
pure $ GraphData { nodes, edges, sides, metaData } pure $ GraphData { nodes, edges, sides, metaData }
...@@ -166,49 +166,49 @@ instance decodeJsonGraphData :: DecodeJson GraphData where ...@@ -166,49 +166,49 @@ instance decodeJsonGraphData :: DecodeJson GraphData where
instance decodeJsonNode :: DecodeJson Node where instance decodeJsonNode :: DecodeJson Node where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
id_ <- obj .? "id" id_ <- obj .: "id"
type_ <- obj .? "type" type_ <- obj .: "type"
label <- obj .? "label" label <- obj .: "label"
size <- obj .? "size" size <- obj .: "size"
attributes <- obj .? "attributes" attributes <- obj .: "attributes"
x <- obj .? "x_coord" x <- obj .: "x_coord"
y <- obj .? "y_coord" y <- obj .: "y_coord"
pure $ Node { id_, type_, size, label, attributes, x, y } pure $ Node { id_, type_, size, label, attributes, x, y }
instance decodeJsonMetaData :: DecodeJson MetaData where instance decodeJsonMetaData :: DecodeJson MetaData where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
title <- obj .? "title" title <- obj .: "title"
legend <- obj .? "legend" legend <- obj .: "legend"
corpusId <- obj .? "corpusId" corpusId <- obj .: "corpusId"
listId <- obj .? "listId" listId <- obj .: "listId"
pure $ MetaData { title, legend, corpusId, listId} pure $ MetaData { title, legend, corpusId, listId}
instance decodeJsonLegend :: DecodeJson Legend where instance decodeJsonLegend :: DecodeJson Legend where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
id_ <- obj .? "id" id_ <- obj .: "id"
color <- obj .? "color" color <- obj .: "color"
label <- obj .? "label" label <- obj .: "label"
pure $ Legend { id_, color, label } pure $ Legend { id_, color, label }
instance decodeJsonCluster :: DecodeJson Cluster where instance decodeJsonCluster :: DecodeJson Cluster where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
clustDefault <- obj .? "clust_default" clustDefault <- obj .: "clust_default"
pure $ Cluster { clustDefault } pure $ Cluster { clustDefault }
instance decodeJsonEdge :: DecodeJson Edge where instance decodeJsonEdge :: DecodeJson Edge where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
id_ <- obj .? "id" id_ <- obj .: "id"
source <- obj .? "source" source <- obj .: "source"
target <- obj .? "target" target <- obj .: "target"
weight <- obj .? "weight" weight <- obj .: "weight"
confluence <- obj .? "confluence" confluence <- obj .: "confluence"
pure $ Edge { id_, source, target, weight, confluence } pure $ Edge { id_, source, target, weight, confluence }
newtype Legend = Legend {id_ ::Int , color :: String, label :: String} newtype Legend = Legend {id_ ::Int , color :: String, label :: String}
......
...@@ -2,7 +2,7 @@ module Gargantext.Components.Login.Types where ...@@ -2,7 +2,7 @@ module Gargantext.Components.Login.Types where
import Prelude import Prelude
import Data.Argonaut ( class DecodeJson, class EncodeJson, decodeJson, jsonEmptyObject import Data.Argonaut ( class DecodeJson, class EncodeJson, decodeJson, jsonEmptyObject
, (.?), (.??), (:=), (~>) , (.:), (.:!), (:=), (~>)
) )
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Eq (genericEq) import Data.Generic.Rep.Eq (genericEq)
...@@ -44,21 +44,21 @@ _AuthData = iso (\(AuthData v) -> v) AuthData ...@@ -44,21 +44,21 @@ _AuthData = iso (\(AuthData v) -> v) AuthData
instance decodeAuthInvalid :: DecodeJson AuthInvalid where instance decodeAuthInvalid :: DecodeJson AuthInvalid where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
message <- obj .? "message" message <- obj .: "message"
pure $ AuthInvalid {message} pure $ AuthInvalid {message}
instance decodeAuthResponse :: DecodeJson AuthResponse where instance decodeAuthResponse :: DecodeJson AuthResponse where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
valid <- obj .?? "valid" valid <- obj .:! "valid"
inval <- obj .?? "inval" inval <- obj .:! "inval"
pure $ AuthResponse {valid, inval} pure $ AuthResponse {valid, inval}
instance decodeAuthData :: DecodeJson AuthData where instance decodeAuthData :: DecodeJson AuthData where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
token <- obj .? "token" token <- obj .: "token"
tree_id <- obj .? "tree_id" tree_id <- obj .: "tree_id"
pure $ AuthData {token, tree_id} pure $ AuthData {token, tree_id}
instance encodeAuthRequest :: EncodeJson AuthRequest where instance encodeAuthRequest :: EncodeJson AuthRequest where
......
...@@ -2,7 +2,7 @@ module Gargantext.Components.Node ...@@ -2,7 +2,7 @@ module Gargantext.Components.Node
where where
import Gargantext.Prelude import Gargantext.Prelude
import Data.Argonaut (class DecodeJson, decodeJson, (.?)) import Data.Argonaut (class DecodeJson, decodeJson, (.:))
newtype NodePoly a = newtype NodePoly a =
NodePoly { id :: Int NodePoly { id :: Int
...@@ -19,14 +19,14 @@ instance decodeNodePoly :: (DecodeJson a) ...@@ -19,14 +19,14 @@ instance decodeNodePoly :: (DecodeJson a)
=> DecodeJson (NodePoly a) where => DecodeJson (NodePoly a) where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
id <- obj .? "id" id <- obj .: "id"
typename <- obj .? "typename" typename <- obj .: "typename"
userId <- obj .? "userId" userId <- obj .: "userId"
parentId <- obj .? "parentId" parentId <- obj .: "parentId"
name <- obj .? "name" name <- obj .: "name"
date <- obj .? "date" date <- obj .: "date"
hyperdata <- obj .? "hyperdata" hyperdata <- obj .: "hyperdata"
hyperdata' <- decodeJson hyperdata hyperdata' <- decodeJson hyperdata
pure $ NodePoly { id : id pure $ NodePoly { id : id
...@@ -43,6 +43,6 @@ newtype HyperdataList = HyperdataList { preferences :: String} ...@@ -43,6 +43,6 @@ newtype HyperdataList = HyperdataList { preferences :: String}
instance decodeHyperdataList :: DecodeJson HyperdataList where instance decodeHyperdataList :: DecodeJson HyperdataList where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
pref <- obj .? "preferences" pref <- obj .: "preferences"
pure $ HyperdataList { preferences : pref} pure $ HyperdataList { preferences : pref}
...@@ -2,7 +2,7 @@ module Gargantext.Pages.Annuaire where ...@@ -2,7 +2,7 @@ module Gargantext.Pages.Annuaire where
import Gargantext.Prelude import Gargantext.Prelude
import Data.Argonaut (class DecodeJson, decodeJson, (.?), (.??)) import Data.Argonaut (class DecodeJson, decodeJson, (.:), (.:!))
import Data.Array (head) import Data.Array (head)
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Lens (Prism', prism) import Data.Lens (Prism', prism)
...@@ -177,8 +177,8 @@ data HyperdataAnnuaire = HyperdataAnnuaire ...@@ -177,8 +177,8 @@ data HyperdataAnnuaire = HyperdataAnnuaire
instance decodeHyperdataAnnuaire :: DecodeJson HyperdataAnnuaire where instance decodeHyperdataAnnuaire :: DecodeJson HyperdataAnnuaire where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
title <- obj .?? "title" title <- obj .:! "title"
desc <- obj .?? "desc" desc <- obj .:! "desc"
pure $ HyperdataAnnuaire { title, desc } pure $ HyperdataAnnuaire { title, desc }
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
...@@ -194,13 +194,13 @@ newtype AnnuaireInfo = AnnuaireInfo { id :: Int ...@@ -194,13 +194,13 @@ newtype AnnuaireInfo = AnnuaireInfo { id :: Int
instance decodeAnnuaireInfo :: DecodeJson AnnuaireInfo where instance decodeAnnuaireInfo :: DecodeJson AnnuaireInfo where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
id <- obj .? "id" id <- obj .: "id"
typename <- obj .? "typename" typename <- obj .: "typename"
userId <- obj .? "userId" userId <- obj .: "userId"
parentId <- obj .? "parentId" parentId <- obj .: "parentId"
name <- obj .? "name" name <- obj .: "name"
date <- obj .? "date" date <- obj .: "date"
hyperdata <- obj .? "hyperdata" hyperdata <- obj .: "hyperdata"
pure $ AnnuaireInfo { id : id pure $ AnnuaireInfo { id : id
, typename : typename , typename : typename
, userId : userId , userId : userId
......
...@@ -2,19 +2,12 @@ module Gargantext.Pages.Annuaire.User.Contacts.Types where ...@@ -2,19 +2,12 @@ module Gargantext.Pages.Annuaire.User.Contacts.Types where
import Prelude import Prelude
import Data.Argonaut (class DecodeJson, decodeJson, (.?), (.??)) import Data.Argonaut (class DecodeJson, decodeJson, (.:), (.:!))
import Data.Either (Either(..)) import Data.Maybe (Maybe, fromMaybe)
import Data.Lens (Lens', Prism', lens, prism) import Data.Map (Map)
import Data.Maybe (Maybe(..), maybe, fromMaybe)
import Data.Map (Map(..))
import React (ReactElement)
import React.DOM (div)
import Gargantext.Components.Loader as Loader
import Gargantext.Components.Tab as Tab
import Gargantext.Utils.DecodeMaybe ((.?|)) import Gargantext.Utils.DecodeMaybe ((.?|))
import Data.Newtype import Data.Newtype (class Newtype)
-- TODO: should it be a NodePoly HyperdataContact ? -- TODO: should it be a NodePoly HyperdataContact ?
newtype Contact = Contact { newtype Contact = Contact {
...@@ -43,11 +36,11 @@ instance decodeContactWho :: DecodeJson ContactWho ...@@ -43,11 +36,11 @@ instance decodeContactWho :: DecodeJson ContactWho
where where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
idWho <- obj .?? "id" idWho <- obj .:! "id"
firstName <- obj .?? "firstName" firstName <- obj .:! "firstName"
lastName <- obj .?? "lastName" lastName <- obj .:! "lastName"
keywords <- obj .?? "keywords" keywords <- obj .:! "keywords"
freetags <- obj .?? "freetags" freetags <- obj .:! "freetags"
let k = fromMaybe [] keywords let k = fromMaybe [] keywords
let f = fromMaybe [] freetags let f = fromMaybe [] freetags
...@@ -75,15 +68,15 @@ instance decodeContactWhere :: DecodeJson ContactWhere ...@@ -75,15 +68,15 @@ instance decodeContactWhere :: DecodeJson ContactWhere
where where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
organization <- obj .?? "organization" organization <- obj .:! "organization"
labTeamDepts <- obj .?? "labTeamDepts" labTeamDepts <- obj .:! "labTeamDepts"
role <- obj .?? "role" role <- obj .:! "role"
office <- obj .?? "office" office <- obj .:! "office"
country <- obj .?? "country" country <- obj .:! "country"
city <- obj .?? "city" city <- obj .:! "city"
touch <- obj .?? "touch" touch <- obj .:! "touch"
entry <- obj .?? "entry" entry <- obj .:! "entry"
exit <- obj .?? "exit" exit <- obj .:! "exit"
let o = fromMaybe [] organization let o = fromMaybe [] organization
let l = fromMaybe [] labTeamDepts let l = fromMaybe [] labTeamDepts
...@@ -101,9 +94,9 @@ instance decodeContactTouch :: DecodeJson ContactTouch ...@@ -101,9 +94,9 @@ instance decodeContactTouch :: DecodeJson ContactTouch
where where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
mail <- obj .?? "mail" mail <- obj .:! "mail"
phone <- obj .?? "phone" phone <- obj .:! "phone"
url <- obj .?? "url" url <- obj .:! "url"
pure $ ContactTouch {mail, phone, url} pure $ ContactTouch {mail, phone, url}
...@@ -123,14 +116,14 @@ instance decodeHyperdataContact :: DecodeJson HyperdataContact ...@@ -123,14 +116,14 @@ instance decodeHyperdataContact :: DecodeJson HyperdataContact
where where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
bdd <- obj .?? "bdd" bdd <- obj .:! "bdd"
who <- obj .?? "who" who <- obj .:! "who"
ou <- obj .?? "where" ou <- obj .:! "where"
title <- obj .?? "title" title <- obj .:! "title"
source <- obj .?? "source" source <- obj .:! "source"
lastValidation <- obj .?? "lastValidation" lastValidation <- obj .:! "lastValidation"
uniqId <- obj .?? "uniqId" uniqId <- obj .:! "uniqId"
uniqIdBdd <- obj .?? "uniqIdBdd" uniqIdBdd <- obj .:! "uniqIdBdd"
let ou' = fromMaybe [] ou let ou' = fromMaybe [] ou
...@@ -155,13 +148,13 @@ instance decodeUserHyperData :: (DecodeJson c, DecodeJson s) => ...@@ -155,13 +148,13 @@ instance decodeUserHyperData :: (DecodeJson c, DecodeJson s) =>
instance decodeUser :: DecodeJson Contact where instance decodeUser :: DecodeJson Contact where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
id <- obj .? "id" id <- obj .: "id"
typename <- obj .?| "typename" typename <- obj .?| "typename"
userId <- obj .?? "userId" userId <- obj .:! "userId"
parentId <- obj .?| "parentId" parentId <- obj .?| "parentId"
name <- obj .?? "name" name <- obj .:! "name"
date <- obj .?| "date" date <- obj .?| "date"
hyperdata <- obj .? "hyperdata" hyperdata <- obj .: "hyperdata"
pure $ Contact { id, typename, userId pure $ Contact { id, typename, userId
, parentId, name, date , parentId, name, date
, hyperdata , hyperdata
......
module Gargantext.Pages.Corpus.Chart.Histo where module Gargantext.Pages.Corpus.Chart.Histo where
import Data.Argonaut (class DecodeJson, decodeJson, (.?)) import Data.Argonaut (class DecodeJson, decodeJson, (.:))
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Gargantext.Config -- (End(..), Path(..), TabType, toUrl) import Gargantext.Config -- (End(..), Path(..), TabType, toUrl)
...@@ -30,7 +30,7 @@ newtype ChartMetrics = ChartMetrics ...@@ -30,7 +30,7 @@ newtype ChartMetrics = ChartMetrics
instance decodeChartMetrics :: DecodeJson ChartMetrics where instance decodeChartMetrics :: DecodeJson ChartMetrics where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
d <- obj .? "data" d <- obj .: "data"
pure $ ChartMetrics { "data": d } pure $ ChartMetrics { "data": d }
newtype HistoMetrics = HistoMetrics newtype HistoMetrics = HistoMetrics
...@@ -41,8 +41,8 @@ newtype HistoMetrics = HistoMetrics ...@@ -41,8 +41,8 @@ newtype HistoMetrics = HistoMetrics
instance decodeHistoMetrics :: DecodeJson HistoMetrics where instance decodeHistoMetrics :: DecodeJson HistoMetrics where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
d <- obj .? "dates" d <- obj .: "dates"
c <- obj .? "count" c <- obj .: "count"
pure $ HistoMetrics { dates : d , count: c} pure $ HistoMetrics { dates : d , count: c}
type Loaded = HistoMetrics type Loaded = HistoMetrics
......
module Gargantext.Pages.Corpus.Chart.Metrics where module Gargantext.Pages.Corpus.Chart.Metrics where
import Data.Argonaut (class DecodeJson, decodeJson, (.?)) import Data.Argonaut (class DecodeJson, decodeJson, (.:))
import Data.Map as Map import Data.Map as Map
import Data.Map (Map) import Data.Map (Map)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
...@@ -39,10 +39,10 @@ newtype Metric = Metric ...@@ -39,10 +39,10 @@ newtype Metric = Metric
instance decodeMetric :: DecodeJson Metric where instance decodeMetric :: DecodeJson Metric where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
label <- obj .? "label" label <- obj .: "label"
x <- obj .? "x" x <- obj .: "x"
y <- obj .? "y" y <- obj .: "y"
cat <- obj .? "cat" cat <- obj .: "cat"
pure $ Metric { label, x, y, cat } pure $ Metric { label, x, y, cat }
newtype Metrics = Metrics newtype Metrics = Metrics
...@@ -52,7 +52,7 @@ newtype Metrics = Metrics ...@@ -52,7 +52,7 @@ newtype Metrics = Metrics
instance decodeMetrics :: DecodeJson Metrics where instance decodeMetrics :: DecodeJson Metrics where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
d <- obj .? "data" d <- obj .: "data"
pure $ Metrics { "data": d } pure $ Metrics { "data": d }
type Loaded = Array Metric type Loaded = Array Metric
...@@ -76,16 +76,16 @@ scatterOptions metrics = Options ...@@ -76,16 +76,16 @@ scatterOptions metrics = Options
map2series ms = toSeries <$> Map.toUnfoldable ms map2series ms = toSeries <$> Map.toUnfoldable ms
where where
-- TODO colors are not respected yet -- TODO colors are not respected yet
toSeries (Tuple k ms) = toSeries (Tuple k ms') =
seriesScatterD2 {symbolSize: 5.0} (toSerie color <$> ms) seriesScatterD2 {symbolSize: 5.0} (toSerie color <$> ms')
where where
color = color =
case k of case k of
StopTerm -> red StopTerm -> red
GraphTerm -> green GraphTerm -> green
CandidateTerm -> grey CandidateTerm -> grey
toSerie color (Metric {label,x,y}) = toSerie color' (Metric {label,x,y}) =
dataSerie { name: label, itemStyle: itemStyle {color} dataSerie { name: label, itemStyle: itemStyle {color: color'}
-- , label: {show: true} -- , label: {show: true}
, value: [x,y] , value: [x,y]
} }
...@@ -108,8 +108,8 @@ metricsLoadView :: R.State Int -> Path -> R.Element ...@@ -108,8 +108,8 @@ metricsLoadView :: R.State Int -> Path -> R.Element
metricsLoadView setReload p = R.createElement el p [] metricsLoadView setReload p = R.createElement el p []
where where
el = R.hooksComponent "MetricsLoadedView" cpt el = R.hooksComponent "MetricsLoadedView" cpt
cpt p _ = do cpt p' _ = do
useLoader p getMetrics $ \{loaded} -> useLoader p' getMetrics $ \{loaded} ->
loadedMetricsView setReload loaded loadedMetricsView setReload loaded
loadedMetricsView :: R.State Int -> Loaded -> R.Element loadedMetricsView :: R.State Int -> Loaded -> R.Element
......
module Gargantext.Pages.Corpus.Chart.Pie where module Gargantext.Pages.Corpus.Chart.Pie where
import Data.Argonaut (class DecodeJson, decodeJson, (.?)) import Data.Argonaut (class DecodeJson, decodeJson, (.:))
import Data.Array (zip, filter) import Data.Array (zip, filter)
import Data.Array as A import Data.Array as A
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
...@@ -34,7 +34,7 @@ newtype ChartMetrics = ChartMetrics ...@@ -34,7 +34,7 @@ newtype ChartMetrics = ChartMetrics
instance decodeChartMetrics :: DecodeJson ChartMetrics where instance decodeChartMetrics :: DecodeJson ChartMetrics where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
d <- obj .? "data" d <- obj .: "data"
pure $ ChartMetrics { "data": d } pure $ ChartMetrics { "data": d }
newtype HistoMetrics = HistoMetrics newtype HistoMetrics = HistoMetrics
...@@ -45,8 +45,8 @@ newtype HistoMetrics = HistoMetrics ...@@ -45,8 +45,8 @@ newtype HistoMetrics = HistoMetrics
instance decodeHistoMetrics :: DecodeJson HistoMetrics where instance decodeHistoMetrics :: DecodeJson HistoMetrics where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
d <- obj .? "dates" d <- obj .: "dates"
c <- obj .? "count" c <- obj .: "count"
pure $ HistoMetrics { dates : d , count: c} pure $ HistoMetrics { dates : d , count: c}
type Loaded = HistoMetrics type Loaded = HistoMetrics
......
module Gargantext.Pages.Corpus.Chart.Tree where module Gargantext.Pages.Corpus.Chart.Tree where
import Data.Argonaut (class DecodeJson, decodeJson, (.?)) import Data.Argonaut (class DecodeJson, decodeJson, (.:))
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Gargantext.Config -- (End(..), Path(..), TabType, toUrl) import Gargantext.Config -- (End(..), Path(..), TabType, toUrl)
...@@ -33,7 +33,7 @@ newtype Metrics = Metrics ...@@ -33,7 +33,7 @@ newtype Metrics = Metrics
instance decodeMetrics :: DecodeJson Metrics where instance decodeMetrics :: DecodeJson Metrics where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
d <- obj .? "data" d <- obj .: "data"
pure $ Metrics { "data": d } pure $ Metrics { "data": d }
type Loaded = Array TreeNode type Loaded = Array TreeNode
......
module Gargantext.Pages.Lists.Tabs.Types where module Gargantext.Pages.Lists.Tabs.Types where
import Data.Argonaut (class DecodeJson, decodeJson, (.?), (.??)) import Data.Argonaut (class DecodeJson, decodeJson, (.:), (.:!))
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
-------------------------------------------------------- --------------------------------------------------------
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Components.Node (NodePoly(..)) import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.Loader as Loader
newtype CorpusInfo = CorpusInfo { title :: String newtype CorpusInfo = CorpusInfo { title :: String
, desc :: String , desc :: String
...@@ -35,11 +34,11 @@ corpusInfoDefault = NodePoly { id : 0 ...@@ -35,11 +34,11 @@ corpusInfoDefault = NodePoly { id : 0
instance decodeCorpusInfo :: DecodeJson CorpusInfo where instance decodeCorpusInfo :: DecodeJson CorpusInfo where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
title <- obj .? "title" title <- obj .: "title"
desc <- obj .? "desc" desc <- obj .: "desc"
query <- obj .? "query" query <- obj .: "query"
authors <- obj .? "authors" authors <- obj .: "authors"
chart <- obj .?? "chart" chart <- obj .:! "chart"
let totalRecords = 47361 -- TODO let totalRecords = 47361 -- TODO
pure $ CorpusInfo {title, desc, query, authors, chart, totalRecords} pure $ CorpusInfo {title, desc, query, authors, chart, totalRecords}
......
module Gargantext.Pages.Texts.Tabs.Types where module Gargantext.Pages.Texts.Tabs.Types where
import Data.Argonaut (class DecodeJson, decodeJson, (.?), (.??)) import Data.Argonaut (class DecodeJson, decodeJson, (.:), (.:!))
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
-------------------------------------------------------- --------------------------------------------------------
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Components.Node (NodePoly(..)) import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.Loader as Loader
newtype CorpusInfo = CorpusInfo { title :: String newtype CorpusInfo = CorpusInfo { title :: String
, desc :: String , desc :: String
...@@ -35,11 +34,11 @@ corpusInfoDefault = NodePoly { id : 0 ...@@ -35,11 +34,11 @@ corpusInfoDefault = NodePoly { id : 0
instance decodeCorpusInfo :: DecodeJson CorpusInfo where instance decodeCorpusInfo :: DecodeJson CorpusInfo where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
title <- obj .? "title" title <- obj .: "title"
desc <- obj .? "desc" desc <- obj .: "desc"
query <- obj .? "query" query <- obj .: "query"
authors <- obj .? "authors" authors <- obj .: "authors"
chart <- obj .?? "chart" chart <- obj .:! "chart"
let totalRecords = 47361 -- TODO let totalRecords = 47361 -- TODO
pure $ CorpusInfo {title, desc, query, authors, chart, totalRecords} pure $ CorpusInfo {title, desc, query, authors, chart, totalRecords}
......
module Gargantext.Types where module Gargantext.Types where
import Data.Argonaut ( class DecodeJson, decodeJson, class EncodeJson, encodeJson import Data.Argonaut ( class DecodeJson, decodeJson, class EncodeJson, encodeJson )
, jsonEmptyObject, (:=), (~>), (.?), (.??) )
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Either (Either(..)) import Data.Either (Either(..))
import Prim.Row (class Union) import Prim.Row (class Union)
......
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