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

[DEMO] adding Annuaire connexion.

parent ed23e69d
......@@ -3,7 +3,10 @@ module DocView where
import Data.Argonaut
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.Aff (Aff, attempt)
import Control.Monad.Aff.Class (liftAff)
......@@ -109,24 +112,44 @@ newtype Hyperdata = Hyperdata
, 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
decodeJson json = do
obj <- decodeJson json
title <- obj .? "title"
source <- obj .? "source"
title <- obj .? "nom"
source <- obj .? "fonction"
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"
created <- pure "2018"
--created <- obj .? "date"
favorite <- pure true
ngramCount <- obj .? "id"
hyperdata <- obj .? "hyperdata"
pure $ Response { cid, created, favorite, ngramCount, hyperdata }
-- | Filter
filterSpec :: forall eff props. Spec eff State props Action
filterSpec = simpleSpec defaultPerformAction render
......@@ -146,9 +169,6 @@ layoutDocview = simpleSpec performAction render
div [className "col-md-12"]
[ p''
, div [] [ text " Filter ", input [] []]
, h3 [] [text "Chart Title"]
, histogram2
, p''
, br' []
, div [] [ b [] [text d.title]
, sizeDD d.pageSize dispatch
......@@ -159,8 +179,10 @@ layoutDocview = simpleSpec performAction render
[thead [ className "thead-dark"]
[tr [] [ th [scope "col"] [ b' [text ""] ]
, th [scope "col"] [ b' [text "Date"]]
, th [scope "col"] [ b' [text "Title"] ]
, th [scope "col"] [ b' [text "Source"] ]
, th [scope "col"] [ b' [text "Name"] ]
--, th [scope "col"] [ b' [text "Title"] ]
--, th [scope "col"] [ b' [text "Source"] ]
, th [scope "col"] [ b' [text "Fonction"] ]
, th [scope "col"] [ b' [text "Delete"] ]
]
]
......@@ -185,7 +207,8 @@ performAction LoadData _ _ = void do
loadPage :: forall eff. Aff (ajax :: AJAX, console :: CONSOLE | eff) (Either String CorpusTableData)
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
Left err -> do
_ <- liftEff $ log $ show err
......@@ -211,10 +234,10 @@ loadPage = do
toTableData :: Array Corpus -> CorpusTableData
toTableData ds = TableData
{ rows : map (\d -> { row : d , delete : false}) ds
, totalPages : 10
, totalPages : 474
, currentPage : 1
, pageSize : PS10
, totalRecords : 100
, pageSize : PS100
, totalRecords : 47361
, title : "Documents"
-- , tree : exampleTree
}
......@@ -251,7 +274,7 @@ showRow {row : (Corpus c), delete} =
[ td [] [div [className $ fa <> "fa-star"][]]
-- TODO show date: Year-Month-Day only
, td [] [text c.date]
, td [] [ a [ href "#/documentView/1"] [ text c.title ] ]
, td [] [ a [ href "#/userPage"] [ text c.title ] ]
, td [] [text c.source]
, td [] [input [ _type "checkbox"] []]
]
......@@ -313,7 +336,7 @@ optps cv val = option [ selected (cv == val), value $ show val ] [text $ show va
textDescription :: Int -> PageSizes -> Int -> ReactElement
textDescription currPage pageSize totalRecords
= div [className "row"]
[ div [className "col-md-12"]
[ div [className "col-md-2"]
[ text $ "Showing " <> show start <> " to " <> show end <> " of " <> show totalRecords ]
]
where
......@@ -325,11 +348,7 @@ textDescription currPage pageSize totalRecords
pagination :: _ -> Int -> Int -> ReactElement
pagination d tp cp
= span [] $
[ text "Pages: "
, prev
, first
, ldots
]
[ text "Pages: ", prev, first, ldots]
<>
lnums
<>
......@@ -337,10 +356,7 @@ pagination d tp cp
<>
rnums
<>
[ rdots
, last
, next
]
[ rdots, last, next ]
where
prev = if cp == 1 then
text " Previous "
......
module Gargantext.Dashboard where
import Prelude (($), (<>), show, pure, unit, map)
import Data.Array (zip)
import Data.Tuple (Tuple(..))
import Gargantext.Charts.ECharts
import Gargantext.Charts.Series
import DOM (DOM)
import Data.Unit (Unit)
import Data.Int (toNumber)
import React.DOM (div, h1, text, title)
import React.DOM.Props (className)
import Thermite (PerformAction, Render, Spec, simpleSpec)
......@@ -32,22 +36,6 @@ render dispatch _ state _ = [
)
]
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 { mainTitle : "School production in 2018"
, subTitle : "Distribution by school"
......@@ -82,22 +70,41 @@ render dispatch _ state _ = [
}
naturePublis :: Options
naturePublis = Options { mainTitle : "Nature of publications"
-----------------------------------------------------------------------------------------------------------
naturePublis_x = ["COMM","ART","COUV","THESE","REPORT","UNDEFINED","OTHER","POSTER","DOUV","OUV","PATENT","MEM","HDR","PRESCONF","LECTURE","VIDEO"]
naturePublis_y' = [23901,17417,1585,1188,1176,895,473,393,323,246,108,43,36,26,9,1]
naturePublis_y = map (\(Tuple n v) -> {name: n, value: toNumber v }) (zip naturePublis_x naturePublis_y')
naturePublis :: Options
naturePublis = Options { mainTitle : "Nature of publications"
, subTitle : "Distribution by type"
, xAxis : xAxis []
, yAxis : [series Funnel "Funnel Data" [ {name: "Articles", value: 60.0}
, {name: "Reports", value: 100.0}
, {name: "Patents", value: 40.0}
, {name: "Books", value: 65.0}
]
]
, yAxis : [series Funnel "Funnel Data" naturePublis_y]
, yAxisFormat : (YAxisFormat { position : "left"
, 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
})
layoutDashboard :: forall props eff. Spec (dom :: DOM | eff) State props Action
......
......@@ -48,25 +48,26 @@ toggleNode sid a = a
------------------------------------------------------------------------
-- 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")
exampleTree :: NTree (Tuple String String)
exampleTree =
NNode 1 true "françois.pineau"
[ annuaire 2 "Annuaire"
, corpus 3 "IMT publications"
]
annuaire :: Int -> String -> NTree (Tuple String String)
annuaire n name = NNode n false name
[ NLeaf (Tuple "Facets" "#/docView")
[ NLeaf (Tuple "IMT community" "#/docView")
]
exampleTree :: NTree (Tuple String String)
exampleTree =
NNode 1 true "françois.pineau"
[ annuaire 2 "Annuaire"
, corpus 3 "IMT publications"
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
-- 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