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
ab385980
Commit
ab385980
authored
Oct 07, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[chart] auto recompute charts after ngrams changed
parent
96cc6c99
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
30 deletions
+68
-30
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+32
-15
Tabs.purs
...gantext/Components/Nodes/Annuaire/User/Contacts/Tabs.purs
+3
-1
Utils.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Utils.purs
+11
-10
Tabs.purs
src/Gargantext/Components/Nodes/Lists/Tabs.purs
+22
-4
No files found.
src/Gargantext/Components/NgramsTable.purs
View file @
ab385980
...
@@ -275,7 +275,8 @@ tableContainerCpt { dispatch
...
@@ -275,7 +275,8 @@ tableContainerCpt { dispatch
-- NEXT
-- NEXT
type Props =
type Props =
( path :: R.State PageParams
( afterSync :: Unit -> Effect Unit
, path :: R.State PageParams
, state :: R.State State
, state :: R.State State
, tabNgramType :: CTabNgramType
, tabNgramType :: CTabNgramType
, versioned :: VersionedNgramsTable
, versioned :: VersionedNgramsTable
...
@@ -288,7 +289,8 @@ loadedNgramsTable p = R.createElement loadedNgramsTableCpt p []
...
@@ -288,7 +289,8 @@ loadedNgramsTable p = R.createElement loadedNgramsTableCpt p []
loadedNgramsTableCpt :: R.Component Props
loadedNgramsTableCpt :: R.Component Props
loadedNgramsTableCpt = R2.hooksComponent thisModule "loadedNgramsTable" cpt
loadedNgramsTableCpt = R2.hooksComponent thisModule "loadedNgramsTable" cpt
where
where
cpt { path: path@(path'@{searchQuery, scoreType, params, termListFilter, termSizeFilter} /\ setPath)
cpt { afterSync
, path: path@(path'@{ searchQuery, scoreType, params, termListFilter, termSizeFilter } /\ setPath)
, state: (state@{ ngramsChildren
, state: (state@{ ngramsChildren
, ngramsLocalPatch
, ngramsLocalPatch
, ngramsParent
, ngramsParent
...
@@ -325,13 +327,19 @@ loadedNgramsTableCpt = R2.hooksComponent thisModule "loadedNgramsTable" cpt
...
@@ -325,13 +327,19 @@ loadedNgramsTableCpt = R2.hooksComponent thisModule "loadedNgramsTable" cpt
] <> syncResetButtons
] <> syncResetButtons
where
where
autoUpdate :: Array R.Element
autoUpdate :: Array R.Element
autoUpdate = if withAutoUpdate then [ R2.buff $ autoUpdateElt { duration: 5000, effect: performAction Synchronize } ] else []
autoUpdate = if withAutoUpdate then
[ R2.buff $ autoUpdateElt { duration: 5000, effect: performAction Synchronize } ]
else []
resetButton :: Boolean -> R.Element
resetButton :: Boolean -> R.Element
resetButton active = H.button { className: "btn btn-primary " <> if active then "" else " disabled"
resetButton active = H.button { className: "btn btn-primary " <> if active then "" else " disabled"
, on: { click: \_ -> performAction ResetPatches } } [ H.text "Reset" ]
, on: { click: \_ -> performAction ResetPatches } } [ H.text "Reset" ]
syncButton :: R.Element
syncButton :: R.Element
syncButton = H.button { className: "btn btn-primary"
syncButton = H.button { className: "btn btn-primary"
, on: { click: \_ -> performAction Synchronize }} [ H.text "Sync" ]
, on: { click: \_ -> do
performAction Synchronize
afterSync unit
}
} [ H.text "Sync" ]
-- I would rather have the two buttons always here and make the reset button inactive when the patch is empty.
-- I would rather have the two buttons always here and make the reset button inactive when the patch is empty.
syncResetButtons :: Array R.Element
syncResetButtons :: Array R.Element
syncResetButtons = [ H.div {} [ resetButton (ngramsLocalPatch /= mempty), syncButton ] ]
syncResetButtons = [ H.div {} [ resetButton (ngramsLocalPatch /= mempty), syncButton ] ]
...
@@ -483,13 +491,14 @@ selectNgramsOnFirstPage rows = Set.fromFoldable $ (view $ _NgramsElement <<< _ng
...
@@ -483,13 +491,14 @@ selectNgramsOnFirstPage rows = Set.fromFoldable $ (view $ _NgramsElement <<< _ng
type MainNgramsTableProps =
type MainNgramsTableProps =
( nodeId :: Int
( afterSync :: Unit -> Effect Unit
-- ^ This node can be a corpus or contact.
, cacheState :: R.State NT.CacheState
, cacheState :: R.State NT.CacheState
, defaultListId :: Int
, defaultListId :: Int
, tabType :: TabType
, nodeId :: Int
-- ^ This node can be a corpus or contact.
, session :: Session
, session :: Session
, tabNgramType :: CTabNgramType
, tabNgramType :: CTabNgramType
, tabType :: TabType
, withAutoUpdate :: Boolean
, withAutoUpdate :: Boolean
)
)
...
@@ -499,10 +508,17 @@ mainNgramsTable props = R.createElement mainNgramsTableCpt props []
...
@@ -499,10 +508,17 @@ mainNgramsTable props = R.createElement mainNgramsTableCpt props []
mainNgramsTableCpt :: R.Component MainNgramsTableProps
mainNgramsTableCpt :: R.Component MainNgramsTableProps
mainNgramsTableCpt = R2.hooksComponent thisModule "mainNgramsTable" cpt
mainNgramsTableCpt = R2.hooksComponent thisModule "mainNgramsTable" cpt
where
where
cpt props@{ cacheState, defaultListId, nodeId, session, tabNgramType, tabType, withAutoUpdate} _ = do
cpt props@{ afterSync
, cacheState
, defaultListId
, nodeId
, session
, tabNgramType
, tabType
, withAutoUpdate } _ = do
let path = initialPageParams session nodeId [defaultListId] tabType
let path = initialPageParams session nodeId [defaultListId] tabType
let render versioned = mainNgramsTablePaint { path, tabNgramType, versioned, withAutoUpdate }
let render versioned = mainNgramsTablePaint {
afterSync,
path, tabNgramType, versioned, withAutoUpdate }
case cacheState of
case cacheState of
(NT.CacheOn /\ _) ->
(NT.CacheOn /\ _) ->
...
@@ -545,10 +561,10 @@ mainNgramsTableCpt = R2.hooksComponent thisModule "mainNgramsTable" cpt
...
@@ -545,10 +561,10 @@ mainNgramsTableCpt = R2.hooksComponent thisModule "mainNgramsTable" cpt
, termListFilter = Nothing }
, termListFilter = Nothing }
type MainNgramsTablePaintProps =
type MainNgramsTablePaintProps =
(
(
afterSync :: Unit -> Effect Unit
path
:: PageParams
, path
:: PageParams
, tabNgramType :: CTabNgramType
, tabNgramType
:: CTabNgramType
, versioned :: VersionedNgramsTable
, versioned
:: VersionedNgramsTable
, withAutoUpdate :: Boolean
, withAutoUpdate :: Boolean
)
)
...
@@ -558,12 +574,13 @@ mainNgramsTablePaint p = R.createElement mainNgramsTablePaintCpt p []
...
@@ -558,12 +574,13 @@ mainNgramsTablePaint p = R.createElement mainNgramsTablePaintCpt p []
mainNgramsTablePaintCpt :: R.Component MainNgramsTablePaintProps
mainNgramsTablePaintCpt :: R.Component MainNgramsTablePaintProps
mainNgramsTablePaintCpt = R2.hooksComponent thisModule "mainNgramsTablePaint" cpt
mainNgramsTablePaintCpt = R2.hooksComponent thisModule "mainNgramsTablePaint" cpt
where
where
cpt {
path, tabNgramType, versioned, withAutoUpdate
} _ = do
cpt {
afterSync, path, tabNgramType, versioned, withAutoUpdate
} _ = do
pathS <- R.useState' path
pathS <- R.useState' path
state <- R.useState' $ initialState versioned
state <- R.useState' $ initialState versioned
pure $ loadedNgramsTable {
pure $ loadedNgramsTable {
path: pathS
afterSync
, path: pathS
, state
, state
, tabNgramType
, tabNgramType
, versioned
, versioned
...
...
src/Gargantext/Components/Nodes/Annuaire/User/Contacts/Tabs.purs
View file @
ab385980
...
@@ -19,6 +19,7 @@ import Gargantext.Sessions (Session)
...
@@ -19,6 +19,7 @@ import Gargantext.Sessions (Session)
import Gargantext.Types (TabType(..), TabSubType(..), CTabNgramType(..), PTabNgramType(..))
import Gargantext.Types (TabType(..), TabSubType(..), CTabNgramType(..), PTabNgramType(..))
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs"
thisModule = "Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs"
...
@@ -93,7 +94,8 @@ type NgramsViewTabsProps =
...
@@ -93,7 +94,8 @@ type NgramsViewTabsProps =
ngramsView :: Record NgramsViewTabsProps -> R.Element
ngramsView :: Record NgramsViewTabsProps -> R.Element
ngramsView { cacheState, defaultListId, mode, nodeId, session } =
ngramsView { cacheState, defaultListId, mode, nodeId, session } =
NT.mainNgramsTable {
NT.mainNgramsTable {
cacheState
afterSync: \_ -> pure unit
, cacheState
, defaultListId
, defaultListId
, nodeId
, nodeId
, tabType
, tabType
...
...
src/Gargantext/Components/Nodes/Corpus/Chart/Utils.purs
View file @
ab385980
...
@@ -26,13 +26,21 @@ reloadButtonWrap setReload el = H.div {} [
...
@@ -26,13 +26,21 @@ reloadButtonWrap setReload el = H.div {} [
reloadButton :: R.State Int -> R.Element
reloadButton :: R.State Int -> R.Element
reloadButton (_ /\ setReload) = H.a { className
reloadButton (_ /\ setReload) = H.a { className
, on: { click: onClick }
, on: { click: onClick }
, title: "Reload" } []
, title: "Reload" } []
where
where
className = "reload-btn fa fa-refresh"
className = "reload-btn fa fa-refresh"
onClick _ = setReload $ (_ + 1)
onClick _ = setReload $ (_ + 1)
mNgramsTypeFromTabType :: T.TabType -> Maybe T.CTabNgramType
mNgramsTypeFromTabType (T.TabCorpus (T.TabNgramType ngramType)) = Just ngramType
mNgramsTypeFromTabType (T.TabCorpus _) = Nothing
mNgramsTypeFromTabType (T.TabDocument (T.TabNgramType ngramType)) = Just ngramType
mNgramsTypeFromTabType (T.TabDocument _) = Nothing
mNgramsTypeFromTabType (T.TabPairing _) = Nothing
type ChartUpdateButtonProps = (
type ChartUpdateButtonProps = (
chartType :: T.ChartType
chartType :: T.ChartType
, path :: Record Path
, path :: Record Path
...
@@ -57,15 +65,8 @@ chartUpdateButtonCpt = R2.hooksComponent thisModule "chartUpdateButton" cpt
...
@@ -57,15 +65,8 @@ chartUpdateButtonCpt = R2.hooksComponent thisModule "chartUpdateButton" cpt
onClick :: forall a. a -> Effect Unit
onClick :: forall a. a -> Effect Unit
onClick _ = do
onClick _ = do
launchAff_ $ do
launchAff_ $ do
case mNgramsType of
case mNgramsType
FromTabType tabType
of
Just ngramsType -> do
Just ngramsType -> do
_ <- recomputeChart session chartType ngramsType corpusId listId
_ <- recomputeChart session chartType ngramsType corpusId listId
liftEffect $ setReload $ (_ + 1)
liftEffect $ setReload $ (_ + 1)
Nothing -> pure unit
Nothing -> pure unit
mNgramsType = case tabType of
T.TabCorpus (T.TabNgramType ngramType) -> Just ngramType
T.TabCorpus _ -> Nothing
T.TabDocument (T.TabNgramType ngramType) -> Just ngramType
T.TabDocument _ -> Nothing
T.TabPairing _ -> Nothing
src/Gargantext/Components/Nodes/Lists/Tabs.purs
View file @
ab385980
module Gargantext.Components.Nodes.Lists.Tabs where
module Gargantext.Components.Nodes.Lists.Tabs where
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Tuple (fst)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log2)
import Effect.Aff (launchAff_)
import Effect.Class (liftEffect)
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
...
@@ -9,16 +13,19 @@ import Gargantext.Prelude
...
@@ -9,16 +13,19 @@ import Gargantext.Prelude
import Gargantext.Components.NgramsTable as NT
import Gargantext.Components.NgramsTable as NT
import Gargantext.Components.Nodes.Corpus.Types (CorpusData)
import Gargantext.Components.Nodes.Corpus.Types (CorpusData)
import Gargantext.Components.Nodes.Corpus.Chart.API (recomputeChart)
import Gargantext.Components.Nodes.Corpus.Chart.Metrics (metrics)
import Gargantext.Components.Nodes.Corpus.Chart.Metrics (metrics)
import Gargantext.Components.Nodes.Corpus.Chart.Pie (pie, bar)
import Gargantext.Components.Nodes.Corpus.Chart.Pie (pie, bar)
import Gargantext.Components.Nodes.Corpus.Chart.Tree (tree)
import Gargantext.Components.Nodes.Corpus.Chart.Tree (tree)
import Gargantext.Components.Nodes.Corpus.Chart (getChartFunction)
import Gargantext.Components.Nodes.Corpus.Chart (getChartFunction)
import Gargantext.Components.Nodes.Corpus.Chart.Utils (mNgramsTypeFromTabType)
import Gargantext.Components.Nodes.Lists.Types as NTypes
import Gargantext.Components.Nodes.Lists.Types as NTypes
import Gargantext.Components.Tab as Tab
import Gargantext.Components.Tab as Tab
import Gargantext.Sessions (Session)
import Gargantext.Sessions (Session)
import Gargantext.Types (ChartType(..), CTabNgramType(..), Mode(..), TabSubType(..), TabType(..), chartTypeFromString, modeTabType)
import Gargantext.Types (ChartType(..), CTabNgramType(..), Mode(..), TabSubType(..), TabType(..), chartTypeFromString, modeTabType)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.Nodes.Lists.Tabs"
thisModule = "Gargantext.Components.Nodes.Lists.Tabs"
type Props = ( cacheState :: R.State NTypes.CacheState
type Props = ( cacheState :: R.State NTypes.CacheState
...
@@ -58,10 +65,12 @@ ngramsViewCpt = R2.hooksComponent thisModule "ngramsView" cpt
...
@@ -58,10 +65,12 @@ ngramsViewCpt = R2.hooksComponent thisModule "ngramsView" cpt
, mode
, mode
, session } _ = do
, session } _ = do
chartType <- R.useState' Histo
chartType <- R.useState' Histo
chartsReload <- R.useState' 0
pure $ R.fragment
pure $ R.fragment
( charts tabNgramType chartType
( charts tabNgramType chartType chartsReload
<> [ NT.mainNgramsTable { cacheState
<> [ NT.mainNgramsTable { afterSync: afterSync (fst chartType) chartsReload
, cacheState
, defaultListId
, defaultListId
, nodeId: corpusId
, nodeId: corpusId
, session
, session
...
@@ -72,8 +81,17 @@ ngramsViewCpt = R2.hooksComponent thisModule "ngramsView" cpt
...
@@ -72,8 +81,17 @@ ngramsViewCpt = R2.hooksComponent thisModule "ngramsView" cpt
]
]
)
)
where
where
afterSync chartType (_ /\ setChartsReload) _ = do
case mNgramsType of
Just ngramsType -> do
launchAff_ $ do
recomputeChart session chartType ngramsType corpusId listId
setChartsReload $ (+) 1
Nothing -> pure unit
tabNgramType = modeTabType mode
tabNgramType = modeTabType mode
tabType = TabCorpus (TabNgramType tabNgramType)
tabType = TabCorpus (TabNgramType tabNgramType)
mNgramsType = mNgramsTypeFromTabType tabType
listId = defaultListId
listId = defaultListId
path = { corpusId
path = { corpusId
, limit: Just 1000
, limit: Just 1000
...
@@ -81,7 +99,7 @@ ngramsViewCpt = R2.hooksComponent thisModule "ngramsView" cpt
...
@@ -81,7 +99,7 @@ ngramsViewCpt = R2.hooksComponent thisModule "ngramsView" cpt
, tabType
, tabType
}
}
charts CTabTerms (chartType /\ setChartType) = [
charts CTabTerms (chartType /\ setChartType)
_
= [
H.div { className: "row chart-type-selector" } [
H.div { className: "row chart-type-selector" } [
H.div { className: "col-md-3" } [
H.div { className: "col-md-3" } [
R2.select { className: "form-control"
R2.select { className: "form-control"
...
@@ -102,7 +120,7 @@ ngramsViewCpt = R2.hooksComponent thisModule "ngramsView" cpt
...
@@ -102,7 +120,7 @@ ngramsViewCpt = R2.hooksComponent thisModule "ngramsView" cpt
]
]
, getChartFunction chartType $ { session, path }
, getChartFunction chartType $ { session, path }
]
]
charts _ _ = [ chart mode ]
charts _ _
_
= [ chart mode ]
chart Authors = pie { session, path }
chart Authors = pie { session, path }
chart Institutes = tree { session, path }
chart Institutes = tree { session, path }
...
...
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