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
6ced4acc
Commit
6ced4acc
authored
Nov 02, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-merge' into dev
parents
0275f3db
1907214d
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
706 additions
and
3642 deletions
+706
-3642
packages.json
.psc-package/local/.set/packages.json
+520
-33
packages-0.13.8-20200822.dhall
packages-0.13.8-20200822.dhall
+0
-3450
packages.dhall
packages.dhall
+1
-1
AnnotatedField.purs
src/Gargantext/Components/Annotation/AnnotatedField.purs
+12
-13
App.purs
src/Gargantext/Components/App.purs
+2
-2
DocsTable.purs
src/Gargantext/Components/DocsTable.purs
+21
-27
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+16
-54
Components.purs
src/Gargantext/Components/NgramsTable/Components.purs
+8
-10
Core.purs
src/Gargantext/Components/NgramsTable/Core.purs
+86
-8
Contacts.purs
src/Gargantext/Components/Nodes/Annuaire/User/Contacts.purs
+1
-1
Tabs.purs
...gantext/Components/Nodes/Annuaire/User/Contacts/Tabs.purs
+0
-1
Document.purs
src/Gargantext/Components/Nodes/Corpus/Document.purs
+35
-25
Types.purs
src/Gargantext/Components/Nodes/Corpus/Document/Types.purs
+3
-12
Lists.purs
src/Gargantext/Components/Nodes/Lists.purs
+0
-1
Tabs.purs
src/Gargantext/Components/Nodes/Lists/Tabs.purs
+0
-3
Texts.purs
src/Gargantext/Components/Nodes/Texts.purs
+1
-1
No files found.
.psc-package/local/.set/packages.json
View file @
6ced4acc
This diff is collapsed.
Click to expand it.
packages-0.13.8-20200822.dhall
deleted
100644 → 0
View file @
0275f3db
This diff is collapsed.
Click to expand it.
packages.dhall
View file @
6ced4acc
let upstream =
./packages-0.13.8-20200822
.dhall
https://github.com/purescript/package-sets/releases/download/psc-0.13.8-20201021/packages
.dhall
let overrides =
{ thermite =
...
...
src/Gargantext/Components/Annotation/AnnotatedField.purs
View file @
6ced4acc
...
...
@@ -12,10 +12,10 @@
module Gargantext.Components.Annotation.AnnotatedField where
import Prelude
import Data.Maybe ( Maybe(..), maybe
, isJust, isNothing
)
import Data.Maybe ( Maybe(..), maybe )
import Data.Tuple ( Tuple(..) )
import Data.Tuple.Nested ( (/\) )
import DOM.Simple.Console (log
, log
2)
import DOM.Simple.Console (log2)
import DOM.Simple.Event as DE
import Effect ( Effect )
import Reactix as R
...
...
@@ -27,7 +27,6 @@ import Gargantext.Components.Annotation.Utils ( termBootstrapClass )
import Gargantext.Components.NgramsTable.Core (NgramsTable, NgramsTerm, findNgramTermList, highlightNgrams, normNgram)
import Gargantext.Components.Annotation.Menu ( AnnotationMenu, annotationMenu, MenuType(..) )
import Gargantext.Utils.Selection as Sel
import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.Annotation.AnnotatedField"
...
...
@@ -58,11 +57,11 @@ annotatedFieldComponent = R.hooksComponentWithModule thisModule "annotatedField"
onSelect :: String -> Maybe TermList -> MouseEvent -> Effect Unit
onSelect text' Nothing event = do
log2 "[onSelect] text'" text'
--
log2 "[onSelect] text'" text'
maybeShowMenu setMenu menuRef setTermList ngrams event
onSelect text' (Just list) event = do
log2 "[onSelect] text'" text'
log2 "[onSelect] list" list
--
log2 "[onSelect] text'" text'
--log2 "[onSelect] list" (show list)
let x = E.clientX event
y = E.clientY event
setList t = do
...
...
@@ -77,8 +76,8 @@ annotatedFieldComponent = R.hooksComponentWithModule thisModule "annotatedField"
, onClose: \_ -> R.setRef menuRef Nothing
, setList
}
--setMenu (const $ menu)
R.setRef menuRef menu
setMenu $ const menu
mapCompile (Tuple t l) = {text: t, list: l, onSelect}
compiled = map mapCompile $ compile ngrams text
...
...
@@ -105,8 +104,8 @@ addMenuCpt = R.hooksComponentWithModule thisModule "addMenu" cpt
R.useEffect' $ do
let m = R.readRef menuRef
log2 "[addMenu] menuRef" m
log2 "[addMenu] mMenu" mMenu
--
log2 "[addMenu] menuRef" m
--
log2 "[addMenu] mMenu" mMenu
setmMenu $ const m
pure $ case mMenu of
...
...
@@ -116,7 +115,7 @@ addMenuCpt = R.hooksComponentWithModule thisModule "addMenu" cpt
-- forall e. IsMouseEvent e => R.Setter (Maybe AnnotationMenu) -> R.Setter ? -> ? -> e -> Effect Unit
maybeShowMenu setMenu menuRef setTermList ngrams event = do
s <- Sel.getSelection
log2 "[maybeShowMenu] s" s
--
log2 "[maybeShowMenu] s" s
case s of
Just sel -> do
case Sel.selectionToString sel of
...
...
@@ -128,11 +127,11 @@ maybeShowMenu setMenu menuRef setTermList ngrams event = do
list = findNgramTermList ngrams n
setList t = do
setTermList n list t
--setMenu (const Nothing)
R.setRef menuRef Nothing
--setMenu (const Nothing)
E.preventDefault event
range <- Sel.getRange sel 0
log2 "[maybeShowMenu] selection range" $ Sel.rangeToTuple range
--
log2 "[maybeShowMenu] selection range" $ Sel.rangeToTuple range
let menu = Just {
x
, y
...
...
@@ -141,8 +140,8 @@ maybeShowMenu setMenu menuRef setTermList ngrams event = do
, onClose: \_ -> R.setRef menuRef Nothing
, setList
}
--setMenu (const $ menu)
R.setRef menuRef menu
setMenu $ const $ menu
Nothing -> pure unit
-- Nothing -> do
-- R.setRef menuRef Nothing
...
...
src/Gargantext/Components/App.purs
View file @
6ced4acc
...
...
@@ -10,7 +10,6 @@ import Reactix.DOM.HTML as H
import Gargantext.Prelude
import Gargantext.Config (publicBackend)
import Gargantext.Components.Forest (forest)
import Gargantext.Components.GraphExplorer (explorerLayout)
import Gargantext.Components.Lang (LandingLang(..))
...
...
@@ -25,7 +24,7 @@ import Gargantext.Components.Nodes.Frame (frameLayout)
import Gargantext.Components.Nodes.Home (homeLayout)
import Gargantext.Components.Nodes.Lists (listsLayout)
import Gargantext.Components.Nodes.Texts (textsLayout)
import Gargantext.Config (defaultFrontends, defaultBackends)
import Gargantext.Config (defaultFrontends, defaultBackends
, publicBackend
)
import Gargantext.Ends (Frontends, Backend)
import Gargantext.Hooks.Router (useHashRouter)
import Gargantext.License (license)
...
...
@@ -36,6 +35,7 @@ import Gargantext.Sessions as Sessions
import Gargantext.Types as GT
import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.App"
-- TODO (what does this mean?)
...
...
src/Gargantext/Components/DocsTable.purs
View file @
6ced4acc
-- TODO: this module should be replaced by FacetsTable
module Gargantext.Components.DocsTable where
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, jsonEmptyObject, (.:), (:=), (~>)
, encodeJson
)
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, jsonEmptyObject, (.:), (:=), (~>))
import Data.Array as A
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Eq (genericEq)
import Data.Generic.Rep.Show (genericShow)
import Data.Lens ((^.))
import Data.Lens.At (at)
import Data.Lens.Record (prop)
import Data.Map (Map)
import Data.Map as Map
import Data.Maybe (Maybe(..), fromMaybe, isJust, maybe)
import Data.Maybe (Maybe(..), fromMaybe, isJust)
import Data.Ord.Down (Down(..))
import Data.Sequence as Seq
import Data.Set (Set)
import Data.Set as Set
import Data.String as Str
...
...
@@ -22,25 +17,23 @@ import Data.Tuple (Tuple(..), fst)
import Data.Tuple.Nested ((/\))
import DOM.Simple.Event as DE
import Effect (Effect)
import Effect.Aff (Aff, launchAff)
import Effect.Class (liftEffect)
import Effect.Aff (Aff)
import Reactix as R
import Reactix.DOM.HTML as H
------------------------------------------------------------------------
import Gargantext.Prelude
import Gargantext.Components.Category
import Gargantext.Components.Category
(Category(..), caroussel, decodeCategory)
import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Table as T
import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoader, useLoaderWithCacheAPI, HashedResponse(..))
import Gargantext.Utils (sortWith)
import Gargantext.Utils.Reactix as R2
import Gargantext.Routes as Routes
import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Sessions (Session, sessionId, get, delete, put)
import Gargantext.Types (NodeType(..), OrderBy(..), TableResult, TabSubType(..), TabType, showTabType')
import Gargantext.Sessions (Session, sessionId, get, delete)
import Gargantext.Types (NodeType(..), OrderBy(..), TableResult, TabSubType, TabType, showTabType')
import Gargantext.Utils (sortWith)
import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.QueryString
import Gargantext.Utils.QueryString
(joinQueryStrings, mQueryParamS, queryParam, queryParamS)
import Gargantext.Utils.Reactix as R2
thisModule :: String
...
...
@@ -285,7 +278,7 @@ getPageHash :: Session -> PageParams -> Aff String
getPageHash session { corpusId, listId, nodeId, query, tabType } = do
(get session $ tableHashRoute nodeId tabType) :: Aff String
convOrderBy :: Maybe (T.OrderByDirection T.ColumnName) -> Maybe OrderBy
convOrderBy (Just (T.ASC (T.ColumnName "Date"))) = Just DateAsc
convOrderBy (Just (T.DESC (T.ColumnName "Date"))) = Just DateDesc
convOrderBy (Just (T.ASC (T.ColumnName "Title"))) = Just TitleAsc
...
...
@@ -332,8 +325,7 @@ pageLayoutCpt = R.hooksComponentWithModule thisModule "pageLayout" cpt where
(NT.CacheOn /\ _) -> do
let paint (Tuple count docs) = page params (props { totalRecords = count }) docs
mkRequest :: PageParams -> GUC.Request
mkRequest p@{ listId, nodeId, tabType } =
GUC.makeGetRequest session $ tableRoute nodeId tabType listId
mkRequest p = GUC.makeGetRequest session $ tableRoute p
useLoaderWithCacheAPI {
cacheEndpoint: getPageHash session
...
...
@@ -345,8 +337,8 @@ pageLayoutCpt = R.hooksComponentWithModule thisModule "pageLayout" cpt where
(NT.CacheOff /\ _) -> do
localCategories <- R.useState' (mempty :: LocalCategories)
paramsS <- R.useState' params
let loader p
@{ listId, nodeId, tabType }
= do
res <- get session $ tableRouteWithPage
{ listId, nodeId, params: fst paramsS, query, tabType }
let loader p = do
res <- get session $ tableRouteWithPage
(p { params = fst paramsS, query = query })
pure $ handleResponse res
render (Tuple count documents) = pagePaintRaw { documents
, layout: props { params = fst paramsS
...
...
@@ -493,17 +485,19 @@ instance encodeJsonSQuery :: EncodeJson SearchQuery where
documentsRoute :: Int -> SessionRoute
documentsRoute nodeId = NodeAPI Node (Just nodeId) "documents"
tableRoute ::
Int -> TabType -> Int
-> SessionRoute
tableRoute
nodeId tabType listId
= NodeAPI Node (Just nodeId) $ "table" <> "?tabType=" <> (showTabType' tabType) <> "&list=" <> (show listId)
tableRoute ::
forall row. {nodeId :: Int, tabType :: TabType, listId :: Int | row}
-> SessionRoute
tableRoute
{nodeId, tabType, listId}
= NodeAPI Node (Just nodeId) $ "table" <> "?tabType=" <> (showTabType' tabType) <> "&list=" <> (show listId)
tableHashRoute :: Int -> TabType -> SessionRoute
tableHashRoute nodeId tabType = NodeAPI Node (Just nodeId) $ "table/hash" <> "?tabType=" <> (showTabType' tabType)
tableRouteWithPage :: { listId :: Int
, nodeId :: Int
, params :: T.Params
, query :: Query
, tabType :: TabType } -> SessionRoute
tableRouteWithPage :: forall row.
{ listId :: Int
, nodeId :: Int
, params :: T.Params
, query :: Query
, tabType :: TabType
| row } -> SessionRoute
tableRouteWithPage { listId, nodeId, params: { limit, offset, orderBy, searchType }, query, tabType } =
NodeAPI Node (Just nodeId) $ "table" <> joinQueryStrings [tt, lst, lmt, odb, ofs, st, q]
where
...
...
src/Gargantext/Components/NgramsTable.purs
View file @
6ced4acc
...
...
@@ -16,18 +16,15 @@ import Data.Map as Map
import Data.Maybe (Maybe(..), isNothing, maybe)
import Data.Monoid.Additive (Additive(..))
import Data.Ord.Down (Down(..))
import Data.Sequence as Seq
import Data.Sequence
(Seq, length)
as Seq
import Data.Set (Set)
import Data.Set as Set
import Data.Symbol (SProxy(..))
import Data.Tuple (Tuple(..), fst)
import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log)
import Effect (Effect)
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import FFI.Simple (delay)
import Reactix as R
import Reactix (Component, Element, State, createElement, fragment, hooksComponentWithModule, unsafeEventValue, useState') as R
import Reactix.DOM.HTML as H
import Unsafe.Coerce (unsafeCoerce)
...
...
@@ -45,8 +42,9 @@ import Gargantext.Types (CTabNgramType, OrderBy(..), SearchQuery, TabType, TermL
import Gargantext.Utils (queryMatchesLabel, toggleSet, sortWith)
import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Seq as Seq
import Gargantext.Utils.Seq
(mapMaybe)
as Seq
thisModule :: String
thisModule = "Gargantext.Components.NgramsTable"
type State' =
...
...
@@ -103,7 +101,7 @@ initialState (Versioned {version}) = {
setTermListSetA :: NgramsTable -> Set NgramsTerm -> TermList -> Action
setTermListSetA ngramsTable ns new_list =
CommitPatch $ fromNgramsPatches $ PatchMap $ mapWithIndex f $ toMap ns
Co
reAction $ Co
mmitPatch $ fromNgramsPatches $ PatchMap $ mapWithIndex f $ toMap ns
where
f :: NgramsTerm -> Unit -> NgramsPatch
f n unit = NgramsPatch { patch_list, patch_children: mempty }
...
...
@@ -116,9 +114,6 @@ setTermListSetA ngramsTable ns new_list =
-- https://github.com/purescript/purescript-ordered-collections/pull/31
-- toMap = Map.fromFoldable
addNewNgramA :: NgramsTerm -> Action
addNewNgramA ngram = CommitPatch $ addNewNgram ngram CandidateTerm
type PreConversionRows = Seq.Seq NgramsElement
type TableContainerProps =
...
...
@@ -157,8 +152,10 @@ tableContainerCpt { dispatch
H.li { className: "list-group-item" } [
H.button { className: "btn btn-primary"
, on: { click: const $ dispatch
$ CoreAction
$ addNewNgramA
$ normNgram tabNgramType searchQuery
(normNgram tabNgramType searchQuery)
CandidateTerm
}
}
[ H.text ("Add " <> searchQuery) ]
...
...
@@ -303,8 +300,12 @@ loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable"
, versioned: Versioned { data: initTable }
, withAutoUpdate } _ = do
let syncResetBtns = [syncResetButtons { afterSync, ngramsLocalPatch
, performAction: performAction <<< CoreAction
}]
pure $ R.fragment $
autoUpdate <>
[syncResetButtons { afterSync, ngramsLocalPatch, performAction }]
<> [
autoUpdate <>
syncResetBtns
<> [
H.h4 {style: {textAlign : "center"}} [
H.span {className: "glyphicon glyphicon-hand-down"} []
, H.text "Extracted Terms"
...
...
@@ -327,13 +328,13 @@ loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable"
, ngramsSelection
}
}
] <>
[syncResetButtons { afterSync, ngramsLocalPatch, performAction }]
] <>
syncResetBtns
where
autoUpdate :: Array R.Element
autoUpdate = if withAutoUpdate then
[ R2.buff $ autoUpdateElt {
duration: 5000
, effect: performAction $ Synchronize { afterSync }
, effect: performAction $
CoreAction $
Synchronize { afterSync }
} ]
else []
...
...
@@ -357,11 +358,6 @@ loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable"
s { ngramsSelection = Set.empty :: Set NgramsTerm }
else
s { ngramsSelection = selectNgramsOnFirstPage filteredRows }
performAction (Synchronize { afterSync }) = syncPatches path' (state /\ setState) afterSync
performAction (CommitPatch pt) =
commitPatch (Versioned {version: ngramsVersion, data: pt}) (state /\ setState)
performAction ResetPatches =
setState $ \s -> s { ngramsLocalPatch = { ngramsPatches: mempty } }
performAction AddTermChildren =
case ngramsParent of
Nothing ->
...
...
@@ -373,6 +369,7 @@ loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable"
pt = singletonNgramsTablePatch parent pe
setState $ setParentResetChildren Nothing
commitPatch (Versioned {version: ngramsVersion, data: pt}) (state /\ setState)
performAction (CoreAction a) = coreDispatch path' (state /\ setState) a
totalRecords = Seq.length rows
filteredConvertedRows :: T.Rows
...
...
@@ -444,41 +441,6 @@ loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable"
setSearchQuery x = setPath $ _ { searchQuery = x }
type SyncResetButtonsProps = (
afterSync :: Unit -> Aff Unit
, ngramsLocalPatch :: NgramsTablePatch
, performAction :: Action -> Effect Unit
)
syncResetButtons :: Record SyncResetButtonsProps -> R.Element
syncResetButtons p = R.createElement syncResetButtonsCpt p []
syncResetButtonsCpt :: R.Component SyncResetButtonsProps
syncResetButtonsCpt = R.hooksComponentWithModule thisModule "syncResetButtons" cpt
where
cpt { afterSync, ngramsLocalPatch, performAction } _ = do
synchronizing@(s /\ _) <- R.useState' false
let hasChanges = ngramsLocalPatch /= mempty
pure $ H.div {} [
H.button { className: "btn btn-danger " <> if hasChanges then "" else " disabled"
, on: { click: \_ -> performAction ResetPatches }
} [ H.text "Reset" ]
, H.button { className: "btn btn-primary " <> (if s || (not hasChanges) then "disabled" else "")
, on: { click: synchronize synchronizing }
} [ H.text "Sync" ]
]
where
synchronize (_ /\ setSynchronizing) _ = delay unit $ \_ -> do
setSynchronizing $ const true
performAction $ Synchronize { afterSync: newAfterSync }
where
newAfterSync x = do
afterSync x
liftEffect $ setSynchronizing $ const false
displayRow :: State -> SearchQuery -> NgramsTable -> Maybe NgramsTerm -> Maybe TermList -> Maybe TermSize -> NgramsElement -> Boolean
displayRow state@{ ngramsChildren
, ngramsLocalPatch
...
...
src/Gargantext/Components/NgramsTable/Components.purs
View file @
6ced4acc
...
...
@@ -17,7 +17,12 @@ 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)
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.Table as Tbl
import Gargantext.Types as T
import Gargantext.Utils.Reactix as R2
...
...
@@ -207,7 +212,7 @@ renderNgramsItemCpt = R.hooksComponentWithModule thisModule "renderNgramsItem" c
ngramsStyle = [termStyle termList ngramsOpacity]
ngramsEdit = Just <<< dispatch <<< SetParentResetChildren <<< Just <<< view _ngrams
ngramsClick
= Just <<< dispatch <<< cycleTermListItem <<< view _ngrams
= Just <<< dispatch <<<
CoreAction <<<
cycleTermListItem <<< view _ngrams
-- ^ This is the old behavior it is nicer to use since one can
-- rapidly change the ngram list without waiting for confirmation.
-- However this might expose bugs. One of them can be reproduced
...
...
@@ -226,7 +231,7 @@ renderNgramsItemCpt = R.hooksComponentWithModule thisModule "renderNgramsItem" c
in
H.input { checked: chkd
, className: "checkbox"
, on: { change: const $ dispatch $
, on: { change: const $ dispatch $
CoreAction $
setTermListA ngrams (replace termList termList'') }
, readOnly: ngramsTransient
, type: "checkbox" }
...
...
@@ -245,13 +250,6 @@ termStyle T.StopTerm opacity = DOM.style { color: "red", opacity
, textDecoration: "line-through" }
termStyle T.CandidateTerm opacity = DOM.style { color: "black", opacity }
setTermListA :: NgramsTerm -> Replace T.TermList -> Action
setTermListA n patch_list =
CommitPatch $
singletonNgramsTablePatch n $
NgramsPatch { patch_list, patch_children: mempty }
tablePatchHasNgrams :: NgramsTablePatch -> NgramsTerm -> Boolean
tablePatchHasNgrams ngramsTablePatch ngrams =
isJust $ ngramsTablePatch.ngramsPatches ^. _PatchMap <<< at ngrams
...
...
src/Gargantext/Components/NgramsTable/Core.purs
View file @
6ced4acc
...
...
@@ -15,6 +15,7 @@ module Gargantext.Components.NgramsTable.Core
, NgramsTerm
, normNgram
, ngramsTermText
, findNgramRoot
, findNgramTermList
, Version
, Versioned(..)
...
...
@@ -51,11 +52,20 @@ module Gargantext.Components.NgramsTable.Core
, commitPatch
, putNgramsPatches
, syncPatches
, addNewNgram
, addNewNgramP
, addNewNgramA
, setTermListP
, setTermListA
, CoreAction(..)
, CoreDispatch
, Action(..)
, Dispatch
, coreDispatch
, isSingleNgramsTerm
, filterTermSize
, SyncResetButtonsProps
, syncResetButtons
, syncResetButtonsCpt
)
where
...
...
@@ -107,7 +117,9 @@ import Effect (Effect)
import Effect.Class (liftEffect)
import Effect.Exception.Unsafe (unsafeThrow)
import Foreign.Object as FO
import Reactix (State) as R
import FFI.Simple.Functions (delay)
import Reactix as R
import Reactix.DOM.HTML as H
import Partial (crashWith)
import Partial.Unsafe (unsafePartial)
...
...
@@ -118,6 +130,9 @@ import Gargantext.Sessions (Session, get, put)
import Gargantext.Types (CTabNgramType(..), OrderBy(..), ScoreType(..), TabSubType(..), TabType(..), TermList(..), TermSize(..))
import Gargantext.Utils.KarpRabin (indicesOfAny)
thisModule :: String
thisModule = "Gargantext.Components.NgramsTable.Core"
type Endo a = a -> a
type CoreParams s =
...
...
@@ -746,8 +761,14 @@ isEmptyNgramsTablePatch {ngramsPatches} = isEmptyPatchMap ngramsPatches
fromNgramsPatches :: NgramsPatches -> NgramsTablePatch
fromNgramsPatches ngramsPatches = {ngramsPatches}
findNgramRoot :: NgramsTable -> NgramsTerm -> NgramsTerm
findNgramRoot (NgramsTable m) n =
fromMaybe n (m.ngrams_repo_elements ^? at n <<< _Just <<< _NgramsRepoElement <<< _root <<< _Just)
findNgramTermList :: NgramsTable -> NgramsTerm -> Maybe TermList
findNgramTermList (NgramsTable m) n = m.ngrams_repo_elements ^? at n <<< _Just <<< _NgramsRepoElement <<< _list
findNgramTermList (NgramsTable m) n = m.ngrams_repo_elements ^? at r <<< _Just <<< _NgramsRepoElement <<< _list
where
r = findNgramRoot (NgramsTable m) n
singletonNgramsTablePatch :: NgramsTerm -> NgramsPatch -> NgramsTablePatch
singletonNgramsTablePatch n p = fromNgramsPatches $ singletonPatchMap n p
...
...
@@ -864,10 +885,21 @@ newNgramPatch list =
}
}
addNewNgram :: NgramsTerm -> TermList -> NgramsTablePatch
addNewNgram ngrams list =
addNewNgram
P
:: NgramsTerm -> TermList -> NgramsTablePatch
addNewNgram
P
ngrams list =
{ ngramsPatches: singletonPatchMap ngrams (newNgramPatch list) }
addNewNgramA :: NgramsTerm -> TermList -> CoreAction
addNewNgramA ngrams list = CommitPatch $ addNewNgramP ngrams list
setTermListP :: NgramsTerm -> Replace TermList -> NgramsTablePatch
setTermListP ngram patch_list = singletonNgramsTablePatch ngram pe
where
pe = NgramsPatch { patch_list, patch_children: mempty }
setTermListA :: NgramsTerm -> Replace TermList -> CoreAction
setTermListA ngram termList = CommitPatch $ setTermListP ngram termList
putNgramsPatches :: forall s. CoreParams s -> VersionedNgramsPatches -> Aff VersionedNgramsPatches
putNgramsPatches {session, nodeId, listIds, tabType} = put session putNgrams
where putNgrams = PutNgrams tabType (head listIds) Nothing (Just nodeId)
...
...
@@ -949,9 +981,13 @@ convOrderBy (T.DESC (T.ColumnName "Score")) = ScoreDesc
convOrderBy (T.ASC _) = TermAsc
convOrderBy (T.DESC _) = TermDesc
data CoreAction
= CommitPatch NgramsTablePatch
| Synchronize { afterSync :: Unit -> Aff Unit }
| ResetPatches
data Action
= Co
mmitPatch NgramsTablePatch
= Co
reAction CoreAction
| SetParentResetChildren (Maybe NgramsTerm)
-- ^ This sets `ngramsParent` and resets `ngramsChildren`.
| ToggleChild Boolean NgramsTerm
...
...
@@ -959,15 +995,22 @@ data Action
-- If the `Boolean` is `true` it means we want to add it if it is not here,
-- if it is `false` it is meant to be removed if not here.
| AddTermChildren
| Synchronize { afterSync :: Unit -> Aff Unit }
| ToggleSelect NgramsTerm
-- ^ Toggles the NgramsTerm in the `Set` `ngramsSelection`.
| ToggleSelectAll
| ResetPatches
type CoreDispatch = CoreAction -> Effect Unit
type Dispatch = Action -> Effect Unit
coreDispatch :: forall p s. CoreParams p -> R.State (CoreState s) -> CoreDispatch
coreDispatch path state (Synchronize { afterSync }) =
syncPatches path state afterSync
coreDispatch _ state@({ngramsVersion} /\ _) (CommitPatch pt) =
commitPatch (Versioned {version: ngramsVersion, data: pt}) state
coreDispatch _ (_ /\ setState) ResetPatches =
setState $ \s -> s { ngramsLocalPatch = { ngramsPatches: mempty } }
isSingleNgramsTerm :: NgramsTerm -> Boolean
isSingleNgramsTerm nt = isSingleTerm $ ngramsTermText nt
where
...
...
@@ -980,3 +1023,38 @@ filterTermSize :: Maybe TermSize -> NgramsTerm -> Boolean
filterTermSize (Just MonoTerm) nt = isSingleNgramsTerm nt
filterTermSize (Just MultiTerm) nt = not $ isSingleNgramsTerm nt
filterTermSize _ _ = true
type SyncResetButtonsProps =
( afterSync :: Unit -> Aff Unit
, ngramsLocalPatch :: NgramsTablePatch
, performAction :: CoreDispatch
)
syncResetButtons :: Record SyncResetButtonsProps -> R.Element
syncResetButtons p = R.createElement syncResetButtonsCpt p []
syncResetButtonsCpt :: R.Component SyncResetButtonsProps
syncResetButtonsCpt = R.hooksComponentWithModule thisModule "syncResetButtons" cpt
where
cpt { afterSync, ngramsLocalPatch, performAction } _ = do
synchronizing@(s /\ setSynchronizing) <- R.useState' false
let
hasChanges = ngramsLocalPatch /= mempty
newAfterSync x = do
afterSync x
liftEffect $ setSynchronizing $ const false
synchronizeClick _ = delay unit $ \_ -> do
setSynchronizing $ const true
performAction $ Synchronize { afterSync: newAfterSync }
pure $ H.div {} [
H.button { className: "btn btn-danger " <> if hasChanges then "" else " disabled"
, on: { click: \_ -> performAction ResetPatches }
} [ H.text "Reset" ]
, H.button { className: "btn btn-primary " <> (if s || (not hasChanges) then "disabled" else "")
, on: { click: synchronizeClick }
} [ H.text "Sync" ]
]
\ No newline at end of file
src/Gargantext/Components/Nodes/Annuaire/User/Contacts.purs
View file @
6ced4acc
...
...
@@ -25,8 +25,8 @@ import Gargantext.Prelude (Unit, bind, const, discard, pure, show, unit, ($), (+
import Gargantext.Routes as Routes
import Gargantext.Sessions (Session, get, put, sessionId)
import Gargantext.Types (NodeType(..))
import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.Nodes.Annuaire.User.Contacts"
display :: String -> Array R.Element -> R.Element
...
...
src/Gargantext/Components/Nodes/Annuaire/User/Contacts/Tabs.purs
View file @
6ced4acc
...
...
@@ -17,7 +17,6 @@ import Gargantext.Components.Nodes.Lists.Types as NTypes
import Gargantext.Ends (Frontends)
import Gargantext.Sessions (Session)
import Gargantext.Types (TabType(..), TabSubType(..), CTabNgramType(..), PTabNgramType(..))
import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs"
...
...
src/Gargantext/Components/Nodes/Corpus/Document.purs
View file @
6ced4acc
This diff is collapsed.
Click to expand it.
src/Gargantext/Components/Nodes/Corpus/Document/Types.purs
View file @
6ced4acc
...
...
@@ -8,15 +8,12 @@ import Data.Maybe (Maybe(..))
import Gargantext.Prelude
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.NgramsTable.Core
(CoreState, NgramsTerm, Replace, Versioned(..) , VersionedNgramsTable)
import Gargantext.Components.Annotation.AnnotatedField as AnnotatedField
import Gargantext.Components.NgramsTable.Core (CoreState, Versioned(..) , VersionedNgramsTable)
import Gargantext.Sessions (Session)
import Gargantext.Types (TabType
, TermList
)
import Gargantext.Types (TabType)
type DocPath =
{
corpusId :: Maybe Int
{ corpusId :: Maybe Int
, listIds :: Array Int
, nodeId :: Int
, session :: Session
...
...
@@ -50,12 +47,6 @@ initialState {loaded: {ngramsTable: Versioned {version}}} =
, ngramsVersion: version
}
-- This is a subset of NgramsTable.Action.
data Action
= SetTermListItem NgramsTerm (Replace TermList)
| AddNewNgram NgramsTerm TermList
| Synchronize
newtype Status = Status { failed :: Int
, succeeded :: Int
, remaining :: Int
...
...
src/Gargantext/Components/Nodes/Lists.purs
View file @
6ced4acc
...
...
@@ -14,7 +14,6 @@ import Gargantext.Components.Table as Table
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude
import Gargantext.Sessions (Session, sessionId)
import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.Nodes.Lists"
...
...
src/Gargantext/Components/Nodes/Lists/Tabs.purs
View file @
6ced4acc
module Gargantext.Components.Nodes.Lists.Tabs where
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Tuple (fst)
import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log2)
import Effect.Aff (launchAff_)
import Effect.Class (liftEffect)
import Reactix as R
import Reactix.DOM.HTML as H
...
...
src/Gargantext/Components/Nodes/Texts.purs
View file @
6ced4acc
...
...
@@ -23,8 +23,8 @@ import Gargantext.Components.Table as Table
import Gargantext.Ends (Frontends)
import Gargantext.Sessions (Session, sessionId)
import Gargantext.Types (CTabNgramType(..), TabSubType(..), TabType(..))
import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.Nodes.Texts"
--------------------------------------------------------
...
...
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