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
caaa9eab
Verified
Commit
caaa9eab
authored
Apr 11, 2024
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[breadcrumb] approute logic moved to frontend
parent
163a9238
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
47 deletions
+74
-47
Breadcrumb.purs
src/Gargantext/Components/Forest/Breadcrumb.purs
+69
-11
GraphQL.purs
src/Gargantext/Components/GraphQL.purs
+1
-1
Endpoints.purs
src/Gargantext/Components/GraphQL/Endpoints.purs
+3
-3
Tree.purs
src/Gargantext/Components/GraphQL/Tree.purs
+1
-1
Routes.purs
src/Gargantext/Routes.purs
+0
-31
No files found.
src/Gargantext/Components/Forest/Breadcrumb.purs
View file @
caaa9eab
...
@@ -5,12 +5,13 @@ module Gargantext.Components.Forest.Breadcrumb
...
@@ -5,12 +5,13 @@ module Gargantext.Components.Forest.Breadcrumb
where
where
import Data.Array as A
import Data.Array as A
import Data.Either (Either(..), either)
import Data.Int (fromString)
import Data.Int (fromString)
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Maybe (Maybe(..), fromMaybe
, maybe
)
import Data.String (Pattern(..), split)
import Data.String (Pattern(..), split)
import Gargantext.Components.App.Store as Store
import Gargantext.Components.App.Store as Store
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.GraphQL.Endpoints (getBreadcrumb)
import Gargantext.Components.GraphQL.Endpoints (getBreadcrumb
, getNodeChildren, getNodeParent
)
import Gargantext.Components.GraphQL.Tree (BreadcrumbInfo, TreeNode)
import Gargantext.Components.GraphQL.Tree (BreadcrumbInfo, TreeNode)
import Gargantext.Config.REST (AffRESTError)
import Gargantext.Config.REST (AffRESTError)
import Gargantext.Ends (Backend(..))
import Gargantext.Ends (Backend(..))
...
@@ -312,12 +313,6 @@ breadcrumbItemCpt = here.component "breadcrumbItemCpt" cpt where
...
@@ -312,12 +313,6 @@ breadcrumbItemCpt = here.component "breadcrumbItemCpt" cpt where
treeId :: Session -> Int
treeId :: Session -> Int
treeId (Session {treeId: tId}) = tId
treeId (Session {treeId: tId}) = tId
getLastUrlElement :: String -> String
getLastUrlElement str = fromMaybe "" $ A.last $ split (Pattern "/") str
getFirstUrlElement :: String -> String
getFirstUrlElement str = fromMaybe "" $ A.head $ split (Pattern "/") str
getInstanceText :: Session -> String
getInstanceText :: Session -> String
getInstanceText (Session { backend }) = cleanBackendUrl backend
getInstanceText (Session { backend }) = cleanBackendUrl backend
...
@@ -327,12 +322,75 @@ getUserText (Session { username }) = username
...
@@ -327,12 +322,75 @@ getUserText (Session { username }) = username
type LoadProps =
type Load
Raw
Props =
(
(
route :: AppRoute
nodeId :: Int
, session :: Session
, session :: Session
-- , reload :: T.Box T2.Reload
-- , reload :: T.Box T2.Reload
)
)
loadBreadcrumbDataRaw :: Record LoadRawProps -> AffRESTError BreadcrumbInfo
loadBreadcrumbDataRaw { nodeId, session } = getBreadcrumb session nodeId
type LoadProps =
( route :: AppRoute
, session :: Session )
loadBreadcrumbData :: Record LoadProps -> AffRESTError BreadcrumbInfo
loadBreadcrumbData :: Record LoadProps -> AffRESTError BreadcrumbInfo
loadBreadcrumbData { route, session } = getBreadcrumb session route
loadBreadcrumbData { route: Annuaire _s nodeId, session } = do
loadBreadcrumbDataRaw { nodeId, session }
loadBreadcrumbData { route: ContactPage _s nodeId annuaireId, session } = do
loadBreadcrumbDataRaw { nodeId: annuaireId, session }
loadBreadcrumbData { route: Corpus _s nodeId, session } = do
loadBreadcrumbDataRaw { nodeId, session }
loadBreadcrumbData { route: CorpusCode _s nodeId, session } = do
loadBreadcrumbDataRaw { nodeId, session }
loadBreadcrumbData { route: CorpusDocument _s corpusId listId documentId, session } = do
texts <- getNodeChildren session corpusId GT.NodeTexts
let docId = maybe corpusId _.id $ either (const Nothing) A.head texts
loadBreadcrumbDataRaw { nodeId: docId, session }
loadBreadcrumbData { route: Dashboard _s nodeId, session } = do
loadBreadcrumbDataRaw { nodeId, session }
loadBreadcrumbData { route: Document _s listId documentId, session } = do
corpora <- getNodeParent session listId GT.Corpus
let nodeId = maybe listId _.id $ either (const Nothing) A.head corpora
loadBreadcrumbDataRaw { nodeId, session }
loadBreadcrumbData { route: Folder _s nodeId, session } = do
loadBreadcrumbDataRaw { nodeId, session }
loadBreadcrumbData { route: FolderPrivate _s nodeId, session } = do
loadBreadcrumbDataRaw { nodeId, session }
loadBreadcrumbData { route: FolderPublic _s nodeId, session } = do
loadBreadcrumbDataRaw { nodeId, session }
loadBreadcrumbData { route: FolderShared _s nodeId, session } = do
loadBreadcrumbDataRaw { nodeId, session }
loadBreadcrumbData { route: Lists _s nodeId, session } = do
loadBreadcrumbDataRaw { nodeId, session }
loadBreadcrumbData { route: NodeTexts _s nodeId, session } = do
loadBreadcrumbDataRaw { nodeId, session }
loadBreadcrumbData { route: PGraphExplorer _s nodeId, session } = do
loadBreadcrumbDataRaw { nodeId, session }
loadBreadcrumbData { route: PhyloExplorer _s nodeId, session } = do
loadBreadcrumbDataRaw { nodeId, session }
loadBreadcrumbData { route: RouteFile _s nodeId, session } = do
loadBreadcrumbDataRaw { nodeId, session }
loadBreadcrumbData { route: RouteFrameCalc _s nodeId, session } = do
loadBreadcrumbDataRaw { nodeId, session }
loadBreadcrumbData { route: RouteFrameCode _s nodeId, session } = do
loadBreadcrumbDataRaw { nodeId, session }
loadBreadcrumbData { route: RouteFrameVisio _s nodeId, session } = do
loadBreadcrumbDataRaw { nodeId, session }
loadBreadcrumbData { route: RouteFrameWrite _s nodeId, session } = do
loadBreadcrumbDataRaw { nodeId, session }
loadBreadcrumbData { route: Team _s nodeId, session } = do
loadBreadcrumbDataRaw { nodeId, session }
loadBreadcrumbData { route: TreeFlat _s nodeId _q, session } = do
loadBreadcrumbDataRaw { nodeId, session }
loadBreadcrumbData { route: UserPage _s nodeId, session } = do
loadBreadcrumbDataRaw { nodeId, session }
loadBreadcrumbData { route: ForgotPassword _s } = do
pure $ Right { parents: [] }
loadBreadcrumbData { route: Home } = do
pure $ Right { parents: [] }
loadBreadcrumbData { route: Login } = do
pure $ Right { parents: [] }
src/Gargantext/Components/GraphQL.purs
View file @
caaa9eab
...
@@ -160,7 +160,7 @@ type Schema
...
@@ -160,7 +160,7 @@ type Schema
, users :: { user_id :: Int } ==> Array User
, users :: { user_id :: Int } ==> Array User
, team :: { team_node_id :: Int } ==> Team
, team :: { team_node_id :: Int } ==> Team
, tree :: { root_id :: Int } ==> TreeFirstLevel
, tree :: { root_id :: Int } ==> TreeFirstLevel
, tree_branch :: {
route :: AppRoute
} ==> BreadcrumbInfo
, tree_branch :: {
nodeId :: Int
} ==> BreadcrumbInfo
}
}
type Mutation
type Mutation
...
...
src/Gargantext/Components/GraphQL/Endpoints.purs
View file @
caaa9eab
...
@@ -227,8 +227,8 @@ getContextNgrams session context_id list_id = do
...
@@ -227,8 +227,8 @@ getContextNgrams session context_id list_id = do
eRes <- queryGql session "get context ngrams" query
eRes <- queryGql session "get context ngrams" query
pure $ rmap (\{ context_ngrams } -> NormNgramsTerm <$> context_ngrams) eRes
pure $ rmap (\{ context_ngrams } -> NormNgramsTerm <$> context_ngrams) eRes
getBreadcrumb :: Session ->
AppRoute
-> AffRESTError BreadcrumbInfo
getBreadcrumb :: Session ->
Int
-> AffRESTError BreadcrumbInfo
getBreadcrumb session
route
= do
getBreadcrumb session
nodeId
= do
eRes <- queryGql session "get breadcrumb branch" $ breadcrumbQuery `withVars` {
route
}
eRes <- queryGql session "get breadcrumb branch" $ breadcrumbQuery `withVars` {
nodeId
}
-- liftEffect $ here.log2 "[getBreadcrumb] breadcrumb" tree_branch
-- liftEffect $ here.log2 "[getBreadcrumb] breadcrumb" tree_branch
pure $ rmap _.tree_branch eRes
pure $ rmap _.tree_branch eRes
src/Gargantext/Components/GraphQL/Tree.purs
View file @
caaa9eab
...
@@ -43,7 +43,7 @@ treeFirstLevelQuery = { tree: { root_id: Var :: _ "id" Int} =>>
...
@@ -43,7 +43,7 @@ treeFirstLevelQuery = { tree: { root_id: Var :: _ "id" Int} =>>
}
}
}
}
breadcrumbQuery = { tree_branch: {
route: Var :: _ "route" AppRoute
} =>>
breadcrumbQuery = { tree_branch: {
nodeId: Var :: _ "nodeId" Int
} =>>
{ parents:
{ parents:
{ name: unit
{ name: unit
, node_type: unit
, node_type: unit
...
...
src/Gargantext/Routes.purs
View file @
caaa9eab
...
@@ -42,37 +42,6 @@ data AppRoute
...
@@ -42,37 +42,6 @@ data AppRoute
| UserPage SessionId Int
| UserPage SessionId Int
derive instance Eq AppRoute
derive instance Eq AppRoute
instance ArgGql AppRoute AppRoute
instance VarTypeName AppRoute where varTypeName _ = "AppRoute!"
instance JSON.WriteForeign AppRoute
where
writeImpl (Annuaire _s n) = JSON.writeImpl { "AnnuaireRoute": { nodeId: n } }
writeImpl (ContactPage _s n a) = JSON.writeImpl { "ContactPageRoute": { nodeId: n, annuaireId: a } }
writeImpl (Corpus _s n) = JSON.writeImpl { "CorpusRoute": { nodeId: n } }
writeImpl (CorpusCode _s n) = JSON.writeImpl { "CorpusCodeRoute": { nodeId: n } }
writeImpl (CorpusDocument _s c l d) = JSON.writeImpl { "CorpusDocumentRoute": { corpusId: c, listId: l, documentId: d } }
writeImpl (Dashboard _s n) = JSON.writeImpl { "DashboardRoute": { nodeId: n } }
writeImpl (Document _s l d) = JSON.writeImpl { "DocumentRoute": { listId: l, documentId: d } }
writeImpl (Folder _s n) = JSON.writeImpl { "FolderRoute": { nodeId: n } }
writeImpl (FolderPrivate _s n) = JSON.writeImpl { "FolderPrivateRoute": { nodeId: n } }
writeImpl (FolderPublic _s n) = JSON.writeImpl { "FolderPublicRoute": { nodeId: n } }
writeImpl (FolderShared _s n) = JSON.writeImpl { "FolderSharedRoute": { nodeId: n } }
writeImpl (Lists _s n) = JSON.writeImpl { "ListsRoute": { nodeId: n } }
writeImpl (NodeTexts _s n) = JSON.writeImpl { "NodeTextsRoute": { nodeId: n } }
writeImpl (PGraphExplorer _s n) = JSON.writeImpl { "PGraphExplorerRoute": { nodeId: n } }
writeImpl (PhyloExplorer _s n) = JSON.writeImpl { "PhyloExplorerRoute": { nodeId: n } }
writeImpl (RouteFile _s n) = JSON.writeImpl { "RouteFileRoute": { nodeId: n } }
writeImpl (RouteFrameCalc _s n) = JSON.writeImpl { "RouteFrameCalcRoute": { nodeId: n } }
writeImpl (RouteFrameCode _s n) = JSON.writeImpl { "RouteFrameCodeRoute": { nodeId: n } }
writeImpl (RouteFrameVisio _s n) = JSON.writeImpl { "RouteFrameVisioRoute": { nodeId: n } }
writeImpl (RouteFrameWrite _s n) = JSON.writeImpl { "RouteFrameWriteRoute": { nodeId: n } }
writeImpl (Team _s n) = JSON.writeImpl { "TeamRoute": { nodeId: n } }
writeImpl (TreeFlat _s n q) = JSON.writeImpl { "TreeFlatRoute": { nodeId: n, query: q } }
writeImpl (UserPage _s n) = JSON.writeImpl { "UserPageRoute": { nodeId: n } }
writeImpl (ForgotPassword _) = JSON.writeImpl { "ForgotPasswordRoute": {} }
writeImpl Home = JSON.writeImpl { "HomeRoute": {} }
writeImpl Login = JSON.writeImpl { "LoginRoute": {} }
instance Argonaut.EncodeJson AppRoute where encodeJson = encodeJsonArgonaut
instance Show AppRoute where
instance Show AppRoute where
show Home = "Home"
show Home = "Home"
...
...
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