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
5356f9db
Commit
5356f9db
authored
Oct 25, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into dev-graphql
parents
0f22711d
ed4b7f46
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
39 deletions
+84
-39
package.json
package.json
+1
-1
shell.nix
shell.nix
+9
-0
Controls.purs
src/Gargantext/Components/GraphExplorer/Controls.purs
+1
-1
Sidebar.purs
src/Gargantext/Components/GraphExplorer/Sidebar.purs
+38
-15
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+35
-22
No files found.
package.json
View file @
5356f9db
{
{
"name"
:
"Gargantext"
,
"name"
:
"Gargantext"
,
"version"
:
"0.0.4.
4
"
,
"version"
:
"0.0.4.
5
"
,
"scripts"
:
{
"scripts"
:
{
"generate-purs-packages-nix"
:
"./nix/generate-purs-packages.nix"
,
"generate-purs-packages-nix"
:
"./nix/generate-purs-packages.nix"
,
"generate-psc-packages-nix"
:
"./nix/generate-packages-json.bash"
,
"generate-psc-packages-nix"
:
"./nix/generate-packages-json.bash"
,
...
...
shell.nix
View file @
5356f9db
...
@@ -35,6 +35,14 @@ let
...
@@ -35,6 +35,14 @@ let
''
;
''
;
serve
=
pkgs
.
writeShellScriptBin
"serve"
''
#!/usr/bin/env bash
set -e
yarn server
''
;
build-watch
=
pkgs
.
writeShellScriptBin
"build-watch"
''
build-watch
=
pkgs
.
writeShellScriptBin
"build-watch"
''
#!/usr/bin/env bash
#!/usr/bin/env bash
set -e
set -e
...
@@ -110,6 +118,7 @@ pkgs.mkShell {
...
@@ -110,6 +118,7 @@ pkgs.mkShell {
pkgs
.
minify
pkgs
.
minify
pkgs
.
nodejs
pkgs
.
nodejs
repl
repl
serve
pkgs
.
pulp
pkgs
.
pulp
pkgs
.
spago
pkgs
.
spago
pkgs
.
yarn
pkgs
.
yarn
...
...
src/Gargantext/Components/GraphExplorer/Controls.purs
View file @
5356f9db
...
@@ -163,7 +163,7 @@ controlsCpt = here.component "controls" cpt
...
@@ -163,7 +163,7 @@ controlsCpt = here.component "controls" cpt
[ RH.ul { className: "navbar-nav mx-auto" }
[ RH.ul { className: "navbar-nav mx-auto" }
[ -- change type button (?)
[ -- change type button (?)
navItem [ centerButton sigmaRef ]
navItem [ centerButton sigmaRef ]
, navItem [ resetForceAtlasButton { forceAtlasState, sigmaRef } [] ]
--
, navItem [ resetForceAtlasButton { forceAtlasState, sigmaRef } [] ]
, navItem [ pauseForceAtlasButton { state: forceAtlasState } [] ]
, navItem [ pauseForceAtlasButton { state: forceAtlasState } [] ]
, navItem [ edgesToggleButton { state: showEdges } [] ]
, navItem [ edgesToggleButton { state: showEdges } [] ]
, navItem [ louvainToggleButton { state: showLouvain } [] ]
, navItem [ louvainToggleButton { state: showLouvain } [] ]
...
...
src/Gargantext/Components/GraphExplorer/Sidebar.purs
View file @
5356f9db
...
@@ -8,6 +8,7 @@ import Control.Parallel (parTraverse)
...
@@ -8,6 +8,7 @@ import Control.Parallel (parTraverse)
import Data.Array (head, last, concat)
import Data.Array (head, last, concat)
import Data.Array as A
import Data.Array as A
import Data.Either (Either(..))
import Data.Either (Either(..))
import Data.Foldable as F
import Data.Int (fromString)
import Data.Int (fromString)
import Data.Map as Map
import Data.Map as Map
import Data.Maybe (Maybe(..), fromJust)
import Data.Maybe (Maybe(..), fromJust)
...
@@ -33,6 +34,7 @@ import Gargantext.Sessions (Session)
...
@@ -33,6 +34,7 @@ import Gargantext.Sessions (Session)
import Gargantext.Types (CTabNgramType, FrontendError(..), NodeID, TabSubType(..), TabType(..), TermList(..), modeTabType)
import Gargantext.Types (CTabNgramType, FrontendError(..), NodeID, TabSubType(..), TabType(..), TermList(..), modeTabType)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
import Gargantext.Utils.Toestand as T2
import Math as Math
import Partial.Unsafe (unsafePartial)
import Partial.Unsafe (unsafePartial)
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
...
@@ -182,6 +184,10 @@ selectedNodesCpt = here.component "selectedNodes" cpt
...
@@ -182,6 +184,10 @@ selectedNodesCpt = here.component "selectedNodes" cpt
{ selectedNodeIds } <- GEST.focusedSidePanel sidePanelGraph
{ selectedNodeIds } <- GEST.focusedSidePanel sidePanelGraph
selectedNodeIds' <- T.useLive T.unequal selectedNodeIds
selectedNodeIds' <- T.useLive T.unequal selectedNodeIds
let badges' = neighbourBadges graph selectedNodeIds'
minSize = F.foldl Math.min 0.0 (Seq.map _.size (SigmaxT.graphNodes graph))
maxSize = F.foldl Math.max 0.0 (Seq.map _.size (SigmaxT.graphNodes graph))
pure $ R2.row
pure $ R2.row
[ R2.col 12
[ R2.col 12
[ RH.ul { className: "nav nav-tabs d-flex justify-content-center"
[ RH.ul { className: "nav nav-tabs d-flex justify-content-center"
...
@@ -191,9 +197,7 @@ selectedNodesCpt = here.component "selectedNodes" cpt
...
@@ -191,9 +197,7 @@ selectedNodesCpt = here.component "selectedNodes" cpt
[ RH.div { className: "d-flex flex-wrap justify-content-center"
[ RH.div { className: "d-flex flex-wrap justify-content-center"
, role: "tabpanel" }
, role: "tabpanel" }
( Seq.toUnfoldable
( Seq.toUnfoldable
$ ( Seq.map (badge selectedNodeIds)
$ ( Seq.map (\node -> badge { maxSize, minSize, node, selectedNodeIds }) badges')
(badges graph selectedNodeIds')
)
)
)
, H.br {}
, H.br {}
]
]
...
@@ -225,15 +229,17 @@ neighborhoodCpt = here.component "neighborhood" cpt
...
@@ -225,15 +229,17 @@ neighborhoodCpt = here.component "neighborhood" cpt
{ selectedNodeIds } <- GEST.focusedSidePanel sidePanelGraph
{ selectedNodeIds } <- GEST.focusedSidePanel sidePanelGraph
selectedNodeIds' <- T.useLive T.unequal selectedNodeIds
selectedNodeIds' <- T.useLive T.unequal selectedNodeIds
let badges' = neighbourBadges graph selectedNodeIds'
minSize = F.foldl Math.min 0.0 (Seq.map _.size (SigmaxT.graphNodes graph))
maxSize = F.foldl Math.max 0.0 (Seq.map _.size (SigmaxT.graphNodes graph))
pure $ RH.div { className: "tab-content", id: "myTabContent" }
pure $ RH.div { className: "tab-content", id: "myTabContent" }
[ RH.div { -- className: "flex-space-around d-flex justify-content-center"
[ RH.div { -- className: "flex-space-around d-flex justify-content-center"
className: "d-flex flex-wrap flex-space-around"
className: "d-flex flex-wrap flex-space-around"
, id: "home"
, id: "home"
, role: "tabpanel"
, role: "tabpanel"
}
}
(Seq.toUnfoldable $ Seq.map (badge selectedNodeIds)
(Seq.toUnfoldable $ Seq.map (\node -> badge { maxSize, minSize, node, selectedNodeIds }) badges')
$ neighbourBadges graph selectedNodeIds'
)
]
]
...
@@ -284,12 +290,29 @@ updateTermButtonCpt = here.component "updateTermButton" cpt
...
@@ -284,12 +290,29 @@ updateTermButtonCpt = here.component "updateTermButton" cpt
T.write_ SigmaxT.emptyNodeIds selectedNodeIds
T.write_ SigmaxT.emptyNodeIds selectedNodeIds
type BadgeProps =
( maxSize :: Number
, minSize :: Number
, node :: Record SigmaxT.Node
, selectedNodeIds :: T.Box SigmaxT.NodeIds )
badge :: R2.Leaf BadgeProps
badge props = R.createElement badgeCpt props []
badgeCpt :: R.Component BadgeProps
badgeCpt = here.component "badge" cpt where
cpt { maxSize, minSize, node: { id, label, size }, selectedNodeIds } _ = do
let minFontSize = 1.0 -- "em"
let maxFontSize = 3.0 -- "em"
let sizeScaled = (size - minSize) / (maxSize - minSize) -- in [0; 1] range
let scale' = Math.log (sizeScaled + 1.0) / (Math.log 2.0) -- in [0; 1] range
let scale = minFontSize + scale' * (maxFontSize - minFontSize)
let style = {
fontSize: show scale <> "em"
}
badge :: T.Box SigmaxT.NodeIds -> Record SigmaxT.Node -> R.Element
pure $ RH.a { className: "badge badge-pill badge-light"
badge selectedNodeIds {id, label} =
RH.a { className: "badge badge-pill badge-light"
, on: { click: onClick }
, on: { click: onClick }
} [ RH.h6 {
} [ RH.text label ] ]
} [ RH.h6 { style
} [ RH.text label ] ]
where
where
onClick _ = do
onClick _ = do
T.write_ (Set.singleton id) selectedNodeIds
T.write_ (Set.singleton id) selectedNodeIds
...
...
src/Gargantext/Components/NgramsTable.purs
View file @
5356f9db
...
@@ -83,7 +83,7 @@ setTermListSetA ngramsTable ns new_list =
...
@@ -83,7 +83,7 @@ setTermListSetA ngramsTable ns new_list =
f n _unit = NgramsPatch { patch_list, patch_children: mempty }
f n _unit = NgramsPatch { patch_list, patch_children: mempty }
where
where
cur_list = ngramsTable ^? at n <<< _Just <<< _NgramsRepoElement <<< _list
cur_list = ngramsTable ^? at n <<< _Just <<< _NgramsRepoElement <<< _list
patch_list = maybe mempty (
\c -> replace c
new_list) cur_list
patch_list = maybe mempty (
replace
new_list) cur_list
toMap :: forall a. Set a -> Map a Unit
toMap :: forall a. Set a -> Map a Unit
toMap = unsafeCoerce
toMap = unsafeCoerce
-- TODO https://github.com/purescript/purescript-ordered-collections/pull/21
-- TODO https://github.com/purescript/purescript-ordered-collections/pull/21
...
@@ -213,7 +213,8 @@ tableContainerCpt { dispatch
...
@@ -213,7 +213,8 @@ tableContainerCpt { dispatch
, ngramsEdit
, ngramsEdit
}
}
, H.button { className: "btn btn-primary"
, H.button { className: "btn btn-primary"
, on: {click: (const $ dispatch AddTermChildren)}
, on: {click: (const $ do
dispatch AddTermChildren)}
} [H.text "Save"]
} [H.text "Save"]
, H.button { className: "btn btn-primary"
, H.button { className: "btn btn-primary"
, on: {click: (const $ dispatch $ SetParentResetChildren Nothing)}
, on: {click: (const $ dispatch $ SetParentResetChildren Nothing)}
...
@@ -314,8 +315,8 @@ loadedNgramsTableBodyCpt = here.component "loadedNgramsTableBody" cpt where
...
@@ -314,8 +315,8 @@ loadedNgramsTableBodyCpt = here.component "loadedNgramsTableBody" cpt where
path'@{ scoreType, termListFilter, termSizeFilter } <- T.useLive T.unequal path
path'@{ scoreType, termListFilter, termSizeFilter } <- T.useLive T.unequal path
params <- T.useFocused (_.params) (\a b -> b { params = a }) path
params <- T.useFocused (_.params) (\a b -> b { params = a }) path
params'@{ orderBy } <- T.useLive T.unequal params
params'@{ orderBy } <- T.useLive T.unequal params
searchQuery <- T.useFocused (_.searchQuery) (\a b -> b { searchQuery = a }) path
searchQuery
Focused
<- T.useFocused (_.searchQuery) (\a b -> b { searchQuery = a }) path
searchQuery
' <- T.useLive T.unequal searchQuery
searchQuery
<- T.useLive T.unequal searchQueryFocused
let ngramsTable = applyNgramsPatches state' initTable
let ngramsTable = applyNgramsPatches state' initTable
rowMap (Tuple ng nre) =
rowMap (Tuple ng nre) =
...
@@ -328,15 +329,18 @@ loadedNgramsTableBodyCpt = here.component "loadedNgramsTableBody" cpt where
...
@@ -328,15 +329,18 @@ loadedNgramsTableBodyCpt = here.component "loadedNgramsTableBody" cpt where
in
in
addOcc <$> rowsFilter (ngramsRepoElementToNgramsElement ng s nre)
addOcc <$> rowsFilter (ngramsRepoElementToNgramsElement ng s nre)
rows :: PreConversionRows
rows :: PreConversionRows
rows = ngramsTableOrderWith orderBy (
rows = ngramsTableOrderWith orderBy (Seq.mapMaybe rowMap nres)
Seq.mapMaybe rowMap $
nres = Map.toUnfoldable (ngramsTable ^. _NgramsTable <<< _ngrams_repo_elements)
Map.toUnfoldable (ngramsTable ^. _NgramsTable <<< _ngrams_repo_elements)
rootOfMatch (Tuple ng nre) =
)
if queryMatchesLabel searchQuery (ngramsTermText ng)
then Just (fromMaybe ng (nre ^. _NgramsRepoElement <<< _root))
else Nothing
rootsWithMatches = Set.fromFoldable (Seq.mapMaybe rootOfMatch nres)
rowsFilter :: NgramsElement -> Maybe NgramsElement
rowsFilter :: NgramsElement -> Maybe NgramsElement
rowsFilter ngramsElement =
rowsFilter ngramsElement =
if displayRow { ngramsElement
if displayRow { ngramsElement
, ngramsParentRoot
, ngramsParentRoot
,
searchQuery: searchQuery'
,
rootsWithMatches
, state: state'
, state: state'
, termListFilter
, termListFilter
, termSizeFilter } then
, termSizeFilter } then
...
@@ -471,23 +475,33 @@ mkDispatch { filteredRows
...
@@ -471,23 +475,33 @@ mkDispatch { filteredRows
s { ngramsSelection = Set.empty :: Set NgramsTerm }
s { ngramsSelection = Set.empty :: Set NgramsTerm }
else
else
s { ngramsSelection = selectNgramsOnFirstPage filteredRows }
s { ngramsSelection = selectNgramsOnFirstPage filteredRows }
performAction AddTermChildren =
performAction AddTermChildren =
do
case ngramsParent of
case ngramsParent of
Nothing ->
Nothing ->
-- impossible but harmless
-- impossible but harmless
pure unit
pure unit
Just parent -> do
Just parent -> do
here.log2 "[performAction] AddTermChildren, parent" parent
let pc = patchSetFromMap ngramsChildren
let pc = patchSetFromMap ngramsChildren
pe = NgramsPatch { patch_list: mempty, patch_children: pc }
pe = NgramsPatch { patch_list: mempty, patch_children: pc }
pt = singletonNgramsTablePatch parent pe
pt = singletonNgramsTablePatch parent pe
T.modify_ (setParentResetChildren Nothing) state
T.modify_ (setParentResetChildren Nothing) state
commitPatch pt state
here.log2 "[performAction] pt" pt
let ppt = case (A.head $ Set.toUnfoldable $ Map.keys ngramsChildren) of
Nothing -> mempty
Just h ->
let pp = NgramsPatch { patch_list: mempty
, patch_children: patchSetFromMap $ Map.mapMaybe (\v -> Just $ not v) ngramsChildren }
in
singletonNgramsTablePatch h pp
here.log2 "[performAction] pt with patchSetFromMap" $ pt <> ppt
commitPatch (pt <> ppt) state
performAction (CoreAction a) = coreDispatch path state a
performAction (CoreAction a) = coreDispatch path state a
displayRow :: { ngramsElement :: NgramsElement
displayRow :: { ngramsElement :: NgramsElement
, ngramsParentRoot :: Maybe NgramsTerm
, ngramsParentRoot :: Maybe NgramsTerm
,
searchQuery :: SearchQuery
,
rootsWithMatches :: Set NgramsTerm
, state :: State
, state :: State
, termListFilter :: Maybe TermList
, termListFilter :: Maybe TermList
, termSizeFilter :: Maybe TermSize } -> Boolean
, termSizeFilter :: Maybe TermSize } -> Boolean
...
@@ -496,14 +510,17 @@ displayRow { ngramsElement: NgramsElement {ngrams, root, list}
...
@@ -496,14 +510,17 @@ displayRow { ngramsElement: NgramsElement {ngrams, root, list}
, state: { ngramsChildren
, state: { ngramsChildren
, ngramsLocalPatch
, ngramsLocalPatch
, ngramsParent }
, ngramsParent }
,
searchQuery
,
rootsWithMatches
, termListFilter
, termListFilter
, termSizeFilter } =
, termSizeFilter } =
(
-- See these issues about the evolution of this filtering.
-- isNothing root
-- * https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/340
-- ^ Display only nodes without parents
-- * https://gitlab.iscpif.fr/gargantext/haskell-gargantext/issues/87
-- ^^ (?) allow child nodes to be searched (see #340)
isNothing root
maybe true (_ == list) termListFilter
-- ^ Display only nodes without parents.
&& Set.member ngrams rootsWithMatches
-- ^ and which matches the search query.
&& maybe true (_ == list) termListFilter
-- ^ and which matches the ListType filter.
-- ^ and which matches the ListType filter.
&& ngramsChildren ^. at ngrams /= Just true
&& ngramsChildren ^. at ngrams /= Just true
-- ^ and which are not scheduled to be added already
-- ^ and which are not scheduled to be added already
...
@@ -517,10 +534,6 @@ displayRow { ngramsElement: NgramsElement {ngrams, root, list}
...
@@ -517,10 +534,6 @@ displayRow { ngramsElement: NgramsElement {ngrams, root, list}
-- ^ unless they are scheduled to be removed.
-- ^ unless they are scheduled to be removed.
|| NTC.tablePatchHasNgrams ngramsLocalPatch ngrams
|| NTC.tablePatchHasNgrams ngramsLocalPatch ngrams
-- ^ unless they are being processed at the moment.
-- ^ unless they are being processed at the moment.
)
&& queryMatchesLabel searchQuery (ngramsTermText ngrams)
-- ^ and which matches the search query.
allNgramsSelectedOnFirstPage :: Set NgramsTerm -> PreConversionRows -> Boolean
allNgramsSelectedOnFirstPage :: Set NgramsTerm -> PreConversionRows -> Boolean
allNgramsSelectedOnFirstPage selected rows = selected == (selectNgramsOnFirstPage rows)
allNgramsSelectedOnFirstPage selected rows = selected == (selectNgramsOnFirstPage rows)
...
...
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