Squashed commit of the following:

commit ea934d83
Author: Przemysław Kaminski <pk@intrepidus.pl>
Date:   Tue Jan 14 06:59:11 2025 +0100

    [search] move EPO user/token into the datafield

commit b01a85eb
Author: Przemysław Kaminski <pk@intrepidus.pl>
Date:   Mon Jan 13 10:15:27 2025 +0100

    [search] search query json format fixes

    Related to haskell-gargantext#441

    Related to commmit
    haskell-gargantext@bc29319c

commit 3b50603a
Merge: a93e055b 2e43c474
Author: Przemysław Kaminski <pk@intrepidus.pl>
Date:   Fri Jan 10 12:04:36 2025 +0100

    Merge branch 'dev' into 204-ngrams-refactor-fixes

commit a93e055b
Author: Przemysław Kaminski <pk@intrepidus.pl>
Date:   Wed Jan 8 18:22:37 2025 +0100

    [search] pubmed constructor with api key

This commit has to be merged together with
haskell-gargantext!385 (03b33383)
parent 2e43c474
Pipeline #7290 passed with stages
in 18 minutes and 7 seconds
...@@ -55,7 +55,7 @@ searchIframesCpt = here.component "searchIframes" cpt ...@@ -55,7 +55,7 @@ searchIframesCpt = here.component "searchIframes" cpt
pure $ pure $
if isIsTex_Advanced search'.datafield then divIframe { frameSource: Istex, iframeRef, search } [] if isIsTex_Advanced search'.datafield then divIframe { frameSource: Istex, iframeRef, search } []
else if Just Web == search'.datafield then divIframe { frameSource: Searx, iframeRef, search } [] else if Web == search'.datafield then divIframe { frameSource: Searx, iframeRef, search } []
else H.div {} [] else H.div {} []
type IFrameProps = type IFrameProps =
......
...@@ -36,12 +36,8 @@ here = R2.here "Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField ...@@ -36,12 +36,8 @@ here = R2.here "Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField
defaultSearch :: Search defaultSearch :: Search
defaultSearch = defaultSearch =
{ databases: Empty { datafield: External Empty
, datafield: Just (External Empty)
, node_id: Nothing , node_id: Nothing
, epoApiUser: Nothing
, epoApiToken: Nothing
, pubmedApiKey: Nothing
, lang: Nothing , lang: Nothing
, term: "" , term: ""
, url: "" , url: ""
...@@ -202,93 +198,73 @@ componentCNRSCpt = here.component "componentCNRS" cpt ...@@ -202,93 +198,73 @@ componentCNRSCpt = here.component "componentCNRS" cpt
--, filterInput fi --, filterInput fi
] ]
isExternal :: Maybe DataField -> Boolean isExternal :: DataField -> Boolean
isExternal (Just (External _)) = true isExternal (External _) = true
isExternal _ = false isExternal _ = false
isArxiv :: Maybe DataField -> Boolean isArxiv :: DataField -> Boolean
isArxiv isArxiv (External Arxiv) = true
( Just
(External Arxiv)
) = true
isArxiv _ = false isArxiv _ = false
isHAL :: Maybe DataField -> Boolean isHAL :: DataField -> Boolean
isHAL isHAL (External (HAL _)) = true
( Just
(External (HAL _))
) = true
isHAL _ = false isHAL _ = false
isIsTex :: Maybe DataField -> Boolean isIsTex :: DataField -> Boolean
isIsTex isIsTex (External (IsTex)) = true
( Just
(External (IsTex))
) = true
isIsTex _ = false isIsTex _ = false
isIMT :: Maybe DataField -> Boolean isIMT :: DataField -> Boolean
isIMT isIMT
( Just ( External
( External ( HAL
( HAL (Just (IMT _))
(Just (IMT _))
)
) )
) = true ) = true
isIMT _ = false isIMT _ = false
isCNRS :: Maybe DataField -> Boolean isCNRS :: DataField -> Boolean
isCNRS isCNRS
( Just ( External
( External ( HAL
( HAL (Just (CNRS _))
(Just (CNRS _))
)
) )
) = true ) = true
isCNRS _ = false isCNRS _ = false
isPubmed :: Maybe DataField -> Boolean isPubmed :: DataField -> Boolean
isPubmed isPubmed (External (PubMed _)) = true
( Just
(External PubMed)
) = true
isPubmed _ = false isPubmed _ = false
isEPO :: Maybe DataField -> Boolean getPubmedAPIKey :: DataField -> Maybe String
isEPO getPubmedAPIKey (External (PubMed mAPI)) = mAPI
( Just getPubmedAPIKey _ = Nothing
(External EPO)
) = true isEPO :: DataField -> Boolean
isEPO (External (EPO _ _)) = true
isEPO _ = false isEPO _ = false
needsLang :: Maybe DataField -> Boolean needsLang :: DataField -> Boolean
needsLang (Just Gargantext) = true needsLang Gargantext = true
needsLang (Just Web) = true needsLang Web = true
needsLang needsLang (External (HAL _)) = true
( Just
(External (HAL _))
) = true
needsLang _ = false needsLang _ = false
isIn :: IMT_org -> Maybe DataField -> Boolean isIn :: IMT_org -> DataField -> Boolean
isIn isIn
org org
( Just ( External
( External ( HAL
( HAL ( Just
( Just (IMT imtOrgs)
(IMT imtOrgs)
)
) )
) )
) = Set.member org imtOrgs ) = Set.member org imtOrgs
isIn _ _ = false isIn _ _ = false
updateFilter :: IMT_org -> Array IMT_org -> Maybe DataField -> Maybe DataField updateFilter :: IMT_org -> Array IMT_org -> DataField -> DataField
updateFilter org allIMTorgs (Just (External (HAL (Just (IMT imtOrgs))))) = updateFilter org allIMTorgs (External (HAL (Just (IMT imtOrgs)))) =
Just $ External $ HAL $ Just $ IMT imtOrgs' External $ HAL $ Just $ IMT imtOrgs'
where where
imtOrgs' = imtOrgs' =
if Set.member org imtOrgs then if Set.member org imtOrgs then
...@@ -297,7 +273,7 @@ updateFilter org allIMTorgs (Just (External (HAL (Just (IMT imtOrgs))))) = ...@@ -297,7 +273,7 @@ updateFilter org allIMTorgs (Just (External (HAL (Just (IMT imtOrgs))))) =
else if org == All_IMT then Set.fromFoldable allIMTorgs else if org == All_IMT then Set.fromFoldable allIMTorgs
else Set.insert org imtOrgs else Set.insert org imtOrgs
updateFilter org allIMTorgs _ = (Just (External (HAL (Just (IMT imtOrgs'))))) updateFilter org allIMTorgs _ = (External (HAL (Just (IMT imtOrgs'))))
where where
imtOrgs' = imtOrgs' =
if org == All_IMT then Set.fromFoldable allIMTorgs if org == All_IMT then Set.fromFoldable allIMTorgs
...@@ -350,8 +326,7 @@ dataFieldNavCpt = here.component "dataFieldNav" cpt ...@@ -350,8 +326,7 @@ dataFieldNavCpt = here.component "dataFieldNav" cpt
[ H.div { className: "text-primary text-bold p-1" } [ H.text "Search options:" ] [ H.div { className: "text-primary text-bold p-1" } [ H.text "Search options:" ]
, H.div { className: "nav nav-tabs" } ((liItem search') <$> dataFields) , H.div { className: "nav nav-tabs" } ((liItem search') <$> dataFields)
, H.div { className: "center p-1" } , H.div { className: "center p-1" }
[ H.text [ H.text $ doc datafield
$ maybe "TODO: add Doc Instance" doc datafield
] ]
] ]
where where
...@@ -366,8 +341,7 @@ dataFieldNavCpt = here.component "dataFieldNav" cpt ...@@ -366,8 +341,7 @@ dataFieldNavCpt = here.component "dataFieldNav" cpt
, on: , on:
{ click: \_ -> T.modify_ { click: \_ -> T.modify_
( _ ( _
{ datafield = Just df' { datafield = df'
, databases = datafield2database df'
} }
) )
search search
...@@ -401,7 +375,7 @@ databaseInputCpt = here.component "databaseInput" cpt ...@@ -401,7 +375,7 @@ databaseInputCpt = here.component "databaseInput" cpt
let let
db = case search'.datafield of db = case search'.datafield of
(Just (External x)) -> Just x (External x) -> Just x
_ -> Nothing _ -> Nothing
dbInputValue = fromMaybe "" $ dbToInputValue <$> db dbInputValue = fromMaybe "" $ dbToInputValue <$> db
...@@ -420,8 +394,7 @@ databaseInputCpt = here.component "databaseInput" cpt ...@@ -420,8 +394,7 @@ databaseInputCpt = here.component "databaseInput" cpt
T.modify_ T.modify_
( _ ( _
{ datafield = Just $ External updatedValue { datafield = External updatedValue
, databases = updatedValue
} }
) )
search search
...@@ -477,15 +450,16 @@ pubmedInputLoadedCpt = here.component "pubmedInputLoaded" cpt ...@@ -477,15 +450,16 @@ pubmedInputLoadedCpt = here.component "pubmedInputLoaded" cpt
search' <- T.useLive T.unequal search search' <- T.useLive T.unequal search
R.useEffectOnce' $ do R.useEffectOnce' $ do
when (search'.pubmedApiKey /= pubmedAPIKey) $ do when (getPubmedAPIKey search'.datafield /= pubmedAPIKey) $ do
T.write_ (search' { pubmedApiKey = pubmedAPIKey }) search T.modify_ (\s -> s { datafield = External $ PubMed pubmedAPIKey }) search
-- T.write_ (search' { pubmedApiKey = pubmedAPIKey }) search
pure $ pure $
H.div { className: "form-group p-1 m-0" } H.div { className: "form-group p-1 m-0" }
[ H.div { className: "text-primary center" } [ H.text "Pubmed API key" ] [ H.div { className: "text-primary center" } [ H.text "Pubmed API key" ]
, H.input , H.input
{ className: "form-control" { className: "form-control"
, defaultValue: fromMaybe "" search'.pubmedApiKey , defaultValue: fromMaybe "" pubmedAPIKey
, on: , on:
{ blur: modifyPubmedAPIKey search { blur: modifyPubmedAPIKey search
, change: modifyPubmedAPIKey search , change: modifyPubmedAPIKey search
...@@ -502,7 +476,7 @@ pubmedInputLoadedCpt = here.component "pubmedInputLoaded" cpt ...@@ -502,7 +476,7 @@ pubmedInputLoadedCpt = here.component "pubmedInputLoaded" cpt
s -> Just s s -> Just s
T.modify_ T.modify_
( \s -> ( \s ->
s { pubmedApiKey = mVal } s { datafield = External $ PubMed mVal }
) )
searchS searchS
...@@ -537,6 +511,14 @@ type EPOInputLoadedProps = ...@@ -537,6 +511,14 @@ type EPOInputLoadedProps =
, search :: T.Box Search , search :: T.Box Search
) )
searchEPOAPIUser :: Search -> Maybe String
searchEPOAPIUser { datafield: External (EPO mAPIUser _) } = mAPIUser
searchEPOAPIUser _ = Nothing
searchEPOAPIToken :: Search -> Maybe String
searchEPOAPIToken { datafield: External (EPO _ mAPIToken) } = mAPIToken
searchEPOAPIToken _ = Nothing
epoInputLoaded :: R2.Component EPOInputLoadedProps epoInputLoaded :: R2.Component EPOInputLoadedProps
epoInputLoaded = R.createElement epoInputLoadedCpt epoInputLoaded = R.createElement epoInputLoadedCpt
...@@ -547,11 +529,10 @@ epoInputLoadedCpt = here.component "epoInputLoaded" cpt ...@@ -547,11 +529,10 @@ epoInputLoadedCpt = here.component "epoInputLoaded" cpt
search' <- T.useLive T.unequal search search' <- T.useLive T.unequal search
R.useEffectOnce' $ do R.useEffectOnce' $ do
when (search'.epoApiUser /= epoAPIUser || search'.epoApiToken /= epoAPIToken) $ do when (searchEPOAPIUser search' /= epoAPIUser || searchEPOAPIToken search' /= epoAPIToken) $ do
T.write_ T.write_
( search' ( search'
{ epoApiUser = epoAPIUser { datafield = External (EPO epoAPIUser epoAPIToken)
, epoApiToken = epoAPIToken
} }
) )
search search
...@@ -561,7 +542,7 @@ epoInputLoadedCpt = here.component "epoInputLoaded" cpt ...@@ -561,7 +542,7 @@ epoInputLoadedCpt = here.component "epoInputLoaded" cpt
[ H.div { className: "text-primary center" } [ H.text "EPO API User" ] [ H.div { className: "text-primary center" } [ H.text "EPO API User" ]
, H.input , H.input
{ className: "form-control" { className: "form-control"
, defaultValue: fromMaybe "" search'.epoApiUser , defaultValue: fromMaybe "" $ searchEPOAPIUser search'
, on: , on:
{ blur: modifyEPOAPIUser search { blur: modifyEPOAPIUser search
, change: modifyEPOAPIUser search , change: modifyEPOAPIUser search
...@@ -571,7 +552,7 @@ epoInputLoadedCpt = here.component "epoInputLoaded" cpt ...@@ -571,7 +552,7 @@ epoInputLoadedCpt = here.component "epoInputLoaded" cpt
, H.div { className: "text-primary center" } [ H.text "EPO API Token" ] , H.div { className: "text-primary center" } [ H.text "EPO API Token" ]
, H.input , H.input
{ className: "form-control" { className: "form-control"
, defaultValue: fromMaybe "" search'.epoApiToken , defaultValue: fromMaybe "" $ searchEPOAPIToken search'
, on: , on:
{ blur: modifyEPOAPIToken search { blur: modifyEPOAPIToken search
, change: modifyEPOAPIToken search , change: modifyEPOAPIToken search
...@@ -586,7 +567,7 @@ epoInputLoadedCpt = here.component "epoInputLoaded" cpt ...@@ -586,7 +567,7 @@ epoInputLoadedCpt = here.component "epoInputLoaded" cpt
mVal = case val of mVal = case val of
"" -> Nothing "" -> Nothing
s -> Just s s -> Just s
T.modify_ (\s -> s { epoApiUser = mVal }) searchS T.modify_ (\s -> s { datafield = External (EPO mVal (searchEPOAPIToken s)) }) searchS
modifyEPOAPIToken searchS e = do modifyEPOAPIToken searchS e = do
let val = R.unsafeEventValue e let val = R.unsafeEventValue e
...@@ -594,7 +575,7 @@ epoInputLoadedCpt = here.component "epoInputLoaded" cpt ...@@ -594,7 +575,7 @@ epoInputLoadedCpt = here.component "epoInputLoaded" cpt
mVal = case val of mVal = case val of
"" -> Nothing "" -> Nothing
s -> Just s s -> Just s
T.modify_ (\s -> s { epoApiToken = mVal }) searchS T.modify_ (\s -> s { datafield = External (EPO (searchEPOAPIUser s) mVal) }) searchS
type OrgInputProps = type OrgInputProps =
( orgs :: Array Org ( orgs :: Array Org
...@@ -611,7 +592,7 @@ orgInputCpt = here.component "orgInput" cpt ...@@ -611,7 +592,7 @@ orgInputCpt = here.component "orgInput" cpt
let let
change e = do change e = do
let value = R.unsafeEventValue e let value = R.unsafeEventValue e
T.modify_ (_ { datafield = Just $ External $ HAL $ read value }) search T.modify_ (_ { datafield = External $ HAL $ read value }) search
pure $ H.div { className: "form-group p-1 m-0" } pure $ H.div { className: "form-group p-1 m-0" }
[ H.div { className: "text-primary center" } [ H.text "filter with organization: " ] [ H.div { className: "text-primary center" } [ H.text "filter with organization: " ]
...@@ -685,7 +666,7 @@ datafieldInputCpt = here.component "datafieldInput" cpt ...@@ -685,7 +666,7 @@ datafieldInputCpt = here.component "datafieldInput" cpt
else H.div {} [] else H.div {} []
, if needsLang search'.datafield then , if needsLang search'.datafield then
if search'.datafield == Just Web then if search'.datafield == Web then
langNav { langs: A.filter (\lang -> lang == FR) langs, search } [] langNav { langs: A.filter (\lang -> lang == FR) langs, search } []
else else
langNav { langs, search } [] langNav { langs, search } []
...@@ -818,19 +799,10 @@ triggerSearch { onSearch, errors, session, selection, search } = ...@@ -818,19 +799,10 @@ triggerSearch { onSearch, errors, session, selection, search } =
-- modalShow "addCorpus" -- modalShow "addCorpus"
searchQuery :: ListSelection.Selection -> Search -> SearchQuery searchQuery :: ListSelection.Selection -> Search -> SearchQuery
searchQuery selection { datafield: Nothing, term } =
over SearchQuery
( _
{ query = term
, selection = selection
}
)
defaultSearchQuery
-- TODO Simplify both HAL Nothing and HAL (Just IMT) cases -- TODO Simplify both HAL Nothing and HAL (Just IMT) cases
searchQuery searchQuery
selection selection
{ databases { datafield: datafield@(External (HAL Nothing))
, datafield: datafield@(Just (External (HAL Nothing)))
, lang , lang
, node_id , node_id
, term , term
...@@ -838,8 +810,7 @@ searchQuery ...@@ -838,8 +810,7 @@ searchQuery
} = } =
over SearchQuery over SearchQuery
( _ ( _
{ databases = databases { datafield = datafield
, datafield = datafield
, lang = lang , lang = lang
, node_id = node_id , node_id = node_id
, query = queryHAL term Nothing lang years , query = queryHAL term Nothing lang years
...@@ -850,8 +821,7 @@ searchQuery ...@@ -850,8 +821,7 @@ searchQuery
searchQuery searchQuery
selection selection
{ databases { datafield: datafield@(External (HAL (Just (IMT imtOrgs))))
, datafield: datafield@(Just (External (HAL (Just (IMT imtOrgs)))))
, lang , lang
, node_id , node_id
, term , term
...@@ -859,8 +829,7 @@ searchQuery ...@@ -859,8 +829,7 @@ searchQuery
} = } =
over SearchQuery over SearchQuery
( _ ( _
{ databases = databases { datafield = datafield
, datafield = datafield
, lang = lang , lang = lang
, node_id = node_id , node_id = node_id
, query = queryHAL term (Just imtOrgs) lang years , query = queryHAL term (Just imtOrgs) lang years
...@@ -868,55 +837,10 @@ searchQuery ...@@ -868,55 +837,10 @@ searchQuery
} }
) )
defaultSearchQuery defaultSearchQuery
searchQuery searchQuery selection { datafield, lang, term, node_id } =
selection
{ databases
, datafield: datafield@(Just (External EPO))
, lang
, epoApiUser
, epoApiToken
, node_id
, term
} =
over SearchQuery
( _
{ databases = databases
, datafield = datafield
, lang = lang
, node_id = node_id
, epoAPIUser = epoApiUser
, epoAPIToken = epoApiToken
, query = term
, selection = selection
}
)
defaultSearchQuery
searchQuery
selection
{ databases
, datafield: datafield@(Just (External PubMed))
, lang
, pubmedApiKey
, node_id
, term
} =
over SearchQuery
( _
{ databases = databases
, datafield = datafield
, lang = lang
, node_id = node_id
, pubmedAPIKey = pubmedApiKey
, query = term
, selection = selection
}
)
defaultSearchQuery
searchQuery selection { databases, datafield, lang, term, node_id } =
over SearchQuery over SearchQuery
( _ ( _
{ databases = databases { datafield = datafield
, datafield = datafield
, lang = lang , lang = lang
, node_id = node_id , node_id = node_id
, query = term , query = term
......
...@@ -2,6 +2,7 @@ module Gargantext.Components.Forest.Tree.Node.Action.Search.Types where ...@@ -2,6 +2,7 @@ module Gargantext.Components.Forest.Tree.Node.Action.Search.Types where
import Gargantext.Prelude import Gargantext.Prelude
import Data.Array as A
-- import Data.Bounded (class Bounded) -- import Data.Bounded (class Bounded)
import Data.Either (Either) import Data.Either (Either)
-- import Data.Enum (class Enum, class BoundedEnum) -- import Data.Enum (class Enum, class BoundedEnum)
...@@ -26,23 +27,16 @@ import URI.Extra.QueryPairs as QP ...@@ -26,23 +27,16 @@ import URI.Extra.QueryPairs as QP
import URI.Query as Q import URI.Query as Q
type Search = type Search =
{ databases :: Database { datafield :: DataField
, datafield :: Maybe DataField
, url :: String , url :: String
, lang :: Maybe Lang , lang :: Maybe Lang
, node_id :: Maybe Int , node_id :: Maybe Int
, epoApiUser :: Maybe String
, epoApiToken :: Maybe String
, pubmedApiKey :: Maybe String
, term :: String , term :: String
, years :: Array String , years :: Array String
} }
isIsTex_Advanced :: Maybe DataField -> Boolean isIsTex_Advanced :: DataField -> Boolean
isIsTex_Advanced isIsTex_Advanced (External (IsTex_Advanced)) = true
( Just
(External (IsTex_Advanced))
) = true
isIsTex_Advanced _ = false isIsTex_Advanced _ = false
------------------------------------------------------------------------ ------------------------------------------------------------------------
...@@ -81,7 +75,7 @@ instance Doc DataField where ...@@ -81,7 +75,7 @@ instance Doc DataField where
derive instance Eq DataField derive instance Eq DataField
instance JSON.WriteForeign DataField where instance JSON.WriteForeign DataField where
writeImpl (External db) = JSON.writeImpl { "External": JSON.writeImpl $ show db } writeImpl (External db) = JSON.writeImpl { "External": db }
writeImpl Gargantext = JSON.writeImpl "Gargantext" writeImpl Gargantext = JSON.writeImpl "Gargantext"
writeImpl Web = JSON.writeImpl "Web" writeImpl Web = JSON.writeImpl "Web"
writeImpl Files = JSON.writeImpl "Files" writeImpl Files = JSON.writeImpl "Files"
...@@ -116,13 +110,13 @@ data Database ...@@ -116,13 +110,13 @@ data Database
= All_Databases = All_Databases
| Empty | Empty
| OpenAlex | OpenAlex
| PubMed | PubMed (Maybe String)
| Arxiv | Arxiv
| HAL (Maybe Org) | HAL (Maybe Org)
| IsTex | IsTex
| IsTex_Advanced | IsTex_Advanced
| Isidore | Isidore
| EPO | EPO (Maybe String) (Maybe String)
-- | News -- | News
-- | SocialNetworks -- | SocialNetworks
...@@ -133,13 +127,13 @@ derive instance Generic Database _ ...@@ -133,13 +127,13 @@ derive instance Generic Database _
instance Show Database where instance Show Database where
show All_Databases = "All Databases" show All_Databases = "All Databases"
show OpenAlex = "OpenAlex" show OpenAlex = "OpenAlex"
show PubMed = "PubMed" show (PubMed _) = "PubMed"
show Arxiv = "Arxiv" show Arxiv = "Arxiv"
show (HAL _) = "HAL" show (HAL _) = "HAL"
show IsTex = "IsTex" show IsTex = "IsTex"
show IsTex_Advanced = "IsTex_Advanced" show IsTex_Advanced = "IsTex_Advanced"
show Isidore = "Isidore" show Isidore = "Isidore"
show EPO = "EPO" show (EPO _ _) = "EPO"
show Empty = "Empty" show Empty = "Empty"
-- show News = "News" -- show News = "News"
...@@ -148,13 +142,13 @@ instance Show Database where ...@@ -148,13 +142,13 @@ instance Show Database where
instance Doc Database where instance Doc Database where
doc All_Databases = "All databases" doc All_Databases = "All databases"
doc OpenAlex = "OpenAlex db" doc OpenAlex = "OpenAlex db"
doc PubMed = "All Medical publications" doc (PubMed _) = "All Medical publications"
doc Arxiv = "Arxiv" doc Arxiv = "Arxiv"
doc (HAL _) = "All open science (archives ouvertes)" doc (HAL _) = "All open science (archives ouvertes)"
doc IsTex = "All Elsevier enriched by CNRS/INIST" doc IsTex = "All Elsevier enriched by CNRS/INIST"
doc IsTex_Advanced = "IsTex advanced search" doc IsTex_Advanced = "IsTex advanced search"
doc Isidore = "All (French) Social Sciences" doc Isidore = "All (French) Social Sciences"
doc EPO = "European Patent Office" doc (EPO _ _) = "European Patent Office"
doc Empty = "Empty" doc Empty = "Empty"
-- doc News = "Web filtered by News" -- doc News = "Web filtered by News"
...@@ -176,17 +170,24 @@ instance Doc Database where ...@@ -176,17 +170,24 @@ instance Doc Database where
derive instance Eq Database derive instance Eq Database
instance JSON.WriteForeign Database where instance JSON.WriteForeign Database where
writeImpl f = JSON.writeImpl $ show f writeImpl (PubMed mAPIKey) = JSON.writeImpl { "db": "PubMed", "api_key": mAPIKey }
writeImpl (EPO mAPIUser mAPIToken) = JSON.writeImpl
{ "db": "PubMed"
, "api_user": mAPIUser
, "api_token": mAPIToken
}
writeImpl (HAL mOrg) = JSON.writeImpl { "db": "HAL", "org": mOrg }
writeImpl d = JSON.writeImpl { "db": show d }
allDatabases :: Array Database allDatabases :: Array Database
allDatabases = allDatabases =
[ Empty [ Empty
, PubMed , PubMed Nothing
, HAL Nothing , HAL Nothing
, Arxiv , Arxiv
, OpenAlex , OpenAlex
, IsTex , IsTex
-- , EPO -- , EPO Nothing Nothing
--, IsTex_Advanced --, IsTex_Advanced
--, Isidore --, Isidore
--, Web --, Web
...@@ -197,25 +198,25 @@ allDatabases = ...@@ -197,25 +198,25 @@ allDatabases =
dbToInputValue :: Database -> String dbToInputValue :: Database -> String
dbToInputValue All_Databases = "all_databases" dbToInputValue All_Databases = "all_databases"
dbToInputValue OpenAlex = "openalex" dbToInputValue OpenAlex = "openalex"
dbToInputValue PubMed = "pubmed" dbToInputValue (PubMed _) = "pubmed"
dbToInputValue Arxiv = "arxiv" dbToInputValue Arxiv = "arxiv"
dbToInputValue (HAL _) = "hal" dbToInputValue (HAL _) = "hal"
dbToInputValue IsTex = "istex" dbToInputValue IsTex = "istex"
dbToInputValue IsTex_Advanced = "istex_advanced" dbToInputValue IsTex_Advanced = "istex_advanced"
dbToInputValue Isidore = "isidore" dbToInputValue Isidore = "isidore"
dbToInputValue EPO = "epo" dbToInputValue (EPO _ _) = "epo"
dbToInputValue Empty = "empty" dbToInputValue Empty = "empty"
dbFromInputValue :: String -> Maybe Database dbFromInputValue :: String -> Maybe Database
dbFromInputValue "all_databases" = Just All_Databases dbFromInputValue "all_databases" = Just All_Databases
dbFromInputValue "openalex" = Just OpenAlex dbFromInputValue "openalex" = Just OpenAlex
dbFromInputValue "pubmed" = Just PubMed dbFromInputValue "pubmed" = Just (PubMed Nothing)
dbFromInputValue "arxiv" = Just Arxiv dbFromInputValue "arxiv" = Just Arxiv
dbFromInputValue "hal" = Just (HAL Nothing) dbFromInputValue "hal" = Just (HAL Nothing)
dbFromInputValue "istex" = Just IsTex dbFromInputValue "istex" = Just IsTex
dbFromInputValue "istex_advanced" = Just IsTex_Advanced dbFromInputValue "istex_advanced" = Just IsTex_Advanced
dbFromInputValue "isidore" = Just Isidore dbFromInputValue "isidore" = Just Isidore
dbFromInputValue "epo" = Just EPO dbFromInputValue "epo" = Just (EPO Nothing Nothing)
dbFromInputValue "empty" = Just Empty dbFromInputValue "empty" = Just Empty
dbFromInputValue _ = Nothing dbFromInputValue _ = Nothing
...@@ -252,6 +253,9 @@ instance Read Org where ...@@ -252,6 +253,9 @@ instance Read Org where
read _ = Nothing read _ = Nothing
derive instance Eq Org derive instance Eq Org
-- | NOTE: IMT_org list isn't really used here in JSON
-- | encoding. Instead, for HAL, a special query is constructed in
-- | SearchField (queryHAL function).
instance JSON.WriteForeign Org where instance JSON.WriteForeign Org where
writeImpl = JSON.writeImpl <<< show writeImpl = JSON.writeImpl <<< show
...@@ -294,8 +298,7 @@ instance Show SearchOrder where ...@@ -294,8 +298,7 @@ instance Show SearchOrder where
newtype SearchQuery = SearchQuery newtype SearchQuery = SearchQuery
{ query :: String { query :: String
, databases :: Database , datafield :: DataField
, datafield :: Maybe DataField
, files_id :: Array String , files_id :: Array String
, lang :: Maybe Lang , lang :: Maybe Lang
, limit :: Maybe Int , limit :: Maybe Int
...@@ -304,7 +307,6 @@ newtype SearchQuery = SearchQuery ...@@ -304,7 +307,6 @@ newtype SearchQuery = SearchQuery
, order :: Maybe SearchOrder , order :: Maybe SearchOrder
, epoAPIUser :: Maybe String , epoAPIUser :: Maybe String
, epoAPIToken :: Maybe String , epoAPIToken :: Maybe String
, pubmedAPIKey :: Maybe String
, selection :: ListSelection.Selection , selection :: ListSelection.Selection
} }
...@@ -329,34 +331,29 @@ instance GT.ToQuery SearchQuery where ...@@ -329,34 +331,29 @@ instance GT.ToQuery SearchQuery where
instance JSON.WriteForeign SearchQuery where instance JSON.WriteForeign SearchQuery where
writeImpl writeImpl
( SearchQuery ( SearchQuery
{ databases { datafield
, datafield
, lang , lang
, node_id , node_id
, epoAPIUser , epoAPIUser
, epoAPIToken , epoAPIToken
, pubmedAPIKey
, query , query
, selection , selection
} }
) = ) =
JSON.writeImpl JSON.writeImpl
{ query: query -- String.replace (String.Pattern "\"") (String.Replacement "\\\"") query { query: query -- String.replace (String.Pattern "\"") (String.Replacement "\\\"") query
, databases
, datafield , datafield
, lang: maybe "EN" show lang , lang: maybe "EN" show lang
, node_id: fromMaybe 0 node_id , node_id: fromMaybe 0 node_id
, flowListWith: selection , flowListWith: selection
, epoAPIUser , epoAPIUser
, epoAPIToken , epoAPIToken
, pubmedAPIKey
} }
defaultSearchQuery :: SearchQuery defaultSearchQuery :: SearchQuery
defaultSearchQuery = SearchQuery defaultSearchQuery = SearchQuery
{ query: "" { query: ""
, databases: Empty , datafield: External Empty
, datafield: Nothing
, files_id: [] , files_id: []
, lang: Nothing , lang: Nothing
, limit: Nothing , limit: Nothing
...@@ -365,7 +362,6 @@ defaultSearchQuery = SearchQuery ...@@ -365,7 +362,6 @@ defaultSearchQuery = SearchQuery
, order: Nothing , order: Nothing
, epoAPIUser: Nothing , epoAPIUser: Nothing
, epoAPIToken: Nothing , epoAPIToken: Nothing
, pubmedAPIKey: Nothing
, selection: ListSelection.NoList -- MyListsFirst , selection: ListSelection.NoList -- MyListsFirst
} }
......
...@@ -68,8 +68,7 @@ asyncProgressCpt = R2.hereComponent here "asyncProgress" hCpt ...@@ -68,8 +68,7 @@ asyncProgressCpt = R2.hereComponent here "asyncProgress" hCpt
here.log "[onProgress] TODO: Implement status killed" here.log "[onProgress] TODO: Implement status killed"
if if
GT.asyncTaskLogIsFinished atl || GT.asyncTaskLogIsFinished atl then do
GT.asyncTaskLogIsError atl then do
handleErrorInAsyncTaskLog errors atl handleErrorInAsyncTaskLog errors atl
-- resetInterval intervalIdRef Nothing (pure unit) -- resetInterval intervalIdRef Nothing (pure unit)
onFinish unit onFinish unit
......
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