Commit 69b8356e authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch 'dev-ngrams-table-online' of...

Merge branch 'dev-ngrams-table-online' of ssh://gitlab.iscpif.fr:20022/gargantext/purescript-gargantext into dev-merge
parents 3bbdfd7c 0590abe5
...@@ -23,24 +23,23 @@ import Data.Set as Set ...@@ -23,24 +23,23 @@ import Data.Set as Set
import Data.Symbol (SProxy(..)) import Data.Symbol (SProxy(..))
import Data.Tuple (Tuple(..), fst) import Data.Tuple (Tuple(..), fst)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log2)
import Effect (Effect) import Effect (Effect)
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Reactix (Component, Element, Ref, State, createElement, fragment, hooksComponentWithModule, unsafeEventValue, useEffect', useState') as R import Reactix (Component, Element, Ref, State, createElement, fragment, hooksComponentWithModule, unsafeEventValue, useState') as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Prelude (class Show, Unit, bind, const, discard, identity, map, mempty, not, otherwise, pure, read, show, unit, (#), ($), (&&), (/=), (<$>), (<<<), (<>), (=<<), (==), (||)) import Gargantext.Prelude
import Gargantext.AsyncTasks as GAT import Gargantext.AsyncTasks as GAT
import Gargantext.Components.AutoUpdate (autoUpdateElt) import Gargantext.Components.AutoUpdate (autoUpdateElt)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Components.Table.Types (ColumnName(..), Rows, TableContainerProps) as T import Gargantext.Components.Table as T
import Gargantext.Components.Table.Types as T
import Gargantext.Components.NgramsTable.Components as NTC import Gargantext.Components.NgramsTable.Components as NTC
import Gargantext.Components.NgramsTable.Core (Action(..), CoreAction(..), CoreState, Dispatch, NgramsElement(..), NgramsPatch(..), NgramsTable, NgramsTerm, PageParams, PatchMap(..), Version, Versioned(..), VersionedNgramsTable, VersionedWithCountNgramsTable, _NgramsElement, _NgramsRepoElement, _NgramsTable, _children, _list, _ngrams, _ngrams_repo_elements, _ngrams_scores, _occurrences, _root, addNewNgramA, applyNgramsPatches, applyPatchSet, chartsAfterSync, commitPatch, convOrderBy, coreDispatch, filterTermSize, fromNgramsPatches, ngramsRepoElementToNgramsElement, ngramsTermText, normNgram, patchSetFromMap, replace, rootsOf, singletonNgramsTablePatch, syncResetButtons, toVersioned) import Gargantext.Components.NgramsTable.Core (Action(..), CoreAction(..), CoreState, Dispatch, NgramsElement(..), NgramsPatch(..), NgramsTable, NgramsTerm, PageParams, PatchMap(..), Version, Versioned(..), VersionedNgramsTable, VersionedWithCountNgramsTable, _NgramsElement, _NgramsRepoElement, _NgramsTable, _children, _list, _ngrams, _ngrams_repo_elements, _ngrams_scores, _occurrences, _root, addNewNgramA, applyNgramsPatches, applyPatchSet, chartsAfterSync, commitPatch, convOrderBy, coreDispatch, filterTermSize, fromNgramsPatches, ngramsRepoElementToNgramsElement, ngramsTermText, normNgram, patchSetFromMap, replace, rootsOf, singletonNgramsTablePatch, syncResetButtons, toVersioned)
import Gargantext.Components.NgramsTable.Loader (useLoaderWithCacheAPI) import Gargantext.Components.NgramsTable.Loader (useLoaderWithCacheAPI)
import Gargantext.Components.Nodes.Lists.Types as NT import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Table (filterRows, table) as T
import Gargantext.Routes (SessionRoute(..)) as R import Gargantext.Routes (SessionRoute(..)) as R
import Gargantext.Sessions (Session, get) import Gargantext.Sessions (Session, get)
import Gargantext.Types (CTabNgramType, OrderBy(..), SearchQuery, TabType, TermList(..), TermSize, termLists, termSizes) import Gargantext.Types (CTabNgramType, OrderBy(..), SearchQuery, TabType, TermList(..), TermSize, termLists, termSizes)
...@@ -48,7 +47,7 @@ import Gargantext.Utils (queryMatchesLabel, toggleSet, sortWith) ...@@ -48,7 +47,7 @@ import Gargantext.Utils (queryMatchesLabel, toggleSet, sortWith)
import Gargantext.Utils.CacheAPI as GUC import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reload as GUR import Gargantext.Utils.Reload as GUR
import Gargantext.Utils.Seq (mapMaybe) as Seq import Gargantext.Utils.Seq as Seq
thisModule :: String thisModule :: String
thisModule = "Gargantext.Components.NgramsTable" thisModule = "Gargantext.Components.NgramsTable"
...@@ -314,7 +313,7 @@ loadedNgramsTable = R.createElement loadedNgramsTableCpt ...@@ -314,7 +313,7 @@ loadedNgramsTable = R.createElement loadedNgramsTableCpt
, syncResetButton: [ syncResetButton ] , syncResetButton: [ syncResetButton ]
, tabNgramType , tabNgramType
} }
, params: params /\ setParams -- TODO-LENS , params: paramsS -- TODO-LENS
, rows: filteredConvertedRows , rows: filteredConvertedRows
, syncResetButton: [ syncResetButton ] , syncResetButton: [ syncResetButton ]
, totalRecords , totalRecords
...@@ -411,13 +410,16 @@ loadedNgramsTable = R.createElement loadedNgramsTableCpt ...@@ -411,13 +410,16 @@ loadedNgramsTable = R.createElement loadedNgramsTableCpt
wrapColElts _ (T.ColumnName "Score") = (_ <> [H.text ("(" <> show scoreType <> ")")]) wrapColElts _ (T.ColumnName "Score") = (_ <> [H.text ("(" <> show scoreType <> ")")])
wrapColElts _ _ = identity wrapColElts _ _ = identity
setParams f = setPath $ \p@{params: ps} -> p {params = f ps} setParams f = setPath $ \p@{params: ps} -> p {params = f ps}
paramsS = params /\ setParams
search :: R.Element search :: R.Element
search = NTC.searchInput { key: "search-input" search = NTC.searchInput { key: "search-input"
, onSearch: setSearchQuery , onSearch: setSearchQuery
, searchQuery: searchQuery } , searchQuery: searchQuery }
setSearchQuery :: String -> Effect Unit setSearchQuery :: String -> Effect Unit
setSearchQuery x = setPath $ _ { searchQuery = x } setSearchQuery x = do
setPath $ _ { searchQuery = x }
T.changePage 1 paramsS
type MkDispatchProps = ( type MkDispatchProps = (
filteredRows :: PreConversionRows filteredRows :: PreConversionRows
......
module Gargantext.Components.Table where module Gargantext.Components.Table where
import Prelude
import Data.Array as A import Data.Array as A
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Sequence as Seq import Data.Sequence as Seq
import Data.Tuple (fst, snd) import Data.Tuple (fst, snd)
import Effect.Aff (Aff, launchAff_)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log2)
import Effect (Effect) import Effect (Effect)
import Gargantext.Sessions (Session, get)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Gargantext.Components.Table.Types import Gargantext.Prelude
import Gargantext.Components.Table.Types (ColumnName, OrderBy, OrderByDirection(..), Params, Props, TableContainerProps, columnName)
import Gargantext.Components.Nodes.Lists.Types as NT import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Search import Gargantext.Components.Search (SearchType(..))
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix (effectLink) import Gargantext.Utils.Reactix (effectLink)
thisModule :: String thisModule :: String
thisModule = "Gargantext.Components.Table" thisModule = "Gargantext.Components.Table"
type Page = Int
type State = type State =
{ page :: Int { page :: Page
, pageSize :: PageSizes , pageSize :: PageSizes
, orderBy :: OrderBy , orderBy :: OrderBy
, searchType :: SearchType , searchType :: SearchType
...@@ -223,8 +221,12 @@ textDescription currPage pageSize totalRecords = ...@@ -223,8 +221,12 @@ textDescription currPage pageSize totalRecords =
end = if end' > totalRecords then totalRecords else end' end = if end' > totalRecords then totalRecords else end'
msg = "Showing " <> show start <> " to " <> show end <> " of " <> show totalRecords msg = "Showing " <> show start <> " to " <> show end <> " of " <> show totalRecords
changePage :: Page -> R.State Params -> Effect Unit
changePage page (_ /\ setParams) =
setParams $ \p -> stateParams $ (paramsState p) { page = page }
pagination :: R.State Params -> Int -> R.Element pagination :: R.State Params -> Int -> R.Element
pagination (params /\ setParams) tp = pagination p@(params /\ setParams) tp =
H.span {} $ H.span {} $
[ H.text " ", prev, first, ldots] [ H.text " ", prev, first, ldots]
<> <>
...@@ -237,7 +239,6 @@ pagination (params /\ setParams) tp = ...@@ -237,7 +239,6 @@ pagination (params /\ setParams) tp =
[ rdots, last, next ] [ rdots, last, next ]
where where
{page} = paramsState params {page} = paramsState params
changePage page = setParams $ \p -> stateParams $ (paramsState p) { page = page }
prev = if page == 1 then prev = if page == 1 then
H.text " Prev. " H.text " Prev. "
else else
...@@ -269,7 +270,7 @@ pagination (params /\ setParams) tp = ...@@ -269,7 +270,7 @@ pagination (params /\ setParams) tp =
changePageLink i s = changePageLink i s =
H.span {} H.span {}
[ H.text " " [ H.text " "
, effectLink (changePage i) s , effectLink (changePage i p) s
, H.text " " , H.text " "
] ]
......
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