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
729b0a4b
Commit
729b0a4b
authored
Jan 02, 2024
by
Karen Konou
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into 548-dev-node-url-share
parents
d9358b74
c13a7aff
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
312 additions
and
90 deletions
+312
-90
package.json
package.json
+1
-1
Breadcrumb.purs
src/Gargantext/Components/Forest/Breadcrumb.purs
+28
-63
SearchField.purs
...omponents/Forest/Tree/Node/Action/Search/SearchField.purs
+98
-1
Types.purs
...text/Components/Forest/Tree/Node/Action/Search/Types.purs
+23
-1
Share.purs
src/Gargantext/Components/Forest/Tree/Node/Action/Share.purs
+4
-2
Search.purs
src/Gargantext/Components/GraphExplorer/Topbar/Search.purs
+2
-0
GraphQL.purs
src/Gargantext/Components/GraphQL.purs
+3
-1
Endpoints.purs
src/Gargantext/Components/GraphQL/Endpoints.purs
+20
-0
User.purs
src/Gargantext/Components/GraphQL/User.purs
+12
-0
InputWithAutocomplete.purs
src/Gargantext/Components/InputWithAutocomplete.purs
+16
-3
User.purs
src/Gargantext/Components/Nodes/Annuaire/User.purs
+103
-18
TopBar.purs
src/Gargantext/Components/PhyloExplorer/Topbar/TopBar.purs
+2
-0
No files found.
package.json
View file @
729b0a4b
{
"name"
:
"Gargantext"
,
"version"
:
"0.0.6.9.9.9.
3.2
"
,
"version"
:
"0.0.6.9.9.9.
4.4
"
,
"scripts"
:
{
"generate-purs-packages-nix"
:
"./nix/generate-purs-packages.nix"
,
"generate-psc-packages-nix"
:
"./nix/generate-packages-json.bash"
,
...
...
src/Gargantext/Components/Forest/Breadcrumb.purs
View file @
729b0a4b
...
...
@@ -6,6 +6,7 @@ import Control.Monad.Trans.Class
import Data.String (Pattern(..), split)
import Data.Array as A
import Data.Int (fromString)
import Data.List (head)
import Data.Map (Map)
import Data.Map as Map
import Data.Maybe (Maybe(..), fromMaybe)
...
...
@@ -254,6 +255,8 @@ breadcrumbItemCpt = here.component "breadcrumbItemCpt" cpt where
, disabled
} _ = do
url <- R.unsafeHooksEffect GU.href
let sid = sessionId session
let rootId = treeId session
...
...
@@ -275,7 +278,21 @@ breadcrumbItemCpt = here.component "breadcrumbItemCpt" cpt where
}
]
,
H.text props.text
if show nodeType == "NodeUser"
then
H.text $ getUserText url
else
H.text props.text
, H.span { className: "text-small" }
[
if show nodeType == "NodeUser"
then
H.text $ " (" <> getInstanceText url <> ")"
else
H.text ""
]
]
else
...
...
@@ -311,6 +328,16 @@ treeId (Session {treeId: tId}) = tId
getLastUrlElement :: String -> String
getLastUrlElement str = fromMaybe "" $ A.last $ split (Pattern "/") str
getFirstUrlElement :: String -> String
getFirstUrlElement str = fromMaybe "" $ A.head $ split (Pattern "/") str
getInstanceText :: String -> String
getInstanceText str = getFirstUrlElement $ fromMaybe "" $ A.last $ split (Pattern "@") str
getUserText :: String -> String
getUserText str = getLastUrlElement $ fromMaybe "" $ A.head $ split (Pattern "@") str
type LoadProps =
(
session :: Session
...
...
@@ -320,65 +347,3 @@ type LoadProps =
loadBreadcrumbData :: Record LoadProps -> AffRESTError BreadcrumbInfo
loadBreadcrumbData {nodeId, session} = getBreadcrumb session nodeId
-- type BreadcrumbProps = ( nodeId :: NodeID )
-- breadcrumbLayout :: R2.Leaf BreadcrumbProps
-- breadcrumbLayout = R2.leaf breadcrumbLayoutCpt
-- breadcrumbLayoutCpt :: R.Component BreadcrumbProps
-- breadcrumbLayoutCpt = here.component "breadcrumbLayout" cpt where
-- cpt props@{ nodeId } _ = do
-- session <- useSession
-- let
-- breadcrumbData = getBreadcrumb session nodeId
-- pure $
-- -- breadcrumb layout
-- H.div {}
-- [
-- H.nav
-- { className: "breadcrumb-wrapper bg-light"
-- , "aria-label": "breadcrumb" }
-- [
-- H.ol { className: "breadcrumb text-small" }
-- [
-- H.li { className: "breadcrumb-item" }
-- [
-- H.a { href: "/" }
-- [ H.span { className: "" }
-- [
-- B.icon { name: "home" }
-- ]
-- , H.text "Home"
-- ]
-- ]
-- ,
-- H.li { className: "breadcrumb-item" }
-- [
-- H.a { href: "/" }
-- [ H.span { className: "" }
-- [
-- B.icon { name: "folder-open-o" }
-- ]
-- , H.text "parent folder"
-- ]
-- ]
-- ,
-- H.li { className: "breadcrumb-item" }
-- [ H.span { className: "active-page" }
-- [ H.span { className: "" }
-- [
-- B.icon { name: "book" }
-- ]
-- , H.text "current node"
-- ]
-- ]
-- ]
-- ]
-- ]
src/Gargantext/Components/Forest/Tree/Node/Action/Search/SearchField.purs
View file @
729b0a4b
...
...
@@ -42,6 +42,8 @@ defaultSearch :: Search
defaultSearch = { databases : Empty
, datafield : Just (External Empty)
, node_id : Nothing
, epoApiUser : Nothing
, epoApiToken : Nothing
, pubmedApiKey : Nothing
, lang : Nothing
, term : ""
...
...
@@ -226,6 +228,12 @@ isPubmed ( Just
) = true
isPubmed _ = false
isEPO :: Maybe DataField -> Boolean
isEPO ( Just
( External EPO )
) = true
isEPO _ = false
needsLang :: Maybe DataField -> Boolean
needsLang (Just Gargantext) = true
needsLang (Just Web) = true
...
...
@@ -394,7 +402,7 @@ pubmedInputCpt = here.component "pubmedInput" cpt where
, render: \user -> pubmedInputLoaded { pubmedAPIKey: user.u_hyperdata.pubmed_api_key
, search } [] }
where
errorHandler = logRESTError here "[
componentIMT
]"
errorHandler = logRESTError here "[
pubmedInput
]"
type PubmedInputLoadedProps = (
...
...
@@ -431,6 +439,74 @@ pubmedInputLoadedCpt = here.component "pubmedInputLoaded" cpt where
s { pubmedApiKey = mVal }) search
type EPOInputProps = (
search :: T.Box Search
, session :: Session
)
epoInput :: R2.Component EPOInputProps
epoInput = R.createElement epoInputCpt
epoInputCpt :: R.Component EPOInputProps
epoInputCpt = here.component "epoInput" cpt where
cpt { search, session: session@(Session { treeId }) } _ = do
useLoader { errorHandler
, loader: \_ -> getUser session treeId
, path: unit
, render: \user -> epoInputLoaded { epoAPIUser: user.u_hyperdata.epo_api_user
, epoAPIToken: user.u_hyperdata.epo_api_token
, search } [] }
where
errorHandler = logRESTError here "[epoInput]"
type EPOInputLoadedProps = (
epoAPIUser :: Maybe String
, epoAPIToken :: Maybe String
, search :: T.Box Search
)
epoInputLoaded :: R2.Component EPOInputLoadedProps
epoInputLoaded = R.createElement epoInputLoadedCpt
epoInputLoadedCpt :: R.Component EPOInputLoadedProps
epoInputLoadedCpt = here.component "epoInputLoaded" cpt where
cpt { epoAPIUser, epoAPIToken, search } _ = do
search' <- T.useLive T.unequal search
R.useEffectOnce' $ do
when (search'.epoApiUser /= epoAPIUser || search'.epoApiToken /= epoAPIToken) $ do
T.write_ (search' { epoApiUser = epoAPIUser
, epoApiToken = epoAPIToken }) search
pure $
H.div { className: "form-group p-1 m-0" }
[ H.div { className: "text-primary center" } [ H.text "EPO API User" ]
, H.input { className: "form-control"
, defaultValue: fromMaybe "" search'.epoApiUser
, on: { blur: modifyEPOAPIUser search
, change: modifyEPOAPIUser search
, input: modifyEPOAPIUser search } }
, H.div { className: "text-primary center" } [ H.text "EPO API Token" ]
, H.input { className: "form-control"
, defaultValue: fromMaybe "" search'.epoApiToken
, on: { blur: modifyEPOAPIToken search
, change: modifyEPOAPIToken search
, input: modifyEPOAPIToken search } } ]
where
modifyEPOAPIUser search e = do
let val = R.unsafeEventValue e
let mVal = case val of
"" -> Nothing
s -> Just s
T.modify_ (\s -> s { epoApiUser = mVal }) search
modifyEPOAPIToken search e = do
let val = R.unsafeEventValue e
let mVal = case val of
"" -> Nothing
s -> Just s
T.modify_ (\s -> s { epoApiToken = mVal }) search
type OrgInputProps =
( orgs :: Array Org
| ComponentProps)
...
...
@@ -499,6 +575,10 @@ datafieldInputCpt = here.component "datafieldInput" cpt where
then pubmedInput { search, session } []
else H.div {} []
, if isEPO search'.datafield
then epoInput { search, session } []
else H.div {} []
, if isHAL search'.datafield
then orgInput { orgs: allOrgs, search } []
else H.div {} []
...
...
@@ -673,6 +753,23 @@ searchQuery selection { databases
, query = queryHAL term (Just imtOrgs) lang years
, selection = selection
}) defaultSearchQuery
searchQuery selection { databases
, datafield: datafield@(Just (External EPO))
, lang
, epoApiUser
, epoApiToken
, node_id
, term
, years } =
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
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Search/Types.purs
View file @
729b0a4b
...
...
@@ -29,6 +29,8 @@ type Search = { databases :: Database
, url :: String
, lang :: Maybe Lang
, node_id :: Maybe Int
, epoApiUser :: Maybe String
, epoApiToken :: Maybe String
, pubmedApiKey :: Maybe String
, term :: String
, years :: Array String
...
...
@@ -110,6 +112,7 @@ data Database = All_Databases
| IsTex
| IsTex_Advanced
| Isidore
| EPO
-- | News
-- | SocialNetworks
derive instance Generic Database _
...
...
@@ -125,6 +128,7 @@ instance Show Database where
show IsTex = "IsTex"
show IsTex_Advanced = "IsTex_Advanced"
show Isidore = "Isidore"
show EPO = "EPO"
show Empty = "Empty"
-- show News = "News"
-- show SocialNetworks = "Social Networks"
...
...
@@ -138,6 +142,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 Empty = "Empty"
-- doc News = "Web filtered by News"
-- doc SocialNetworks = "Web filtered by MicroBlogs"
...
...
@@ -167,6 +172,7 @@ allDatabases = [ Empty
, Arxiv
, OpenAlex
, IsTex
-- , EPO
--, IsTex_Advanced
--, Isidore
--, Web
...
...
@@ -183,6 +189,7 @@ dbToInputValue (HAL _) = "hal"
dbToInputValue IsTex = "istex"
dbToInputValue IsTex_Advanced = "istex_advanced"
dbToInputValue Isidore = "isidore"
dbToInputValue EPO = "epo"
dbToInputValue Empty = "empty"
dbFromInputValue :: String -> Maybe Database
...
...
@@ -194,6 +201,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 "empty" = Just Empty
dbFromInputValue _ = Nothing
...
...
@@ -274,6 +282,8 @@ newtype SearchQuery = SearchQuery
, node_id :: Maybe Int
, offset :: Maybe Int
, order :: Maybe SearchOrder
, epoAPIUser :: Maybe String
, epoAPIToken :: Maybe String
, pubmedAPIKey :: Maybe String
, selection :: ListSelection.Selection
}
...
...
@@ -292,13 +302,23 @@ instance GT.ToQuery SearchQuery where
pair k = maybe [] $ \v ->
[ QP.keyFromString k /\ Just (QP.valueFromString $ show v) ]
instance JSON.WriteForeign SearchQuery where
writeImpl (SearchQuery { databases, datafield, lang, node_id, pubmedAPIKey, query, selection }) =
writeImpl (SearchQuery { databases
, datafield
, lang
, node_id
, epoAPIUser
, epoAPIToken
, pubmedAPIKey
, query
, selection }) =
JSON.writeImpl { query: query -- String.replace (String.Pattern "\"") (String.Replacement "\\\"") query
, databases
, datafield
, lang: maybe "EN" show lang
, node_id: fromMaybe 0 node_id
, flowListWith: selection
, epoAPIUser
, epoAPIToken
, pubmedAPIKey
}
...
...
@@ -313,6 +333,8 @@ defaultSearchQuery = SearchQuery
, node_id : Nothing
, offset : Nothing
, order : Nothing
, epoAPIUser : Nothing
, epoAPIToken : Nothing
, pubmedAPIKey : Nothing
, selection : ListSelection.NoList -- MyListsFirst
}
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Share.purs
View file @
729b0a4b
...
...
@@ -6,7 +6,7 @@ import Data.Array (filter, nub)
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..))
import Data.Show.Generic (genericShow)
import Data.String (Pattern(..), contains)
import Data.String (Pattern(..), contains
, trim
)
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff)
import Gargantext.Components.Forest.Tree.Node.Action.Types (Action)
...
...
@@ -41,7 +41,7 @@ getCompletionsReq { session } =
get session GR.Members
shareAction :: String -> Action
shareAction username = Action.ShareTeam
username
shareAction username = Action.ShareTeam
(trim username)
------------------------------------------------------------------------
...
...
@@ -100,6 +100,8 @@ shareNodeInnerCpt = here.component "shareNodeInner" cpt
, autocompleteSearch
, onAutocompleteClick
, text
, pattern: "^\\S+$" -- pattern doesn't allow space characters
, title: "Enter a username or an email address (space characters are not allowed)"
, placeholder: "username or email"}
] (H.div {} [H.text text'])
where
...
...
src/Gargantext/Components/GraphExplorer/Topbar/Search.purs
View file @
729b0a4b
...
...
@@ -66,6 +66,8 @@ nodeSearchControlCpt = here.component "nodeSearchControl" cpt
, onEnterPress: doSearch
, classes: "filter-results-completions rounded-circle-2 text-small py-0"
, state: search
, pattern: ".*"
, title: ""
, placeholder: "find and select a term here..."
}
,
...
...
src/Gargantext/Components/GraphQL.purs
View file @
729b0a4b
...
...
@@ -16,7 +16,7 @@ import Gargantext.Components.GraphQL.IMT as GQLIMT
import Gargantext.Components.GraphQL.NLP as GQLNLP
import Gargantext.Components.GraphQL.Node as GQLNode
import Gargantext.Components.GraphQL.Tree (TreeFirstLevel, BreadcrumbInfo)
import Gargantext.Components.GraphQL.User (User, UserInfo, UserInfoM, UserPubmedAPIKeyM)
import Gargantext.Components.GraphQL.User (User, UserInfo, UserInfoM, UserPubmedAPIKeyM
, UserEPOAPIUserM, UserEPOAPITokenM
)
import Gargantext.Components.GraphQL.Team (Team, TeamDeleteM)
import Gargantext.Ends (Backend(..))
import Gargantext.Sessions (Session(..))
...
...
@@ -92,5 +92,7 @@ type Schema
type Mutation
= { update_user_info :: UserInfoM ==> Int
, update_user_pubmed_api_key :: UserPubmedAPIKeyM ==> Int
, update_user_epo_api_user :: UserEPOAPIUserM ==> Int
, update_user_epo_api_token :: UserEPOAPITokenM ==> Int
, delete_team_membership :: TeamDeleteM ==> Array Int
, update_node_context_category :: GQLCTX.NodeContextCategoryM ==> Array Int }
src/Gargantext/Components/GraphQL/Endpoints.purs
View file @
729b0a4b
...
...
@@ -81,6 +81,26 @@ updateUserPubmedAPIKey session user_id api_key = do
{ update_user_pubmed_api_key: onlyArgs { user_id
, api_key } }
pure $ Right unit
updateUserEPOAPIUser :: Session -> Int -> String -> AffRESTError Unit
updateUserEPOAPIUser session user_id api_user = do
client <- liftEffect $ getClient session
{ update_user_epo_api_user } <- mutation
client
"update_user_epo_api_user"
{ update_user_epo_api_user: onlyArgs { user_id
, api_user } }
pure $ Right unit
updateUserEPOAPIToken :: Session -> Int -> String -> AffRESTError Unit
updateUserEPOAPIToken session user_id api_token = do
client <- liftEffect $ getClient session
{ update_user_epo_api_token } <- mutation
client
"update_user_epo_api_token"
{ update_user_epo_api_token: onlyArgs { user_id
, api_token } }
pure $ Right unit
getUserInfo :: Session -> Int -> AffRESTError UserInfo
getUserInfo session id = do
...
...
src/Gargantext/Components/GraphQL/User.purs
View file @
729b0a4b
...
...
@@ -148,6 +148,8 @@ type User
{ organization :: Array String }
}
, pubmed_api_key :: Maybe String
, epo_api_user :: Maybe String
, epo_api_token :: Maybe String
}
, u_username :: String
, u_email :: String
...
...
@@ -172,6 +174,8 @@ userQuery = { users: { user_id: Var :: _ "id" Int } =>>
, "where": { organization: unit }
}
, pubmed_api_key: unit
, epo_api_user: unit
, epo_api_token: unit
}
, u_username: unit
, u_email: unit
...
...
@@ -182,3 +186,11 @@ userQuery = { users: { user_id: Var :: _ "id" Int } =>>
type UserPubmedAPIKeyM =
{ user_id :: Int
, api_key :: String }
type UserEPOAPIUserM =
{ user_id :: Int
, api_user :: String }
type UserEPOAPITokenM =
{ user_id :: Int
, api_token :: String }
src/Gargantext/Components/InputWithAutocomplete.purs
View file @
729b0a4b
...
...
@@ -7,6 +7,7 @@ import DOM.Simple as DOM
import DOM.Simple.Event as DE
import Data.Maybe (Maybe(..), maybe)
import Data.Nullable (Nullable, null, toMaybe)
import Data.String as S
import Effect (Effect)
import Effect.Aff (Aff, launchAff_)
import FFI.Simple ((..))
...
...
@@ -31,6 +32,8 @@ type Props =
, onAutocompleteClick :: String -> Effect Unit
, onEnterPress :: String -> Effect Unit
, placeholder :: String
, pattern :: String
, title :: String
, state :: T.Box String
)
...
...
@@ -44,6 +47,8 @@ inputWithAutocompleteCpt = here.component "inputWithAutocomplete" cpt
, onAutocompleteClick
, onEnterPress
, placeholder
, pattern
, title
, state } _ = do
-- States
state' <- T.useLive T.unequal state
...
...
@@ -68,6 +73,8 @@ inputWithAutocompleteCpt = here.component "inputWithAutocomplete" cpt
, ref: inputRef
, className: "form-control"
, value: state'
, pattern: pattern
, title: title
, placeholder
, on: { focus: onFocus completions state'
, input: onInput completions
...
...
@@ -114,7 +121,7 @@ inputWithAutocompleteCpt = here.component "inputWithAutocomplete" cpt
onInput :: forall event. T.Box Completions -> event -> Effect Unit
onInput completions e = do
let val = R.unsafeEventValue e
let val =
S.trim $
R.unsafeEventValue e
T.write_ val state
cs <- autocompleteSearch val
T.write_ cs completions
...
...
@@ -145,6 +152,8 @@ type Props' =
, boxAction :: String -> Action
, state :: T.Box String
, text :: T.Box String
, pattern :: String
, title :: String
, placeholder :: String
)
...
...
@@ -160,6 +169,8 @@ inputWithAutocompleteCpt' = here.component "inputWithAutocomplete" cpt
, boxAction
, state
, text
, pattern
, title
, placeholder } _ = do
-- States
state' <- T.useLive T.unequal state
...
...
@@ -184,6 +195,8 @@ inputWithAutocompleteCpt' = here.component "inputWithAutocomplete" cpt
, ref: inputRef
, className: "form-control"
, value: state'
, pattern: pattern
, title: title
, placeholder
, on: { focus: onFocus completions state'
, input: onInput completions
...
...
@@ -246,7 +259,7 @@ inputWithAutocompleteCpt' = here.component "inputWithAutocomplete" cpt
if DE.key e == "Enter" then do
R2.preventDefault e
R2.stopPropagation e
let val = R.unsafeEventValue e
let val =
S.trim $
R.unsafeEventValue e
let mInput = toMaybe $ R.readRef inputRef
T.write_ val state
launchAff_ $ dispatch (boxAction val)
...
...
@@ -260,7 +273,7 @@ inputWithAutocompleteCpt' = here.component "inputWithAutocomplete" cpt
pure $ false
submit val _ = do
T.write_ ("Invited " <> val <> " to the team") text
T.write_ ("Invited " <>
S.trim
val <> " to the team") text
launchAff_ $ dispatch (boxAction val)
---------------------------------------------------------
...
...
src/Gargantext/Components/Nodes/Annuaire/User.purs
View file @
729b0a4b
...
...
@@ -15,7 +15,7 @@ import Effect.Aff (launchAff_)
import Effect.Class (liftEffect)
import Gargantext.Components.App.Store (Boxes)
import Gargantext.Components.GraphQL (getClient)
import Gargantext.Components.GraphQL.Endpoints (getUserInfo, getUser, updateUserPubmedAPIKey)
import Gargantext.Components.GraphQL.Endpoints (getUserInfo, getUser, updateUserPubmedAPIKey
, updateUserEPOAPIUser, updateUserEPOAPIToken
)
import Gargantext.Components.GraphQL.User (UserInfo, _ui_cwCity, _ui_cwCountry, _ui_cwFirstName, _ui_cwLabTeamDeptsFirst, _ui_cwLastName, _ui_cwOffice, _ui_cwOrganizationFirst, _ui_cwRole, _ui_cwTouchMail, _ui_cwTouchPhone, _ui_cwDescription)
import Gargantext.Components.InputWithEnter (inputWithEnter)
import Gargantext.Components.Nodes.Annuaire.Tabs as Tabs
...
...
@@ -114,6 +114,7 @@ userLayoutWithKeyCpt = here.component "userLayoutWithKey" cpt where
display { title: fromMaybe "no name" (Just ui_username) }
(contactInfos userInfo (onUpdateUserInfo boxes.errors reload))
, pubmedSettings { boxes, nodeId, session }
, epoSettings { boxes, nodeId, session }
-- , Tabs.tabs {
-- boxes
-- , cacheState
...
...
@@ -185,7 +186,7 @@ pubmedSettingsLoaded :: R2.Leaf PubmedSettingsLoadedProps
pubmedSettingsLoaded = R2.leaf pubmedSettingsLoadedCpt
pubmedSettingsLoadedCpt :: R.Component PubmedSettingsLoadedProps
pubmedSettingsLoadedCpt = here.component "pubmedSettingsLoaded" cpt where
cpt { boxes
: { errors }
cpt { boxes
, nodeId
, mPubmedAPIKey
, session } _ = do
...
...
@@ -197,26 +198,110 @@ pubmedSettingsLoadedCpt = here.component "pubmedSettingsLoaded" cpt where
[ R2.col 12
[ R2.row
[ H.h2 {} [ H.text "PubMed settings" ] ]
, H.div { className: "form-group row"}
[ H.span { className: "col-sm-2 col-form-label" } [ H.text "API Key" ]
, H.div { className: "input-group col-sm-6"}
[ itemEditable { defaultVal: ""
, isEditing
, onUpdate: \s -> do
here.log2 "[pubmedSettingsLoaded] new api key" s
case s of
"" -> pure unit
_ -> do
launchAff_ $ do
res <- updateUserPubmedAPIKey session nodeId s
handleRESTError here errors res $ \_result ->
liftEffect $ here.log "[pubmedSettingsLoaded] api key updated"
, valueBox: box }]
]
, editableUserField { boxes
, callback: updateUserPubmedAPIKey session nodeId
, description: "API Key"
, mValue: mPubmedAPIKey }
]
]
]
------------------------------------------------------------
type EPOSettingsProps =
( boxes :: Boxes
, nodeId :: CorpusId
, session :: Session )
epoSettings :: R2.Leaf EPOSettingsProps
epoSettings = R2.leaf epoSettingsCpt
epoSettingsCpt :: R.Component EPOSettingsProps
epoSettingsCpt = here.component "epoSettings" cpt where
cpt { boxes
, nodeId
, session } _ = do
useLoader { errorHandler
, loader: \_ -> getUser session nodeId
, path: unit
, render: \user -> epoSettingsLoaded { boxes
, nodeId
, mEPOAPIUser: user.u_hyperdata.epo_api_user
, mEPOAPIToken: user.u_hyperdata.epo_api_token
, session } }
where
errorHandler = logRESTError here "[epoSettings]"
type EPOSettingsLoadedProps =
( mEPOAPIUser :: Maybe String
, mEPOAPIToken :: Maybe String
| EPOSettingsProps )
epoSettingsLoaded :: R2.Leaf EPOSettingsLoadedProps
epoSettingsLoaded = R2.leaf epoSettingsLoadedCpt
epoSettingsLoadedCpt :: R.Component EPOSettingsLoadedProps
epoSettingsLoadedCpt = here.component "epoSettingsLoaded" cpt where
cpt { boxes
, nodeId
, mEPOAPIUser
, mEPOAPIToken
, session } _ = do
pure $ R2.row
[ R2.col 12
[ R2.col 12
[ R2.row
[ H.h2 {} [ H.text "EPO settings" ] ]
, editableUserField { boxes
, callback: updateUserEPOAPIUser session nodeId
, description: "API User"
, mValue: mEPOAPIUser }
, editableUserField { boxes
, callback: updateUserEPOAPIToken session nodeId
, description: "API Token"
, mValue: mEPOAPIToken }
]
]
]
------------------------------------------------------------
type EditableUserField =
( boxes :: Boxes
, callback :: String -> AffRESTError Unit
, description :: String
, mValue :: Maybe String )
editableUserField :: R2.Leaf EditableUserField
editableUserField = R2.leaf editableUserFieldCpt
editableUserFieldCpt :: R.Component EditableUserField
editableUserFieldCpt = here.component "editableUserField" cpt where
cpt { boxes: { errors }
, callback
, description
, mValue } _ = do
box <- T.useBox $ fromMaybe "" mValue
isEditing <- T.useBox false
pure $ H.div { className: "form-group row"}
[ H.span { className: "col-sm-2 col-form-label" } [ H.text description ]
, H.div { className: "input-group col-sm-6"}
[ itemEditable { defaultVal: ""
, isEditing
, onUpdate: \s -> do
here.log2 ("[editableUserField] " <> description) s
case s of
"" -> pure unit
_ -> do
launchAff_ $ do
res <- callback s
handleRESTError here errors res $ \_result ->
liftEffect $ here.log ("[editableUserField] " <> description <> " updated")
, valueBox: box }]
]
------------------------------------------------------------
-- | TODO format data in better design (UI) shape
contactInfos :: UserInfo -> (UserInfo -> Effect Unit) -> Array R.Element
contactInfos userInfo onUpdateUserInfo = item <$> contactInfoItems where
...
...
src/Gargantext/Components/PhyloExplorer/Topbar/TopBar.purs
View file @
729b0a4b
...
...
@@ -147,6 +147,8 @@ component = here.component "main" cpt where
Nothing -> pure unit
Just h -> autocompleteClickCallback h
, classes: "filter-results-completions rounded-circle-2 text-small py-0"
, pattern: ".*"
, title: ""
, placeholder: "find and select a term here..."
, state: searchState
}
...
...
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