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
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
e987d153
Unverified
Commit
e987d153
authored
Mar 12, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NGRAMS,METRICS] WIP
parent
decd3c80
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
113 additions
and
4 deletions
+113
-4
Config.purs
src/Gargantext/Config.purs
+13
-1
Metrics.purs
src/Gargantext/Pages/Corpus/Metrics.purs
+90
-0
Specs.purs
src/Gargantext/Pages/Corpus/Tabs/Specs.purs
+10
-3
No files found.
src/Gargantext/Config.purs
View file @
e987d153
...
@@ -112,6 +112,10 @@ offsetUrl o = "&offset=" <> show o
...
@@ -112,6 +112,10 @@ offsetUrl o = "&offset=" <> show o
orderUrl :: forall a. Show a => Maybe a -> UrlPath
orderUrl :: forall a. Show a => Maybe a -> UrlPath
orderUrl = maybe "" (\x -> "&order=" <> show x)
orderUrl = maybe "" (\x -> "&order=" <> show x)
showTabType' :: TabType -> String
showTabType' (TabCorpus t) = show t
showTabType' (TabPairing t) = show t
tabTypeNgramsGet :: TabType -> UrlPath
tabTypeNgramsGet :: TabType -> UrlPath
tabTypeNgramsGet (TabCorpus t) = "listGet?ngramsType=" <> show t
tabTypeNgramsGet (TabCorpus t) = "listGet?ngramsType=" <> show t
tabTypeNgramsGet (TabPairing t) = "listGet?ngramsType=" <> show t -- TODO
tabTypeNgramsGet (TabPairing t) = "listGet?ngramsType=" <> show t -- TODO
...
@@ -155,7 +159,11 @@ pathUrl c (NodeAPI nt) i = c.prePath <> nodeTypeUrl nt <> (maybe "" (\i' -> "/"
...
@@ -155,7 +159,11 @@ pathUrl c (NodeAPI nt) i = c.prePath <> nodeTypeUrl nt <> (maybe "" (\i' -> "/"
pathUrl c (Search {limit,offset,orderBy}) _TODO =
pathUrl c (Search {limit,offset,orderBy}) _TODO =
c.prePath <> "search/?dummy=dummy"
c.prePath <> "search/?dummy=dummy"
<> offsetUrl offset <> limitUrl limit <> orderUrl orderBy
<> offsetUrl offset <> limitUrl limit <> orderUrl orderBy
pathUrl c (CorpusMetrics {tabType, listId, limit}) i =
pathUrl c (NodeAPI Corpus) i <> "/metrics"
<> "&list=" <> show listId
<> "&ngramsType=" <> showTabType' tabType
<> maybe "" (\x -> "&limit=" <> show x) limit
------------------------------------------------------------
------------------------------------------------------------
...
@@ -233,6 +241,10 @@ data Path
...
@@ -233,6 +241,10 @@ data Path
, offset :: Offset
, offset :: Offset
, orderBy :: Maybe OrderBy
, orderBy :: Maybe OrderBy
}
}
| CorpusMetrics { tabType :: TabType
, listId :: ListId
, limit :: Maybe Limit
}
data End = Back | Front
data End = Back | Front
type Id = Int
type Id = Int
...
...
src/Gargantext/Pages/Corpus/Metrics.purs
0 → 100644
View file @
e987d153
module Gargantext.Pages.Corpus.Metrics where
import Data.Argonaut (class DecodeJson, decodeJson, (.?))
import Data.Maybe (Maybe(..))
import Effect.Aff (Aff)
import Gargantext.Config -- (End(..), Path(..), TabType, toUrl)
import Gargantext.Config.REST (get)
import React (ReactClass, ReactElement, createElement)
import Thermite (Spec, Render, defaultPerformAction, simpleSpec, createClass)
import Gargantext.Prelude
import Gargantext.Types (TermList)
import Gargantext.Components.Loader as Loader
import Gargantext.Components.Charts.Options.ECharts
import Gargantext.Components.Charts.Options.Series
type Path =
{ corpusId :: Int
, listId :: Int
, tabType :: TabType
, limit :: Maybe Int
}
newtype Metric = Metric
{ label :: String
, x :: Number
, y :: Number
, cat :: TermList
}
instance decodeMetric :: 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 }
newtype Metrics = Metrics
{ "data" :: Array Metric
}
instance decodeMetrics :: DecodeJson Metrics where
decodeJson json = do
obj <- decodeJson json
d <- obj .? "data"
pure $ Metrics { "data": d }
type Loaded = Array Metric
loadedMetricsSpec :: Spec {} (Loader.InnerProps Path Loaded ()) Void
loadedMetricsSpec = simpleSpec defaultPerformAction render
where
render :: Render {} (Loader.InnerProps Path Loaded ()) Void
render dispatch {loaded} {} _ = [chart (scatterOptions loaded)]
scatterOptions :: Loaded -> Options
scatterOptions ds = Options
{ mainTitle : "TODO Scatter test"
, subTitle : "TODO Scatter subtitle"
, xAxis : xAxis [] -- $ SeriesD2 $ seriesD2 Scatter 5.0 (_.x <$> ds)
, yAxis : [ SeriesD2 $ seriesD2 Scatter 5.0 (_y <$> ds) ]
, yAxisFormat : (YAxisFormat { position : ""
, visible : true
})
, addZoom : false
}
where
_y (Metric {x,y}) = [x,y]
getMetrics :: Path -> Aff Loaded
getMetrics {corpusId, listId, limit, tabType} = do
Metrics ms <- get $ toUrl Back (CorpusMetrics {listId, tabType, limit}) $ Just corpusId
pure ms."data"
metricsLoaderClass :: ReactClass (Loader.Props Path Loaded)
metricsLoaderClass = Loader.createLoaderClass "MetricsLoader" getMetrics
metricsLoader :: Loader.Props' Path Loaded -> ReactElement
metricsLoader props = createElement metricsLoaderClass props []
metricsSpec :: Spec {} Path Void
metricsSpec = simpleSpec defaultPerformAction render
where
render :: Render {} Path Void
render dispatch path {} _ =
[ metricsLoader
{ path
, component: createClass "LoadedMetrics" loadedMetricsSpec (const {})
} ]
src/Gargantext/Pages/Corpus/Tabs/Specs.purs
View file @
e987d153
...
@@ -5,11 +5,13 @@ import Prelude hiding (div)
...
@@ -5,11 +5,13 @@ import Prelude hiding (div)
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Generic.Rep.Show (genericShow)
import Data.List (fromFoldable)
import Data.List (fromFoldable)
import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..))
import Data.Tuple (Tuple(..))
import Gargantext.Config (TabType(..), TabSubType(..))
import Gargantext.Config (TabType(..), TabSubType(..))
import Gargantext.Config (CTabNgramType(..), End(..), Path(..), TabSubType(..), TabType(..), toUrl)
import Gargantext.Config (CTabNgramType(..), End(..), Path(..), TabSubType(..), TabType(..), toUrl)
import Gargantext.Pages.Corpus.Tabs.Types (Props)
import Gargantext.Pages.Corpus.Tabs.Types (Props)
import Gargantext.Pages.Corpus.Metrics (metricsSpec)
import Gargantext.Pages.Corpus.Dashboard (globalPublis)
import Gargantext.Pages.Corpus.Dashboard (globalPublis)
import Gargantext.Components.NgramsTable as NT
import Gargantext.Components.NgramsTable as NT
...
@@ -55,8 +57,13 @@ statefulTabs =
...
@@ -55,8 +57,13 @@ statefulTabs =
ngramsViewSpec :: {mode :: Mode} -> Spec Tab.State Props Tab.Action
ngramsViewSpec :: {mode :: Mode} -> Spec Tab.State Props Tab.Action
ngramsViewSpec {mode} =
ngramsViewSpec {mode} =
cmapProps (\{loaded: {defaultListId}, path, dispatch} ->
noState (
{loaded: {defaultListId}, path, dispatch, tabType})
cmapProps (\{loaded: {defaultListId}, path: corpusId} ->
(noState NT.mainNgramsTableSpec)
{corpusId, listId: defaultListId, tabType, limit: Nothing})
metricsSpec <>
cmapProps (\{loaded: {defaultListId}, path, dispatch} ->
{loaded: {defaultListId}, path, dispatch, tabType})
NT.mainNgramsTableSpec
)
where
where
tabType = TabCorpus $ TabNgramType $ modeTabType mode
tabType = TabCorpus $ TabNgramType $ modeTabType mode
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