Commit 6e229ca7 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[DEMO] adding Annuaire connexion.

parent ed23e69d
...@@ -3,7 +3,10 @@ module DocView where ...@@ -3,7 +3,10 @@ module DocView where
import Data.Argonaut import Data.Argonaut
import Data.Generic (class Generic, gShow) import Data.Generic (class Generic, gShow)
import Gargantext.Chart (histogram2, p'') import Gargantext.Charts.ECharts
import Gargantext.Chart (p'')
import Gargantext.Dashboard (globalPublis)
import Control.Monad.Eff.Class (liftEff) import Control.Monad.Eff.Class (liftEff)
import Control.Monad.Aff (Aff, attempt) import Control.Monad.Aff (Aff, attempt)
import Control.Monad.Aff.Class (liftAff) import Control.Monad.Aff.Class (liftAff)
...@@ -109,24 +112,44 @@ newtype Hyperdata = Hyperdata ...@@ -109,24 +112,44 @@ newtype Hyperdata = Hyperdata
, source :: String , source :: String
} }
--instance decodeHyperdata :: DecodeJson Hyperdata where
-- decodeJson json = do
-- obj <- decodeJson json
-- title <- obj .? "title"
-- source <- obj .? "source"
-- pure $ Hyperdata { title,source }
--instance decodeResponse :: DecodeJson Response where
-- decodeJson json = do
-- obj <- decodeJson json
-- cid <- obj .? "id"
-- created <- obj .? "created"
-- favorite <- obj .? "favorite"
-- ngramCount <- obj .? "ngramCount"
-- hyperdata <- obj .? "hyperdata"
-- pure $ Response { cid, created, favorite, ngramCount, hyperdata }
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" title <- obj .? "nom"
source <- obj .? "source" source <- obj .? "fonction"
pure $ Hyperdata { title,source } pure $ Hyperdata { title,source }
instance decodeResponse :: DecodeJson Response where instance decodeResponse :: DecodeJson Response where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
cid <- obj .? "id" cid <- obj .? "id"
created <- obj .? "created" created <- pure "2018"
favorite <- obj .? "favorite" --created <- obj .? "date"
ngramCount <- obj .? "ngramCount" favorite <- pure true
ngramCount <- obj .? "id"
hyperdata <- obj .? "hyperdata" hyperdata <- obj .? "hyperdata"
pure $ Response { cid, created, favorite, ngramCount, hyperdata } pure $ Response { cid, created, favorite, ngramCount, hyperdata }
-- | Filter -- | Filter
filterSpec :: forall eff props. Spec eff State props Action filterSpec :: forall eff props. Spec eff State props Action
filterSpec = simpleSpec defaultPerformAction render filterSpec = simpleSpec defaultPerformAction render
...@@ -146,9 +169,6 @@ layoutDocview = simpleSpec performAction render ...@@ -146,9 +169,6 @@ layoutDocview = simpleSpec performAction render
div [className "col-md-12"] div [className "col-md-12"]
[ p'' [ p''
, div [] [ text " Filter ", input [] []] , div [] [ text " Filter ", input [] []]
, h3 [] [text "Chart Title"]
, histogram2
, p''
, br' [] , br' []
, div [] [ b [] [text d.title] , div [] [ b [] [text d.title]
, sizeDD d.pageSize dispatch , sizeDD d.pageSize dispatch
...@@ -159,8 +179,10 @@ layoutDocview = simpleSpec performAction render ...@@ -159,8 +179,10 @@ layoutDocview = simpleSpec performAction render
[thead [ className "thead-dark"] [thead [ className "thead-dark"]
[tr [] [ th [scope "col"] [ b' [text ""] ] [tr [] [ th [scope "col"] [ b' [text ""] ]
, th [scope "col"] [ b' [text "Date"]] , th [scope "col"] [ b' [text "Date"]]
, th [scope "col"] [ b' [text "Title"] ] , th [scope "col"] [ b' [text "Name"] ]
, th [scope "col"] [ b' [text "Source"] ] --, th [scope "col"] [ b' [text "Title"] ]
--, th [scope "col"] [ b' [text "Source"] ]
, th [scope "col"] [ b' [text "Fonction"] ]
, th [scope "col"] [ b' [text "Delete"] ] , th [scope "col"] [ b' [text "Delete"] ]
] ]
] ]
...@@ -185,7 +207,8 @@ performAction LoadData _ _ = void do ...@@ -185,7 +207,8 @@ performAction LoadData _ _ = void do
loadPage :: forall eff. Aff (ajax :: AJAX, console :: CONSOLE | eff) (Either String CorpusTableData) loadPage :: forall eff. Aff (ajax :: AJAX, console :: CONSOLE | eff) (Either String CorpusTableData)
loadPage = do loadPage = do
res <- get "http://localhost:8008/corpus/472764/facet/documents/table?offset=0&limit=10" res <- get "http://localhost:8008/node/452132/children"
-- res <- get "http://localhost:8008/corpus/472764/facet/documents/table?offset=0&limit=10"
case res of case res of
Left err -> do Left err -> do
_ <- liftEff $ log $ show err _ <- liftEff $ log $ show err
...@@ -211,10 +234,10 @@ loadPage = do ...@@ -211,10 +234,10 @@ loadPage = do
toTableData :: Array Corpus -> CorpusTableData toTableData :: Array Corpus -> CorpusTableData
toTableData ds = TableData toTableData ds = TableData
{ rows : map (\d -> { row : d , delete : false}) ds { rows : map (\d -> { row : d , delete : false}) ds
, totalPages : 10 , totalPages : 474
, currentPage : 1 , currentPage : 1
, pageSize : PS10 , pageSize : PS100
, totalRecords : 100 , totalRecords : 47361
, title : "Documents" , title : "Documents"
-- , tree : exampleTree -- , tree : exampleTree
} }
...@@ -251,7 +274,7 @@ showRow {row : (Corpus c), delete} = ...@@ -251,7 +274,7 @@ showRow {row : (Corpus 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 [ href "#/documentView/1"] [ text c.title ] ] , td [] [ a [ href "#/userPage"] [ text c.title ] ]
, td [] [text c.source] , td [] [text c.source]
, td [] [input [ _type "checkbox"] []] , td [] [input [ _type "checkbox"] []]
] ]
...@@ -313,7 +336,7 @@ optps cv val = option [ selected (cv == val), value $ show val ] [text $ show va ...@@ -313,7 +336,7 @@ optps cv val = option [ selected (cv == val), value $ show val ] [text $ show va
textDescription :: Int -> PageSizes -> Int -> ReactElement textDescription :: Int -> PageSizes -> Int -> ReactElement
textDescription currPage pageSize totalRecords textDescription currPage pageSize totalRecords
= div [className "row"] = div [className "row"]
[ div [className "col-md-12"] [ div [className "col-md-2"]
[ text $ "Showing " <> show start <> " to " <> show end <> " of " <> show totalRecords ] [ text $ "Showing " <> show start <> " to " <> show end <> " of " <> show totalRecords ]
] ]
where where
...@@ -325,11 +348,7 @@ textDescription currPage pageSize totalRecords ...@@ -325,11 +348,7 @@ textDescription currPage pageSize totalRecords
pagination :: _ -> Int -> Int -> ReactElement pagination :: _ -> Int -> Int -> ReactElement
pagination d tp cp pagination d tp cp
= span [] $ = span [] $
[ text "Pages: " [ text "Pages: ", prev, first, ldots]
, prev
, first
, ldots
]
<> <>
lnums lnums
<> <>
...@@ -337,10 +356,7 @@ pagination d tp cp ...@@ -337,10 +356,7 @@ pagination d tp cp
<> <>
rnums rnums
<> <>
[ rdots [ rdots, last, next ]
, last
, next
]
where where
prev = if cp == 1 then prev = if cp == 1 then
text " Previous " text " Previous "
......
module Gargantext.Dashboard where module Gargantext.Dashboard where
import Prelude (($), (<>), show, pure, unit, map) import Prelude (($), (<>), show, pure, unit, map)
import Data.Array (zip)
import Data.Tuple (Tuple(..))
import Gargantext.Charts.ECharts import Gargantext.Charts.ECharts
import Gargantext.Charts.Series import Gargantext.Charts.Series
import DOM (DOM) import DOM (DOM)
import Data.Unit (Unit) import Data.Unit (Unit)
import Data.Int (toNumber)
import React.DOM (div, h1, text, title) import React.DOM (div, h1, text, title)
import React.DOM.Props (className) import React.DOM.Props (className)
import Thermite (PerformAction, Render, Spec, simpleSpec) import Thermite (PerformAction, Render, Spec, simpleSpec)
...@@ -32,22 +36,6 @@ render dispatch _ state _ = [ ...@@ -32,22 +36,6 @@ render dispatch _ state _ = [
) )
] ]
where where
globalPublis :: Options
globalPublis = (Options { mainTitle : "Global Scientific Publications"
, subTitle : "Distribution of scientific publications by IMT's Schools over time"
, xAxis : xAxis ["Jan", "Feb", "Mar", "Apr", "May"]
, yAxis : [series Bar "Number of publication of IMT / year" [ {name: "Test1", value: 12.0}
, {name: "Test2", value: 20.0}
, {name: "Test4", value: 35.0}
, {name: "Test5", value: 2.0}
, {name: "Test3", value: 32.0}
]
]
, yAxisFormat : (YAxisFormat { position : "left"
, visible : true
})
, addZoom : true
})
distriBySchool :: Options distriBySchool :: Options
distriBySchool = Options { mainTitle : "School production in 2018" distriBySchool = Options { mainTitle : "School production in 2018"
, subTitle : "Distribution by school" , subTitle : "Distribution by school"
...@@ -82,21 +70,40 @@ render dispatch _ state _ = [ ...@@ -82,21 +70,40 @@ render dispatch _ state _ = [
} }
naturePublis :: Options -----------------------------------------------------------------------------------------------------------
naturePublis = Options { mainTitle : "Nature of publications"
, subTitle : "Distribution by type" naturePublis_x = ["COMM","ART","COUV","THESE","REPORT","UNDEFINED","OTHER","POSTER","DOUV","OUV","PATENT","MEM","HDR","PRESCONF","LECTURE","VIDEO"]
, xAxis : xAxis [] naturePublis_y' = [23901,17417,1585,1188,1176,895,473,393,323,246,108,43,36,26,9,1]
, yAxis : [series Funnel "Funnel Data" [ {name: "Articles", value: 60.0}
, {name: "Reports", value: 100.0} naturePublis_y = map (\(Tuple n v) -> {name: n, value: toNumber v }) (zip naturePublis_x naturePublis_y')
, {name: "Patents", value: 40.0}
, {name: "Books", value: 65.0} naturePublis :: Options
] naturePublis = Options { mainTitle : "Nature of publications"
] , subTitle : "Distribution by type"
, yAxisFormat : (YAxisFormat { position : "left" , xAxis : xAxis []
, visible : false , yAxis : [series Funnel "Funnel Data" naturePublis_y]
}) , yAxisFormat : (YAxisFormat { position : "left"
, addZoom : false , visible : false
} })
, addZoom : false
}
-----------------------------------------------------------------------------------------------------------
globalPublis_x = [1982,1986,1987,1988,1990,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017]
globalPublis_y = [1,4,2,1,1,2,1,1,8,38,234,76,40,82,75,202,1475,1092,1827,2630,4978,3668,4764,5915,4602,5269,6814,4018]
globalPublis :: Options
globalPublis = (Options { mainTitle : "Global Scientific Publications"
, subTitle : "Distribution of scientific publications by IMT's Schools over time"
, xAxis : xAxis (map show globalPublis_x)
, yAxis : [series Bar "Number of publication of IMT / year" $ map (\n -> {name: "", value: toNumber n }) globalPublis_y]
, yAxisFormat : (YAxisFormat { position : "left"
, visible : true
})
, addZoom : true
})
......
...@@ -48,18 +48,6 @@ toggleNode sid a = a ...@@ -48,18 +48,6 @@ toggleNode sid a = a
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Realistic Tree for the UI -- Realistic Tree for the UI
corpus :: Int -> String -> NTree (Tuple String String)
corpus n name = NNode n false name
[ NLeaf (Tuple "Facets" "#/docView")
, NLeaf (Tuple "Dashboard" "#/dashboard")
, NLeaf (Tuple "Graph" "#/graphExplorer")
]
annuaire :: Int -> String -> NTree (Tuple String String)
annuaire n name = NNode n false name
[ NLeaf (Tuple "Facets" "#/docView")
]
exampleTree :: NTree (Tuple String String) exampleTree :: NTree (Tuple String String)
exampleTree = exampleTree =
NNode 1 true "françois.pineau" NNode 1 true "françois.pineau"
...@@ -67,6 +55,19 @@ exampleTree = ...@@ -67,6 +55,19 @@ exampleTree =
, corpus 3 "IMT publications" , corpus 3 "IMT publications"
] ]
annuaire :: Int -> String -> NTree (Tuple String String)
annuaire n name = NNode n false name
[ NLeaf (Tuple "IMT community" "#/docView")
]
corpus :: Int -> String -> NTree (Tuple String String)
corpus n name = NNode n false name
[ NLeaf (Tuple "Facets" "#/corpus")
, NLeaf (Tuple "Dashboard" "#/dashboard")
, NLeaf (Tuple "Graph" "#/graphExplorer")
]
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- TODO -- TODO
-- alignment to the right -- alignment to the right
......
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