Commit 4bb618e2 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[Corpus] Facets added.

parent 898dae3c
...@@ -5,7 +5,10 @@ import Prelude hiding (div) ...@@ -5,7 +5,10 @@ import Prelude hiding (div)
import Control.Monad.Trans.Class (lift) import Control.Monad.Trans.Class (lift)
import Data.Maybe (Maybe(..), maybe) import Data.Maybe (Maybe(..), maybe)
import Data.Lens (Lens', Prism', lens, prism, (?~)) import Data.Lens (Lens', Prism', lens, prism, (?~))
import Data.List (fromFoldable)
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Tuple (Tuple(..))
import Data.Argonaut (class DecodeJson, decodeJson, (.?)) import Data.Argonaut (class DecodeJson, decodeJson, (.?))
import Effect.Aff (Aff) import Effect.Aff (Aff)
...@@ -14,14 +17,11 @@ import Effect.Console (log) ...@@ -14,14 +17,11 @@ import Effect.Console (log)
import React.DOM (div, h3, hr, i, p, text) import React.DOM (div, h3, hr, i, p, text)
import React.DOM.Props (className, style) import React.DOM.Props (className, style)
import Thermite ( Render, Spec, PerformAction import Thermite ( Render, Spec, PerformAction, focus, hide
, defaultPerformAction, simpleSpec, modifyState) , defaultPerformAction, simpleSpec, modifyState)
-------------------------------------------------------- --------------------------------------------------------
import Gargantext.Config (toUrl, NodeType(..), End(..)) import Gargantext.Config (toUrl, NodeType(..), End(..))
import Gargantext.Config.REST (get) import Gargantext.Config.REST (get)
import Gargantext.Components.Charts.Options.ECharts (chart)
import Gargantext.Pages.Corpus.Doc.Facets.Dashboard (globalPublis)
import Gargantext.Pages.Corpus.Doc.Facets (pureTab1)
--------------------------------------------------------- ---------------------------------------------------------
-- Facets -- Facets
import Gargantext.Pages.Corpus.Doc.Facets.Documents as D import Gargantext.Pages.Corpus.Doc.Facets.Documents as D
...@@ -30,19 +30,80 @@ import Gargantext.Pages.Corpus.Doc.Facets.Authors as A ...@@ -30,19 +30,80 @@ import Gargantext.Pages.Corpus.Doc.Facets.Authors as A
import Gargantext.Pages.Corpus.Doc.Facets.Terms as T import Gargantext.Pages.Corpus.Doc.Facets.Terms as T
import Gargantext.Components.Tab as Tab import Gargantext.Components.Tab as Tab
------------------------------------------------------------------- -------------------------------------------------------------------
type State = { info :: Maybe (NodePoly CorpusInfo) type State = { info :: Maybe (NodePoly CorpusInfo)
-- , docview :: D.state , docsView :: D.State
-- , authorview :: A.State , authorsView :: A.State
-- , sourceview :: S.State , sourcesView :: S.State
-- , termsview :: T.State , termsView :: T.State
-- , activeTab :: Int , activeTab :: Int
} }
initialState :: State initialState :: State
initialState = { info : Nothing } initialState = { info : Nothing
, docsView : D.initialState
, authorsView : A.initialState
, sourcesView : S.initialState
, termsView : T.initialState
, activeTab : 0
}
------------------------------------------------------------------------
_info :: Lens' State (Maybe (NodePoly CorpusInfo))
_info = lens (\s -> s.info) (\s ss -> s{info = ss})
_doclens :: Lens' State D.State
_doclens = lens (\s -> s.docsView) (\s ss -> s {docsView = ss})
_authorlens :: Lens' State A.State
_authorlens = lens (\s -> s.authorsView) (\s ss -> s {authorsView = ss})
_sourcelens :: Lens' State S.State
_sourcelens = lens (\s -> s.sourcesView) (\s ss -> s {sourcesView = ss})
_termslens :: Lens' State T.State
_termslens = lens (\s -> s.termsView) (\s ss -> s {termsView = ss})
data Action = Load Int _tablens :: Lens' State Tab.State
_tablens = lens (\s -> s.activeTab) (\s ss -> s {activeTab = ss})
------------------------------------------------------------------------
data Action = Load Int
| DocviewA D.Action
| AuthorviewA A.Action
| SourceviewA S.Action
| TermsviewA T.Action
| TabViewA Tab.Action
_docAction :: Prism' Action D.Action
_docAction = prism DocviewA \ action ->
case action of
DocviewA laction -> Right laction
_-> Left action
_authorAction :: Prism' Action A.Action
_authorAction = prism AuthorviewA \ action ->
case action of
AuthorviewA laction -> Right laction
_-> Left action
_sourceAction :: Prism' Action S.Action
_sourceAction = prism SourceviewA \ action ->
case action of
SourceviewA laction -> Right laction
_-> Left action
_termsAction :: Prism' Action T.Action
_termsAction = prism TermsviewA \ action ->
case action of
TermsviewA laction -> Right laction
_-> Left action
_tabAction :: Prism' Action Tab.Action
_tabAction = prism TabViewA \ action ->
case action of
TabViewA laction -> Right laction
_-> Left action
------------------------------------------------------------------------
newtype NodePoly a = NodePoly { id :: Int newtype NodePoly a = NodePoly { id :: Int
, typename :: Int , typename :: Int
, userId :: Int , userId :: Int
...@@ -111,7 +172,7 @@ instance decodeNode :: (DecodeJson a) => DecodeJson (NodePoly a) where ...@@ -111,7 +172,7 @@ instance decodeNode :: (DecodeJson a) => DecodeJson (NodePoly a) where
------------------------------------------------------------------------ ------------------------------------------------------------------------
layout :: Spec State {} Action layout :: Spec State {} Action
layout = corpusSpec -- <> pureTab1 layout = corpusSpec <> facets
corpusSpec :: Spec State {} Action corpusSpec :: Spec State {} Action
corpusSpec = simpleSpec performAction render corpusSpec = simpleSpec performAction render
...@@ -152,7 +213,6 @@ corpusSpec = simpleSpec performAction render ...@@ -152,7 +213,6 @@ corpusSpec = simpleSpec performAction render
------------------------------------------------------------------------ ------------------------------------------------------------------------
performAction :: PerformAction State {} Action performAction :: PerformAction State {} Action
performAction (Load nId) _ _ = do performAction (Load nId) _ _ = do
eitherInfo <- lift $ getNode nId eitherInfo <- lift $ getNode nId
...@@ -166,14 +226,30 @@ performAction _ _ _ = pure unit ...@@ -166,14 +226,30 @@ performAction _ _ _ = pure unit
getNode :: Int -> Aff (Either String (NodePoly CorpusInfo)) getNode :: Int -> Aff (Either String (NodePoly CorpusInfo))
getNode id = get $ toUrl Back Node id getNode id = get $ toUrl Back Node id
_info :: Lens' State (Maybe (NodePoly CorpusInfo))
_info = lens (\s -> s.info) (\s ss -> s{info = ss})
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Tabs -- Facets
------------------------------------------------------------------------ ------------------------------------------------------------------------
facets :: Spec State {} Action
facets = hide initialState statefulFacets
statefulFacets :: Spec State {} Action
statefulFacets =
Tab.tabs _tablens _tabAction $ fromFoldable [ Tuple "Doc View" docPageSpec
, Tuple "Author View" authorPageSpec
, Tuple "Source View" sourcePageSpec
, Tuple "Terms View" termsPageSpec
]
docPageSpec :: Spec State {} Action
docPageSpec = focus _doclens _docAction D.layoutDocview
authorPageSpec :: Spec State {} Action
authorPageSpec = focus _authorlens _authorAction A.authorspec'
sourcePageSpec :: Spec State {} Action
sourcePageSpec = focus _sourcelens _sourceAction S.sourcespec'
termsPageSpec :: Spec State {} Action
termsPageSpec = focus _termslens _termsAction T.termSpec'
...@@ -10,7 +10,7 @@ import Thermite (PerformAction, Render, Spec, defaultPerformAction, simpleSpec) ...@@ -10,7 +10,7 @@ import Thermite (PerformAction, Render, Spec, defaultPerformAction, simpleSpec)
type State = D.State type State = D.State
initialState :: State initialState :: State
initialState = D.tdata initialState = D.initialState
type Action = D.Action type Action = D.Action
......
...@@ -21,6 +21,11 @@ import Gargantext.Config (NodeType(..), toUrl, End(..)) ...@@ -21,6 +21,11 @@ import Gargantext.Config (NodeType(..), toUrl, End(..))
import Gargantext.Config.REST (get) import Gargantext.Config.REST (get)
import Gargantext.Utils.DecodeMaybe ((.|)) import Gargantext.Utils.DecodeMaybe ((.|))
------------------------------------------------------------------------
import Gargantext.Components.Charts.Options.ECharts (chart)
import Gargantext.Pages.Corpus.Doc.Facets.Dashboard (globalPublis)
------------------------------------------------------------------------
import React (ReactElement) import React (ReactElement)
import React.DOM (a, b, b', br', div, input, option, select, span, table, tbody, td, text, th, thead, tr, p) import React.DOM (a, b, b', br', div, input, option, select, span, table, tbody, td, text, th, thead, tr, p)
import React.DOM.Props (_type, className, href, onChange, onClick, scope, selected, value) import React.DOM.Props (_type, className, href, onChange, onClick, scope, selected, value)
...@@ -51,7 +56,7 @@ data Action ...@@ -51,7 +56,7 @@ data Action
type State = CorpusTableData type State = CorpusTableData
type CorpusTableData = TableData CorpusView type CorpusTableData = TableData DocumentsView
newtype TableData a newtype TableData a
= TableData = TableData
...@@ -66,8 +71,8 @@ newtype TableData a ...@@ -66,8 +71,8 @@ newtype TableData a
-- , tree :: FTree -- , tree :: FTree
} }
newtype CorpusView newtype DocumentsView
= CorpusView = DocumentsView
{ _id :: Int { _id :: Int
, url :: String , url :: String
, date :: String , date :: String
...@@ -78,9 +83,9 @@ newtype CorpusView ...@@ -78,9 +83,9 @@ newtype CorpusView
} }
derive instance genericCorpus :: Generic CorpusView _ derive instance genericCorpus :: Generic DocumentsView _
instance showCorpus :: Show CorpusView where instance showCorpus :: Show DocumentsView where
show = genericShow show = genericShow
...@@ -150,8 +155,8 @@ layoutDocview = simpleSpec performAction render ...@@ -150,8 +155,8 @@ layoutDocview = simpleSpec performAction render
render dispatch _ state@(TableData d) _ = render dispatch _ state@(TableData d) _ =
[ div [className "container1"] [ div [className "container1"]
[ div [className "row"] [ div [className "row"]
[ [ chart globalPublis
div [className "col-md-12"] , div [className "col-md-12"]
[ p [] [] [ p [] []
, div [] [ text " Filter ", input []] , div [] [ text " Filter ", input []]
, br' , br'
...@@ -186,12 +191,12 @@ performAction (LoadData n) _ _ = do ...@@ -186,12 +191,12 @@ performAction (LoadData n) _ _ = do
res <- lift $ loadPage n res <- lift $ loadPage n
case res of case res of
Left err -> do Left err -> do
_ <- liftEffect $ log $ show err _ <- liftEffect $ log $ show $ "Error: loading page documents:" <> show err
_ <- liftEffect $ log $ show "Error: loading page documents"
pure unit pure unit
Right resData -> do Right resData -> do
_ <- liftEffect $ log $ show "OK: loading page documents" _ <- liftEffect $ log $ show "OK: loading page documents."
void $ modifyState $ const resData _ <- modifyState $ const resData
pure unit
loadPage :: Int -> Aff (Either String CorpusTableData) loadPage :: Int -> Aff (Either String CorpusTableData)
...@@ -210,9 +215,9 @@ loadPage n = do ...@@ -210,9 +215,9 @@ loadPage n = do
_ <- 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)
pure $ Right docs pure $ Right docs
where where
res2corpus :: Array Response -> Array CorpusView res2corpus :: Array Response -> Array DocumentsView
res2corpus rs = map (\(Response r) -> res2corpus rs = map (\(Response r) ->
CorpusView { _id : r.cid DocumentsView { _id : r.cid
, url : "" , url : ""
, date : r.created , date : r.created
, title : (\(Hyperdata hr) -> hr.title) r.hyperdata , title : (\(Hyperdata hr) -> hr.title) r.hyperdata
...@@ -222,7 +227,7 @@ loadPage n = do ...@@ -222,7 +227,7 @@ loadPage n = do
}) rs }) rs
toTableData :: Array CorpusView -> CorpusTableData toTableData :: Array DocumentsView -> CorpusTableData
toTableData ds = TableData toTableData ds = TableData
{ rows : map (\d -> { row : d , delete : false}) ds { rows : map (\d -> { row : d , delete : false}) ds
, totalPages : 474 , totalPages : 474
...@@ -234,25 +239,25 @@ loadPage n = do ...@@ -234,25 +239,25 @@ loadPage n = do
--------------------------------------------------------- ---------------------------------------------------------
sampleData' :: CorpusView sampleData' :: DocumentsView
sampleData' = CorpusView {_id : 1, url : "", date : "date3", title : "title", source : "source", fav : false, ngramCount : 1} sampleData' = DocumentsView {_id : 1, url : "", date : "date3", title : "title", source : "source", fav : false, ngramCount : 1}
sampleData :: Array CorpusView sampleData :: Array DocumentsView
--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) -> DocumentsView {_id : 1, url : "", date : "2017", title: t, source: s, fav : false, ngramCount : 10}) 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"]
data' :: Array CorpusView -> Array {row :: CorpusView, delete :: Boolean} data' :: Array DocumentsView -> Array {row :: DocumentsView, delete :: Boolean}
data' = map {row : _, delete : false} data' = map {row : _, delete : false}
sdata :: Array { row :: CorpusView, delete :: Boolean } sdata :: Array { row :: DocumentsView, delete :: Boolean }
sdata = data' sampleData sdata = data' sampleData
tdata :: TableData CorpusView initialState :: TableData DocumentsView
tdata = TableData initialState = TableData
{ rows : sdata { rows : sdata
, totalPages : 10 , totalPages : 10
, currentPage : 1 , currentPage : 1
...@@ -263,8 +268,8 @@ tdata = TableData ...@@ -263,8 +268,8 @@ tdata = TableData
} }
showRow :: {row :: CorpusView, delete :: Boolean} -> ReactElement showRow :: {row :: DocumentsView, delete :: Boolean} -> ReactElement
showRow {row : (CorpusView c), delete} = showRow {row : (DocumentsView c), delete} =
tr [] tr []
[ 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
......
...@@ -11,7 +11,7 @@ type State = D.State ...@@ -11,7 +11,7 @@ type State = D.State
initialState :: D.State initialState :: D.State
initialState = D.tdata initialState = D.initialState
type Action = D.Action type Action = D.Action
......
...@@ -18,11 +18,11 @@ type State = ...@@ -18,11 +18,11 @@ type State =
initialState :: State initialState :: State
initialState = initialState =
{ docview : DV.tdata { docview : DV.initialState
, authorview : AV.initialState , authorview : AV.initialState
, sourceview : SV.initialState , sourceview : SV.initialState
, termsview : TV.initialState , termsview : TV.initialState
, activeTab : 0 , activeTab : 0
} }
_doclens :: Lens' State DV.State _doclens :: Lens' State DV.State
......
...@@ -12,7 +12,7 @@ type State = D.State ...@@ -12,7 +12,7 @@ type State = D.State
initialState :: D.State initialState :: D.State
initialState = D.tdata initialState = D.initialState
type Action = D.Action type Action = D.Action
......
...@@ -8,7 +8,7 @@ import Gargantext.Pages.Layout.Specs.AddCorpus as AC ...@@ -8,7 +8,7 @@ import Gargantext.Pages.Layout.Specs.AddCorpus as AC
-- import Gargantext.Pages.Corpus.Doc.Annotation as D -- import Gargantext.Pages.Corpus.Doc.Annotation as D
import Gargantext.Pages.Corpus as Corpus import Gargantext.Pages.Corpus as Corpus
import Gargantext.Pages.Corpus.Doc.Facets.Documents as DV import Gargantext.Pages.Corpus.Doc.Facets.Documents as D
import Gargantext.Pages.Corpus.Doc.Facets.Graph as GE import Gargantext.Pages.Corpus.Doc.Facets.Graph as GE
-- import Gargantext.Pages.Corpus.Doc.Facets.Terms.NgramsTable as NG -- import Gargantext.Pages.Corpus.Doc.Facets.Terms.NgramsTable as NG
...@@ -38,11 +38,12 @@ dispatchAction dispatcher _ AddCorpus = do ...@@ -38,11 +38,12 @@ dispatchAction dispatcher _ AddCorpus = do
dispatchAction dispatcher _ (DocView n) = do dispatchAction dispatcher _ (DocView n) = do
dispatcher $ SetRoute (DocView n) dispatcher $ SetRoute (DocView n)
dispatcher $ DocViewA $ DV.LoadData n dispatcher $ DocViewA $ D.LoadData n
dispatchAction dispatcher _ (Corpus n) = do dispatchAction dispatcher _ (Corpus n) = do
dispatcher $ SetRoute $ Corpus n dispatcher $ SetRoute $ Corpus n
dispatcher $ CorpusAction $ Corpus.Load n dispatcher $ CorpusAction $ Corpus.Load n
dispatcher $ DocViewA $ D.LoadData n
dispatchAction dispatcher _ SearchView = do dispatchAction dispatcher _ SearchView = do
dispatcher $ SetRoute SearchView dispatcher $ SetRoute SearchView
......
...@@ -9,10 +9,10 @@ import Gargantext.Components.Tree as Tree ...@@ -9,10 +9,10 @@ import Gargantext.Components.Tree as Tree
import Gargantext.Pages.Corpus as Corpus import Gargantext.Pages.Corpus as Corpus
import Gargantext.Pages.Corpus.Doc.Annotation as D import Gargantext.Pages.Corpus.Doc.Annotation as D
import Gargantext.Pages.Annuaire as Annuaire import Gargantext.Pages.Annuaire as Annuaire
import Gargantext.Pages.Corpus.Doc.Facets.Documents as DV import Gargantext.Pages.Corpus.Doc.Facets.Documents as DV
import Gargantext.Pages.Corpus.Doc.Facets.Graph as GE import Gargantext.Pages.Corpus.Doc.Facets.Graph as GE
import Gargantext.Pages.Annuaire.User.Users as U import Gargantext.Pages.Annuaire.User.Users as U
import Gargantext.Pages.Layout.Specs.AddCorpus as AC import Gargantext.Pages.Layout.Specs.AddCorpus as AC
import Gargantext.Pages.Layout.Specs.Search as S import Gargantext.Pages.Layout.Specs.Search as S
import Gargantext.Router (Routes(..)) import Gargantext.Router (Routes(..))
...@@ -41,7 +41,7 @@ initAppState = ...@@ -41,7 +41,7 @@ initAppState =
, corpus : Corpus.initialState , corpus : Corpus.initialState
, loginState : LN.initialState , loginState : LN.initialState
, addCorpusState : AC.initialState , addCorpusState : AC.initialState
, docViewState : DV.tdata , docViewState : DV.initialState
, searchState : S.initialState , searchState : S.initialState
, userPageState : U.initialState , userPageState : U.initialState
, docAnnotationState : D.initialState , docAnnotationState : D.initialState
......
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