Commit a417fb7f authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FOREST] Search form, ergo almost done.

parent 2832f44b
...@@ -13,7 +13,7 @@ import Reactix as R ...@@ -13,7 +13,7 @@ import Reactix as R
import DOM.Simple.Console (log2) import DOM.Simple.Console (log2)
import Effect.Aff (Aff, launchAff_) import Effect.Aff (Aff, launchAff_)
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Gargantext.Components.Search.Types (Database, SearchQuery(..), defaultSearchQuery, performSearch, Lang(..)) import Gargantext.Components.Search.Types -- (Database, SearchQuery(..), defaultSearchQuery, performSearch, Lang(..))
import Gargantext.Components.Modals.Modal (modalShow) import Gargantext.Components.Modals.Modal (modalShow)
import Gargantext.Components.Search.SearchField (Search, searchField) import Gargantext.Components.Search.SearchField (Search, searchField)
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
......
module Gargantext.Components.Search.Types where module Gargantext.Components.Search.Types where
import Prelude (class Eq, class Show, show, ($), (<>)) import Prelude (class Eq, class Show, show, ($), (<>), map)
import Data.Set (Set)
import Data.Ord
import Data.Set as Set
import Data.Array (concat)
import Data.Argonaut (class EncodeJson, class DecodeJson, jsonEmptyObject, (:=), (~>), encodeJson) import Data.Argonaut (class EncodeJson, class DecodeJson, jsonEmptyObject, (:=), (~>), encodeJson)
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Eq (genericEq) import Data.Generic.Rep.Eq (genericEq)
...@@ -50,13 +54,15 @@ instance encodeJsonLang :: EncodeJson Lang where ...@@ -50,13 +54,15 @@ instance encodeJsonLang :: EncodeJson Lang where
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- | Database search specifications -- | Database search specifications
allDatabases :: Array Database allDatabases :: Array Database
allDatabases = [All, PubMed allDatabases = [ All
, PubMed
, HAL , HAL
, IsTex , IsTex
, Isidore , Isidore
] ]
data Database = All | PubMed data Database = All
| PubMed
| HAL | HAL
| IsTex | IsTex
| Isidore | Isidore
...@@ -87,118 +93,162 @@ instance encodeJsonDatabase :: EncodeJson Database where ...@@ -87,118 +93,162 @@ instance encodeJsonDatabase :: EncodeJson Database where
allOrgs :: Array Org allOrgs :: Array Org
allOrgs = [ All_Orgs allOrgs = [ All_Orgs
, IMT {orgs:[]} , IMT
, CNRS {orgs:[]} , CNRS
] ]
data Org = All_Orgs data Org = All_Orgs
| CNRS { orgs :: Array Int } | CNRS
| IMT { orgs :: Array IMT_org } | IMT
| Others { orgs :: Array Int } | Others
instance showOrg :: Show Org where instance showOrg :: Show Org where
show All_Orgs = "All__Orgs" show All_Orgs = "All__Orgs"
show (CNRS _) = "CNRS" show CNRS = "CNRS"
show (IMT _) = "IMT" show IMT = "IMT"
show (Others _) = "Others" show Others = "Others"
readOrg :: String -> Maybe Org readOrg :: String -> Maybe Org
readOrg "All_Orgs" = Just $ All_Orgs readOrg "All_Orgs" = Just $ All_Orgs
readOrg "CNRS" = Just $ CNRS {orgs: []} readOrg "CNRS" = Just $ CNRS
readOrg "IMT" = Just $ IMT {orgs: []} readOrg "IMT" = Just $ IMT
readOrg "Others" = Just $ Others {orgs: []} readOrg "Others" = Just $ Others
readOrg _ = Nothing readOrg _ = Nothing
instance eqOrg :: Eq Org instance eqOrg :: Eq Org
where where
eq All_Orgs All_Orgs = true eq All_Orgs All_Orgs = true
eq (CNRS _) (CNRS _) = true eq CNRS CNRS = true
eq (IMT _) (IMT _) = true eq IMT IMT = true
eq (Others _) (Others _) = true eq Others Others = true
eq _ _ = false eq _ _ = false
instance encodeJsonOrg :: EncodeJson Org where instance encodeJsonOrg :: EncodeJson Org where
encodeJson a = encodeJson (show a) 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 :: Array IMT_org
allIMTorgs = [ ARMINES allIMTorgs = [All_IMT] <> allIMTSubOrgs
, Eurecom
, IMT_Atlantique allIMTSubOrgs :: Array IMT_org
, IMT_Business_School allIMTSubOrgs = [ ARMINES
, IMT_Lille_Douai , Eurecom
, IMT_Mines_ALES , IMT_Atlantique
, IMT_Mines_Albi , IMT_Business_School
, Institut_MinesTelecom_Paris , IMT_Lille_Douai
, MINES_ParisTech , IMT_Mines_ALES
, Mines_Douai , IMT_Mines_Albi
, Mines_Nantes , Institut_MinesTelecom_Paris
, Mines_SaintEtienne , MINES_ParisTech
, Telecom_Bretagne , Mines_Douai
, Telecom_Ecole_de_Management , Mines_Nantes
, Telecom_Lille , Mines_SaintEtienne
, Telecom_ParisTech , Telecom_Bretagne
, Telecom_SudParis , Telecom_Ecole_de_Management
] , Telecom_Lille
, Telecom_ParisTech
data IMT_org = ARMINES , Telecom_SudParis
| Eurecom ]
| IMT_Atlantique
| IMT_Business_School data IMT_org = All_IMT
| IMT_Lille_Douai | ARMINES
| IMT_Mines_ALES | Eurecom
| IMT_Mines_Albi | IMT_Atlantique
| Institut_MinesTelecom_Paris | IMT_Business_School
| MINES_ParisTech | IMT_Lille_Douai
| Mines_Douai | IMT_Mines_ALES
| Mines_Nantes | IMT_Mines_Albi
| Mines_SaintEtienne | Institut_MinesTelecom_Paris
| Telecom_Bretagne | MINES_ParisTech
| Telecom_Ecole_de_Management | Mines_Douai
| Telecom_Lille | Mines_Nantes
| Telecom_ParisTech | Mines_SaintEtienne
| Telecom_SudParis | Telecom_Bretagne
| Telecom_Ecole_de_Management
| Telecom_Lille
| Telecom_ParisTech
| Telecom_SudParis
derive instance ordIMT_org :: Ord IMT_org
derive instance eqIMT_org :: Eq IMT_org
instance showIMT_org :: Show IMT_org where instance showIMT_org :: Show IMT_org where
show ARMINES = "ARMINES" show All_IMT = "All_IMT"
show Eurecom = "Eurecom" show ARMINES = "ARMINES"
show IMT_Atlantique = "IMT_Atlantique" show Eurecom = "Eurecom"
show IMT_Atlantique = "IMT_Atlantique"
show IMT_Business_School = "IMT_Business_School" show IMT_Business_School = "IMT_Business_School"
show IMT_Lille_Douai = "IMT_Lille_Douai" show IMT_Lille_Douai = "IMT_Lille_Douai"
show IMT_Mines_ALES = "IMT_Mines_ALES" show IMT_Mines_ALES = "IMT_Mines_ALES"
show IMT_Mines_Albi = "IMT_Mines_Albi" show IMT_Mines_Albi = "IMT_Mines_Albi"
show Institut_MinesTelecom_Paris = "Institut_MinesTelecom_Paris" show Institut_MinesTelecom_Paris = "Institut_MinesTelecom_Paris"
show MINES_ParisTech = "MINES_ParisTech" show MINES_ParisTech = "MINES_ParisTech"
show Mines_Douai = "Mines_Douai" show Mines_Douai = "Mines_Douai"
show Mines_Nantes = "Mines_Nantes" show Mines_Nantes = "Mines_Nantes"
show Mines_SaintEtienne = "Mines_SaintEtienne" show Mines_SaintEtienne = "Mines_SaintEtienne"
show Telecom_Bretagne = "Telecom_Bretagne" show Telecom_Bretagne = "Telecom_Bretagne"
show Telecom_Ecole_de_Management = "Telecom_Ecole_de_Management" show Telecom_Ecole_de_Management = "Telecom_Ecole_de_Management"
show Telecom_Lille = "Telecom_Lille" show Telecom_Lille = "Telecom_Lille"
show Telecom_ParisTech = "Telecom_ParisTech" show Telecom_ParisTech = "Telecom_ParisTech"
show Telecom_SudParis = "Telecom_SudParis" show Telecom_SudParis = "Telecom_SudParis"
readIMT_org :: String -> Maybe IMT_org
readIMT_org "All_IMT" = Just All_IMT
{- readIMT_org "ARMINES" = Just ARMINES
Mines_Douai 224096 readIMT_org "Eurecom" = Just Eurecom
Telecom_Lille 144103 readIMT_org "IMT_Atlantique" = Just IMT_Atlantique
Mines_Nantes 84538 readIMT_org "IMT_Business_School" = Just IMT_Business_School
ARMINES 300104 readIMT_org "IMT_Lille_Douai" = Just IMT_Lille_Douai
Telecom_ParisTech 300362 readIMT_org "IMT_Mines_ALES" = Just IMT_Mines_ALES
Telecom_Bretagne 301262 readIMT_org "IMT_Mines_Albi" = Just IMT_Mines_Albi
Telecom_Ecole_de_Management 301442 readIMT_org "Institut_MinesTelecom_Paris" = Just Institut_MinesTelecom_Paris
MINES_ParisTech 301492 readIMT_org "MINES_ParisTech" = Just MINES_ParisTech
Institut_MinesTelecom_Paris 302102 readIMT_org "Mines_Douai" = Just Mines_Douai
Eurecom 421532 readIMT_org "Mines_Nantes" = Just Mines_Nantes
IMT_Lille_Douai 497330 readIMT_org "Mines_SaintEtienne" = Just Mines_SaintEtienne
Telecom_SudParis 352124 readIMT_org "Telecom_Bretagne" = Just Telecom_Bretagne
IMT_Atlantique 481355 readIMT_org "Telecom_Ecole_de_Management" = Just Telecom_Ecole_de_Management
IMT_Mines_Albi 469216 readIMT_org "Telecom_Lille" = Just Telecom_Lille
IMT_Business_School 542824 readIMT_org "Telecom_ParisTech" = Just Telecom_ParisTech
IMT_Mines_ALES 6279 readIMT_org "Telecom_SudParis" = Just Telecom_SudParis
Mines_SaintEtienne 29212 readIMT_org _ = Nothing
-}
imtStructId :: IMT_org -> Array StructId
imtStructId All_IMT = concat $ map imtStructId allIMTSubOrgs
imtStructId Mines_Douai = [224096]
imtStructId Telecom_Lille = [144103]
imtStructId Mines_Nantes = [84538]
imtStructId ARMINES = [300104]
imtStructId Telecom_ParisTech = [300362]
imtStructId Telecom_Bretagne = [301262]
imtStructId Telecom_Ecole_de_Management = [301442]
imtStructId MINES_ParisTech = [301492]
imtStructId Institut_MinesTelecom_Paris = [302102]
imtStructId Eurecom = [421532]
imtStructId IMT_Lille_Douai = [497330]
imtStructId Telecom_SudParis = [352124]
imtStructId IMT_Atlantique = [481355]
imtStructId IMT_Mines_Albi = [469216]
imtStructId IMT_Business_School = [542824]
imtStructId IMT_Mines_ALES = [6279]
imtStructId Mines_SaintEtienne = [29212]
------------------------------------------------------------------------ ------------------------------------------------------------------------
data SearchOrder data SearchOrder
......
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