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
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Grégoire Locqueville
purescript-gargantext
Commits
a368e49c
Commit
a368e49c
authored
May 06, 2020
by
Przemyslaw Kaminski
Committed by
Alexandre Delanoë
May 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ngrams] temp changes
parent
5a6f1071
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
74 deletions
+93
-74
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+89
-72
Table.purs
src/Gargantext/Components/Table.purs
+1
-1
Types.purs
src/Gargantext/Types.purs
+3
-1
No files found.
src/Gargantext/Components/NgramsTable.purs
View file @
a368e49c
...
@@ -20,25 +20,26 @@ import Data.Ord.Down (Down(..))
...
@@ -20,25 +20,26 @@ import Data.Ord.Down (Down(..))
import Data.Set (Set)
import Data.Set (Set)
import Data.Set as Set
import Data.Set as Set
import Data.Symbol (SProxy(..))
import Data.Symbol (SProxy(..))
import Data.Tuple (Tuple(..), snd)
import Data.Tuple (Tuple(..),
fst,
snd)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect (Effect)
import Prelude (class Show, Unit, bind, const, discard, identity, map, mempty, not, otherwise, pure, show, unit, (#), ($), (&&), (+), (/=), (<$>), (<<<), (<>), (=<<), (==), (||))
import React.DOM (a, span, text)
import React.DOM.Props (onClick, style)
import React.DOM.Props as DOM
import Reactix as R
import Reactix.DOM.HTML as H
import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Components.AutoUpdate (autoUpdateElt)
import Gargantext.Components.AutoUpdate (autoUpdateElt)
import Gargantext.Components.Loader (loader)
import Gargantext.Components.Loader (loader)
import Gargantext.Components.LoadingSpinner (loadingSpinner)
import Gargantext.Components.LoadingSpinner (loadingSpinner)
import Gargantext.Components.NgramsTable.Core (CoreState, NgramsElement(..), NgramsPatch(..), NgramsTable, NgramsTablePatch, NgramsTerm, PageParams, PatchMap(..), Replace, Versioned(..), VersionedNgramsTable, _NgramsElement, _NgramsTable, _PatchMap, _children, _list, _ngrams, _occurrences, _root, addNewNgram, applyNgramsPatches, applyPatchSet, commitPatchR, convOrderBy, fromNgramsPatches, initialPageParams, loadNgramsTableAll, ngramsTermText, normNgram, patchSetFromMap, replace, rootsOf, singletonNgramsTablePatch, syncPatchesR)
import Gargantext.Components.NgramsTable.Core (CoreState, NgramsElement(..), NgramsPatch(..), NgramsTable, NgramsTablePatch, NgramsTerm, PageParams, PatchMap(..), Replace, Versioned(..), VersionedNgramsTable, _NgramsElement, _NgramsTable, _PatchMap, _children, _list, _ngrams, _occurrences, _root, addNewNgram, applyNgramsPatches, applyPatchSet, commitPatchR, convOrderBy, fromNgramsPatches, initialPageParams, loadNgramsTableAll, ngramsTermText, normNgram, patchSetFromMap, replace, rootsOf, singletonNgramsTablePatch, syncPatchesR)
import Gargantext.Components.Table as T
import Gargantext.Components.Table as T
import Gargantext.Sessions (Session)
import Gargantext.Sessions (Session)
import Gargantext.Types (CTabNgramType, OrderBy(..), TabType, TermList(..), readTermList, readTermSize, termLists, termSizes)
import Gargantext.Types (CTabNgramType, OrderBy(..),
SearchQuery,
TabType, TermList(..), readTermList, readTermSize, termLists, termSizes)
import Gargantext.Utils (queryMatchesLabel, toggleSet)
import Gargantext.Utils (queryMatchesLabel, toggleSet)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Prelude (class Show, Unit, bind, const, discard, identity, map, mempty, not, otherwise, pure, show, unit, (#), ($), (&&), (+), (/=), (<$>), (<<<), (<>), (=<<), (==), (||))
import React.DOM (a, span, text)
import React.DOM.Props (onClick, style)
import React.DOM.Props as DOM
import Reactix as R
import Reactix.DOM.HTML as H
import Unsafe.Coerce (unsafeCoerce)
type State' =
type State' =
CoreState
CoreState
...
@@ -181,13 +182,13 @@ tableContainerCpt { dispatch
...
@@ -181,13 +182,13 @@ tableContainerCpt { dispatch
[ H.input { className: "form-control"
[ H.input { className: "form-control"
, defaultValue: searchQuery
, defaultValue: searchQuery
, name: "search"
, name: "search"
, on: {
input: setSearchQuery <<< R2.unsafeEventValue
}
, on: {
input: setSearchQuery <<< R2.unsafeEventValue
}
, placeholder: "Search"
, placeholder: "Search"
, type: "value" }
, type: "value" }
, H.div {} (
, H.div {} (
if A.null props.tableBody && searchQuery /= "" then [
if A.null props.tableBody && searchQuery /= "" then [
H.button { className: "btn btn-primary"
H.button { className: "btn btn-primary"
, on: {click: const $ dispatch
, on: {
click: const $ dispatch
$ addNewNgramA
$ addNewNgramA
$ normNgram tabNgramType searchQuery
$ normNgram tabNgramType searchQuery
}
}
...
@@ -197,7 +198,7 @@ tableContainerCpt { dispatch
...
@@ -197,7 +198,7 @@ tableContainerCpt { dispatch
)
)
]
]
, H.div {className: "col-md-2", style: {marginTop : "6px"}}
, H.div {className: "col-md-2", style: {marginTop : "6px"}}
[ H.li {className: "
list-group-item"}
[ H.li {className: "list-group-item"}
[ R2.select { id: "picklistmenu"
[ R2.select { id: "picklistmenu"
, className: "form-control custom-select"
, className: "form-control custom-select"
, defaultValue: (maybe "" show termListFilter)
, defaultValue: (maybe "" show termListFilter)
...
@@ -211,7 +212,7 @@ tableContainerCpt { dispatch
...
@@ -211,7 +212,7 @@ tableContainerCpt { dispatch
, on: {change: setTermSizeFilter <<< readTermSize <<< R2.unsafeEventValue}}
, on: {change: setTermSizeFilter <<< readTermSize <<< R2.unsafeEventValue}}
(map optps1 termSizes)]]
(map optps1 termSizes)]]
, H.div {className: "col-md-4", style: {marginTop : "6px", marginBottom : "1px"}}
, H.div {className: "col-md-4", style: {marginTop : "6px", marginBottom : "1px"}}
[ H.li {className: "
list-group-item"}
[ H.li {className: "list-group-item"}
[ props.pageSizeDescription
[ props.pageSizeDescription
, props.pageSizeControl
, props.pageSizeControl
, H.text " items / "
, H.text " items / "
...
@@ -325,12 +326,21 @@ loadedNgramsTableSpecCpt = R.hooksComponent "G.C.NT.loadedNgramsTable" cpt
...
@@ -325,12 +326,21 @@ loadedNgramsTableSpecCpt = R.hooksComponent "G.C.NT.loadedNgramsTable" cpt
, ngramsSelection
, ngramsSelection
, ngramsVersion } /\ setState)
, ngramsVersion } /\ setState)
, tabNgramType
, tabNgramType
, versioned:
Versioned { data: initTable }
, versioned:
versioned@(Versioned { data: initTable })
, withAutoUpdate } _ = do
, withAutoUpdate } _ = do
pure $ R.fragment $
pure $ R.fragment $
autoUpdate <> resetSaveButtons <> [
autoUpdate <> resetSaveButtons <> [
T.table { colNames
T.table { colNames
, container
, container: tableContainer { dispatch: performAction
, ngramsChildren
, ngramsParent
, ngramsSelectAll
, ngramsSelection
, ngramsTable
, path
, tabNgramType
}
, params: params /\ setParams -- TODO-LENS
, params: params /\ setParams -- TODO-LENS
, rows: filteredRows
, rows: filteredRows
, totalRecords
, totalRecords
...
@@ -394,6 +404,37 @@ loadedNgramsTableSpecCpt = R.hooksComponent "G.C.NT.loadedNgramsTable" cpt
...
@@ -394,6 +404,37 @@ loadedNgramsTableSpecCpt = R.hooksComponent "G.C.NT.loadedNgramsTable" cpt
totalRecords = A.length rows
totalRecords = A.length rows
filteredRows = T.filterRows { params } rows
filteredRows = T.filterRows { params } rows
rows :: T.Rows
rows = convertRow
<$> orderWith (
addOcc
<$> List.fromFoldable (Map.toUnfoldable (Map.filter rowsFilter (ngramsTable ^. _NgramsTable)))
)
rowsFilter = displayRow state searchQuery versioned termListFilter
addOcc (Tuple ne ngramsElement) =
let Additive occurrences = sumOccurrences ngramsTable ngramsElement in
Tuple ne (ngramsElement # _NgramsElement <<< _occurrences .~ occurrences)
ngramsTable = applyNgramsPatches state initTable
convertRow (Tuple ngrams ngramsElement) =
{ row: renderNgramsItem { dispatch: performAction
, ngrams
, ngramsElement
, ngramsLocalPatch
, ngramsParent
, ngramsSelection
, ngramsTable }
, delete: false
}
orderWith =
case convOrderBy <$> params.orderBy of
Just ScoreAsc -> List.sortBy \x -> (snd x) ^. _NgramsElement <<< _occurrences
Just ScoreDesc -> List.sortBy \x -> Down $ (snd x) ^. _NgramsElement <<< _occurrences
Just TermAsc -> List.sortBy \x -> (snd x) ^. _NgramsElement <<< _ngrams
Just TermDesc -> List.sortBy \x -> Down $ (snd x) ^. _NgramsElement <<< _ngrams
_ -> identity -- the server ordering is enough here
colNames = T.ColumnName <$> ["Select", "Map", "Stop", "Terms", "Score"] -- see convOrderBy
colNames = T.ColumnName <$> ["Select", "Map", "Stop", "Terms", "Score"] -- see convOrderBy
selected =
selected =
H.input { checked: ngramsSelectAll
H.input { checked: ngramsSelectAll
...
@@ -404,41 +445,17 @@ loadedNgramsTableSpecCpt = R.hooksComponent "G.C.NT.loadedNgramsTable" cpt
...
@@ -404,41 +445,17 @@ loadedNgramsTableSpecCpt = R.hooksComponent "G.C.NT.loadedNgramsTable" cpt
wrapColElts (T.ColumnName "Select") = const [selected]
wrapColElts (T.ColumnName "Select") = const [selected]
wrapColElts (T.ColumnName "Score") = (_ <> [H.text ("(" <> show scoreType <> ")")])
wrapColElts (T.ColumnName "Score") = (_ <> [H.text ("(" <> show scoreType <> ")")])
wrapColElts _ = identity
wrapColElts _ = identity
container = tableContainer { dispatch: performAction
, ngramsChildren
, ngramsParent
, ngramsSelectAll
, ngramsSelection
, ngramsTable
, path
, tabNgramType
}
setParams f = setPath $ \p@{params: ps} -> p {params = f ps}
setParams f = setPath $ \p@{params: ps} -> p {params = f ps}
ngramsTable = applyNgramsPatches state initTable
orderWith =
case convOrderBy <$> params.orderBy of
Just ScoreAsc -> A.sortWith \x -> (snd x) ^. _NgramsElement <<< _occurrences
Just ScoreDesc -> A.sortWith \x -> Down $ (snd x) ^. _NgramsElement <<< _occurrences
Just TermAsc -> A.sortWith \x -> (snd x) ^. _NgramsElement <<< _ngrams
Just TermDesc -> A.sortWith \x -> Down $ (snd x) ^. _NgramsElement <<< _ngrams
_ -> identity -- the server ordering is enough here
rows :: T.Rows
rows = convertRow <$> orderWith (addOcc <$> Map.toUnfoldable (Map.filter displayRow (ngramsTable ^. _NgramsTable)))
addOcc (Tuple ne ngramsElement) =
let Additive occurrences = sumOccurrences ngramsTable ngramsElement in
Tuple ne (ngramsElement # _NgramsElement <<< _occurrences .~ occurrences)
ngramsParentRoot :: Maybe NgramsTerm
displayRow :: State -> SearchQuery -> VersionedNgramsTable -> Maybe TermList -> NgramsElement -> Boolean
ngramsParentRoot =
displayRow state@{ ngramsChildren
(\np -> ngramsTable ^? at np
, ngramsLocalPatch
<<< _Just
, ngramsParent }
<<< _NgramsElement
searchQuery
<<< _root
(Versioned { data: initTable })
<<< _Just
termListFilter
) =<< ngramsParent
(NgramsElement {ngrams, root, list}) =
displayRow (NgramsElement {ngrams, root, list}) =
root == Nothing
root == Nothing
-- ^ Display only nodes without parents
-- ^ Display only nodes without parents
&& ngramsChildren ^. at ngrams /= Just true
&& ngramsChildren ^. at ngrams /= Just true
...
@@ -455,16 +472,16 @@ loadedNgramsTableSpecCpt = R.hooksComponent "G.C.NT.loadedNgramsTable" cpt
...
@@ -455,16 +472,16 @@ loadedNgramsTableSpecCpt = R.hooksComponent "G.C.NT.loadedNgramsTable" cpt
-- ^ unless they are scheduled to be removed.
-- ^ unless they are scheduled to be removed.
|| tablePatchHasNgrams ngramsLocalPatch ngrams
|| tablePatchHasNgrams ngramsLocalPatch ngrams
-- ^ unless they are being processed at the moment.
-- ^ unless they are being processed at the moment.
convertRow (Tuple ngrams ngramsElement) =
where
{ row: renderNgramsItem { dispatch: performAction
ngramsTable = applyNgramsPatches state initTable
, ngrams
ngramsParentRoot :: Maybe NgramsTerm
, ngramsElement
ngramsParentRoot =
, ngramsLocalPatch
(\np -> ngramsTable ^? at np
, ngramsParen
t
<<< _Jus
t
, ngramsSelection
<<< _NgramsElement
, ngramsTable }
<<< _root
, delete: false
<<< _Just
}
) =<< ngramsParent
type MainNgramsTableProps =
type MainNgramsTableProps =
( nodeId :: Int
( nodeId :: Int
...
...
src/Gargantext/Components/Table.purs
View file @
a368e49c
...
@@ -154,8 +154,8 @@ tableCpt = R.hooksComponent "G.C.Table.table" cpt
...
@@ -154,8 +154,8 @@ tableCpt = R.hooksComponent "G.C.Table.table" cpt
{ pageSizeControl: sizeDD { params }
{ pageSizeControl: sizeDD { params }
, pageSizeDescription: textDescription state.page state.pageSize totalRecords
, pageSizeDescription: textDescription state.page state.pageSize totalRecords
, paginationLinks: pagination params totalPages
, paginationLinks: pagination params totalPages
, tableHead: H.tr {} (colHeader <$> colNames)
, tableBody: map _.row rows
, tableBody: map _.row rows
, tableHead: H.tr {} (colHeader <$> colNames)
}
}
makeRow :: Array R.Element -> R.Element
makeRow :: Array R.Element -> R.Element
...
...
src/Gargantext/Types.purs
View file @
a368e49c
...
@@ -287,6 +287,8 @@ derive instance genericScoreType :: Generic ScoreType _
...
@@ -287,6 +287,8 @@ derive instance genericScoreType :: Generic ScoreType _
instance showScoreType :: Show ScoreType where
instance showScoreType :: Show ScoreType where
show = genericShow
show = genericShow
type SearchQuery = String
type NgramsGetOpts =
type NgramsGetOpts =
{ tabType :: TabType
{ tabType :: TabType
, offset :: Offset
, offset :: Offset
...
@@ -296,7 +298,7 @@ type NgramsGetOpts =
...
@@ -296,7 +298,7 @@ type NgramsGetOpts =
, termListFilter :: Maybe TermList
, termListFilter :: Maybe TermList
, termSizeFilter :: Maybe TermSize
, termSizeFilter :: Maybe TermSize
, scoreType :: ScoreType
, scoreType :: ScoreType
, searchQuery :: S
tring
, searchQuery :: S
earchQuery
}
}
type NgramsGetTableAllOpts =
type NgramsGetTableAllOpts =
...
...
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