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
be376bfa
Commit
be376bfa
authored
Mar 28, 2022
by
Karen Konou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Folder View] Use GQL API
parent
0539153f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
19 deletions
+64
-19
FolderView.purs
src/Gargantext/Components/FolderView.purs
+20
-19
GraphQL.purs
src/Gargantext/Components/GraphQL.purs
+2
-0
Endpoints.purs
src/Gargantext/Components/GraphQL/Endpoints.purs
+7
-0
Tree.purs
src/Gargantext/Components/GraphQL/Tree.purs
+35
-0
No files found.
src/Gargantext/Components/FolderView.purs
View file @
be376bfa
...
...
@@ -21,15 +21,16 @@ import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..))
import Gargantext.Components.Forest.Tree.Node.Action.Update (updateRequest)
import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadArbitraryFile, uploadFile)
import Gargantext.Components.Forest.Tree.Node.Box (nodePopupView)
import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTree(..), fTreeID)
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types (SubTreeOut(..))
import Gargantext.Components.GraphQL.Endpoints (getTreeFirstLevel)
import Gargantext.Components.GraphQL.Tree (TreeFirstLevel, TreeNode)
import Gargantext.Config.REST (AffRESTError, logRESTError)
import Gargantext.Config.Utils (handleRESTError)
import Gargantext.Hooks.LinkHandler (Methods, useLinkHandler)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (Ordering, Unit, bind, compare, discard, pure, unit, void, ($), (<$>), (<>))
import Gargantext.Routes (AppRoute(Home),
SessionRoute(..),
nodeTypeAppRoute)
import Gargantext.Sessions (Session,
get,
sessionId)
import Gargantext.Routes (AppRoute(Home), nodeTypeAppRoute)
import Gargantext.Sessions (Session, sessionId)
import Gargantext.Types (NodeType(..))
import Gargantext.Types as GT
import Gargantext.Utils.Popover as Popover
...
...
@@ -76,7 +77,7 @@ folderViewCpt = here.component "folderViewCpt" cpt where
type FolderViewProps =
( backFolder :: Boolean
, boxes :: Boxes
, folders ::
FTree
, folders ::
TreeFirstLevel
, nodeId :: Int
, reload :: T.Box T2.Reload
, session :: Session
...
...
@@ -89,24 +90,24 @@ folderViewMainCpt :: R.Component FolderViewProps
folderViewMainCpt = here.component "folderViewMainCpt" cpt where
cpt { backFolder
, boxes
, folders:
NTree (LNode {parent_id: parentId, nodeType}) (folders)
, folders:
{parent: parentNode, root: {node_type: nodeType}, children}
, nodeId
, reload
, session
, setPopoverRef } _ = do
linkHandlers <- useLinkHandler
let foldersS = A.sortBy sortFolders
folders
let foldersS = A.sortBy sortFolders
children
let backHome = isBackHome nodeType
let parent = makeParentFolder linkHandlers parent
Id
session backFolder backHome
let children = makeFolderElements foldersS { boxes, nodeId, reload, session, setPopoverRef }
let parent = makeParentFolder linkHandlers parent
Node
session backFolder backHome
let children
El
= makeFolderElements foldersS { boxes, nodeId, reload, session, setPopoverRef }
pure $ H.div {className: "fv folders"} $ parent <> children
pure $ H.div {className: "fv folders"} $ parent <> children
El
makeFolderElements foldersS props = makeFolderElementsMap <$> foldersS where
makeFolderElementsMap ::
NTree L
Node -> R.Element
makeFolderElementsMap
(NTree (LNode node) _)
= folder { boxes: props.boxes
makeFolderElementsMap ::
Tree
Node -> R.Element
makeFolderElementsMap
node
= folder { boxes: props.boxes
, nodeId: node.id
, nodeType: node.node
T
ype
, nodeType: node.node
_t
ype
, parentId: props.nodeId
, reload: props.reload
, session: props.session
...
...
@@ -114,11 +115,11 @@ folderViewMainCpt = here.component "folderViewMainCpt" cpt where
, style: FolderChild
, text: node.name } []
makeParentFolder :: Record Methods -> Maybe
Int
-> Session -> Boolean -> Boolean -> Array R.Element
makeParentFolder _ (Just parent
Id
) session _ _ =
makeParentFolder :: Record Methods -> Maybe
TreeNode
-> Session -> Boolean -> Boolean -> Array R.Element
makeParentFolder _ (Just parent) session _ _ =
-- FIXME: The NodeType here should not be hardcoded to FolderPrivate but we currently can't get the actual NodeType
-- without performing another API call. Also parentId is never being returned by this API even when it clearly exists
[ folderSimple {style: FolderUp, text: "..", nodeId: parent
I
d, nodeType: GT.FolderPrivate, session: session} [] ]
[ folderSimple {style: FolderUp, text: "..", nodeId: parent
.i
d, nodeType: GT.FolderPrivate, session: session} [] ]
makeParentFolder linkHandlers Nothing _ _ true = [ H.button {className: "btn btn-primary", on: { click: \_ -> linkHandlers.goToRoute Home}} [ H.i { className: "fa fa-folder-open" } []
, H.br {}
, H.text ".."] ]
...
...
@@ -128,8 +129,8 @@ folderViewMainCpt = here.component "folderViewMainCpt" cpt where
makeParentFolder _ Nothing _ _ _ = []
sortFolders ::
FTree -> FTre
e -> Ordering
sortFolders a b = compare
(fTreeID a) (fTreeID b)
sortFolders ::
TreeNode-> TreeNod
e -> Ordering
sortFolders a b = compare
a.id b.id
isBackHome :: GT.NodeType -> Boolean
isBackHome GT.FolderPrivate = true
...
...
@@ -261,8 +262,8 @@ type LoadProps =
reload :: T2.Reload
)
loadFolders :: Record LoadProps -> AffRESTError
FTree
loadFolders {nodeId, session} = get
session $ TreeFirstLevel (Just nodeId) ""
loadFolders :: Record LoadProps -> AffRESTError
TreeFirstLevel
loadFolders {nodeId, session} = get
TreeFirstLevel session nodeId
type PerformActionProps =
( boxes :: Boxes
...
...
src/Gargantext/Components/GraphQL.purs
View file @
be376bfa
...
...
@@ -11,6 +11,7 @@ import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Foreign (unsafeToForeign, ForeignError)
import Gargantext.Components.GraphQL.Node (Node)
import Gargantext.Components.GraphQL.Tree (TreeFirstLevel)
import Gargantext.Components.GraphQL.User (User, UserInfo, UserInfoM)
import Gargantext.Ends (Backend(..))
import Gargantext.Sessions (Session(..))
...
...
@@ -70,6 +71,7 @@ type Schema
= { node_parent :: { node_id :: Int, parent_type :: String } ==> Array Node -- TODO: parent_type :: NodeType
, user_infos :: { user_id :: Int } ==> Array UserInfo
, users :: { user_id :: Int } ==> Array User
, tree :: { root_id :: Int } ==> TreeFirstLevel
}
type Mutation
...
...
src/Gargantext/Components/GraphQL/Endpoints.purs
View file @
be376bfa
...
...
@@ -2,6 +2,7 @@ module Gargantext.Components.GraphQL.Endpoints where
import Gargantext.Components.GraphQL.Node
import Gargantext.Components.GraphQL.User
import Gargantext.Components.GraphQL.Tree
import Gargantext.Prelude
import Data.Array as A
...
...
@@ -41,3 +42,9 @@ getUserInfo session id = do
-- NOTE Contact is at G.C.N.A.U.C.Types
Just ui -> Right ui
getTreeFirstLevel :: Session -> Int -> AffRESTError TreeFirstLevel
getTreeFirstLevel session id = do
{ tree } <- queryGql session "get tree first level" $ treeFirstLevelQuery `withVars` { id }
liftEffect $ here.log2 "[getTreeFirstLevel] tree first level" tree
pure $ Right tree -- TODO: error handling
src/Gargantext/Components/GraphQL/Tree.purs
0 → 100644
View file @
be376bfa
module Gargantext.Components.GraphQL.Tree where
import Gargantext.Prelude
import Data.Maybe (Maybe)
import Gargantext.Types (NodeType)
import GraphQL.Client.Args ((=>>))
import GraphQL.Client.Variable (Var(..))
type TreeNode =
{ name :: String
, id :: Int
, node_type :: NodeType
}
type TreeFirstLevel =
{ root :: TreeNode
, children :: Array TreeNode
, parent :: Maybe TreeNode
}
treeFirstLevelQuery = { tree: { root_id: Var :: _ "id" Int} =>>
{ root: { name: unit
, node_type: unit
, id: unit
}
, children: { name: unit
, node_type: unit
, id: unit
}
, parent: { name: unit
, node_type: unit
, id: unit
}
}
}
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