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
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
7aa76f18
Commit
7aa76f18
authored
5 years ago
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FOREST][SEARCH] fix types for search with datafield.
parent
360cb569
No related merge requests found
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
107 additions
and
138 deletions
+107
-138
Box.purs
src/Gargantext/Components/Forest/Tree/Node/Box.purs
+1
-1
SearchBar.purs
src/Gargantext/Components/Search/SearchBar.purs
+7
-14
SearchField.purs
src/Gargantext/Components/Search/SearchField.purs
+68
-69
Types.purs
src/Gargantext/Components/Search/Types.purs
+31
-54
No files found.
src/Gargantext/Components/Forest/Tree/Node/Box.purs
View file @
7aa76f18
...
...
@@ -318,7 +318,7 @@ panelAction d {id,name,nodeType,action, session} p = case action of
(Just Download) -> R.fragment [ H.p {} [H.text $ "Soon, you will be able to dowload your file here"]]
(Just SearchBox) -> R.fragment [ H.p {} [ H.text $ "Search and create a private corpus with the search query as corpus name." ]
, searchBar {session, data
bases:allDatabases
, langs:allLangs, node_id: (Just id)}
, searchBar {session, data
field:Nothing
, langs:allLangs, node_id: (Just id)}
]
(Just Delete) -> case nodeType of
NodeUser -> R.fragment [ H.div {} [H.text "Yes, we are RGPD compliant! But you can not delete User Node yet (we are still on development). Thanks for your comprehensin."]]
...
...
This diff is collapsed.
Click to expand it.
src/Gargantext/Components/Search/SearchBar.purs
View file @
7aa76f18
...
...
@@ -21,7 +21,7 @@ import Gargantext.Components.Search.SearchField (Search, searchField)
import Gargantext.Sessions (Session)
type Props = ( session :: Session
, data
bases :: Array Database
, data
field :: Maybe DataField
, langs :: Array Lang
, node_id :: Maybe Int
)
...
...
@@ -32,10 +32,10 @@ searchBar props = R.createElement searchBarCpt props []
searchBarCpt :: R.Component Props
searchBarCpt = R.hooksComponent "G.C.Node.SearchBar.searchBar" cpt
where
cpt {session, data
bases
, langs, node_id} _ = do
cpt {session, data
field
, langs, node_id} _ = do
search <- R.useState' Nothing
onSearchChange session search
pure $ H.div {} [ searchField {databases, langs, search, node_id}]
pure $ H.div {} [ searchField {databases
:allDatabases
, langs, search, node_id}]
onSearchChange :: Session -> R.State (Maybe Search) -> R.Hooks Unit
...
...
@@ -46,9 +46,8 @@ onSearchChange session (search /\ setSearch) =
launchAff_ $ do
liftEffect $ do
log2 "Searching db
: " $ show q.database
-- log2 "Searching datafield
: " $ show q.database
log2 "Searching term: " q.term
log2 "Searching filters: " q.filters
log2 "Searching lang: " q.lang
r <- (performSearch session $ searchQuery q) :: Aff Unit
...
...
@@ -57,19 +56,13 @@ onSearchChange session (search /\ setSearch) =
log2 "Return:" r
modalShow "addCorpus"
searchQuery {data
base
: Nothing, lang, term} =
searchQuery {data
field
: Nothing, lang, term} =
over SearchQuery (_ {query=term}) defaultSearchQuery
searchQuery {data
base: Just db, lang, term, filters
, node_id} =
over SearchQuery (_ { data
bases=[db]
searchQuery {data
field: datafield, lang, term
, node_id} =
over SearchQuery (_ { data
field=datafield
, lang=lang
, query=term
, filters=filters'
, node_id=node_id
}
) defaultSearchQuery
where
filters' = toInt filters
toInt (Just (HAL_StructId {structIds})) = Set.toUnfoldable structIds
toInt (Just (HAL_IMT {imtOrgs, structIds})) = nub $ (concat $ map imtStructId $ Set.toUnfoldable imtOrgs) <> (Set.toUnfoldable structIds)
toInt _ = []
This diff is collapsed.
Click to expand it.
src/Gargantext/Components/Search/SearchField.purs
View file @
7aa76f18
This diff is collapsed.
Click to expand it.
src/Gargantext/Components/Search/Types.purs
View file @
7aa76f18
module Gargantext.Components.Search.Types where
import Prelude (class Eq, class Show, show, ($), (<>), map)
import Prelude (class Eq, class Show, show, ($), (<>), map
, (&&), (==)
)
import Data.Set (Set)
import Data.Ord
import Data.Set as Set
...
...
@@ -62,7 +62,7 @@ dataFields :: Array DataField
dataFields = [ Gargantext
, Web
, External Nothing
, Files
--
, Files
]
data DataField = Gargantext
...
...
@@ -82,19 +82,19 @@ instance docDataField :: Doc DataField where
doc Web = "All the web crawled with meta-search-engine SearX"
doc Files = "Zip files with formats.."
-- derive instance eqDataField :: Eq DataField
instance eqDataField :: Eq DataField where
eq Gargantext Gargantext = true
eq (External _) (External _) = true
eq Web Web = true
eq Files Files = true
eq _ _ = false
eq _ _ = false
------------------------------------------------------------------------
-- | Database search specifications
allDatabases :: Array Database
allDatabases = [ PubMed
, HAL
, HAL
Nothing
, IsTex
, Isidore
--, Web
...
...
@@ -104,7 +104,7 @@ allDatabases = [ PubMed
data Database = All_Databases
| PubMed
| HAL
| HAL
(Maybe Org)
| IsTex
| Isidore
-- | News
...
...
@@ -113,7 +113,7 @@ data Database = All_Databases
instance showDatabase :: Show Database where
show All_Databases= "All Databases"
show PubMed = "PubMed"
show
HAL
= "HAL"
show
(HAL _)
= "HAL"
show IsTex = "IsTex"
show Isidore= "Isidore"
-- show News = "News"
...
...
@@ -122,7 +122,7 @@ instance showDatabase :: Show Database where
instance docDatabase :: Doc Database where
doc All_Databases = "All databases"
doc PubMed = "All Medical publications"
doc
HAL
= "All open science (archives ouvertes)"
doc
(HAL _)
= "All open science (archives ouvertes)"
doc IsTex = "All Elsevier enriched by CNRS/INIST"
doc Isidore = "All (French) Social Sciences"
-- doc News = "Web filtered by News"
...
...
@@ -131,7 +131,7 @@ instance docDatabase :: Doc Database where
readDatabase :: String -> Maybe Database
readDatabase "All Databases" = Just All_Databases
readDatabase "PubMed" = Just PubMed
readDatabase "HAL" = Just
HAL
readDatabase "HAL" = Just
$ HAL Nothing
readDatabase "IsTex" = Just IsTex
readDatabase "Isidore"= Just Isidore
-- readDatabase "Web" = Just Web
...
...
@@ -141,65 +141,45 @@ readDatabase _ = Nothing
derive instance eqDatabase :: Eq Database
instance encodeJsonDatabase :: EncodeJson Database where
encodeJson a = encodeJson (show a)
------------------------------------------------------------------------
-- | Database Filter specifications
-- filter by organization
-- | Organization specifications
allOrgs :: Array Org
allOrgs = [ All_Orgs
, IMT
, CNRS
, IMT
$ Set.fromFoldable []
, CNRS
$ Set.fromFoldable []
]
data Org = All_Orgs
| CNRS
| IMT
| Others
| CNRS (Set StructId)
| Others (Set StructId)
| IMT (Set IMT_org)
type StructId = Int
instance showOrg :: Show Org where
show All_Orgs = "All_Orgs"
show
CNRS
= "CNRS"
show
IMT
= "IMT"
show
Others
= "Others"
show
(CNRS _)
= "CNRS"
show
(IMT _)
= "IMT"
show
(Others _)
= "Others"
readOrg :: String -> Maybe Org
readOrg "All_Orgs" = Just $ All_Orgs
readOrg "CNRS" = Just $ CNRS
readOrg "IMT" = Just $ IMT
readOrg "Others" = Just $ Others
readOrg "CNRS" = Just $ CNRS
$ Set.fromFoldable []
readOrg "IMT" = Just $ IMT
$ Set.fromFoldable []
readOrg "Others" = Just $ Others
$ Set.fromFoldable []
readOrg _ = Nothing
instance eqOrg :: Eq Org
where
eq All_Orgs All_Orgs = true
eq CNRS CNRS = true
eq IMT IMT = true
eq Others Others = true
eq _ _ = false
derive instance eqOrg :: Eq Org
instance encodeJsonOrg :: EncodeJson Org where
encodeJson a = encodeJson (show a)
------------------------------------------------------------------------
type StructId = Int
data HAL_Filters = HAL_StructId { structIds :: Set StructId}
| HAL_IMT { imtOrgs :: Set IMT_org
, structIds :: Set StructId
}
instance eqHAL_Filters :: Eq HAL_Filters
where
eq (HAL_StructId _) (HAL_StructId _) = true
eq (HAL_IMT _ ) (HAL_IMT _) = true
eq _ _ = false
allIMTorgs :: Array IMT_org
allIMTorgs = [All_IMT] <> allIMTSubOrgs
...
...
@@ -326,9 +306,8 @@ instance showSearchOrder :: Show SearchOrder where
------------------------------------------------------------------------
newtype SearchQuery = SearchQuery
{ query :: String
, data
bases :: Array Database
, data
field :: Maybe DataField
, lang :: Maybe Lang
, filters :: (Array Int)
, node_id :: Maybe Int
, files_id :: Array String
, offset :: Maybe Int
...
...
@@ -341,10 +320,9 @@ derive instance newtypeSearchQuery :: Newtype SearchQuery _
defaultSearchQuery :: SearchQuery
defaultSearchQuery = SearchQuery
{ query: ""
, data
bases: allDatabases
, data
field: Nothing
, lang : Nothing
, node_id : Nothing
, filters : []
, files_id : []
, offset: Nothing
, limit: Nothing
...
...
@@ -366,12 +344,11 @@ instance searchQueryToQuery :: ToQuery SearchQuery where
[ QP.keyFromString k /\ Just (QP.valueFromString $ show v) ]
instance encodeJsonSearchQuery :: EncodeJson SearchQuery where
encodeJson (SearchQuery {query, data
bases, node_id, files_id, filters
, lang})
encodeJson (SearchQuery {query, data
field, node_id
, lang})
= "query" := query
~> "data
bases" := databases
~> "data
field" := "" -- fromMaybe "" datafield
~> "node_id" := fromMaybe 0 node_id
~> "files_id" := files_id
~> "filters" := filters
-- ~> "files_id" := files_id
~> "lang" := maybe "EN" show lang
~> jsonEmptyObject
...
...
This diff is collapsed.
Click to expand it.
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