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
143
Issues
143
List
Board
Labels
Milestones
Merge Requests
8
Merge Requests
8
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
gargantext
purescript-gargantext
Commits
ea934d83
Verified
Commit
ea934d83
authored
Jan 14, 2025
by
Przemyslaw Kaminski
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[search] move EPO user/token into the datafield
parent
b01a85eb
Pipeline
#7210
passed with stages
in 19 minutes and 12 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
57 deletions
+27
-57
SearchField.purs
...omponents/Forest/Tree/Node/Action/Search/SearchField.purs
+15
-48
Types.purs
...text/Components/Forest/Tree/Node/Action/Search/Types.purs
+12
-9
No files found.
src/Gargantext/Components/Forest/Tree/Node/Action/Search/SearchField.purs
View file @
ea934d83
...
...
@@ -38,8 +38,6 @@ defaultSearch :: Search
defaultSearch =
{ datafield: External Empty
, node_id: Nothing
, epoApiUser: Nothing
, epoApiToken: Nothing
, lang: Nothing
, term: ""
, url: ""
...
...
@@ -243,7 +241,7 @@ getPubmedAPIKey (External (PubMed mAPI)) = mAPI
getPubmedAPIKey _ = Nothing
isEPO :: DataField -> Boolean
isEPO (External
EPO
) = true
isEPO (External
(EPO _ _)
) = true
isEPO _ = false
needsLang :: DataField -> Boolean
...
...
@@ -513,6 +511,14 @@ type EPOInputLoadedProps =
, 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 = R.createElement epoInputLoadedCpt
...
...
@@ -523,11 +529,10 @@ epoInputLoadedCpt = here.component "epoInputLoaded" cpt
search' <- T.useLive T.unequal search
R.useEffectOnce' $ do
when (search
'.epoApiUser /= epoAPIUser || search'.epoApiToken
/= epoAPIToken) $ do
when (search
EPOAPIUser search' /= epoAPIUser || searchEPOAPIToken search'
/= epoAPIToken) $ do
T.write_
( search'
{ epoApiUser = epoAPIUser
, epoApiToken = epoAPIToken
{ datafield = External (EPO epoAPIUser epoAPIToken)
}
)
search
...
...
@@ -537,7 +542,7 @@ epoInputLoadedCpt = here.component "epoInputLoaded" cpt
[ H.div { className: "text-primary center" } [ H.text "EPO API User" ]
, H.input
{ className: "form-control"
, defaultValue: fromMaybe ""
search'.epoApiUser
, defaultValue: fromMaybe ""
$ searchEPOAPIUser search'
, on:
{ blur: modifyEPOAPIUser search
, change: modifyEPOAPIUser search
...
...
@@ -547,7 +552,7 @@ epoInputLoadedCpt = here.component "epoInputLoaded" cpt
, H.div { className: "text-primary center" } [ H.text "EPO API Token" ]
, H.input
{ className: "form-control"
, defaultValue: fromMaybe ""
search'.epoApiToken
, defaultValue: fromMaybe ""
$ searchEPOAPIToken search'
, on:
{ blur: modifyEPOAPIToken search
, change: modifyEPOAPIToken search
...
...
@@ -562,7 +567,7 @@ epoInputLoadedCpt = here.component "epoInputLoaded" cpt
mVal = case val of
"" -> Nothing
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
let val = R.unsafeEventValue e
...
...
@@ -570,7 +575,7 @@ epoInputLoadedCpt = here.component "epoInputLoaded" cpt
mVal = case val of
"" -> Nothing
s -> Just s
T.modify_ (\s -> s {
epoApiToken = mVal
}) searchS
T.modify_ (\s -> s {
datafield = External (EPO (searchEPOAPIUser s) mVal)
}) searchS
type OrgInputProps =
( orgs :: Array Org
...
...
@@ -832,44 +837,6 @@ searchQuery
}
)
defaultSearchQuery
searchQuery
selection
{ datafield: datafield@(External EPO)
, lang
, epoApiUser
, epoApiToken
, node_id
, term
} =
over SearchQuery
( _
{ datafield = datafield
, lang = lang
, node_id = node_id
, epoAPIUser = epoApiUser
, epoAPIToken = epoApiToken
, query = term
, selection = selection
}
)
defaultSearchQuery
searchQuery
selection
{ datafield: datafield@(External (PubMed mAPIKey))
, lang
, node_id
, term
} =
over SearchQuery
( _
{ datafield = datafield
, lang = lang
, node_id = node_id
, query = term
, selection = selection
}
)
defaultSearchQuery
searchQuery selection { datafield, lang, term, node_id } =
over SearchQuery
( _
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Search/Types.purs
View file @
ea934d83
...
...
@@ -31,8 +31,6 @@ type Search =
, url :: String
, lang :: Maybe Lang
, node_id :: Maybe Int
, epoApiUser :: Maybe String
, epoApiToken :: Maybe String
, term :: String
, years :: Array String
}
...
...
@@ -118,7 +116,7 @@ data Database
| IsTex
| IsTex_Advanced
| Isidore
| EPO
| EPO
(Maybe String) (Maybe String)
-- | News
-- | SocialNetworks
...
...
@@ -135,7 +133,7 @@ instance Show Database where
show IsTex = "IsTex"
show IsTex_Advanced = "IsTex_Advanced"
show Isidore = "Isidore"
show
EPO
= "EPO"
show
(EPO _ _)
= "EPO"
show Empty = "Empty"
-- show News = "News"
...
...
@@ -150,7 +148,7 @@ instance Doc Database where
doc IsTex = "All Elsevier enriched by CNRS/INIST"
doc IsTex_Advanced = "IsTex advanced search"
doc Isidore = "All (French) Social Sciences"
doc
EPO
= "European Patent Office"
doc
(EPO _ _)
= "European Patent Office"
doc Empty = "Empty"
-- doc News = "Web filtered by News"
...
...
@@ -173,6 +171,11 @@ instance Doc Database where
derive instance Eq Database
instance JSON.WriteForeign Database where
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 }
...
...
@@ -184,7 +187,7 @@ allDatabases =
, Arxiv
, OpenAlex
, IsTex
-- , EPO
-- , EPO
Nothing Nothing
--, IsTex_Advanced
--, Isidore
--, Web
...
...
@@ -201,7 +204,7 @@ dbToInputValue (HAL _) = "hal"
dbToInputValue IsTex = "istex"
dbToInputValue IsTex_Advanced = "istex_advanced"
dbToInputValue Isidore = "isidore"
dbToInputValue
EPO
= "epo"
dbToInputValue
(EPO _ _)
= "epo"
dbToInputValue Empty = "empty"
dbFromInputValue :: String -> Maybe Database
...
...
@@ -213,7 +216,7 @@ dbFromInputValue "hal" = Just (HAL Nothing)
dbFromInputValue "istex" = Just IsTex
dbFromInputValue "istex_advanced" = Just IsTex_Advanced
dbFromInputValue "isidore" = Just Isidore
dbFromInputValue "epo" = Just
EPO
dbFromInputValue "epo" = Just
(EPO Nothing Nothing)
dbFromInputValue "empty" = Just Empty
dbFromInputValue _ = Nothing
...
...
@@ -252,7 +255,7 @@ instance Read Org where
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).
)
-- | SearchField (queryHAL function).
instance JSON.WriteForeign Org where
writeImpl = JSON.writeImpl <<< show
...
...
Przemyslaw Kaminski
@cgenie
mentioned in commit
c010d97a
·
Jan 30, 2025
mentioned in commit
c010d97a
mentioned in commit c010d97ad517cab5d8a6c43ceeaeb4769082ebed
Toggle commit list
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