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

Merge branch 'dev-doc-table-score' of...

Merge branch 'dev-doc-table-score' of ssh://gitlab.iscpif.fr:20022/gargantext/purescript-gargantext into dev-merge
parents 03915048 c656128e
...@@ -7,7 +7,7 @@ import Data.Lens ((^.)) ...@@ -7,7 +7,7 @@ import Data.Lens ((^.))
import Data.Lens.At (at) import Data.Lens.At (at)
import Data.Lens.Record (prop) import Data.Lens.Record (prop)
import Data.Map (Map) import Data.Map (Map)
import Data.Maybe (Maybe(..), fromMaybe, isJust) import Data.Maybe (Maybe(..), fromMaybe, isJust, maybe)
import Data.Ord.Down (Down(..)) import Data.Ord.Down (Down(..))
import Data.Set (Set) import Data.Set (Set)
import Data.Set as Set import Data.Set as Set
...@@ -19,6 +19,7 @@ import DOM.Simple.Console (log, log2) ...@@ -19,6 +19,7 @@ import DOM.Simple.Console (log, log2)
import DOM.Simple.Event as DE import DOM.Simple.Event as DE
import Effect (Effect) import Effect (Effect)
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
------------------------------------------------------------------------ ------------------------------------------------------------------------
...@@ -215,12 +216,13 @@ convOrderBy _ = Nothing ...@@ -215,12 +216,13 @@ convOrderBy _ = Nothing
res2corpus :: Response -> DocumentsView res2corpus :: Response -> DocumentsView
res2corpus (Response r) = res2corpus (Response r) =
DocumentsView { _id : r.cid DocumentsView { _id : r.cid
, url : "" , category : r.category
, date : (\(Hyperdata hr) -> hr.pub_year) r.hyperdata , date : (\(Hyperdata hr) -> hr.pub_year) r.hyperdata
, title : (\(Hyperdata hr) -> hr.title) r.hyperdata
, source : (\(Hyperdata hr) -> hr.source) r.hyperdata
, category : r.category
, ngramCount : r.ngramCount , ngramCount : r.ngramCount
, score : r.score
, source : (\(Hyperdata hr) -> hr.source) r.hyperdata
, title : (\(Hyperdata hr) -> hr.title) r.hyperdata
, url : ""
} }
filterDocs :: Query -> Array Response -> Array Response filterDocs :: Query -> Array Response -> Array Response
...@@ -274,7 +276,11 @@ pageLayoutCpt = R.hooksComponentWithModule thisModule "pageLayout" cpt where ...@@ -274,7 +276,11 @@ pageLayoutCpt = R.hooksComponentWithModule thisModule "pageLayout" cpt where
localCategories <- R.useState' (mempty :: LocalCategories) localCategories <- R.useState' (mempty :: LocalCategories)
paramsS <- R.useState' params paramsS <- R.useState' params
let loader p = do let loader p = do
res <- get session $ tableRouteWithPage (p { params = fst paramsS, query = query }) let route = tableRouteWithPage (p { params = fst paramsS, query = query })
res <- get session $ route
liftEffect $ do
log2 "[pageLayout] table route" route
log2 "[pageLayout] table res" res
pure $ handleResponse res pure $ handleResponse res
render (Tuple count documents) = pagePaintRaw { documents render (Tuple count documents) = pagePaintRaw { documents
, layout: props { params = fst paramsS , layout: props { params = fst paramsS
...@@ -372,7 +378,7 @@ pagePaintRawCpt = R.hooksComponentWithModule thisModule "pagePaintRawCpt" cpt wh ...@@ -372,7 +378,7 @@ pagePaintRawCpt = R.hooksComponentWithModule thisModule "pagePaintRawCpt" cpt wh
corpusDocument corpusDocument
| Just cid <- mCorpusId = Routes.CorpusDocument sid cid listId | Just cid <- mCorpusId = Routes.CorpusDocument sid cid listId
| otherwise = Routes.Document sid listId | otherwise = Routes.Document sid listId
colNames = T.ColumnName <$> [ "Show", "Tag", "Date", "Title", "Source"] colNames = T.ColumnName <$> [ "Show", "Tag", "Date", "Title", "Source", "Score" ]
wrapColElts = const identity wrapColElts = const identity
getCategory (lc /\ _) {_id, category} = fromMaybe category (lc ^. at _id) getCategory (lc /\ _) {_id, category} = fromMaybe category (lc ^. at _id)
rows reload lc@(_ /\ setLocalCategories) = row <$> A.toUnfoldable documents rows reload lc@(_ /\ setLocalCategories) = row <$> A.toUnfoldable documents
...@@ -390,6 +396,7 @@ pagePaintRawCpt = R.hooksComponentWithModule thisModule "pagePaintRawCpt" cpt wh ...@@ -390,6 +396,7 @@ pagePaintRawCpt = R.hooksComponentWithModule thisModule "pagePaintRawCpt" cpt wh
H.a { href: url frontends $ corpusDocument r._id, target: "_blank"} [ H.text r.title ] H.a { href: url frontends $ corpusDocument r._id, target: "_blank"} [ H.text r.title ]
] ]
, H.div { className: tClassName } [ H.text $ if r.source == "" then "Source" else r.source ] , H.div { className: tClassName } [ H.text $ if r.source == "" then "Source" else r.source ]
, H.div {} [ H.text $ maybe "-" show r.ngramCount ]
] ]
, delete: true } , delete: true }
where where
......
...@@ -3,6 +3,7 @@ module Gargantext.Components.DocsTable.Types where ...@@ -3,6 +3,7 @@ module Gargantext.Components.DocsTable.Types where
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, jsonEmptyObject, (.:), (:=), (~>)) import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, jsonEmptyObject, (.:), (:=), (~>))
import Data.Map (Map) import Data.Map (Map)
import Data.Map as Map import Data.Map as Map
import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
import Gargantext.Prelude import Gargantext.Prelude
...@@ -14,13 +15,14 @@ data Action ...@@ -14,13 +15,14 @@ data Action
newtype DocumentsView newtype DocumentsView
= DocumentsView = DocumentsView
{ _id :: Int { _id :: Int
, category :: Category , category :: Category
, date :: Int , date :: Int
, ngramCount :: Int , ngramCount :: Maybe Int
, source :: String , score :: Maybe Int
, title :: String , source :: String
, url :: String , title :: String
, url :: String
} }
{- {-
...@@ -36,23 +38,25 @@ instance encodeJsonSearchType :: Argonaut.EncodeJson SearchType where ...@@ -36,23 +38,25 @@ instance encodeJsonSearchType :: Argonaut.EncodeJson SearchType where
instance decodeDocumentsView :: DecodeJson DocumentsView where instance decodeDocumentsView :: DecodeJson DocumentsView where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
_id <- obj .: "id" _id <- obj .: "id"
category <- obj .: "category" category <- obj .: "category"
date <- obj .: "date" date <- obj .: "date"
ngramCount <- obj .: "ngramCount" ngramCount <- obj .: "ngramCount"
source <- obj .: "source" score <- obj .: "score"
title <- obj .: "title" source <- obj .: "source"
url <- obj .: "url" title <- obj .: "title"
pure $ DocumentsView { _id, category, date, ngramCount, source, title, url } url <- obj .: "url"
pure $ DocumentsView { _id, category, date, ngramCount, score, source, title, url }
instance encodeDocumentsView :: EncodeJson DocumentsView where instance encodeDocumentsView :: EncodeJson DocumentsView where
encodeJson (DocumentsView dv) = encodeJson (DocumentsView dv) =
"id" := dv._id "id" := dv._id
~> "category" := dv.category ~> "category" := dv.category
~> "date" := dv.date ~> "date" := dv.date
~> "ngramCount" := dv.ngramCount ~> "ngramCount" := dv.ngramCount
~> "source" := dv.source ~> "score" := dv.score
~> "title" := dv.title ~> "source" := dv.source
~> "url" := dv.url ~> "title" := dv.title
~> "url" := dv.url
~> jsonEmptyObject ~> jsonEmptyObject
...@@ -60,24 +64,25 @@ newtype Response = Response ...@@ -60,24 +64,25 @@ newtype Response = Response
{ cid :: Int { cid :: Int
, hyperdata :: Hyperdata , hyperdata :: Hyperdata
, category :: Category , category :: Category
, ngramCount :: Int , ngramCount :: Maybe Int
, score :: Maybe Int
, title :: String , title :: String
} }
newtype Hyperdata = Hyperdata newtype Hyperdata = Hyperdata
{ title :: String { title :: String
, source :: String , source :: String
, pub_year :: Int , pub_year :: Int
} }
instance decodeHyperdata :: DecodeJson Hyperdata where instance decodeHyperdata :: DecodeJson Hyperdata where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
title <- obj .: "title"
source <- obj .: "source"
pub_year <- obj .: "publication_year" pub_year <- obj .: "publication_year"
source <- obj .: "source"
title <- obj .: "title"
pure $ Hyperdata { title,source, pub_year} pure $ Hyperdata { title,source, pub_year}
instance decodeResponse :: DecodeJson Response where instance decodeResponse :: DecodeJson Response where
...@@ -86,9 +91,10 @@ instance decodeResponse :: DecodeJson Response where ...@@ -86,9 +91,10 @@ instance decodeResponse :: DecodeJson Response where
category <- obj .: "category" category <- obj .: "category"
cid <- obj .: "id" cid <- obj .: "id"
hyperdata <- obj .: "hyperdata" hyperdata <- obj .: "hyperdata"
ngramCount <- obj .: "id" ngramCount <- obj .: "ngramCount"
score <- obj .: "score"
title <- obj .: "title" title <- obj .: "title"
pure $ Response { cid, title, category: decodeCategory category, ngramCount, hyperdata } pure $ Response { category: decodeCategory category, cid, hyperdata, ngramCount, score, title }
type LocalCategories = Map Int Category type LocalCategories = Map Int Category
...@@ -102,7 +108,8 @@ sampleData' = DocumentsView { _id : 1 ...@@ -102,7 +108,8 @@ sampleData' = DocumentsView { _id : 1
, title : "title" , title : "title"
, source : "source" , source : "source"
, category : UnRead , category : UnRead
, ngramCount : 1} , ngramCount : Just 1
, score: Just 1 }
sampleData :: Array DocumentsView sampleData :: Array DocumentsView
--sampleData = replicate 10 sampleData' --sampleData = replicate 10 sampleData'
...@@ -112,7 +119,8 @@ sampleData = map (\(Tuple t s) -> DocumentsView { _id : 1 ...@@ -112,7 +119,8 @@ sampleData = map (\(Tuple t s) -> DocumentsView { _id : 1
, title: t , title: t
, source: s , source: s
, category : UnRead , category : UnRead
, ngramCount : 10}) sampleDocuments , ngramCount : Just 10
, score: Just 1 }) sampleDocuments
sampleDocuments :: Array (Tuple String String) 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"]
...@@ -20,7 +20,6 @@ import Gargantext.Components.InputWithEnter (inputWithEnter) ...@@ -20,7 +20,6 @@ import Gargantext.Components.InputWithEnter (inputWithEnter)
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs as Tabs import Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs as Tabs
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (Contact(..), ContactData, ContactTouch(..), ContactWhere(..), ContactWho(..), HyperdataContact(..), HyperdataUser(..), _city, _country, _firstName, _labTeamDeptsJoinComma, _lastName, _mail, _office, _organizationJoinComma, _ouFirst, _phone, _role, _shared, _touch, _who, defaultContactTouch, defaultContactWhere, defaultContactWho, defaultHyperdataContact, defaultHyperdataUser) import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (Contact(..), ContactData, ContactTouch(..), ContactWhere(..), ContactWho(..), HyperdataContact(..), HyperdataUser(..), _city, _country, _firstName, _labTeamDeptsJoinComma, _lastName, _mail, _office, _organizationJoinComma, _ouFirst, _phone, _role, _shared, _touch, _who, defaultContactTouch, defaultContactWhere, defaultContactWho, defaultHyperdataContact, defaultHyperdataUser)
import Gargantext.Components.Nodes.Lists.Types as LT import Gargantext.Components.Nodes.Lists.Types as LT
import Gargantext.Components.Nodes.Texts.Types as TT
import Gargantext.Ends (Frontends) import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (Unit, bind, const, discard, pure, show, unit, ($), (+), (<$>), (<<<), (<>), (==)) import Gargantext.Prelude (Unit, bind, const, discard, pure, show, unit, ($), (+), (<$>), (<<<), (<>), (==))
......
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