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
97a4b906
Commit
97a4b906
authored
Dec 18, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[WIP] SyncResetButton in the table
parent
4aedec4a
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
289 additions
and
185 deletions
+289
-185
AnnotatedField.purs
src/Gargantext/Components/Annotation/AnnotatedField.purs
+2
-2
DocsTable.purs
src/Gargantext/Components/DocsTable.purs
+3
-1
FacetsTable.purs
src/Gargantext/Components/FacetsTable.purs
+5
-1
Sidebar.purs
src/Gargantext/Components/GraphExplorer/Sidebar.purs
+1
-1
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+29
-28
Components.purs
src/Gargantext/Components/NgramsTable/Components.purs
+3
-11
Core.purs
src/Gargantext/Components/NgramsTable/Core.purs
+136
-69
Annuaire.purs
src/Gargantext/Components/Nodes/Annuaire.purs
+6
-1
Tabs.purs
src/Gargantext/Components/Nodes/Lists/Tabs.purs
+3
-2
Table.purs
src/Gargantext/Components/Table.purs
+28
-69
Types.purs
src/Gargantext/Components/Table/Types.purs
+73
-0
No files found.
src/Gargantext/Components/Annotation/AnnotatedField.purs
View file @
97a4b906
...
...
@@ -24,7 +24,7 @@ import Reactix.SyntheticEvent as E
import Gargantext.Types (CTabNgramType(..), TermList)
import Gargantext.Components.Annotation.Utils ( termBootstrapClass )
import Gargantext.Components.NgramsTable.Core
(NgramsTable, NgramsTerm, findNgramTermList, highlightNgrams, normNgram)
import Gargantext.Components.NgramsTable.Core
import Gargantext.Components.Annotation.Menu ( annotationMenu, MenuType(..) )
import Gargantext.Utils.Selection as Sel
...
...
@@ -132,4 +132,4 @@ annotatedRunComponent = R.staticComponent "AnnotatedRun" cpt
case list of
Nothing -> HTML.span { on: { mouseUp: cb } }
Just l -> HTML.span { className: "annotation-run bg-" <> termBootstrapClass l
, on: { click: cb } }
\ No newline at end of file
, on: { click: cb } }
src/Gargantext/Components/DocsTable.purs
View file @
97a4b906
...
...
@@ -27,6 +27,7 @@ import Gargantext.Prelude
import Gargantext.Components.Category (caroussel)
import Gargantext.Components.Category.Types (Category(..), decodeCategory)
import Gargantext.Components.DocsTable.Types
import Gargantext.Components.Table.Types as T
import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Nodes.Texts.Types (SidePanelTriggers)
import Gargantext.Components.Table as T
...
...
@@ -361,7 +362,8 @@ pagePaintRawCpt = R.hooksComponentWithModule thisModule "pagePaintRawCpt" cpt wh
reload <- R.useState' 0
pure $ T.table
{ colNames
{ syncResetButton : [ H.div {} [] ]
, colNames
, container: T.defaultContainer { title: "Documents" }
, params
, rows: rows reload localCategories
...
...
src/Gargantext/Components/FacetsTable.purs
View file @
97a4b906
...
...
@@ -26,6 +26,7 @@ import Gargantext.Components.Category (CategoryQuery(..), putCategories)
import Gargantext.Components.Category.Types (Category(..), decodeCategory, favCategory)
import Gargantext.Components.Search
import Gargantext.Components.Table as T
import Gargantext.Components.Table.Types as T
import Gargantext.Ends (url, Frontends)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes (SessionRoute(Search, NodeAPI))
...
...
@@ -304,7 +305,10 @@ pageCpt :: R.Component PageProps
pageCpt = R.hooksComponentWithModule thisModule "page" cpt
where
cpt {frontends, totalRecords, container, deletions, documents, session, path: path@({nodeId, listId, query} /\ setPath)} _ = do
pure $ T.table { rows, container, colNames, totalRecords, params, wrapColElts }
pure $ T.table { syncResetButton : [ H.div {} [] ]
, rows, container, colNames
, totalRecords, params, wrapColElts
}
where
setParams f = setPath $ \p@{params: ps} -> p {params = f ps}
params = (fst path).params /\ setParams
...
...
src/Gargantext/Components/GraphExplorer/Sidebar.purs
View file @
97a4b906
...
...
@@ -224,7 +224,7 @@ deleteNode :: TermList
-> Record SigmaxT.Node
-> Aff NTC.VersionedNgramsPatches
deleteNode termList session (GET.MetaData metaData) node = do
ret <- NTC.putNgramsPatches coreParams versioned
ret
<- NTC.putNgramsPatches coreParams versioned
task <- NTC.postNgramsChartsAsync coreParams -- TODO add task
pure ret
where
...
...
src/Gargantext/Components/NgramsTable.purs
View file @
97a4b906
...
...
@@ -37,6 +37,7 @@ import Gargantext.Prelude
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.AutoUpdate (autoUpdateElt)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Components.Table.Types as T
import Gargantext.Components.NgramsTable.Components as NTC
import Gargantext.Components.NgramsTable.Core
import Gargantext.Components.NgramsTable.Loader (useLoaderWithCacheAPI)
...
...
@@ -319,21 +320,16 @@ loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable"
, versioned: Versioned { data: initTable }
, withAutoUpdate } _ = do
let syncResetBtns = [ syncResetButtons
{ afterSync: chartsAfterSync
, ngramsLocalPatch
, performAction: performAction <<< CoreAction
}
]
pure $ R.fragment $
autoUpdate <>
syncResetBtns <>
[
autoUpdate <> [
H.h4 {style: {textAlign : "center"}}
[ H.span {className: "glyphicon glyphicon-hand-down"} []
, H.text "Extracted Terms"
]
, search
, T.table { colNames
, search ]
<> syncResetButton <>
[ T.table { syncResetButton
, colNames
, container: tableContainer { dispatch: performAction
, ngramsChildren
, ngramsParent
...
...
@@ -350,28 +346,30 @@ loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable"
, ngramsSelection
}
}
] <> syncResetBtns
] <> syncResetButton
where
chartsAfterSync _ = do
task <- postNgramsChartsAsync path'
liftEffect $ do
log2 "[chartsAfterSync] Synchronize task" task
case R.readRef asyncTasksRef of
Nothing -> log "[chartsAfterSync] asyncTasksRef is Nothing"
Just asyncTasks -> do
snd asyncTasks $ GAT.Insert nodeId task
case R.readRef treeReloadRef of
Nothing -> log "[chartsAfterSync] can't reload tree: ref empty"
Just treeReload -> do
snd treeReload $ (_ + 1)
-- snd appReload $ (_ + 1)
syncResetButton = syncResetBtns (chartsAfterSync path' asyncTasksRef nodeId treeReloadRef)
ngramsLocalPatch
performAction
autoUpdate :: Array R.Element
autoUpdate = if withAutoUpdate then
[ R2.buff $ autoUpdateElt {
duration: 5000
, effect: performAction $ CoreAction $ Synchronize { afterSync: chartsAfterSync }
} ]
[ R2.buff
$ autoUpdateElt
{ duration: 5000
, effect: performAction
$ CoreAction
$ Synchronize { afterSync: chartsAfterSync
path'
asyncTasksRef
nodeId
treeReloadRef
}
}
]
else []
setParentResetChildren :: Maybe NgramsTerm -> State -> State
...
...
@@ -747,3 +745,6 @@ sumOccurrences nt = sumOccChildren mempty
optps1 :: forall a. Show a => { desc :: String, mval :: Maybe a } -> R.Element
optps1 { desc, mval } = H.option { value: value } [H.text desc]
where value = maybe "" show mval
src/Gargantext/Components/NgramsTable/Components.purs
View file @
97a4b906
...
...
@@ -17,12 +17,7 @@ import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Prelude
import Gargantext.Components.NgramsTable.Core ( Action(..), Dispatch, NgramsElement, NgramsPatch(..)
, NgramsTable, NgramsTablePatch, NgramsTerm, Replace
, _NgramsElement, _NgramsRepoElement, _PatchMap, _children
, _list, _ngrams, _occurrences, ngramsTermText, replace
, singletonNgramsTablePatch, setTermListA
)
import Gargantext.Components.NgramsTable.Core
import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Table as Tbl
import Gargantext.Types as T
...
...
@@ -30,7 +25,6 @@ import Gargantext.Utils.Reactix as R2
thisModule = "Gargantext.Components.NgramsTable.Components"
type SearchInputProps =
( key :: String -- to prevent refreshing & losing input
, onSearch :: String -> Effect Unit
...
...
@@ -71,8 +65,7 @@ searchInputCpt = R.hooksComponentWithModule thisModule "searchInput" cpt
}
type SelectionCheckboxProps =
(
allNgramsSelected :: Boolean
( allNgramsSelected :: Boolean
, dispatch :: Dispatch
, ngramsSelection :: Set NgramsTerm
)
...
...
@@ -137,8 +130,7 @@ type NgramsDepth = {ngrams :: NgramsTerm, depth :: Int}
type NgramsClick = NgramsDepth -> Maybe (Effect Unit)
type TreeProps =
(
ngramsClick :: NgramsClick
( ngramsClick :: NgramsClick
, ngramsDepth :: NgramsDepth
, ngramsEdit :: NgramsClick
, ngramsStyle :: Array DOM.Props
...
...
src/Gargantext/Components/NgramsTable/Core.purs
View file @
97a4b906
This diff is collapsed.
Click to expand it.
src/Gargantext/Components/Nodes/Annuaire.purs
View file @
97a4b906
...
...
@@ -17,6 +17,7 @@ import Gargantext.Components.NgramsTable.Loader (clearCache)
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types as CT
import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Table as T
import Gargantext.Components.Table.Types as T
import Gargantext.Ends (url, Frontends)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes (SessionRoute(..))
...
...
@@ -149,7 +150,11 @@ pageCpt = R.hooksComponentWithModule thisModule "page" cpt
where
cpt { session, pagePath, frontends
, table: ({count: totalRecords, docs})} _ = do
pure $ T.table { rows, params, container, colNames, totalRecords, wrapColElts }
pure $ T.table { syncResetButton : [ H.div {} [] ]
, rows, params, container
, colNames, totalRecords
, wrapColElts
}
where
path = fst pagePath
rows = (\c -> {
...
...
src/Gargantext/Components/Nodes/Lists/Tabs.purs
View file @
97a4b906
...
...
@@ -63,10 +63,11 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
pure $ Tab.tabs { selected, tabs: tabs' }
where
tabs' = [ "Authors" /\ view Authors
tabs' = [ "Terms" /\ view Terms
, "Authors" /\ view Authors
, "Institutes" /\ view Institutes
, "Sources" /\ view Sources
, "Terms" /\ view Terms
]
]
view mode = ngramsView { appReload
, asyncTasksRef
, cacheState
...
...
src/Gargantext/Components/Table.purs
View file @
97a4b906
...
...
@@ -7,12 +7,15 @@ import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..))
import Data.Sequence as Seq
import Data.Tuple (fst, snd)
import Effect.Aff (Aff, launchAff_)
import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log2)
import Effect (Effect)
import Gargantext.Sessions (Session, get)
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Components.Table.Types
import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Search
import Gargantext.Utils.Reactix as R2
...
...
@@ -21,60 +24,6 @@ import Gargantext.Utils.Reactix (effectLink)
thisModule :: String
thisModule = "Gargantext.Components.Table"
type TableContainerProps =
( pageSizeControl :: R.Element
, pageSizeDescription :: R.Element
, paginationLinks :: R.Element
, tableHead :: R.Element
, tableBody :: Array R.Element
)
type Row = { row :: R.Element, delete :: Boolean }
type Rows = Seq.Seq Row
type OrderBy = Maybe (OrderByDirection ColumnName)
type Params = { limit :: Int
, offset :: Int
, orderBy :: OrderBy
, searchType :: SearchType
}
newtype ColumnName = ColumnName String
derive instance genericColumnName :: Generic ColumnName _
instance showColumnName :: Show ColumnName where
show = genericShow
derive instance eqColumnName :: Eq ColumnName
columnName :: ColumnName -> String
columnName (ColumnName c) = c
data OrderByDirection a = ASC a | DESC a
derive instance genericOrderByDirection :: Generic (OrderByDirection a) _
instance showOrderByDirection :: Show a => Show (OrderByDirection a) where
show = genericShow
derive instance eqOrderByDirection :: Eq a => Eq (OrderByDirection a)
orderByToForm :: OrderByDirection ColumnName -> String
orderByToForm (ASC (ColumnName x)) = x <> "Asc"
orderByToForm (DESC (ColumnName x)) = x <> "Desc"
type Props =
( colNames :: Array ColumnName
, container :: Record TableContainerProps -> R.Element
, params :: R.State Params
, rows :: Rows
, totalRecords :: Int
, wrapColElts :: ColumnName -> Array R.Element -> Array R.Element
-- ^ Use `const identity` as a default behavior.
)
type State =
{ page :: Int
, pageSize :: PageSizes
...
...
@@ -174,7 +123,7 @@ table props = R.createElement tableCpt props []
tableCpt :: R.Component Props
tableCpt = R.hooksComponentWithModule thisModule "table" cpt
where
cpt {container, colNames, wrapColElts, totalRecords, rows, params} _ = do
cpt {container,
syncResetButton,
colNames, wrapColElts, totalRecords, rows, params} _ = do
let
state = paramsState $ fst params
ps = pageSizes2Int state.pageSize
...
...
@@ -187,11 +136,12 @@ tableCpt = R.hooksComponentWithModule thisModule "table" cpt
cs =
wrapColElts c $
case state.orderBy of
Just (ASC d) | c == d -> [lnk (Just (DESC c)) "ASC ", lnk Nothing (columnName c)]
Just (DESC d) | c == d -> [lnk (Just (ASC c)) "DESC ",
lnk Nothing (columnName c)]
Just (ASC d) | c == d -> [lnk (Just (DESC c)) "ASC "
, lnk Nothing (columnName c)]
Just (DESC d) | c == d -> [lnk (Just (ASC c)) "DESC ", lnk Nothing (columnName c)]
_ -> [lnk (Just (ASC c)) (columnName c)]
pure $ container
{ pageSizeControl: sizeDD { params }
{ syncResetButton
, pageSizeControl: sizeDD { params }
, pageSizeDescription: textDescription state.page state.pageSize totalRecords
, paginationLinks: pagination params totalPages
, tableBody: map _.row $ A.fromFoldable rows
...
...
@@ -213,17 +163,18 @@ filterRows { params: { limit, offset, orderBy } } rs = newRs
newRs = Seq.take limit $ Seq.drop offset $ rs
defaultContainer :: {title :: String} -> Record TableContainerProps -> R.Element
defaultContainer {title} props = R.fragment
[ R2.row
[ H.div {className: "col-md-4"} [ props.pageSizeDescription ]
, H.div {className: "col-md-4"} [ props.paginationLinks ]
, H.div {className: "col-md-4"} [ props.pageSizeControl ]
]
, H.table {className: "table"}
[ H.thead {className: "thead-dark"} [ props.tableHead ]
, H.tbody {} props.tableBody
]
]
defaultContainer {title} props = R.fragment $ props.syncResetButton <> controls
where
controls = [ R2.row
[ H.div {className: "col-md-4"} [ props.pageSizeDescription ]
, H.div {className: "col-md-4"} [ props.paginationLinks ]
, H.div {className: "col-md-4"} [ props.pageSizeControl ]
]
, H.table {className: "table"}
[ H.thead {className: "thead-dark"} [ props.tableHead ]
, H.tbody {} props.tableBody
]
]
-- TODO: this needs to be in Gargantext.Pages.Corpus.Graph.Tabs
graphContainer :: {title :: String} -> Record TableContainerProps -> R.Element
...
...
@@ -356,3 +307,11 @@ string2PageSize "50" = PS50
string2PageSize "100" = PS100
string2PageSize "200" = PS200
string2PageSize _ = PS10
src/Gargantext/Components/Table/Types.purs
0 → 100644
View file @
97a4b906
module Gargantext.Components.Table.Types where
import Prelude
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..))
import Data.Sequence as Seq
import Data.Tuple (fst, snd)
import Effect.Aff (Aff, launchAff_)
import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log2)
import Effect (Effect)
import Gargantext.Sessions (Session, get)
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Search
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix (effectLink)
import Data.Generic.Rep (class Generic)
type Params = { limit :: Int
, offset :: Int
, orderBy :: OrderBy
, searchType :: SearchType
}
type OrderBy = Maybe (OrderByDirection ColumnName)
data OrderByDirection a = ASC a | DESC a
derive instance genericOrderByDirection :: Generic (OrderByDirection a) _
instance showOrderByDirection :: Show a => Show (OrderByDirection a) where
show = genericShow
derive instance eqOrderByDirection :: Eq a => Eq (OrderByDirection a)
orderByToForm :: OrderByDirection ColumnName -> String
orderByToForm (ASC (ColumnName x)) = x <> "Asc"
orderByToForm (DESC (ColumnName x)) = x <> "Desc"
newtype ColumnName = ColumnName String
derive instance genericColumnName :: Generic ColumnName _
instance showColumnName :: Show ColumnName where
show = genericShow
derive instance eqColumnName :: Eq ColumnName
columnName :: ColumnName -> String
columnName (ColumnName c) = c
type Props =
( syncResetButton :: Array R.Element
, colNames :: Array ColumnName
, container :: Record TableContainerProps -> R.Element
, params :: R.State Params
, rows :: Rows
, totalRecords :: Int
, wrapColElts :: ColumnName -> Array R.Element -> Array R.Element
-- ^ Use `const identity` as a default behavior.
)
type TableContainerProps =
( syncResetButton :: Array R.Element
, pageSizeControl :: R.Element
, pageSizeDescription :: R.Element
, paginationLinks :: R.Element
, tableHead :: R.Element
, tableBody :: Array R.Element
)
type Row = { row :: R.Element, delete :: Boolean }
type Rows = Seq.Seq Row
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