[search] pubmed constructor with api key

parent 282dafcd
Pipeline #7191 passed with stages
in 20 minutes and 22 seconds
......@@ -41,7 +41,6 @@ defaultSearch =
, node_id: Nothing
, epoApiUser: Nothing
, epoApiToken: Nothing
, pubmedApiKey: Nothing
, lang: Nothing
, term: ""
, url: ""
......@@ -252,10 +251,14 @@ isCNRS _ = false
isPubmed :: Maybe DataField -> Boolean
isPubmed
( Just
(External PubMed)
(External (PubMed _))
) = true
isPubmed _ = false
getPubmedAPIKey :: Maybe DataField -> Maybe String
getPubmedAPIKey (Just (External (PubMed mAPI))) = mAPI
getPubmedAPIKey _ = Nothing
isEPO :: Maybe DataField -> Boolean
isEPO
( Just
......@@ -477,15 +480,16 @@ pubmedInputLoadedCpt = here.component "pubmedInputLoaded" cpt
search' <- T.useLive T.unequal search
R.useEffectOnce' $ do
when (search'.pubmedApiKey /= pubmedAPIKey) $ do
T.write_ (search' { pubmedApiKey = pubmedAPIKey }) search
when (getPubmedAPIKey search'.datafield /= pubmedAPIKey) $ do
T.modify_ (\s -> s { datafield = Just $ External $ PubMed pubmedAPIKey }) search
-- T.write_ (search' { pubmedApiKey = pubmedAPIKey }) search
pure $
H.div { className: "form-group p-1 m-0" }
[ H.div { className: "text-primary center" } [ H.text "Pubmed API key" ]
, H.input
{ className: "form-control"
, defaultValue: fromMaybe "" search'.pubmedApiKey
, defaultValue: fromMaybe "" pubmedAPIKey
, on:
{ blur: modifyPubmedAPIKey search
, change: modifyPubmedAPIKey search
......@@ -502,7 +506,7 @@ pubmedInputLoadedCpt = here.component "pubmedInputLoaded" cpt
s -> Just s
T.modify_
( \s ->
s { pubmedApiKey = mVal }
s { datafield = Just $ External $ PubMed mVal }
)
searchS
......@@ -894,9 +898,8 @@ searchQuery
searchQuery
selection
{ databases
, datafield: datafield@(Just (External PubMed))
, datafield: datafield@(Just (External (PubMed mAPIKey)))
, lang
, pubmedApiKey
, node_id
, term
} =
......@@ -906,7 +909,7 @@ searchQuery
, datafield = datafield
, lang = lang
, node_id = node_id
, pubmedAPIKey = pubmedApiKey
, pubmedAPIKey = mAPIKey
, query = term
, selection = selection
}
......
......@@ -33,7 +33,6 @@ type Search =
, node_id :: Maybe Int
, epoApiUser :: Maybe String
, epoApiToken :: Maybe String
, pubmedApiKey :: Maybe String
, term :: String
, years :: Array String
}
......@@ -116,7 +115,7 @@ data Database
= All_Databases
| Empty
| OpenAlex
| PubMed
| PubMed (Maybe String)
| Arxiv
| HAL (Maybe Org)
| IsTex
......@@ -133,7 +132,7 @@ derive instance Generic Database _
instance Show Database where
show All_Databases = "All Databases"
show OpenAlex = "OpenAlex"
show PubMed = "PubMed"
show (PubMed _) = "PubMed"
show Arxiv = "Arxiv"
show (HAL _) = "HAL"
show IsTex = "IsTex"
......@@ -148,7 +147,7 @@ instance Show Database where
instance Doc Database where
doc All_Databases = "All databases"
doc OpenAlex = "OpenAlex db"
doc PubMed = "All Medical publications"
doc (PubMed _) = "All Medical publications"
doc Arxiv = "Arxiv"
doc (HAL _) = "All open science (archives ouvertes)"
doc IsTex = "All Elsevier enriched by CNRS/INIST"
......@@ -181,7 +180,7 @@ instance JSON.WriteForeign Database where
allDatabases :: Array Database
allDatabases =
[ Empty
, PubMed
, PubMed Nothing
, HAL Nothing
, Arxiv
, OpenAlex
......@@ -197,7 +196,7 @@ allDatabases =
dbToInputValue :: Database -> String
dbToInputValue All_Databases = "all_databases"
dbToInputValue OpenAlex = "openalex"
dbToInputValue PubMed = "pubmed"
dbToInputValue (PubMed _) = "pubmed"
dbToInputValue Arxiv = "arxiv"
dbToInputValue (HAL _) = "hal"
dbToInputValue IsTex = "istex"
......@@ -209,7 +208,7 @@ dbToInputValue Empty = "empty"
dbFromInputValue :: String -> Maybe Database
dbFromInputValue "all_databases" = Just All_Databases
dbFromInputValue "openalex" = Just OpenAlex
dbFromInputValue "pubmed" = Just PubMed
dbFromInputValue "pubmed" = Just (PubMed Nothing)
dbFromInputValue "arxiv" = Just Arxiv
dbFromInputValue "hal" = Just (HAL Nothing)
dbFromInputValue "istex" = Just IsTex
......
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