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
fe45614a
Verified
Commit
fe45614a
authored
Apr 26, 2023
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[chart] fix components to be truly react components
parent
823a1866
Pipeline
#3948
failed with stage
in 0 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
105 additions
and
55 deletions
+105
-55
Common.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Common.purs
+3
-2
Histo.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Histo.purs
+20
-8
Metrics.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Metrics.purs
+18
-9
Pie.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Pie.purs
+34
-16
Tree.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Tree.purs
+17
-8
Utils.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Utils.purs
+13
-12
No files found.
src/Gargantext/Components/Nodes/Corpus/Chart/Common.purs
View file @
fe45614a
...
@@ -56,7 +56,8 @@ metricsLoadViewCpt = here.component "metricsLoadView" cpt
...
@@ -56,7 +56,8 @@ metricsLoadViewCpt = here.component "metricsLoadView" cpt
type MetricsWithCacheLoadViewProps res ret =
type MetricsWithCacheLoadViewProps res ret =
( getMetricsHash :: Session -> ReloadPath -> AffRESTError Hash
( getMetricsHash :: Session -> ReloadPath -> AffRESTError Hash
, handleResponse :: HashedResponse res -> ret
, handleResponse :: HashedResponse res -> ret
, loaded :: Record MetricsProps -> ret -> R.Element
-- , loaded :: Record MetricsProps -> ret -> R.Element
, loaded :: Record (metrics :: ret | MetricsProps) -> R.Element
, mkRequest :: ReloadPath -> GUC.Request
, mkRequest :: ReloadPath -> GUC.Request
| MetricsProps
| MetricsProps
)
)
...
@@ -87,5 +88,5 @@ metricsWithCacheLoadViewCpt = here.component "metricsWithCacheLoadView" cpt
...
@@ -87,5 +88,5 @@ metricsWithCacheLoadViewCpt = here.component "metricsWithCacheLoadView" cpt
, handleResponse
, handleResponse
, mkRequest
, mkRequest
, path: (reload' /\ path)
, path: (reload' /\ path)
, renderer:
loaded { boxes, path, reload, session, onClick, onInit
}
, renderer:
\metrics -> loaded { boxes, path, reload, session, onClick, onInit, metrics
}
, spinnerClass: Just "echarts-for-react-spinner" }
, spinnerClass: Just "echarts-for-react-spinner" }
src/Gargantext/Components/Nodes/Corpus/Chart/Histo.purs
View file @
fe45614a
...
@@ -24,6 +24,7 @@ import Gargantext.Utils.Reactix as R2
...
@@ -24,6 +24,7 @@ import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
import Gargantext.Utils.Toestand as T2
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
import Record.Extra as RX
import Simple.JSON as JSON
import Simple.JSON as JSON
import Toestand as T
import Toestand as T
...
@@ -47,8 +48,14 @@ derive newtype instance JSON.WriteForeign HistoMetrics
...
@@ -47,8 +48,14 @@ derive newtype instance JSON.WriteForeign HistoMetrics
type Loaded = HistoMetrics
type Loaded = HistoMetrics
chartOptions :: Record MetricsProps -> HistoMetrics -> Options
type LoadedProps =
chartOptions { onClick, onInit } (HistoMetrics { dates: dates', count: count'}) = Options
( metrics :: HistoMetrics
| MetricsProps )
chartOptions :: Record LoadedProps -> Options
chartOptions { onClick
, onInit
, metrics: HistoMetrics { dates: dates', count: count'} } = Options
{ mainTitle : "Histogram"
{ mainTitle : "Histogram"
, subTitle : "Distribution of publications over time"
, subTitle : "Distribution of publications over time"
, xAxis : xAxis' dates'
, xAxis : xAxis' dates'
...
@@ -112,10 +119,15 @@ histoCpt = here.component "histo" cpt
...
@@ -112,10 +119,15 @@ histoCpt = here.component "histo" cpt
, onInit
, onInit
}
}
loaded :: Record MetricsProps -> HistoMetrics -> R.Element
loaded :: R2.Leaf LoadedProps
loaded p l =
loaded = R2.leaf loadedCpt
H.div {} [ U.reloadButton p.reload
loadedCpt :: R.Component LoadedProps
, U.chartUpdateButton { chartType: Histo, path:p.path, reload:p.reload, session:p.session }
loadedCpt = here.component "loaded" cpt where
, chart $ chartOptions p l
cpt p@{ path
]
, reload
, session } _ = do
pure $ H.div {} [ U.reloadButton { reload }
, U.chartUpdateButton { chartType: Histo, path, reload, session }
, chart $ chartOptions p
]
-- TODO: parametrize ngramsType above
-- TODO: parametrize ngramsType above
src/Gargantext/Components/Nodes/Corpus/Chart/Metrics.purs
View file @
fe45614a
...
@@ -54,8 +54,12 @@ derive newtype instance JSON.ReadForeign Metrics
...
@@ -54,8 +54,12 @@ derive newtype instance JSON.ReadForeign Metrics
type Loaded = Array Metric
type Loaded = Array Metric
scatterOptions :: Record MetricsProps -> Array Metric -> Options
type LoadedProps =
scatterOptions { onClick, onInit } metrics' = Options
( metrics :: Array Metric
| MetricsProps )
scatterOptions :: Record LoadedProps -> Options
scatterOptions { onClick, onInit, metrics: metrics' } = Options
{ mainTitle : "Ngrams Selection Metrics"
{ mainTitle : "Ngrams Selection Metrics"
, subTitle : "Local metrics (Inc/Exc, Spe/Gen), Global metrics (TFICF maillage)"
, subTitle : "Local metrics (Inc/Exc, Spe/Gen), Global metrics (TFICF maillage)"
, xAxis : xAxis { min: -1 }
, xAxis : xAxis { min: -1 }
...
@@ -125,10 +129,15 @@ metricsCpt = here.component "etrics" cpt
...
@@ -125,10 +129,15 @@ metricsCpt = here.component "etrics" cpt
}
}
loaded :: Record MetricsProps -> Loaded -> R.Element
loaded :: R2.Leaf LoadedProps
loaded p loaded' =
loaded = R2.leaf loadedCpt
H.div {} [
loadedCpt :: R.Component LoadedProps
{- U.reloadButton reload
loadedCpt = here.component "loaded" cpt where
, U.chartUpdateButton { chartType: Scatter, path, reload, session }
cpt p@{ path
, -} chart $ scatterOptions p loaded'
, reload
]
, session } _ = do
pure $ H.div {} [
{- U.reloadButton reload
, U.chartUpdateButton { chartType: Scatter, path, reload, session }
, -} chart $ scatterOptions p
]
src/Gargantext/Components/Nodes/Corpus/Chart/Pie.purs
View file @
fe45614a
...
@@ -52,8 +52,14 @@ derive newtype instance JSON.WriteForeign HistoMetrics
...
@@ -52,8 +52,14 @@ derive newtype instance JSON.WriteForeign HistoMetrics
type Loaded = HistoMetrics
type Loaded = HistoMetrics
chartOptionsBar :: Record MetricsProps -> HistoMetrics -> Options
type LoadedProps =
chartOptionsBar { onClick, onInit } (HistoMetrics { dates: dates', count: count'}) = Options
( metrics :: HistoMetrics
| MetricsProps )
chartOptionsBar :: Record LoadedProps -> Options
chartOptionsBar { onClick
, onInit
, metrics: HistoMetrics { dates: dates', count: count'} } = Options
{ mainTitle : "Bar"
{ mainTitle : "Bar"
, subTitle : "Count of MapTerm"
, subTitle : "Count of MapTerm"
, xAxis : xAxis' $ map (\t -> joinWith " " $ map (take 3) $ A.take 3 $ filter (\s -> length s > 3) $ split (Pattern " ") t) dates'
, xAxis : xAxis' $ map (\t -> joinWith " " $ map (take 3) $ A.take 3 $ filter (\s -> length s > 3) $ split (Pattern " ") t) dates'
...
@@ -65,8 +71,10 @@ chartOptionsBar { onClick, onInit } (HistoMetrics { dates: dates', count: count'
...
@@ -65,8 +71,10 @@ chartOptionsBar { onClick, onInit } (HistoMetrics { dates: dates', count: count'
, onInit
, onInit
}
}
chartOptionsPie :: Record MetricsProps -> HistoMetrics -> Options
chartOptionsPie :: Record LoadedProps -> Options
chartOptionsPie { onClick, onInit } (HistoMetrics { dates: dates', count: count'}) = Options
chartOptionsPie { onClick
, onInit
, metrics: HistoMetrics { dates: dates', count: count'} } = Options
{ mainTitle : "Pie"
{ mainTitle : "Pie"
, subTitle : "Distribution by MapTerm"
, subTitle : "Distribution by MapTerm"
, xAxis : xAxis' []
, xAxis : xAxis' []
...
@@ -117,13 +125,18 @@ pieCpt = here.component "pie" cpt
...
@@ -117,13 +125,18 @@ pieCpt = here.component "pie" cpt
, onInit
, onInit
}
}
loadedPie :: Record MetricsProps -> HistoMetrics -> R.Element
loadedPie :: R2.Leaf LoadedProps
loadedPie p loaded =
loadedPie = R2.leaf loadedPieCpt
H.div {} [
loadedPieCpt :: R.Component LoadedProps
{- U.reloadButton reload
loadedPieCpt = here.component "loadedPie" cpt where
cpt p@{ path
, reload
, session } _ = do
pure $ H.div {} [
{- U.reloadButton reload
, U.chartUpdateButton { chartType: ChartPie, path, reload, session }
, U.chartUpdateButton { chartType: ChartPie, path, reload, session }
, -} chart $ chartOptionsPie p
loaded
, -} chart $ chartOptionsPie p
]
]
bar :: Record Props -> R.Element
bar :: Record Props -> R.Element
...
@@ -147,10 +160,15 @@ barCpt = here.component "bar" cpt
...
@@ -147,10 +160,15 @@ barCpt = here.component "bar" cpt
, onInit
, onInit
}
}
loadedBar :: Record MetricsProps -> Loaded -> R.Element
loadedBar :: R2.Leaf LoadedProps
loadedBar p loaded =
loadedBar = R2.leaf loadedBarCpt
H.div {} [
loadedBarCpt :: R.Component LoadedProps
{- U.reloadButton reload
loadedBarCpt = here.component "loadedBar" cpt where
cpt p@{ path
, reload
, session } _ = do
pure $ H.div {} [
{- U.reloadButton reload
, U.chartUpdateButton { chartType: ChartBar, path, reload, session }
, U.chartUpdateButton { chartType: ChartBar, path, reload, session }
, -} chart $ chartOptionsBar p
loaded
, -} chart $ chartOptionsBar p
]
]
src/Gargantext/Components/Nodes/Corpus/Chart/Tree.purs
View file @
fe45614a
...
@@ -37,8 +37,12 @@ derive newtype instance JSON.WriteForeign Metrics
...
@@ -37,8 +37,12 @@ derive newtype instance JSON.WriteForeign Metrics
type Loaded = Array TreeNode
type Loaded = Array TreeNode
scatterOptions :: Record MetricsProps -> Array TreeNode -> Options
type LoadedProps =
scatterOptions { onClick, onInit } nodes = Options
( metrics :: Array TreeNode
| MetricsProps )
scatterOptions :: Record LoadedProps -> Options
scatterOptions { onClick, onInit, metrics: nodes } = Options
{ mainTitle : "Tree"
{ mainTitle : "Tree"
, subTitle : "Tree Sub Title"
, subTitle : "Tree Sub Title"
, xAxis : xAxis' []
, xAxis : xAxis' []
...
@@ -91,10 +95,15 @@ treeCpt = here.component "tree" cpt
...
@@ -91,10 +95,15 @@ treeCpt = here.component "tree" cpt
, onInit
, onInit
}
}
loaded :: Record MetricsProps -> Loaded -> R.Element
loaded :: R2.Leaf LoadedProps
loaded p loaded' =
loaded = R2.leaf loadedCpt
H.div {} [
loadedCpt :: R.Component LoadedProps
{- U.reloadButton reload
loadedCpt = here.component "loaded" cpt where
cpt p@{ path
, reload
, session } _ = do
pure $ H.div {} [
{- U.reloadButton reload
, U.chartUpdateButton { chartType: ChartTree, path, reload, session }
, U.chartUpdateButton { chartType: ChartTree, path, reload, session }
, -} chart
(scatterOptions p loaded')
, -} chart
$ scatterOptions p
]
]
src/Gargantext/Components/Nodes/Corpus/Chart/Utils.purs
View file @
fe45614a
...
@@ -18,16 +18,18 @@ import Gargantext.Utils.Toestand as T2
...
@@ -18,16 +18,18 @@ import Gargantext.Utils.Toestand as T2
here :: R2.Here
here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Corpus.Chart.Utils"
here = R2.here "Gargantext.Components.Nodes.Corpus.Chart.Utils"
reloadButtonWrap :: T2.ReloadS -> R.Element -> R.Element
type ReloadButtonProps =
reloadButtonWrap setReload el = H.div {} [
( reload :: T2.ReloadS )
reloadButton setReload
, el
]
reloadButton :: T2.ReloadS -> R.Element
reloadButton :: R2.Leaf ReloadButtonProps
reloadButton reloadS = H.a { className, on: { click }, title: "Reload" } [] where
reloadButton = R2.leaf reloadButtonCpt
className = "pr-1 fa fa-refresh"
reloadButtonCpt :: R.Component ReloadButtonProps
click _ = T2.reload reloadS
reloadButtonCpt = here.component "reloadButton" cpt where
cpt { reload } _ = do
pure $ H.a { className, on: { click }, title: "Reload" } []
where
className = "pr-1 fa fa-refresh"
click _ = T2.reload reload
mNgramsTypeFromTabType :: T.TabType -> Maybe T.CTabNgramType
mNgramsTypeFromTabType :: T.TabType -> Maybe T.CTabNgramType
...
@@ -43,9 +45,8 @@ type ChartUpdateButtonProps =
...
@@ -43,9 +45,8 @@ type ChartUpdateButtonProps =
, session :: Session
, session :: Session
)
)
chartUpdateButton :: Record ChartUpdateButtonProps -> R.Element
chartUpdateButton :: R2.Leaf ChartUpdateButtonProps
chartUpdateButton p = R.createElement chartUpdateButtonCpt p []
chartUpdateButton = R2.leaf chartUpdateButtonCpt
chartUpdateButtonCpt :: R.Component ChartUpdateButtonProps
chartUpdateButtonCpt :: R.Component ChartUpdateButtonProps
chartUpdateButtonCpt = here.component "chartUpdateButton" cpt where
chartUpdateButtonCpt = here.component "chartUpdateButton" cpt where
cpt { path: { corpusId, listId, tabType }
cpt { path: { corpusId, listId, tabType }
...
...
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