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
6ad8e253
Commit
6ad8e253
authored
Jul 05, 2024
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/242-dev-phylo-search-documents' into dev
parents
7a142290
48f7bf95
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
156 additions
and
24 deletions
+156
-24
FacetsTable.purs
src/Gargantext/Components/FacetsTable.purs
+8
-6
DocList.purs
src/Gargantext/Components/GraphExplorer/Sidebar/DocList.purs
+67
-4
GraphQL.purs
src/Gargantext/Components/GraphQL.purs
+1
-1
Context.purs
src/Gargantext/Components/GraphQL/Context.purs
+4
-2
Endpoints.purs
src/Gargantext/Components/GraphQL/Endpoints.purs
+4
-3
Lists.purs
src/Gargantext/Components/Nodes/Lists.purs
+1
-1
DocList.purs
src/Gargantext/Components/PhyloExplorer/Sidebar/DocList.purs
+71
-7
No files found.
src/Gargantext/Components/FacetsTable.purs
View file @
6ad8e253
...
...
@@ -253,12 +253,13 @@ type PageGQLParams =
( corpusId :: Int
, params :: T.Params
, ngramsTerms :: Array String
, session :: Session )
, session :: Session
, logic :: Boolean )
initialPageGQL :: { corpusId :: Int, ngramsTerms :: Array String, session :: Session }
initialPageGQL :: { corpusId :: Int, ngramsTerms :: Array String, session :: Session
, logic :: Boolean
}
-> Record PageGQLParams
initialPageGQL { corpusId, ngramsTerms, session } =
{ corpusId, ngramsTerms, params: T.initialParams, session }
initialPageGQL { corpusId, ngramsTerms, session
, logic
} =
{ corpusId, ngramsTerms, params: T.initialParams, session
, logic
}
loadPageGQL :: Record PageGQLParams -> AffRESTError Rows
...
...
@@ -266,9 +267,10 @@ loadPageGQL { corpusId
-- NOTE: unused
-- , params: { limit, offset, orderBy }
, ngramsTerms
, session } = do
, session
, logic } = do
eResult <- GQLE.getContextsForNgrams session corpusId ngramsTerms
eResult <- GQLE.getContextsForNgrams session corpusId ngramsTerms
logic
pure $ (\res -> Docs { docs: gqlContextToDocumentsView <$> Seq.fromFoldable res }) <$> eResult
...
...
src/Gargantext/Components/GraphExplorer/Sidebar/DocList.purs
View file @
6ad8e253
...
...
@@ -14,7 +14,7 @@ import Data.Set as Set
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (Variant(..))
import Gargantext.Components.Bootstrap.Types (
ButtonVariant(..),
Variant(..))
import Gargantext.Components.FacetsTable (DocumentsView(..), Rows(..), initialPageGQL, loadPageGQL, publicationDate)
import Gargantext.Components.GraphExplorer.Store as GraphStore
import Gargantext.Components.GraphExplorer.Types (CorpusId, DocId, GraphSideDoc(..), ListId)
...
...
@@ -63,6 +63,8 @@ docListWrapperCpt = here.component "wrapper" cpt where
selectedNgramsTerms <- T.useBox []
buttonState <- T.useBox false
-- | Helpers
-- |
let
...
...
@@ -89,6 +91,7 @@ docListWrapperCpt = here.component "wrapper" cpt where
, selectedNgramsTerms
, session
, showDoc
, buttonState
}
_ /\ _ ->
...
...
@@ -109,6 +112,7 @@ type ListProps =
, selectedNgramsTerms :: T.Box (Array SigmaxT.Label)
, session :: Session
, showDoc :: T.Box (Maybe GraphSideDoc)
, buttonState :: T.Box Boolean
)
docList :: R2.Leaf ListProps
...
...
@@ -132,6 +136,7 @@ docListCpt = here.component "main" cpt where
, selectedNgramsTerms
, session
, showDoc
, buttonState
} _ = do
-- | States
-- |
...
...
@@ -141,10 +146,13 @@ docListCpt = here.component "main" cpt where
selectedNgramsTerms' <- T.useLive T.unequal selectedNgramsTerms
buttonState' <- R2.useLive' buttonState
path' /\ path
<- R2.useBox' $ initialPageGQL { corpusId: nodeId
, ngramsTerms: A.fromFoldable selectedNgramsTerms'
, session }
, session
, logic: buttonState' }
state' /\ state <-
R2.useBox' Nothing
...
...
@@ -174,7 +182,14 @@ docListCpt = here.component "main" cpt where
useUpdateEffect1' selectedNgramsTerms' $
flip T.write_ path $ initialPageGQL { corpusId: nodeId
, ngramsTerms: A.fromFoldable selectedNgramsTerms'
, session }
, session
, logic: buttonState' }
useUpdateEffect1' buttonState' $
T.write_ (initialPageGQL { corpusId: nodeId
, ngramsTerms: A.fromFoldable selectedNgramsTerms'
, session
, logic: buttonState' }) path
-- (on fetch success, extract existing docs)
useUpdateEffect1' state' do
...
...
@@ -239,7 +254,12 @@ docListCpt = here.component "main" cpt where
H.div {}
[
H.h6 {} [ H.text $ show (Seq.length results) <> " related documents"]
H.ul { className: "flex-row list-group vertical-align-middle" }
[ H.li {} [ andOrButton { state: buttonState } ]
, H.li {} [ H.h6 {} [ H.text $ show (Seq.length results) <> " related documents" ] ]
, H.li {} [ B.iconButton { name: "search", title: "Search the web", callback: \_ -> pure unit} ]
, H.li {} [ B.iconButton { name: "wikipedia-w", title: "Search Wikipedia", callback: \_ -> pure unit} ]
]
, H.ul
{ className: intercalate " "
[ "graph-doc-list"
...
...
@@ -348,3 +368,46 @@ itemCpt = here.component "item" cpt where
]
]
]
---------------------------------------------------------
type AndOrButtonProps =
( state :: T.Box Boolean
)
andOrButton :: R2.Leaf AndOrButtonProps
andOrButton = R2.leaf andOrButtonCpt
andOrButtonCpt :: R.Component AndOrButtonProps
andOrButtonCpt = here.component "andOrButton" cpt
where
cpt { state } _ = do
state' <- R2.useLive' state
pure $
H.div
{ className: intercalate " "
[ "btn-group"
, "align-items-center"
]
, role: "group"
}
[
B.button
{ className: "btn-sm"
, callback: \_ -> T.write_ false state
, variant: state' ?
OutlinedButtonVariant Secondary $
ButtonVariant Secondary
}
[ H.text "OR" ]
,
B.button
{ className: "btn-sm"
, callback: \_ -> T.write_ true state
, variant: state' ?
ButtonVariant Secondary $
OutlinedButtonVariant Secondary
}
[ H.text "AND" ]
]
src/Gargantext/Components/GraphQL.purs
View file @
6ad8e253
...
...
@@ -148,7 +148,7 @@ type Schema
= { annuaire_contacts :: { contact_id :: Int } -> Array AnnuaireContact
, context_ngrams :: { context_id :: Int, list_id :: Int } -> Array String
, contexts :: { context_id :: Int, node_id :: Int } -> Array GQLCTX.NodeContext
, contexts_for_ngrams :: { corpus_id :: Int, ngrams_terms :: Array String } -> Array GQLCTX.Context
, contexts_for_ngrams :: { corpus_id :: Int, ngrams_terms :: Array String
, and_logic :: String
} -> Array GQLCTX.Context
, imt_schools :: {} -> Array GQLIMT.School
, languages :: {} -> Array GQLNLP.Language
, node_children :: { node_id :: Int, child_type :: NodeType } -> Array GQLNode.Node
...
...
src/Gargantext/Components/GraphQL/Context.purs
View file @
6ad8e253
...
...
@@ -89,7 +89,8 @@ nodeContextQuery
type ContextsForNgramsQuery
= { contexts_for_ngrams :: Args
{ corpus_id :: Var "corpus_id" Int
, ngrams_terms :: Var "ngrams_terms" NgramsTerms }
, ngrams_terms :: Var "ngrams_terms" NgramsTerms
, and_logic :: Var "and_logic" String }
{ c_id :: Unit
, c_score :: Unit
, c_date :: Unit
...
...
@@ -124,7 +125,8 @@ contextsForNgramsQuery :: ContextsForNgramsQuery
contextsForNgramsQuery
= { contexts_for_ngrams:
{ corpus_id: Var :: _ "corpus_id" Int
, ngrams_terms: Var :: _ "ngrams_terms" NgramsTerms } =>>
, ngrams_terms: Var :: _ "ngrams_terms" NgramsTerms
, and_logic: Var :: _ "and_logic" String } =>>
GGQL.getFieldsStandard (Proxy :: _ Context)
}
...
...
src/Gargantext/Components/GraphQL/Endpoints.purs
View file @
6ad8e253
...
...
@@ -190,10 +190,11 @@ getNodeContext session context_id node_id = do
Just context -> pure $ Right context -- TODO: error handling
type ContextsForNgramsGQL = { contexts_for_ngrams :: Array GQLCTX.Context }
getContextsForNgrams :: Session -> CorpusId -> Array String -> AffRESTError (Array GQLCTX.Context)
getContextsForNgrams session corpus_id ngrams_terms = do
getContextsForNgrams :: Session -> CorpusId -> Array String ->
Boolean ->
AffRESTError (Array GQLCTX.Context)
getContextsForNgrams session corpus_id ngrams_terms
logic
= do
let query = GQLCTX.contextsForNgramsQuery `withVars` { corpus_id
, ngrams_terms: GQLCTX.NgramsTerms ngrams_terms }
, ngrams_terms: GQLCTX.NgramsTerms ngrams_terms
, and_logic: show logic }
eRes <- queryGql session "get contexts for ngrams" query
pure $ rmap _.contexts_for_ngrams eRes
...
...
src/Gargantext/Components/Nodes/Lists.purs
View file @
6ad8e253
...
...
@@ -213,7 +213,7 @@ type NgramsDocLoadProps =
loaderNgramsDocList :: Record NgramsDocLoadProps -> AffRESTError (Array GQLCTX.Context)
loaderNgramsDocList { corpusId, ngrams: NormNgramsTerm ngrams, session } =
getContextsForNgrams session corpusId [ngrams]
getContextsForNgrams session corpusId [ngrams]
false
type NgramsDocListLoadedProps =
( contexts :: Array GQLCTX.Context
...
...
src/Gargantext/Components/PhyloExplorer/Sidebar/DocList.purs
View file @
6ad8e253
...
...
@@ -11,7 +11,7 @@ import Data.Sequence as Seq
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (Variant(..))
import Gargantext.Components.Bootstrap.Types (
ButtonVariant(..),
Variant(..))
import Gargantext.Components.FacetsTable (DocumentsView(..), Rows(..), publicationDate, initialPageGQL, loadPageGQL)
import Gargantext.Components.PhyloExplorer.Store as PhyloStore
import Gargantext.Components.PhyloExplorer.Types (CorpusId, DocId, FrameDoc(..), ListId)
...
...
@@ -51,6 +51,8 @@ docListWrapperCpt = here.component "wrapper" cpt where
listId <- R2.useLive' store.listId
selectedTerm <- R2.useLive' store.selectedTerm
buttonState <- T.useBox false
query' /\ query <- R2.useBox' Nothing
-- | Helpers
...
...
@@ -90,6 +92,7 @@ docListWrapperCpt = here.component "wrapper" cpt where
, listId
, frameDoc: store.frameDoc
, frontends: defaultFrontends
, buttonState
}
]
...
...
@@ -102,6 +105,7 @@ type ListProps =
, session :: Session
, frameDoc :: T.Box (Maybe FrameDoc)
, frontends :: Frontends
, buttonState :: T.Box Boolean
)
docList :: R2.Leaf ListProps
...
...
@@ -125,15 +129,12 @@ docListCpt = here.component "main" cpt where
, listId
, frameDoc
, frontends
, buttonState
} _ = do
-- | States
-- |
path' /\ path <- R2.useBox' $ initialPageGQL { corpusId: nodeId
, ngramsTerms: q'
, session }
state' /\ state <-
R2.useBox' Nothing
...
...
@@ -143,6 +144,14 @@ docListCpt = here.component "main" cpt where
frameDoc' <-
R2.useLive' frameDoc
buttonState' <-
R2.useLive' buttonState
path' /\ path <- R2.useBox' $ initialPageGQL { corpusId: nodeId
, ngramsTerms: q'
, session
, logic: buttonState' }
-- | Hooks
-- |
...
...
@@ -160,7 +169,14 @@ docListCpt = here.component "main" cpt where
useUpdateEffect1' query $
T.write_ (initialPageGQL { corpusId: nodeId
, ngramsTerms: q'
, session }) path
, session
, logic: buttonState' }) path
useUpdateEffect1' buttonState' $
T.write_ (initialPageGQL { corpusId: nodeId
, ngramsTerms: q'
, session
, logic: buttonState' }) path
-- (on fetch success, extract existing docs)
useUpdateEffect1' state' case state' of
...
...
@@ -223,7 +239,12 @@ docListCpt = here.component "main" cpt where
R2.when (not $ eq results Seq.empty) $
H.div {}
[
H.h6 {} [ H.text $ show (Seq.length results) <> " related documents"]
H.ul { className: "flex-row list-group vertical-align-middle" }
[ H.li {} [ andOrButton { state: buttonState } ]
, H.li {} [ H.h6 {} [ H.text $ show (Seq.length results) <> " related documents" ] ]
, H.li {} [ B.iconButton { name: "search", title: "Search the web", callback: \_ -> pure unit} ]
, H.li {} [ B.iconButton { name: "wikipedia-w", title: "Search Wikipedia", callback: \_ -> pure unit} ]
]
,
H.ul
{ className: intercalate " "
...
...
@@ -334,3 +355,46 @@ itemCpt = here.component "item" cpt where
]
]
]
---------------------------------------------------------
type AndOrButtonProps =
( state :: T.Box Boolean
)
andOrButton :: R2.Leaf AndOrButtonProps
andOrButton = R2.leaf andOrButtonCpt
andOrButtonCpt :: R.Component AndOrButtonProps
andOrButtonCpt = here.component "andOrButton" cpt
where
cpt { state } _ = do
state' <- R2.useLive' state
pure $
H.div
{ className: intercalate " "
[ "btn-group"
, "align-items-center"
]
, role: "group"
}
[
B.button
{ className: "btn-sm"
, callback: \_ -> T.write_ false state
, variant: state' ?
OutlinedButtonVariant Secondary $
ButtonVariant Secondary
}
[ H.text "OR" ]
,
B.button
{ className: "btn-sm"
, callback: \_ -> T.write_ true state
, variant: state' ?
ButtonVariant Secondary $
OutlinedButtonVariant Secondary
}
[ H.text "AND" ]
]
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