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
9b63f39a
Commit
9b63f39a
authored
Jun 22, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-refact' into dev
parents
8c872d4b
badd1fa8
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
221 additions
and
33 deletions
+221
-33
Tree.purs
src/Gargantext/Components/Forest/Tree.purs
+11
-3
Action.purs
src/Gargantext/Components/Forest/Tree/Node/Action.purs
+0
-2
Box.purs
src/Gargantext/Components/Forest/Tree/Node/Box.purs
+11
-7
Settings.purs
src/Gargantext/Components/Forest/Tree/Node/Settings.purs
+81
-20
SubTree.purs
...Gargantext/Components/Forest/Tree/Node/Tools/SubTree.purs
+113
-0
Graph.purs
src/Gargantext/Components/Graph.purs
+2
-1
SlideButton.purs
src/Gargantext/Components/GraphExplorer/SlideButton.purs
+2
-0
Sigma.js
src/Gargantext/Hooks/Sigmax/Sigma.js
+1
-0
No files found.
src/Gargantext/Components/Forest/Tree.purs
View file @
9b63f39a
...
...
@@ -2,7 +2,7 @@ module Gargantext.Components.Forest.Tree where
import DOM.Simple.Console (log, log2)
import Data.Array as A
import Data.Maybe (Maybe)
import Data.Maybe (Maybe
(..)
)
import Data.Set as Set
import Data.Tuple (Tuple(..), fst, snd)
import Data.Tuple.Nested ((/\))
...
...
@@ -12,7 +12,6 @@ import Gargantext.AsyncTasks as GAT
import Gargantext.Components.Forest.Tree.Node (nodeMainSpan)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Gargantext.Components.Forest.Tree.Node.Action.Add (AddNodeValue(..), addNode)
import Gargantext.Components.Forest.Tree.Node.Action.CopyFrom (getNodeTree)
import Gargantext.Components.Forest.Tree.Node.Action.Delete (deleteNode)
import Gargantext.Components.Forest.Tree.Node.Action.Rename (RenameValue(..), rename)
import Gargantext.Components.Forest.Tree.Node.Action.Share (ShareValue(..), share)
...
...
@@ -24,8 +23,10 @@ import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (Unit, bind, discard, map, pure, void, ($), (+), (<>))
import Gargantext.Routes (AppRoute)
import Gargantext.Sessions (OpenNodes, Session, mkNodeId)
import Gargantext.Sessions (OpenNodes, Session, mkNodeId
, get
)
import Gargantext.Types (ID, Reload)
import Gargantext.Types as GT
import Gargantext.Routes as GR
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
...
...
@@ -95,6 +96,13 @@ treeLoadView p = R.createElement treeLoadViewCpt p []
}
useLoader { root, counter: fst reload } fetch paint
--------------
getNodeTree :: Session -> GT.ID -> Aff FTree
getNodeTree session nodeId = get session $ GR.NodeAPI GT.Tree (Just nodeId) ""
--------------
type TreeViewProps = ( asyncTasks :: R.State GAT.Storage
, tree :: FTree
, tasks :: Record Tasks
...
...
src/Gargantext/Components/Forest/Tree/Node/Action.purs
View file @
9b63f39a
...
...
@@ -19,7 +19,6 @@ type UpdateNodeProps =
)
-}
data Action = AddNode String GT.NodeType
| DeleteNode
| RenameNode String
...
...
@@ -30,7 +29,6 @@ data Action = AddNode String GT.NodeType
| DownloadNode
| RefreshTree
instance showShow :: Show Action where
show (AddNode _ _ )= "AddNode"
show DeleteNode = "DeleteNode"
...
...
src/Gargantext/Components/Forest/Tree/Node/Box.purs
View file @
9b63f39a
...
...
@@ -8,7 +8,6 @@ import Effect.Aff (Aff)
import Effect.Uncurried (mkEffectFn1)
import Gargantext.Components.Forest.Tree.Node.Action (Action)
import Gargantext.Components.Forest.Tree.Node.Action.Add (NodePopup(..), addNodeView)
import Gargantext.Components.Forest.Tree.Node.Action.CopyFrom (copyFromCorpusView)
import Gargantext.Components.Forest.Tree.Node.Action.Delete (actionDelete)
import Gargantext.Components.Forest.Tree.Node.Action.Documentation (actionDoc)
import Gargantext.Components.Forest.Tree.Node.Action.Download (actionDownload)
...
...
@@ -19,8 +18,9 @@ import Gargantext.Components.Forest.Tree.Node.Action.Share as Share
import Gargantext.Components.Forest.Tree.Node.Action.Update (update)
import Gargantext.Components.Forest.Tree.Node.Action.Upload (actionUpload)
import Gargantext.Components.Forest.Tree.Node.Box.Types (NodePopupProps, NodePopupS)
import Gargantext.Components.Forest.Tree.Node.Settings (NodeAction(..), SettingsBox(..), glyphiconNodeAction, settingsBox)
import Gargantext.Components.Forest.Tree.Node.Settings (NodeAction(..), SettingsBox(..), glyphiconNodeAction, settingsBox
, SubTreeParams(..)
)
import Gargantext.Components.Forest.Tree.Node.Tools (textInputBox, fragmentPT)
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree (subTreeView)
import Gargantext.Prelude (Unit, bind, const, map, pure, show, ($), (<>), (==), (<))
import Gargantext.Sessions (Session)
import Gargantext.Types (Name, ID)
...
...
@@ -238,12 +238,16 @@ panelActionCpt = R.hooksComponent "G.C.F.T.N.B.panelAction" cpt
cpt {action: Config , dispatch, id, nodeType, session} _ = do
pure $ fragmentPT $ "Config " <> show nodeType
cpt {action: CopyFromCorpus, dispatch, id, nodeType, session} _ = do
pure $ copyFromCorpusView {dispatch, id, nodeType, session}
-----------
cpt {action: Merge {subTreeParams}, dispatch, id, nodeType, session} _ = do
pure $ subTreeView {dispatch, id, nodeType, session, subTreeParams}
cpt {action: Link _} _ = pure $ fragmentPT $ "Soon, you will be able "
<> "to link the corpus with your Annuaire"
<> " (and reciprocally)."
cpt {action: Move {subTreeParams}, dispatch, id, nodeType, session} _ = do
pure $ subTreeView {dispatch, id, nodeType, session, subTreeParams}
cpt {action: Link {subTreeParams}, dispatch, id, nodeType, session} _ = do
pure $ subTreeView {dispatch, id, nodeType, session, subTreeParams}
-----------
cpt {action : Share, dispatch, id, name } _ = do
isOpen <- R.useState' true
...
...
src/Gargantext/Components/Forest/Tree/Node/Settings.purs
View file @
9b63f39a
module Gargantext.Components.Forest.Tree.Node.Settings where
import Prelude (class Eq, class Show, show, (&&), (<>), (==))
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Generic.Rep.Eq (genericEq)
import Gargantext.Prelude (class Eq, class Show, show, (&&), (<>), (==))
import Data.Array (foldl)
import Gargantext.Types
...
...
@@ -12,16 +15,32 @@ if user has access to node then he can do all his related actions
-}
------------------------------------------------------------------------
------------------------------------------------------------------------
data Status a = IsBeta a | IsProd a
-- Beta Status
data Status a = TODO a | WIP a | OnTest a | Beta a
data NodeAction = Documentation NodeType
| SearchBox
| Download | Upload | Refresh | Config
| Move | Clone | Delete
| Share | Link NodeType
| Add (Array NodeType)
| CopyFromCorpus
| Delete
| Share
| Add (Array NodeType)
| Merge { subTreeParams :: SubTreeParams }
| Move { subTreeParams :: SubTreeParams }
| Link { subTreeParams :: SubTreeParams }
| Clone
------------------------------------------------------------------------
-- TODO move elsewhere
data SubTreeParams = SubTreeParams { showtypes :: Array NodeType
, valitypes :: Array NodeType
}
derive instance eqSubTreeParams :: Eq SubTreeParams
derive instance genericSubTreeParams :: Generic SubTreeParams _
instance showSubTreeParams :: Show SubTreeParams where
show = genericShow
------------------------------------------------------------------------
instance eqNodeAction :: Eq NodeAction where
eq (Documentation x) (Documentation y) = true && (x == y)
...
...
@@ -29,13 +48,13 @@ instance eqNodeAction :: Eq NodeAction where
eq Download Download = true
eq Upload Upload = true
eq Refresh Refresh = true
eq
Move Move = true
eq
(Move x) (Move y) = x == y
eq Clone Clone = true
eq Delete Delete = true
eq Share Share = true
eq (Link x) (Link y)
= (x == y)
eq (Add x) (Add y)
= (x == y)
eq
CopyFromCorpus CopyFromCorpus = true
eq (Link x) (Link y)
= x == y
eq (Add x) (Add y)
= x == y
eq
(Merge x) (Merge y) = x == y
eq Config Config = true
eq _ _ = false
...
...
@@ -45,14 +64,14 @@ instance showNodeAction :: Show NodeAction where
show Download = "Download"
show Upload = "Upload"
show Refresh = "Refresh"
show
Move = "Move"
show
(Move t) = "Move with subtree params" <> show t
show Clone = "Clone"
show Delete = "Delete"
show Share = "Share"
show Config = "Config"
show (Link x) = "Link to " <> show x
show (Add xs) = foldl (\a b -> a <> show b) "Add " xs
show
CopyFromCorpus = "Copy from corpus"
show
(Merge t) = "Merge with subtree" <> show t
glyphiconNodeAction :: NodeAction -> String
...
...
@@ -63,11 +82,11 @@ glyphiconNodeAction SearchBox = "search"
glyphiconNodeAction Upload = "upload"
glyphiconNodeAction (Link _) = "arrows-h"
glyphiconNodeAction Download = "download"
glyphiconNodeAction
CopyFromCorpus
= "random"
glyphiconNodeAction
(Merge _)
= "random"
glyphiconNodeAction Refresh = "refresh"
glyphiconNodeAction Config = "wrench"
glyphiconNodeAction Share = "user-plus"
glyphiconNodeAction
Move
= "share-square-o"
glyphiconNodeAction
(Move _)
= "share-square-o"
glyphiconNodeAction _ = ""
...
...
@@ -138,7 +157,7 @@ settingsBox Folder =
, Folder
, Annuaire
]
, Move
, Move
moveParameters
, Delete
]
}
...
...
@@ -154,9 +173,9 @@ settingsBox Corpus =
, SearchBox
, Upload
, Download
, Move
, Move
moveParameters
--, Clone
, Link
Annuaire
, Link
linkParams
, Delete
]
}
...
...
@@ -191,7 +210,17 @@ settingsBox NodeList =
, Config
, Download
, Upload
, CopyFromCorpus
, Merge {subTreeParams : SubTreeParams { showtypes: [ FolderPrivate
, FolderShared
, Team
, FolderPublic
, Folder
, Corpus
, NodeList
]
, valitypes: [ NodeList ]
}
}
, Delete
]
}
...
...
@@ -207,10 +236,10 @@ settingsBox Dashboard =
settingsBox Annuaire =
SettingsBox { show : true
, edit :
fals
e
, edit :
tru
e
, doc : Documentation Annuaire
, buttons : [ Upload
, Move
, Move
moveParameters
, Delete
]
}
...
...
@@ -221,3 +250,35 @@ settingsBox _ =
, doc : Documentation NodeUser
, buttons : []
}
-- | SubTree Parameters
moveParameters = { subTreeParams : SubTreeParams
{ showtypes: [ FolderPrivate
, FolderShared
, Team
, FolderPublic
, Folder
]
, valitypes: [ FolderPrivate
, FolderShared
, Team
, FolderPublic
, Folder
]
}
}
linkParams = { subTreeParams : SubTreeParams
{ showtypes: [ FolderPrivate
, FolderShared
, Team
, FolderPublic
, Folder
, Annuaire
]
, valitypes: [ Annuaire
]
}
}
src/Gargantext/Components/Forest/Tree/Node/
Action/CopyFrom
.purs
→
src/Gargantext/Components/Forest/Tree/Node/
Tools/SubTree
.purs
View file @
9b63f39a
module Gargantext.Components.Forest.Tree.Node.
Action.CopyFrom
where
module Gargantext.Components.Forest.Tree.Node.
Tools.SubTree
where
import DOM.Simple.Console (log2)
import Data.Array as A
import Data.Maybe (Maybe(..))
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Eq (genericEq)
import Effect.Aff (Aff)
import Gargantext.Components.Forest.Tree.Node.Action (Props)
import Gargantext.Components.Forest.Tree.Node.Settings (SubTreeParams(..))
import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTree(..))
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (discard, map, pure, show, unit, ($), (&&), (/=), (<>))
import Gargantext.Prelude (discard, map, pure, show, unit, ($), (&&), (/=), (<>)
, class Eq
)
import Gargantext.Routes as GR
import Gargantext.Sessions (Session(..), get)
import Gargantext.Types as GT
...
...
@@ -16,56 +19,71 @@ import Reactix.DOM.HTML as H
------------------------------------------------------------------------
getNodeTree :: Session -> GT.ID -> Aff FTree
getNodeTree session nodeId = get session $ GR.NodeAPI GT.Tree (Just nodeId) ""
type SubTreeParamsProps =
( subTreeParams :: SubTreeParams
| Props
)
copyFromCorpusView :: Record
Props -> R.Element
copyFromCorpusView props = R.createElement copyFromCorpus
ViewCpt props []
subTreeView :: Record SubTreeParams
Props -> R.Element
subTreeView props = R.createElement subTree
ViewCpt props []
copyFromCorpusViewCpt :: R.Component
Props
copyFromCorpusViewCpt = R.hooksComponent "G.C.F.T.N.A.U.copyFromCorpus
View" cpt
subTreeViewCpt :: R.Component SubTreeParams
Props
subTreeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.subTree
View" cpt
where
cpt { dispatch
cpt
params@
{ dispatch
, id
, nodeType
, session
, subTreeParams
} _ =
do
useLoader session loadCorporaTree $
let SubTreeParams {showtypes} = subTreeParams
useLoader session (loadSubTree showtypes) $
\tree ->
copyFromCorpus
ViewLoaded { dispatch
subTree
ViewLoaded { dispatch
, id
, nodeType
, session
, tree
, subTreeParams
}
------------------------------------------------------------------------
loadSubTree :: Array GT.NodeType -> Session -> Aff FTree
loadSubTree nodetypes session = getSubTree session treeId nodetypes
where
Session { treeId } = session
getSubTree :: Session -> Int -> Array GT.NodeType -> Aff FTree
getSubTree session treeId showtypes = get session $ GR.NodeAPI GT.Tree (Just treeId) nodeTypes
where
nodeTypes = A.foldl (\a b -> a <> "type=" <> show b <> "&") "?" showtypes
------------------------------------------------------------------------
type CorpusTreeProps =
( tree :: FTree
| Props
|
SubTreeParams
Props
)
copyFromCorpus
ViewLoaded :: Record CorpusTreeProps -> R.Element
copyFromCorpusViewLoaded props = R.createElement copyFromCorpus
ViewLoadedCpt props []
subTree
ViewLoaded :: Record CorpusTreeProps -> R.Element
subTreeViewLoaded props = R.createElement subTree
ViewLoadedCpt props []
copyFromCorpus
ViewLoadedCpt :: R.Component CorpusTreeProps
copyFromCorpusViewLoadedCpt = R.hooksComponent "G.C.F.T.N.A.U.copyFromCorpus
ViewLoadedCpt" cpt
subTree
ViewLoadedCpt :: R.Component CorpusTreeProps
subTreeViewLoadedCpt = R.hooksComponent "G.C.F.T.N.A.U.subTree
ViewLoadedCpt" cpt
where
cpt p@{dispatch, id, nodeType, session, tree} _ = do
pure $ H.div { className: "copy-from-corpus" }
[ H.div { className: "tree" }
[
copyFromCorpus
TreeView p]
[
subTree
TreeView p]
]
copyFromCorpus
TreeView :: Record CorpusTreeProps -> R.Element
copyFromCorpusTreeView props = R.createElement copyFromCorpus
TreeViewCpt props []
subTree
TreeView :: Record CorpusTreeProps -> R.Element
subTreeTreeView props = R.createElement subTree
TreeViewCpt props []
copyFromCorpus
TreeViewCpt :: R.Component CorpusTreeProps
copyFromCorpusTreeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.copyFromCorpus
TreeViewCpt" cpt
subTree
TreeViewCpt :: R.Component CorpusTreeProps
subTreeTreeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.subTree
TreeViewCpt" cpt
where
cpt p@{id, tree: NTree (LNode { id: sourceId, name, nodeType }) ary} _ = do
cpt p@{id, tree: NTree (LNode { id: sourceId, name, nodeType }) ary
, subTreeParams
} _ = do
pure $ {- H.div {} [ H.h5 { className: GT.fldr nodeType true} []
, -} H.div { className: "node" }
( [ H.span { className: "name " <> clickable
...
...
@@ -76,29 +94,20 @@ copyFromCorpusTreeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.copyFromCorpusTreeVi
)
-- ]
where
children = map (\c -> copyFromCorpusTreeView (p { tree = c })) ary
validNodeType = (A.elem nodeType [GT.NodeList]) && (id /= sourceId)
SubTreeParams { valitypes } = subTreeParams
children = map (\c -> subTreeTreeView (p { tree = c })) ary
validNodeType = (A.elem nodeType valitypes) && (id /= sourceId)
clickable = if validNodeType then "clickable" else ""
onClick _ = case validNodeType of
false -> pure unit
true -> do
log2 "[
copyFromCorpus
TreeViewCpt] issue copy into" id
log2 "[
copyFromCorpus
TreeViewCpt] issue copy from" sourceId
log2 "[
subTree
TreeViewCpt] issue copy into" id
log2 "[
subTree
TreeViewCpt] issue copy from" sourceId
loadCorporaTree :: Session -> Aff FTree
loadCorporaTree session = getCorporaTree session treeId
where
Session { treeId } = session
--------------------------------------------------------------------------------------------
getCorporaTree :: Session -> Int -> Aff FTree
getCorporaTree session treeId = get session $ GR.NodeAPI GT.Tree (Just treeId) nodeTypes
where
nodeTypes = A.foldl (\a b -> a <> "type=" <> show b <> "&") "?" typesList
typesList = [ GT.FolderPrivate
, GT.FolderShared
, GT.Team
, GT.FolderPublic
, GT.Folder
, GT.Corpus
, GT.NodeList
]
src/Gargantext/Components/Graph.purs
View file @
9b63f39a
...
...
@@ -231,7 +231,8 @@ sigmaSettings =
, font: "arial" -- font params
, fontStyle: "bold"
, hideEdgesOnMove: true
, labelSize : "proportional" -- alt : proportional
--, labelSize : "proportional" -- alt : proportional, fixed
, labelSize: "fixed"
, labelSizeRatio: 2.0 -- label size in ratio of node size
, labelThreshold: 7.0 -- min node cam size to start showing label
, maxEdgeSize: 1.0
...
...
src/Gargantext/Components/GraphExplorer/SlideButton.purs
View file @
9b63f39a
...
...
@@ -58,6 +58,8 @@ labelSizeButton sigmaRef state =
Sigmax.dependOnSigma sigma "[labelSizeButton] sigma: Nothing" $ \s -> do
Sigma.setSettings s {
defaultLabelSize: newValue
, drawLabels: true
, labelSizeRatio: newValue / 2.5
}
setValue $ const newValue
}
...
...
src/Gargantext/Hooks/Sigmax/Sigma.js
View file @
9b63f39a
...
...
@@ -42,6 +42,7 @@ sigma.canvas.nodes.selected = (node, context, settings) => {
node
.
type
=
'def'
;
sigma
.
canvas
.
hovers
.
def
(
node
,
context
,
settings
);
node
.
type
=
'selected'
;
console
.
log
(
'hovers, settings:'
,
settings
);
};
CustomShapes
.
init
();
...
...
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