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

[READ] reading the code and cosmetics to ease reading.

parent 98d40dfd
...@@ -47,7 +47,7 @@ import Unsafe.Coerce (unsafeCoerce) ...@@ -47,7 +47,7 @@ import Unsafe.Coerce (unsafeCoerce)
data Action data Action
= LoadData = LoadData
| ChangePageSize PageSizes | ChangePageSize PageSizes
| ChangePage Int | ChangePage Int
type State = CorpusTableData type State = CorpusTableData
...@@ -203,7 +203,7 @@ loadPage = do ...@@ -203,7 +203,7 @@ loadPage = do
Right resData -> do Right resData -> do
let docs = toTableData (res2corpus $ resData) let docs = toTableData (res2corpus $ resData)
_ <- liftEffect $ log $ show $ map (\({ row: r, delete :_}) -> show r) ((\(TableData docs') -> docs'.rows) docs) _ <- liftEffect $ log $ show $ map (\({ row: r, delete :_}) -> show r) ((\(TableData docs') -> docs'.rows) docs)
_ <- liftEffect $ log $ show "loading" _ <- liftEffect $ log $ show "loading page documents"
pure $ Right docs pure $ Right docs
where where
res2corpus :: Array Response -> Array CorpusView res2corpus :: Array Response -> Array CorpusView
...@@ -226,14 +226,13 @@ loadPage = do ...@@ -226,14 +226,13 @@ loadPage = do
, pageSize : PS100 , pageSize : PS100
, totalRecords : 47361 , totalRecords : 47361
, title : "Documents" , title : "Documents"
-- , tree : exampleTree
} }
--------------------------------------------------------- ---------------------------------------------------------
sampleData' :: CorpusView sampleData' :: CorpusView
sampleData' = CorpusView {_id : 1, url : "", date : "date3", title : "title", source : "source", fav : false, ngramCount : 1} sampleData' = CorpusView {_id : 1, url : "", date : "date3", title : "title", source : "source", fav : false, ngramCount : 1}
--
sampleData :: Array CorpusView sampleData :: Array CorpusView
--sampleData = replicate 10 sampleData' --sampleData = replicate 10 sampleData'
sampleData = map (\(Tuple t s) -> CorpusView {_id : 1, url : "", date : "2017", title: t, source: s, fav : false, ngramCount : 10}) sampleDocuments sampleData = map (\(Tuple t s) -> CorpusView {_id : 1, url : "", date : "2017", title: t, source: s, fav : false, ngramCount : 10}) sampleDocuments
...@@ -242,15 +241,12 @@ sampleDocuments :: Array (Tuple String String) ...@@ -242,15 +241,12 @@ sampleDocuments :: Array (Tuple String String)
sampleDocuments = [Tuple "Macroscopic dynamics of the fusion process" "Journal de Physique Lettres",Tuple "Effects of static and cyclic fatigue at high temperature upon reaction bonded silicon nitride" "Journal de Physique Colloques",Tuple "Reliability of metal/glass-ceramic junctions made by solid state bonding" "Journal de Physique Colloques",Tuple "High temperature mechanical properties and intergranular structure of sialons" "Journal de Physique Colloques",Tuple "SOLUTIONS OF THE LANDAU-VLASOV EQUATION IN NUCLEAR PHYSICS" "Journal de Physique Colloques",Tuple "A STUDY ON THE FUSION REACTION 139La + 12C AT 50 MeV/u WITH THE VUU EQUATION" "Journal de Physique Colloques",Tuple "Atomic structure of \"vitreous\" interfacial films in sialon" "Journal de Physique Colloques",Tuple "MICROSTRUCTURAL AND ANALYTICAL CHARACTERIZATION OF Al2O3/Al-Mg COMPOSITE INTERFACES" "Journal de Physique Colloques",Tuple "Development of oxidation resistant high temperature NbTiAl alloys and intermetallics" "Journal de Physique IV Colloque",Tuple "Determination of brazed joint constitutive law by inverse method" "Journal de Physique IV Colloque",Tuple "Two dimensional estimates from ocean SAR images" "Nonlinear Processes in Geophysics",Tuple "Comparison Between New Carbon Nanostructures Produced by Plasma with Industrial Carbon Black Grades" "Journal de Physique III",Tuple "<i>Letter to the Editor:</i> SCIPION, a new flexible ionospheric sounder in Senegal" "Annales Geophysicae",Tuple "Is reducibility in nuclear multifragmentation related to thermal scaling?" "Physics Letters B",Tuple "Independence of fragment charge distributions of the size of heavy multifragmenting sources" "Physics Letters B",Tuple "Hard photons and neutral pions as probes of hot and dense nuclear matter" "Nuclear Physics A",Tuple "Surveying the nuclear caloric curve" "Physics Letters B",Tuple "A hot expanding source in 50 A MeV Xe+Sn central reactions" "Physics Letters B"] sampleDocuments = [Tuple "Macroscopic dynamics of the fusion process" "Journal de Physique Lettres",Tuple "Effects of static and cyclic fatigue at high temperature upon reaction bonded silicon nitride" "Journal de Physique Colloques",Tuple "Reliability of metal/glass-ceramic junctions made by solid state bonding" "Journal de Physique Colloques",Tuple "High temperature mechanical properties and intergranular structure of sialons" "Journal de Physique Colloques",Tuple "SOLUTIONS OF THE LANDAU-VLASOV EQUATION IN NUCLEAR PHYSICS" "Journal de Physique Colloques",Tuple "A STUDY ON THE FUSION REACTION 139La + 12C AT 50 MeV/u WITH THE VUU EQUATION" "Journal de Physique Colloques",Tuple "Atomic structure of \"vitreous\" interfacial films in sialon" "Journal de Physique Colloques",Tuple "MICROSTRUCTURAL AND ANALYTICAL CHARACTERIZATION OF Al2O3/Al-Mg COMPOSITE INTERFACES" "Journal de Physique Colloques",Tuple "Development of oxidation resistant high temperature NbTiAl alloys and intermetallics" "Journal de Physique IV Colloque",Tuple "Determination of brazed joint constitutive law by inverse method" "Journal de Physique IV Colloque",Tuple "Two dimensional estimates from ocean SAR images" "Nonlinear Processes in Geophysics",Tuple "Comparison Between New Carbon Nanostructures Produced by Plasma with Industrial Carbon Black Grades" "Journal de Physique III",Tuple "<i>Letter to the Editor:</i> SCIPION, a new flexible ionospheric sounder in Senegal" "Annales Geophysicae",Tuple "Is reducibility in nuclear multifragmentation related to thermal scaling?" "Physics Letters B",Tuple "Independence of fragment charge distributions of the size of heavy multifragmenting sources" "Physics Letters B",Tuple "Hard photons and neutral pions as probes of hot and dense nuclear matter" "Nuclear Physics A",Tuple "Surveying the nuclear caloric curve" "Physics Letters B",Tuple "A hot expanding source in 50 A MeV Xe+Sn central reactions" "Physics Letters B"]
data' :: Array CorpusView -> Array {row :: CorpusView, delete :: Boolean} data' :: Array CorpusView -> Array {row :: CorpusView, delete :: Boolean}
data' = map {row : _, delete : false} data' = map {row : _, delete : false}
sdata :: Array { row :: CorpusView, delete :: Boolean } sdata :: Array { row :: CorpusView, delete :: Boolean }
sdata = data' sampleData sdata = data' sampleData
tdata :: TableData CorpusView tdata :: TableData CorpusView
tdata = TableData tdata = TableData
{ rows : sdata { rows : sdata
...@@ -269,7 +265,7 @@ showRow {row : (CorpusView c), delete} = ...@@ -269,7 +265,7 @@ showRow {row : (CorpusView c), delete} =
[ td [] [div [className $ fa <> "fa-star"][]] [ td [] [div [className $ fa <> "fa-star"][]]
-- TODO show date: Year-Month-Day only -- TODO show date: Year-Month-Day only
, td [] [text c.date] , td [] [text c.date]
, td [] [ a [ if c.fav == true then href "#/user" else href "#/document/1" ] [ text c.title ] ] , td [] [ a [ href (toUrl Back Document 1) ] [ text c.title ] ]
, td [] [text c.source] , td [] [text c.source]
, td [] [input [ _type "checkbox"]] , td [] [input [ _type "checkbox"]]
] ]
...@@ -296,15 +292,15 @@ data PageSizes = PS10 | PS20 | PS50 | PS100 ...@@ -296,15 +292,15 @@ data PageSizes = PS10 | PS20 | PS50 | PS100
derive instance eqPageSizes :: Eq PageSizes derive instance eqPageSizes :: Eq PageSizes
instance showPageSize :: Show PageSizes where instance showPageSize :: Show PageSizes where
show PS10 = "10" show PS10 = "10"
show PS20 = "20" show PS20 = "20"
show PS50 = "50" show PS50 = "50"
show PS100 = "100" show PS100 = "100"
pageSizes2Int :: PageSizes -> Int pageSizes2Int :: PageSizes -> Int
pageSizes2Int PS10 = 10 pageSizes2Int PS10 = 10
pageSizes2Int PS20 = 20 pageSizes2Int PS20 = 20
pageSizes2Int PS50 = 50 pageSizes2Int PS50 = 50
pageSizes2Int PS100 = 100 pageSizes2Int PS100 = 100
aryPS :: Array PageSizes aryPS :: Array PageSizes
......
...@@ -9,12 +9,14 @@ import Data.Maybe (Maybe(..)) ...@@ -9,12 +9,14 @@ import Data.Maybe (Maybe(..))
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Effect.Console (log) import Effect.Console (log)
import Gargantext.Config (toUrl, NodeType(..), End(..))
import Gargantext.Config.REST (get) import Gargantext.Config.REST (get)
import Gargantext.Pages.Corpus.User.Users.Types (Action(..), State, User, _user) import Gargantext.Pages.Corpus.User.Users.Types (Action(..), State, User, _user)
import Thermite (PerformAction, modifyState) import Thermite (PerformAction, modifyState)
getUser :: Int -> Aff (Either String User) getUser :: Int -> Aff (Either String User)
getUser id = get $ "http://localhost:8008/node/" <> show id getUser id = get $ toUrl Back Node id
performAction :: PerformAction State {} Action performAction :: PerformAction State {} Action
......
...@@ -7,76 +7,85 @@ import Data.Maybe (Maybe) ...@@ -7,76 +7,85 @@ import Data.Maybe (Maybe)
import Gargantext.Utils.DecodeMaybe ((.?|)) import Gargantext.Utils.DecodeMaybe ((.?|))
newtype User = newtype User =
User { User { id :: Int
id ::Int, , typename :: Maybe Int
typename :: Maybe Int, , userId :: Int
userId ::Int, , parentId :: Int
parentId :: Int, , name :: String
name :: String, , date :: Maybe String
date ::Maybe String, , hyperdata :: HyperData
hyperdata :: HyperData
} }
newtype HyperData = newtype HyperData =
HyperData HyperData
{ { bureau :: Maybe String
bureau ::Maybe String, , atel :: Maybe String
atel ::Maybe String, , fax :: Maybe String
fax ::Maybe String, , aprecision :: Maybe String
aprecision ::Maybe String, , service :: Maybe String
service ::Maybe String, , service2 :: Maybe String
service2 ::Maybe String, , groupe :: Maybe String
groupe ::Maybe String, , lieu :: Maybe String
lieu ::Maybe String, , pservice :: Maybe String
pservice ::Maybe String, , date_modification :: Maybe String
date_modification ::Maybe String, , fonction :: Maybe String
fonction ::Maybe String, , pfonction :: Maybe String
pfonction ::Maybe String, , url :: Maybe String
url ::Maybe String, , prenom :: Maybe String
prenom ::Maybe String, , nom :: Maybe String
nom ::Maybe String, , idutilentite :: Maybe String
idutilentite ::Maybe String, , afonction :: Maybe String
afonction ::Maybe String, , grprech :: Maybe String
grprech ::Maybe String, , entite :: Maybe String
entite ::Maybe String, , entite2 :: Maybe String
entite2 ::Maybe String, , mail :: Maybe String
mail :: Maybe String
} }
instance decodeUserHyperData :: DecodeJson HyperData where instance decodeUserHyperData :: DecodeJson HyperData where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
bureau <- obj .?| "bureau" bureau <- obj .?| "bureau"
atel <- obj .?| "atel" atel <- obj .?| "atel"
fax <- obj .?| "fax" fax <- obj .?| "fax"
aprecision <- obj .?| "aprecision" aprecision <- obj .?| "aprecision"
service <- obj .?| "service" service <- obj .?| "service"
service2 <- obj .?| "service2" service2 <- obj .?| "service2"
groupe <- obj .?| "groupe" groupe <- obj .?| "groupe"
lieu <- obj .?| "lieu" lieu <- obj .?| "lieu"
pservice <- obj .?| "pservice" pservice <- obj .?| "pservice"
date_modification <- obj .?| "date_modification" date_modification <- obj .?| "date_modification"
fonction <- obj .?| "fonction" fonction <- obj .?| "fonction"
pfonction <- obj .?| "pfonction" pfonction <- obj .?| "pfonction"
url <- obj .?| "url" url <- obj .?| "url"
prenom <- obj .?| "prenom" prenom <- obj .?| "prenom"
nom <- obj .?| "nom" nom <- obj .?| "nom"
idutilentite <- obj .?| "idutilentite" idutilentite <- obj .?| "idutilentite"
afonction <- obj .?| "afonction" afonction <- obj .?| "afonction"
grprech <- obj .?| "grprech" grprech <- obj .?| "grprech"
entite <- obj .?| "entite" entite <- obj .?| "entite"
entite2 <- obj .?| "entite2" entite2 <- obj .?| "entite2"
mail <- obj .?| "mail" mail <- obj .?| "mail"
pure $ HyperData {bureau, atel, fax, aprecision, service, service2, groupe, lieu, pservice, date_modification, fonction, pfonction, url, prenom, nom, idutilentite, afonction, grprech, entite, entite2, mail} pure $ HyperData { bureau, atel, fax
, aprecision, service
, service2, groupe, lieu
, pservice, date_modification
, fonction, pfonction, url
, prenom, nom, idutilentite
, afonction, grprech, entite
, entite2, mail
}
instance decodeUser :: DecodeJson User where instance decodeUser :: DecodeJson User where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
id <- obj .? "id" id <- obj .? "id"
typename <- obj .?| "typename" typename <- obj .?| "typename"
userId <- obj .? "userId" userId <- obj .? "userId"
parentId <- obj .? "parentId" parentId <- obj .? "parentId"
name <- obj .? "name" name <- obj .? "name"
date <- obj .?| "date" date <- obj .?| "date"
hyperdata <- obj .? "hyperdata" hyperdata <- obj .? "hyperdata"
pure $ User {id, typename, userId, parentId, name, date, hyperdata} pure $ User { id, typename, userId
, parentId, name, date
, hyperdata
}
...@@ -39,11 +39,11 @@ initAppState = ...@@ -39,11 +39,11 @@ initAppState =
, searchState : S.initialState , searchState : S.initialState
, userPageState : U.initialState , userPageState : U.initialState
, docAnnotationState : D.initialState , docAnnotationState : D.initialState
, ntreeState : Tree.exampleTree , ntreeState : Tree.exampleTree
, search : "" , search : ""
, showLogin : false , showLogin : false
, showCorpus : false , showCorpus : false
, graphExplorerState : GE.initialState , graphExplorerState : GE.initialState
, initialized : false , initialized : false
} }
......
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