Commit 8846d516 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch 'testing' into stable

parents 1352a7bf 702e218f
Pipeline #6396 failed with stages
#!/bin/bash
nix run .#repl
{ {
"name": "Gargantext", "name": "Gargantext",
"version": "0.0.7.1.6.5", "version": "0.0.7.1.11",
"scripts": { "scripts": {
"build": "spago build", "build": "spago build",
"bundle": "spago bundle --module Main --outfile dist/bundle.js", "bundle": "spago bundle --module Main --outfile dist/bundle.js",
......
nix-shell --run repl
...@@ -253,12 +253,13 @@ type PageGQLParams = ...@@ -253,12 +253,13 @@ type PageGQLParams =
( corpusId :: Int ( corpusId :: Int
, params :: T.Params , params :: T.Params
, ngramsTerms :: Array String , 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 -> Record PageGQLParams
initialPageGQL { corpusId, ngramsTerms, session } = initialPageGQL { corpusId, ngramsTerms, session, logic } =
{ corpusId, ngramsTerms, params: T.initialParams, session } { corpusId, ngramsTerms, params: T.initialParams, session, logic }
loadPageGQL :: Record PageGQLParams -> AffRESTError Rows loadPageGQL :: Record PageGQLParams -> AffRESTError Rows
...@@ -266,9 +267,10 @@ loadPageGQL { corpusId ...@@ -266,9 +267,10 @@ loadPageGQL { corpusId
-- NOTE: unused -- NOTE: unused
-- , params: { limit, offset, orderBy } -- , params: { limit, offset, orderBy }
, ngramsTerms , 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 pure $ (\res -> Docs { docs: gqlContextToDocumentsView <$> Seq.fromFoldable res }) <$> eResult
......
...@@ -149,6 +149,7 @@ settingsBoxLens Calc = ...@@ -149,6 +149,7 @@ settingsBoxLens Calc =
, Add [ Calc , Add [ Calc
, Notes ] , Notes ]
, Move moveFrameParameters , Move moveFrameParameters
, ShareURL
, Delete ] , Delete ]
settingsBoxLens Corpus = settingsBoxLens Corpus =
_buttons .~ [ Add [ Graph _buttons .~ [ Add [ Graph
......
...@@ -14,7 +14,7 @@ import Data.Set as Set ...@@ -14,7 +14,7 @@ import Data.Set as Set
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Effect (Effect) import Effect (Effect)
import Gargantext.Components.Bootstrap as B 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.FacetsTable (DocumentsView(..), Rows(..), initialPageGQL, loadPageGQL, publicationDate)
import Gargantext.Components.GraphExplorer.Store as GraphStore import Gargantext.Components.GraphExplorer.Store as GraphStore
import Gargantext.Components.GraphExplorer.Types (CorpusId, DocId, GraphSideDoc(..), ListId) import Gargantext.Components.GraphExplorer.Types (CorpusId, DocId, GraphSideDoc(..), ListId)
...@@ -63,6 +63,8 @@ docListWrapperCpt = here.component "wrapper" cpt where ...@@ -63,6 +63,8 @@ docListWrapperCpt = here.component "wrapper" cpt where
selectedNgramsTerms <- T.useBox [] selectedNgramsTerms <- T.useBox []
buttonState <- T.useBox false
-- | Helpers -- | Helpers
-- | -- |
let let
...@@ -89,6 +91,7 @@ docListWrapperCpt = here.component "wrapper" cpt where ...@@ -89,6 +91,7 @@ docListWrapperCpt = here.component "wrapper" cpt where
, selectedNgramsTerms , selectedNgramsTerms
, session , session
, showDoc , showDoc
, buttonState
} }
_ /\ _ -> _ /\ _ ->
...@@ -109,6 +112,7 @@ type ListProps = ...@@ -109,6 +112,7 @@ type ListProps =
, selectedNgramsTerms :: T.Box (Array SigmaxT.Label) , selectedNgramsTerms :: T.Box (Array SigmaxT.Label)
, session :: Session , session :: Session
, showDoc :: T.Box (Maybe GraphSideDoc) , showDoc :: T.Box (Maybe GraphSideDoc)
, buttonState :: T.Box Boolean
) )
docList :: R2.Leaf ListProps docList :: R2.Leaf ListProps
...@@ -132,6 +136,7 @@ docListCpt = here.component "main" cpt where ...@@ -132,6 +136,7 @@ docListCpt = here.component "main" cpt where
, selectedNgramsTerms , selectedNgramsTerms
, session , session
, showDoc , showDoc
, buttonState
} _ = do } _ = do
-- | States -- | States
-- | -- |
...@@ -141,10 +146,13 @@ docListCpt = here.component "main" cpt where ...@@ -141,10 +146,13 @@ docListCpt = here.component "main" cpt where
selectedNgramsTerms' <- T.useLive T.unequal selectedNgramsTerms selectedNgramsTerms' <- T.useLive T.unequal selectedNgramsTerms
buttonState' <- R2.useLive' buttonState
path' /\ path path' /\ path
<- R2.useBox' $ initialPageGQL { corpusId: nodeId <- R2.useBox' $ initialPageGQL { corpusId: nodeId
, ngramsTerms: A.fromFoldable selectedNgramsTerms' , ngramsTerms: A.fromFoldable selectedNgramsTerms'
, session } , session
, logic: buttonState' }
state' /\ state <- state' /\ state <-
R2.useBox' Nothing R2.useBox' Nothing
...@@ -174,7 +182,14 @@ docListCpt = here.component "main" cpt where ...@@ -174,7 +182,14 @@ docListCpt = here.component "main" cpt where
useUpdateEffect1' selectedNgramsTerms' $ useUpdateEffect1' selectedNgramsTerms' $
flip T.write_ path $ initialPageGQL { corpusId: nodeId flip T.write_ path $ initialPageGQL { corpusId: nodeId
, ngramsTerms: A.fromFoldable selectedNgramsTerms' , 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) -- (on fetch success, extract existing docs)
useUpdateEffect1' state' do useUpdateEffect1' state' do
...@@ -239,7 +254,12 @@ docListCpt = here.component "main" cpt where ...@@ -239,7 +254,12 @@ docListCpt = here.component "main" cpt where
H.div {} 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 , H.ul
{ className: intercalate " " { className: intercalate " "
[ "graph-doc-list" [ "graph-doc-list"
...@@ -348,3 +368,46 @@ itemCpt = here.component "item" cpt where ...@@ -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" ]
]
...@@ -148,7 +148,7 @@ type Schema ...@@ -148,7 +148,7 @@ type Schema
= { annuaire_contacts :: { contact_id :: Int } -> Array AnnuaireContact = { annuaire_contacts :: { contact_id :: Int } -> Array AnnuaireContact
, context_ngrams :: { context_id :: Int, list_id :: Int } -> Array String , context_ngrams :: { context_id :: Int, list_id :: Int } -> Array String
, contexts :: { context_id :: Int, node_id :: Int } -> Array GQLCTX.NodeContext , 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 , imt_schools :: {} -> Array GQLIMT.School
, languages :: {} -> Array GQLNLP.Language , languages :: {} -> Array GQLNLP.Language
, node_children :: { node_id :: Int, child_type :: NodeType } -> Array GQLNode.Node , node_children :: { node_id :: Int, child_type :: NodeType } -> Array GQLNode.Node
......
...@@ -89,7 +89,8 @@ nodeContextQuery ...@@ -89,7 +89,8 @@ nodeContextQuery
type ContextsForNgramsQuery type ContextsForNgramsQuery
= { contexts_for_ngrams :: Args = { contexts_for_ngrams :: Args
{ corpus_id :: Var "corpus_id" Int { 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_id :: Unit
, c_score :: Unit , c_score :: Unit
, c_date :: Unit , c_date :: Unit
...@@ -124,7 +125,8 @@ contextsForNgramsQuery :: ContextsForNgramsQuery ...@@ -124,7 +125,8 @@ contextsForNgramsQuery :: ContextsForNgramsQuery
contextsForNgramsQuery contextsForNgramsQuery
= { contexts_for_ngrams: = { contexts_for_ngrams:
{ corpus_id: Var :: _ "corpus_id" Int { 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) GGQL.getFieldsStandard (Proxy :: _ Context)
} }
......
...@@ -190,10 +190,11 @@ getNodeContext session context_id node_id = do ...@@ -190,10 +190,11 @@ getNodeContext session context_id node_id = do
Just context -> pure $ Right context -- TODO: error handling Just context -> pure $ Right context -- TODO: error handling
type ContextsForNgramsGQL = { contexts_for_ngrams :: Array GQLCTX.Context } type ContextsForNgramsGQL = { contexts_for_ngrams :: Array GQLCTX.Context }
getContextsForNgrams :: Session -> CorpusId -> Array String -> AffRESTError (Array GQLCTX.Context) getContextsForNgrams :: Session -> CorpusId -> Array String -> Boolean -> AffRESTError (Array GQLCTX.Context)
getContextsForNgrams session corpus_id ngrams_terms = do getContextsForNgrams session corpus_id ngrams_terms logic = do
let query = GQLCTX.contextsForNgramsQuery `withVars` { corpus_id 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 eRes <- queryGql session "get contexts for ngrams" query
pure $ rmap _.contexts_for_ngrams eRes pure $ rmap _.contexts_for_ngrams eRes
......
...@@ -213,7 +213,7 @@ type NgramsDocLoadProps = ...@@ -213,7 +213,7 @@ type NgramsDocLoadProps =
loaderNgramsDocList :: Record NgramsDocLoadProps -> AffRESTError (Array GQLCTX.Context) loaderNgramsDocList :: Record NgramsDocLoadProps -> AffRESTError (Array GQLCTX.Context)
loaderNgramsDocList { corpusId, ngrams: NormNgramsTerm ngrams, session } = loaderNgramsDocList { corpusId, ngrams: NormNgramsTerm ngrams, session } =
getContextsForNgrams session corpusId [ngrams] getContextsForNgrams session corpusId [ngrams] false
type NgramsDocListLoadedProps = type NgramsDocListLoadedProps =
( contexts :: Array GQLCTX.Context ( contexts :: Array GQLCTX.Context
......
...@@ -11,7 +11,7 @@ import Data.Sequence as Seq ...@@ -11,7 +11,7 @@ import Data.Sequence as Seq
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Effect (Effect) import Effect (Effect)
import Gargantext.Components.Bootstrap as B 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.FacetsTable (DocumentsView(..), Rows(..), publicationDate, initialPageGQL, loadPageGQL)
import Gargantext.Components.PhyloExplorer.Store as PhyloStore import Gargantext.Components.PhyloExplorer.Store as PhyloStore
import Gargantext.Components.PhyloExplorer.Types (CorpusId, DocId, FrameDoc(..), ListId) import Gargantext.Components.PhyloExplorer.Types (CorpusId, DocId, FrameDoc(..), ListId)
...@@ -50,6 +50,8 @@ docListWrapperCpt = here.component "wrapper" cpt where ...@@ -50,6 +50,8 @@ docListWrapperCpt = here.component "wrapper" cpt where
corpusId <- R2.useLive' store.corpusId corpusId <- R2.useLive' store.corpusId
listId <- R2.useLive' store.listId listId <- R2.useLive' store.listId
selectedTerm <- R2.useLive' store.selectedTerm selectedTerm <- R2.useLive' store.selectedTerm
buttonState <- T.useBox false
query' /\ query <- R2.useBox' Nothing query' /\ query <- R2.useBox' Nothing
...@@ -90,6 +92,7 @@ docListWrapperCpt = here.component "wrapper" cpt where ...@@ -90,6 +92,7 @@ docListWrapperCpt = here.component "wrapper" cpt where
, listId , listId
, frameDoc: store.frameDoc , frameDoc: store.frameDoc
, frontends: defaultFrontends , frontends: defaultFrontends
, buttonState
} }
] ]
...@@ -102,6 +105,7 @@ type ListProps = ...@@ -102,6 +105,7 @@ type ListProps =
, session :: Session , session :: Session
, frameDoc :: T.Box (Maybe FrameDoc) , frameDoc :: T.Box (Maybe FrameDoc)
, frontends :: Frontends , frontends :: Frontends
, buttonState :: T.Box Boolean
) )
docList :: R2.Leaf ListProps docList :: R2.Leaf ListProps
...@@ -125,15 +129,12 @@ docListCpt = here.component "main" cpt where ...@@ -125,15 +129,12 @@ docListCpt = here.component "main" cpt where
, listId , listId
, frameDoc , frameDoc
, frontends , frontends
, buttonState
} _ = do } _ = do
-- | States -- | States
-- | -- |
path' /\ path <- R2.useBox' $ initialPageGQL { corpusId: nodeId
, ngramsTerms: q'
, session }
state' /\ state <- state' /\ state <-
R2.useBox' Nothing R2.useBox' Nothing
...@@ -143,6 +144,14 @@ docListCpt = here.component "main" cpt where ...@@ -143,6 +144,14 @@ docListCpt = here.component "main" cpt where
frameDoc' <- frameDoc' <-
R2.useLive' frameDoc R2.useLive' frameDoc
buttonState' <-
R2.useLive' buttonState
path' /\ path <- R2.useBox' $ initialPageGQL { corpusId: nodeId
, ngramsTerms: q'
, session
, logic: buttonState' }
-- | Hooks -- | Hooks
-- | -- |
...@@ -160,7 +169,14 @@ docListCpt = here.component "main" cpt where ...@@ -160,7 +169,14 @@ docListCpt = here.component "main" cpt where
useUpdateEffect1' query $ useUpdateEffect1' query $
T.write_ (initialPageGQL { corpusId: nodeId T.write_ (initialPageGQL { corpusId: nodeId
, ngramsTerms: q' , 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) -- (on fetch success, extract existing docs)
useUpdateEffect1' state' case state' of useUpdateEffect1' state' case state' of
...@@ -223,7 +239,12 @@ docListCpt = here.component "main" cpt where ...@@ -223,7 +239,12 @@ docListCpt = here.component "main" cpt where
R2.when (not $ eq results Seq.empty) $ R2.when (not $ eq results Seq.empty) $
H.div {} 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 H.ul
{ className: intercalate " " { className: intercalate " "
...@@ -334,3 +355,46 @@ itemCpt = here.component "item" cpt where ...@@ -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" ]
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment