Commit 9a6d8cc0 authored by Mael NICOLAS's avatar Mael NICOLAS

merged

parents 8309e9f4 9264eae1
{ {
"name": "purescript-gargantext", "name": "purescript-gargantext",
"ignore": [ "ignore": [
"**/.*", "**/.*",
"node_modules", "node_modules",
"bower_components", "bower_components",
"output" "output"
], ],
"dependencies": { "dependencies": {
"purescript-prelude": "^3.1.0", "purescript-console": "^4.1.0",
"purescript-console": "^3.0.0", "purescript-thermite": "https://github.com/np/purescript-thermite.git#hide",
"purescript-thermite": "^5.0.0", "purescript-affjax": "^7.0.0",
"purescript-affjax": "^5.0.0", "purescript-routing": "^8.0.0",
"purescript-routing": "^6.1.2", "purescript-argonaut": "^4.0.1",
"purescript-argonaut-codecs": "^2.0.0", "purescript-random": "^4.0.0",
"purescript-argonaut-traversals": "^2.0.0", "purescript-css": "^4.0.0"
"purescript-argonaut": "^3.1.0", },
"purescript-random": "^3.0.0", "devDependencies": {
"purescript-css": "^3.4.0" "purescript-psci-support": "^4.0.0"
}, },
"devDependencies": { "resolutions": {
"purescript-psci-support": "^3.0.0" "purescript-react": "exports"
}, }
"resolutions": {
"purescript-maybe": "^3.0.0",
"purescript-monoid": "^3.0.0",
"purescript-invariant": "^3.0.0",
"purescript-functions": "^3.0.0",
"purescript-functors": "^2.0.0",
"purescript-const": "^3.0.0",
"purescript-contravariant": "^3.0.0",
"purescript-tuples": "^4.0.0",
"purescript-distributive": "^3.0.0",
"purescript-identity": "^3.0.0",
"purescript-transformers": "^3.0.0",
"purescript-arrays": "^4.0.1",
"purescript-nonempty": "^4.0.0",
"purescript-unfoldable": "^3.0.0",
"purescript-lazy": "^3.0.0",
"purescript-unsafe-coerce": "^3.0.0",
"purescript-strings": "^3.0.0",
"purescript-generics": "^4.0.0",
"purescript-tailrec": "^3.0.0",
"purescript-proxy": "^2.0.0",
"purescript-integers": "^3.0.0",
"purescript-globals": "^3.0.0",
"purescript-maps": "^3.0.0",
"purescript-st": "^3.0.0",
"purescript-eff": "^3.0.0",
"purescript-profunctor": "^3.0.0",
"purescript-enums": "^3.1.0",
"purescript-profunctor-lenses": "^3.0.0",
"purescript-sets": "^3.0.0",
"purescript-argonaut-core": "^3.1.0",
"purescript-lists": "^4.0.0",
"purescript-argonaut-codecs": "^3.0.0",
"purescript-argonaut-traversals": "^3.0.0",
"purescript-argonaut": "^3.1.0",
"purescript-prelude": "^3.1.0",
"purescript-either": "^3.1.0",
"purescript-foldable-traversable": "^3.6.1",
"purescript-control": "^3.0.0",
"purescript-bifunctors": "^3.0.0",
"purescript-newtype": "^2.0.0"
}
} }
...@@ -2,6 +2,7 @@ module Gargantext.Components.Charts.Charts where ...@@ -2,6 +2,7 @@ module Gargantext.Components.Charts.Charts where
import Prelude hiding (min) import Prelude hiding (min)
import Gargantext.Components.Charts.Options.Series (Series(..), D1, seriesType, SeriesShape(..))
import CSS (Color, white) import CSS (Color, white)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import React as R import React as R
...@@ -30,7 +31,7 @@ group = unsafeMkProps "group" ...@@ -30,7 +31,7 @@ group = unsafeMkProps "group"
-- resizable :: Boolean, -- PropTypes.bool, -- resizable :: Boolean, -- PropTypes.bool,
-- onEvents :: String -- PropTypes.object -- onEvents :: String -- PropTypes.object
type EchartsProps eff = type EchartsProps=
{ className :: String, { className :: String,
style :: String, -- objealect-black-altdarkmincnaquadahherry-blossomect, style :: String, -- objealect-black-altdarkmincnaquadahherry-blossomect,
theme :: String, theme :: String,
...@@ -55,7 +56,7 @@ type OptsLoading = ...@@ -55,7 +56,7 @@ type OptsLoading =
} }
type OpTest = type OpTest =
{option :: Option} {children :: R.Children, option :: Option}
type Option = type Option =
{ title :: Maybe Title { title :: Maybe Title
...@@ -161,11 +162,12 @@ type AxisLabel = ...@@ -161,11 +162,12 @@ type AxisLabel =
} }
type Series = --type Series =
{ name :: String -- { name :: String
, "type" :: String -- , "type" :: String
, "data" :: Array Int -- , "data" :: Array Int
} -- }
type Title = type Title =
{ text :: String { text :: String
...@@ -202,14 +204,14 @@ type Title = ...@@ -202,14 +204,14 @@ type Title =
type Rich = {} type Rich = {}
foreign import eChartsClass :: forall props. R.ReactClass props foreign import eChartsClass :: forall props. R.ReactClass { children :: R.Children | props}
foreign import eChartsClass2 :: R.ReactClass OpTest foreign import eChartsClass2 :: R.ReactClass OpTest
echarts :: forall eff. Array Props -> R.ReactElement echarts :: Array Props -> R.ReactElement
echarts p = R.createElementDynamic eChartsClass (unsafeFromPropsArray p) [] echarts p = R.unsafeCreateElementDynamic eChartsClass (unsafeFromPropsArray p) []
echarts' :: forall eff. Option -> R.ReactElement echarts' :: Option -> R.ReactElement
echarts' chart = R.createElementDynamic eChartsClass2 {option: chart} [] echarts' chart = R.unsafeCreateElementDynamic eChartsClass2 {option: chart} []
-- Props -- Props
...@@ -436,12 +438,12 @@ tooltip' = ...@@ -436,12 +438,12 @@ tooltip' =
} }
series' :: Series series' :: D1
series' = series' =
{ {
name: "All" name: "All"
, "type": "bar" , "type": seriesType Bar
, "data": [201, 777, 879] , "data": [201.0, 777, 879]
} }
opt :: Option opt :: Option
...@@ -453,7 +455,7 @@ opt = ...@@ -453,7 +455,7 @@ opt =
,grid: {containLabel: true} ,grid: {containLabel: true}
,xAxis: xAxis' ,xAxis: xAxis'
,yAxis: yData1 ,yAxis: yData1
,series: [series'] ,series: [SeriesD1 series']
,dataZoom: [dz1', dz1', dz2', dz2'] ,dataZoom: [dz1', dz1', dz2', dz2']
} }
...@@ -591,5 +593,4 @@ sd2 = unsafeFromPropsArray ...@@ -591,5 +593,4 @@ sd2 = unsafeFromPropsArray
] ]
p'' :: R.ReactElement
p'' = p [] []
...@@ -17,3 +17,4 @@ type DataS = ...@@ -17,3 +17,4 @@ type DataS =
{ name :: String { name :: String
, value :: Number , value :: Number
} }
...@@ -11,9 +11,11 @@ import Gargantext.Components.Charts.Options.Data (DataN, DataS, DataV) ...@@ -11,9 +11,11 @@ import Gargantext.Components.Charts.Options.Data (DataN, DataS, DataV)
import Gargantext.Components.Charts.Options.Font (IconOptions(..), Shape(..), TextStyle, chartFontStyle, chartFontWeight, icon) import Gargantext.Components.Charts.Options.Font (IconOptions(..), Shape(..), TextStyle, chartFontStyle, chartFontWeight, icon)
import Gargantext.Components.Charts.Options.Legend (legendType, LegendMode(..), PlainOrScroll(..), selectedMode, Orientation(..), orient) import Gargantext.Components.Charts.Options.Legend (legendType, LegendMode(..), PlainOrScroll(..), selectedMode, Orientation(..), orient)
import Gargantext.Components.Charts.Options.Position (Align(..), LeftRelativePosition(..), TopRelativePosition(..), numberPosition, percentPosition, relativePosition) import Gargantext.Components.Charts.Options.Position (Align(..), LeftRelativePosition(..), TopRelativePosition(..), numberPosition, percentPosition, relativePosition)
import Gargantext.Components.Charts.Options.Series (Series, SeriesName, SeriesShape(..), seriesType) import Gargantext.Components.Charts.Options.Series (Serie(..), Series(..), toSeries, SeriesName, Chart(..), seriesType, D1, D2)
import Gargantext.Components.Charts.Options.Type (DataZoom, Echarts, Legend, Option, Title, Tooltip, XAxis, YAxis) import Gargantext.Components.Charts.Options.Type (DataZoom, Echarts, Legend, Option, Title, Tooltip, XAxis, YAxis)
import React (unsafeCreateElementDynamic)
import React as R import React as R
import Unsafe.Coerce (unsafeCoerce)
foreign import eChartsClass :: R.ReactClass Echarts foreign import eChartsClass :: R.ReactClass Echarts
...@@ -23,23 +25,23 @@ chart = echarts <<< chartWith <<< opts ...@@ -23,23 +25,23 @@ chart = echarts <<< chartWith <<< opts
chartWith :: Option -> Echarts chartWith :: Option -> Echarts
chartWith opts = { className: Nothing chartWith opts = { className : Nothing
, style: Nothing , style : Nothing
, theme: Nothing , theme : Nothing
, group: Nothing , group : Nothing
, option: opts , option : opts
, initOpts: Nothing , initOpts : Nothing
, notMerge: Nothing , notMerge : Nothing
, lazyUpdate: Nothing , lazyUpdate: Nothing
, loading: Nothing , loading : Nothing
, optsLoading: Nothing , optsLoading: Nothing
, onReady: Nothing , onReady : Nothing
, resizable: Nothing , resizable : Nothing
, onEvents: Nothing , onEvents : Nothing
} }
echarts :: forall eff. Echarts -> R.ReactElement echarts :: Echarts -> R.ReactElement
echarts chart = R.createElementDynamic eChartsClass chart [] echarts chart = unsafeCreateElementDynamic (unsafeCoerce eChartsClass) chart []
type MainTitle = String type MainTitle = String
type SubTitle = String type SubTitle = String
...@@ -112,7 +114,9 @@ data2 = {name: "Favorites", icon: icon $ Shape Circle, textStyle: textStyle'} ...@@ -112,7 +114,9 @@ data2 = {name: "Favorites", icon: icon $ Shape Circle, textStyle: textStyle'}
data3 :: DataN data3 :: DataN
data3 = {name: "Test", icon: icon $ Shape Diamond, textStyle: textStyle'} data3 = {name: "Test", icon: icon $ Shape Diamond, textStyle: textStyle'}
xAxis :: Array String -> XAxis xAxis :: Array String -> XAxis
xAxis [] = unsafeCoerce {}
xAxis xs = { "data": xData xs xAxis xs = { "data": xData xs
, "type": "category" , "type": "category"
, axisTick: {alignWithLabel: true} , axisTick: {alignWithLabel: true}
...@@ -153,12 +157,20 @@ tooltip' = ...@@ -153,12 +157,20 @@ tooltip' =
} }
series :: SeriesShape -> SeriesName -> Array DataS -> Series series :: Chart -> SeriesName -> Array DataS -> D1
series sh name ss = { name: name series sh name ss = { name: name
, "type": seriesType sh , "type": seriesType sh
, "data": ss , "data": ss
} }
seriesD2 :: Chart -> Number -> Array (Array Number) -> D2
seriesD2 sh size ds = { "symbolSize" : size
, "data" : ds
, "type" : seriesType sh
}
data YAxisFormat = YAxisFormat { position :: String data YAxisFormat = YAxisFormat { position :: String
, visible :: Boolean , visible :: Boolean
} }
...@@ -166,7 +178,7 @@ data YAxisFormat = YAxisFormat { position :: String ...@@ -166,7 +178,7 @@ data YAxisFormat = YAxisFormat { position :: String
data Options = Options { mainTitle :: MainTitle data Options = Options { mainTitle :: MainTitle
, subTitle :: SubTitle , subTitle :: SubTitle
, xAxis :: XAxis , xAxis :: XAxis
, yAxis :: Array Series , yAxis :: Array Serie
, yAxisFormat :: YAxisFormat , yAxisFormat :: YAxisFormat
, addZoom :: Boolean , addZoom :: Boolean
} }
...@@ -187,7 +199,7 @@ opts (Options { mainTitle : mainTitle ...@@ -187,7 +199,7 @@ opts (Options { mainTitle : mainTitle
} }
, grid : {containLabel: true} , grid : {containLabel: true}
, xAxis : xs , xAxis : xs
, series : ss , series : map toSeries $ ss
, yAxis : { "type": "value" , yAxis : { "type": "value"
, name: "data" , name: "data"
, min: 0 , min: 0
...@@ -195,7 +207,8 @@ opts (Options { mainTitle : mainTitle ...@@ -195,7 +207,8 @@ opts (Options { mainTitle : mainTitle
, axisLabel: {formatter: "{value}"} , axisLabel: {formatter: "{value}"}
, show: visible , show: visible
} }
,dataZoom: if addZoom then [zoom Slider, zoom Inside] else [] , dataZoom: if addZoom then [zoom Slider, zoom Inside] else []
, children : unsafeCoerce []
} }
...@@ -215,10 +228,10 @@ zoom z = { ...@@ -215,10 +228,10 @@ zoom z = {
} }
seriesPie :: Series seriesPie :: D1
seriesPie = seriesPie =
{ {
name: "Pie" name: "Pie name"
, "type": seriesType Pie , "type": seriesType Pie
, "data": [{name: "t1", value: 50.0}, , "data": [{name: "t1", value: 50.0},
{name: "t2", value: 45.0}, {name: "t2", value: 45.0},
...@@ -229,7 +242,6 @@ seriesPie = ...@@ -229,7 +242,6 @@ seriesPie =
} }
textStyle2 :: TextStyle textStyle2 :: TextStyle
textStyle2 = textStyle2 =
{ {
......
...@@ -14,8 +14,9 @@ module Gargantext.Components.Charts.Options.Font ...@@ -14,8 +14,9 @@ module Gargantext.Components.Charts.Options.Font
import Prelude (Unit, ($), (<<<), (<>)) import Prelude (Unit, ($), (<<<), (<>))
import Data.Generic.Rep
import Data.Generic.Rep.Show
import CSS (FontStyle(..), FontWeight(..), Prefixed(..), Value(..)) import CSS (FontStyle(..), FontWeight(..), Prefixed(..), Value(..))
import Data.Generic (class Generic, gShow)
import Data.String (toLower) import Data.String (toLower)
import Gargantext.Components.Charts.Options.Color (ChartColor) import Gargantext.Components.Charts.Options.Color (ChartColor)
import Gargantext.Components.Charts.Options.Position (LeftRelativePosition, Position, TopRelativePosition) import Gargantext.Components.Charts.Options.Position (LeftRelativePosition, Position, TopRelativePosition)
...@@ -63,10 +64,10 @@ newtype Icon = Icon String ...@@ -63,10 +64,10 @@ newtype Icon = Icon String
newtype ImageURL = ImageURL String newtype ImageURL = ImageURL String
data Shape = Circle | Rect | RoundRect | Triangle | Diamond | Pin | Arrow data Shape = Circle | Rect | RoundRect | Triangle | Diamond | Pin | Arrow
derive instance genericShape :: Generic Shape derive instance genericShape :: Generic Shape _
data IconOptions = Shape Shape | Image ImageURL data IconOptions = Shape Shape | Image ImageURL
icon :: IconOptions -> Icon icon :: IconOptions -> Icon
icon (Shape s) = Icon <<< toLower $ gShow s icon (Shape s) = Icon <<< toLower $ genericShow s
icon (Image (ImageURL url)) = Icon $ "image://" <> url icon (Image (ImageURL url)) = Icon $ "image://" <> url
...@@ -13,7 +13,8 @@ module Gargantext.Components.Charts.Options.Legend ...@@ -13,7 +13,8 @@ module Gargantext.Components.Charts.Options.Legend
import Prelude (class Show, show, (<<<)) import Prelude (class Show, show, (<<<))
import Data.Generic (class Generic, gShow) import Data.Generic.Rep
import Data.Generic.Rep.Show
import Data.String (toLower) import Data.String (toLower)
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
...@@ -31,16 +32,16 @@ legendType = LegendType <<< toLower <<< show ...@@ -31,16 +32,16 @@ legendType = LegendType <<< toLower <<< show
newtype Orient = Orient String newtype Orient = Orient String
data Orientation = Horizontal | Vertical data Orientation = Horizontal | Vertical
derive instance genericOrientation :: Generic Orientation derive instance genericOrientation :: Generic Orientation _
orient :: Orientation -> Orient orient :: Orientation -> Orient
orient = Orient <<< toLower <<< gShow orient = Orient <<< toLower <<< genericShow
foreign import data SelectedMode :: Type foreign import data SelectedMode :: Type
data LegendMode = Bool Boolean | Single | Multiple data LegendMode = Bool Boolean | Single | Multiple
derive instance genericLegendMode :: Generic LegendMode derive instance genericLegendMode :: Generic LegendMode _
selectedMode :: LegendMode -> SelectedMode selectedMode :: LegendMode -> SelectedMode
selectedMode (Bool b) = unsafeCoerce b selectedMode (Bool b) = unsafeCoerce b
......
module Gargantext.Components.Charts.Options.Series where module Gargantext.Components.Charts.Options.Series where
import Effect.Exception (error, Error(..))
import Unsafe.Coerce (unsafeCoerce)
import Prelude import Prelude
import Gargantext.Components.Charts.Options.Data (DataS) import Gargantext.Components.Charts.Options.Data (DataS)
...@@ -9,39 +11,152 @@ newtype SeriesType = SeriesType String ...@@ -9,39 +11,152 @@ newtype SeriesType = SeriesType String
type SeriesName = String type SeriesName = String
data SeriesShape = Line
| Bar | PictorialBar data Chart = Line
| Pie | Bar | PictorialBar
| Scatter | EffectScater | Pie
| Radar | Scatter | EffectScatter
| Tree | TreeMap | Radar
| Sunburst | Trees
| Boxplot | Sunburst
| Candlestick | Boxplot
| Heatmap | Candlestick
| Map | Heatmap
| Parallel | Map
| Lines | Parallel
| Graph | Lines
| Sankey | Graph
| Funnel | Sankey
| Gauge | Funnel
| ThemeRiver | Gauge
| ThemeRiver
instance showSeriesShape :: Show SeriesShape where -- Trees
show Line = "line"
instance showChart :: Show Chart where
show Bar = "bar" show Bar = "bar"
show Pie = "pie" show EffectScatter = "effectScatter" -- ^ https://ecomfe.github.io/echarts-examples/public/editor.html?c=scatter-effect
show Sunburst = "sunburst"
show Funnel = "funnel" show Funnel = "funnel"
show Heatmap = "heatmap" show Heatmap = "heatmap"
show _ = "" show Line = "line"
show Pie = "pie"
show Sankey = "sankey"
show Scatter = "scatter" -- ^ https://ecomfe.github.io/echarts-examples/public/editor.html?c=scatter-simple
show Sunburst = "sunburst"
show _ = "not implemented yet: should throw error here"
seriesType :: SeriesShape -> SeriesType seriesType :: Chart -> SeriesType
seriesType = SeriesType <<< show seriesType = SeriesType <<< show
type Series =
type Series = {}
data Serie = SeriesD1 D1 | SeriesD2 D2 | SerieSankey Sankey | SerieTree Tree
type D1 =
{ name :: String { name :: String
, "type" :: SeriesType , "type" :: SeriesType
, "data" :: Array DataS , "data" :: Array DataS
} }
-- | Scatter Dimension 2 data
type D2 =
{ "symbolSize" :: Number
, "data" :: Array (Array Number)
, "type" :: SeriesType
}
toSeries :: Serie -> Series
toSeries (SeriesD1 a) = unsafeCoerce a
toSeries (SeriesD2 a) = unsafeCoerce a
toSeries (SerieSankey a) = unsafeCoerce a
toSeries (SerieTree a) = unsafeCoerce a
-- | Sankey Chart
-- https://ecomfe.github.io/echarts-examples/public/editor.html?c=sankey-simple
type Sankey = { "type" :: SeriesType
, layout :: String
, "data" :: Array Node
, "links" :: Array Link
}
type Node = { name :: String}
type Link = { source :: String
, target :: String
, value :: Number
}
mkSankey :: Array Node -> Array Link -> Serie
mkSankey ns ls = SerieSankey { "type" : seriesType Sankey
, layout : "none"
, "data" : ns
, "links" : ls
}
-- | * Trees Chart
-- All these Trees are hierarchical Trees structure (or diagram)
-- https://en.wikipedia.org/wiki/Tree_structure
-- Tree types
data Trees = TreeLine | TreeRadial | TreeMap
instance showTrees :: Show Trees where
show TreeLine = "tree" -- ^ https://ecomfe.github.io/echarts-examples/public/editor.html?c=tree-radial
show TreeRadial = "tree" -- ^ https://ecomfe.github.io/echarts-examples/public/editor.html?c=scatter-simple
show TreeMap = "treemap" -- ^ https://ecomfe.github.io/echarts-examples/public/editor.html?c=treemap-simple
-- TreeLine is a 1-Dimension horizontal hierchical Tree
-- TreeRadial is 1-Dimension radial (as circle) Tree with no surface meaning
-- https://en.wikipedia.org/wiki/Radial_tree
-- https://ecomfe.github.io/echarts-examples/public/editor.html?c=tree-radial
-- TreeMap is a is 2-Dimension Tree with surface meaning
-- TreeMap example implementation:
-- https://ecomfe.github.io/echarts-examples/public/editor.html?c=treemap-simple
type Tree = { "type" :: SeriesType
, "data" :: Array TreeData
, layout :: String
}
mkTree :: Trees -> Array TreeData -> Serie
mkTree t ts = SerieTree { "type" : SeriesType (show t)
, "data" : map toJsTree ts
, layout : layout
}
where
layout = case t of
TreeRadial -> "radial"
_ -> "none"
-- ** Data Structure of the Trees
data TreeData = TreeLeaf TreeLeaf
| TreeNode TreeNode
toJsTree :: TreeData -> TreeData
toJsTree (TreeLeaf x) = unsafeCoerce x
toJsTree (TreeNode x) = unsafeCoerce { name : x.name
, value : x.value
, children : (map toJsTree x.children)
}
type TreeNode = { name :: String
, value :: Number
, children :: Array TreeData
}
type TreeLeaf = { name :: String
, value :: Number
}
treeNode :: String -> Number -> Array TreeData -> TreeData
treeNode n v ts = TreeNode {name : n, value:v, children:ts}
treeLeaf :: String -> Number -> TreeData
treeLeaf n v = TreeLeaf { name : n, value : v}
-- | TODO
-- https://ecomfe.github.io/echarts-examples/public/data/asset/data/life-expectancy-table.json
-- https://ecomfe.github.io/echarts-examples/public/editor.html?c=scatter3D-dataset&gl=1
...@@ -10,23 +10,23 @@ import Gargantext.Components.Charts.Options.Font (TextStyle) ...@@ -10,23 +10,23 @@ import Gargantext.Components.Charts.Options.Font (TextStyle)
import Gargantext.Components.Charts.Options.Legend (LegendType, Orient, SelectedMode) import Gargantext.Components.Charts.Options.Legend (LegendType, Orient, SelectedMode)
import Gargantext.Components.Charts.Options.Position (LeftRelativePosition, Position, TopRelativePosition) import Gargantext.Components.Charts.Options.Position (LeftRelativePosition, Position, TopRelativePosition)
import Gargantext.Components.Charts.Options.Series (Series) import Gargantext.Components.Charts.Options.Series (Series)
import React as R
newtype ChartAlign = ChartAlign String newtype ChartAlign = ChartAlign String
type Echarts = type Echarts =
{ className :: Maybe String, { className :: Maybe String
style :: Maybe String, -- objealect-black-altdarkmincnaquadahherry-blossomect, , style :: Maybe String -- objealect-black-altdarkmincnaquadahherry-blossomect,
theme :: Maybe String, , theme :: Maybe String
group :: Maybe String, , group :: Maybe String
option :: Option, -- PropTypes.object.isRequired, , option :: Option -- PropTypes.object.isRequired,
initOpts :: Maybe String, -- PropTypes.object, , initOpts :: Maybe String -- PropTypes.object,
notMerge :: Maybe Boolean, , notMerge :: Maybe Boolean
lazyUpdate :: Maybe Boolean, , lazyUpdate :: Maybe Boolean
loading :: Maybe Boolean, , loading :: Maybe Boolean
optsLoading :: Maybe OptsLoading, -- PropTypes.object, , optsLoading :: Maybe OptsLoading -- PropTypes.object,
onReady :: Maybe String, -- PropTypes.func, , onReady :: Maybe String -- PropTypes.func,
resizable :: Maybe Boolean, -- PropTypes.bool, , resizable :: Maybe Boolean -- PropTypes.bool,
onEvents :: Maybe String -- PropTypes.object , onEvents :: Maybe String -- PropTypes.object
} }
type Option = type Option =
...@@ -38,11 +38,11 @@ type Option = ...@@ -38,11 +38,11 @@ type Option =
, yAxis :: YAxis , yAxis :: YAxis
, series :: Array Series , series :: Array Series
, dataZoom :: Array DataZoom , dataZoom :: Array DataZoom
, children :: R.Children
} }
type Title = type Title =
{ { id :: String -- None by default
id :: String -- None by default
, show :: Boolean -- default True , show :: Boolean -- default True
, text :: String -- default '' , text :: String -- default ''
, link :: String -- default '' , link :: String -- default ''
...@@ -71,11 +71,11 @@ type Title = ...@@ -71,11 +71,11 @@ type Title =
} }
type OptsLoading = type OptsLoading =
{ text :: String, { text :: String
color :: Color, --- color , color :: Color --- color
textColor :: Color, --color , textColor :: Color --color
maskColor :: Color, --color , maskColor :: Color --color
zlevel :: Int , zlevel :: Int
} }
type DataZoom = type DataZoom =
......
...@@ -2,8 +2,9 @@ module Gargantext.Components.GraphExplorer.Sigmajs where ...@@ -2,8 +2,9 @@ module Gargantext.Components.GraphExplorer.Sigmajs where
import Prelude import Prelude
import Control.Monad.Eff (Eff) import Effect (Effect)
import React (ReactClass, ReactElement, createElement) import Prim.Row (class Union)
import React (Children, ReactClass, ReactElement, createElement, unsafeCreateElement)
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
foreign import edgeShapesClass :: forall props. ReactClass props foreign import edgeShapesClass :: forall props. ReactClass props
...@@ -12,51 +13,51 @@ foreign import forceAtlas2Class :: forall props. ReactClass props ...@@ -12,51 +13,51 @@ foreign import forceAtlas2Class :: forall props. ReactClass props
foreign import forceLinkClass :: forall props. ReactClass props foreign import forceLinkClass :: forall props. ReactClass props
foreign import loadGEXFClass :: forall props. ReactClass props foreign import loadGEXFClass :: forall props. ReactClass props
foreign import loadJSONClass :: forall props. ReactClass props foreign import loadJSONClass :: forall props. ReactClass props
foreign import nOverlapClass :: forall props. ReactClass props foreign import nOverlapClass :: ReactClass {children :: Children}
foreign import neoCypherClass :: forall props. ReactClass props foreign import neoCypherClass :: ReactClass {children :: Children}
foreign import neoGraphItemsProducersClass :: forall props. ReactClass props foreign import neoGraphItemsProducersClass :: forall props. ReactClass props
foreign import nodeShapesClass :: forall props. ReactClass props foreign import nodeShapesClass :: ReactClass {children :: Children}
foreign import randomizeNodePositionsClass :: forall props. ReactClass props foreign import randomizeNodePositionsClass :: ReactClass {children :: Children}
foreign import relativeSizeClass :: forall props. ReactClass props foreign import relativeSizeClass :: forall props. ReactClass props
foreign import sigmaClass :: forall props. ReactClass props foreign import sigmaClass :: ReactClass {children :: Children}
foreign import sigmaEnableSVGClass :: forall props. ReactClass props foreign import sigmaEnableSVGClass :: forall props. ReactClass props
foreign import sigmaEnableWebGLClass :: forall props. ReactClass props foreign import sigmaEnableWebGLClass :: ReactClass {children :: Children}
neoCypher :: forall eff o. Optional o (NeoCypherOptProps eff) => NeoCypherReqProps o -> ReactElement neoCypher :: forall o. Optional o NeoCypherOptProps => NeoCypherReqProps o -> ReactElement
neoCypher props = createElement neoCypherClass props [] neoCypher props = unsafeCreateElement neoCypherClass (unsafeCoerce props) []
loadJSON :: forall eff o. Optional o (onGraphLoaded :: Eff eff Unit) => { "path" :: String | o } -> ReactElement loadJSON :: forall o. Optional o (onGraphLoaded :: Effect Unit) => { "path" :: String | o } -> ReactElement
loadJSON props = createElement loadJSONClass props [] loadJSON props = unsafeCreateElement loadJSONClass props []
loadGEXF :: forall eff o. Optional o (onGraphLoaded :: Eff eff Unit) => { "path" :: String | o } -> ReactElement loadGEXF :: forall o. Optional o (onGraphLoaded :: Effect Unit) => { "path" :: String | o } -> ReactElement
loadGEXF props = createElement loadGEXFClass props [] loadGEXF props = unsafeCreateElement loadGEXFClass props []
forceLink :: forall eff o. Optional o (ForceLinkOptProps eff) => { | o} -> ReactElement forceLink :: forall o. Optional o ForceLinkOptProps => { | o} -> ReactElement
forceLink props = createElement forceLinkClass props [] forceLink props = unsafeCreateElement forceLinkClass props []
nOverlap :: forall o. Optional o NOverlapOptProps => { | o } -> ReactElement nOverlap :: forall o. Optional o NOverlapOptProps => { | o } -> ReactElement
nOverlap props = createElement nOverlapClass props [] nOverlap props = unsafeCreateElement nOverlapClass (unsafeCoerce props) []
randomizeNodePositions :: ReactElement randomizeNodePositions :: ReactElement
randomizeNodePositions = createElement randomizeNodePositionsClass {} [] randomizeNodePositions = createElement randomizeNodePositionsClass {} []
relativeSize :: {initialSize :: Number } -> ReactElement relativeSize :: {initialSize :: Number } -> ReactElement
relativeSize props = createElement randomizeNodePositionsClass props [] relativeSize props = unsafeCreateElement randomizeNodePositionsClass (unsafeCoerce props) []
forceAtlas2 :: forall eff o. Optional o (ForceAtlas2OptProps eff) => { | o } -> ReactElement forceAtlas2 :: forall o. Optional o ForceAtlas2OptProps => { | o } -> ReactElement
forceAtlas2 props = createElement forceAtlas2Class props [] forceAtlas2 props = unsafeCreateElement forceAtlas2Class props []
sigma :: forall props eff. Optional props (SigmaProps eff) => { | props} -> Array ReactElement -> ReactElement sigma :: forall props. Optional props SigmaProps => { | props} -> Array ReactElement -> ReactElement
sigma = createElement sigmaClass sigma props children = unsafeCreateElement sigmaClass (unsafeCoerce props) children
sigmaEnableWebGL :: ReactElement sigmaEnableWebGL :: ReactElement
sigmaEnableWebGL = createElement sigmaEnableWebGLClass {} [] sigmaEnableWebGL = createElement sigmaEnableWebGLClass {} []
edgeShapes :: { "default" :: EdgeShape } -> ReactElement edgeShapes :: { "default" :: EdgeShape } -> ReactElement
edgeShapes props = createElement edgeShapesClass props [] edgeShapes props = unsafeCreateElement edgeShapesClass props []
nodeShapes :: { "default" :: NodeShape } -> ReactElement nodeShapes :: { "default" :: NodeShape } -> ReactElement
nodeShapes props = createElement nodeShapesClass props [] nodeShapes props = unsafeCreateElement nodeShapesClass (unsafeCoerce props) []
foreign import data SigmaNode :: Type foreign import data SigmaNode :: Type
...@@ -69,9 +70,9 @@ instance srInstance :: Union r t s => Optional r s ...@@ -69,9 +70,9 @@ instance srInstance :: Union r t s => Optional r s
type NeoCypherOptProps eff = type NeoCypherOptProps =
( producers :: String ( producers :: String
, onGraphLoaded :: Eff eff Unit , onGraphLoaded :: Effect Unit
) )
type NeoCypherReqProps o = type NeoCypherReqProps o =
...@@ -84,7 +85,7 @@ type NeoCypherReqProps o = ...@@ -84,7 +85,7 @@ type NeoCypherReqProps o =
type ForceLinkOptProps eff = type ForceLinkOptProps =
( barnesHutOptimize :: Boolean ( barnesHutOptimize :: Boolean
, barnesHutTheta :: Number , barnesHutTheta :: Number
, adjustSizes :: Boolean , adjustSizes :: Boolean
...@@ -138,7 +139,7 @@ sigmaEasing = ...@@ -138,7 +139,7 @@ sigmaEasing =
, cubicInOut : SigmaEasing "cubicInOut" , cubicInOut : SigmaEasing "cubicInOut"
} }
type ForceAtlas2OptProps eff = type ForceAtlas2OptProps =
( worker :: Boolean ( worker :: Boolean
, barnesHutOptimize :: Boolean , barnesHutOptimize :: Boolean
, barnesHutTheta :: Number , barnesHutTheta :: Number
...@@ -248,17 +249,17 @@ sigmaSettings = unsafeCoerce ...@@ -248,17 +249,17 @@ sigmaSettings = unsafeCoerce
foreign import data SigmaStyle :: Type foreign import data SigmaStyle :: Type
type SigmaProps eff = type SigmaProps =
( renderer :: Renderer ( renderer :: Renderer
, settings :: SigmaSettings , settings :: SigmaSettings
, style :: SigmaStyle , style :: SigmaStyle
, graph :: SigmaGraphData , graph :: SigmaGraphData
, onClickNode :: SigmaNodeEvent -> Unit , onClickNode :: SigmaNodeEvent -> Unit
, onOverNode :: SigmaNodeEvent -> Unit , onOverNode :: SigmaNodeEvent -> Unit
, onOutNode :: SigmaNodeEvent -> Eff eff Unit , onOutNode :: SigmaNodeEvent -> Effect Unit
, onClickEdge :: SigmaEdgeEvent -> Eff eff Unit , onClickEdge :: SigmaEdgeEvent -> Effect Unit
, onOverEdge :: SigmaEdgeEvent -> Eff eff Unit , onOverEdge :: SigmaEdgeEvent -> Effect Unit
, onOutEdge :: SigmaEdgeEvent -> Eff eff Unit , onOutEdge :: SigmaEdgeEvent -> Effect Unit
) )
sStyle :: forall style. { | style } -> SigmaStyle sStyle :: forall style. { | style } -> SigmaStyle
......
...@@ -3,11 +3,8 @@ module Gargantext.Components.GraphExplorer.Types where ...@@ -3,11 +3,8 @@ module Gargantext.Components.GraphExplorer.Types where
import Prelude import Prelude
import Data.Argonaut (class DecodeJson, decodeJson, (.?)) import Data.Argonaut (class DecodeJson, decodeJson, (.?))
import Data.Array (concat, group, head, length, sort, take) import Data.Array (concat, fromFoldable, group, sort, take)
import Data.Maybe (fromJust)
import Data.Newtype (class Newtype) import Data.Newtype (class Newtype)
import Data.NonEmpty (NonEmpty(..))
import Partial.Unsafe (unsafePartial)
newtype Node = Node newtype Node = Node
{ id_ :: String { id_ :: String
...@@ -82,10 +79,10 @@ instance ordLegend :: Ord Legend where ...@@ -82,10 +79,10 @@ instance ordLegend :: Ord Legend where
getLegendData :: GraphData -> Array Legend getLegendData :: GraphData -> Array Legend
getLegendData (GraphData {nodes, edges}) = nn getLegendData (GraphData {nodes, edges}) = nn
where where
mp (NonEmpty a ary) = [a] <> (if length ary > 0 then [unsafePartial $ fromJust $ head ary] else []) --mp (NonEmptyArray a ary) = [a] <> (if length ary > 0 then [unsafePartial $ fromJust $ head ary] else [])
n = sort $ map t' nodes n = sort $ map t' nodes
g = group n g = group n
nn = take 5 $ concat $ map mp g nn = take 5 $ concat $ map fromFoldable g -- TODO: fix this after checking the output
t' :: Node -> Legend t' :: Node -> Legend
t' (Node r) = Legend { id_ : clustDefault, label : r.label} t' (Node r) = Legend { id_ : clustDefault, label : r.label}
......
...@@ -2,30 +2,28 @@ module Gargantext.Components.Login where ...@@ -2,30 +2,28 @@ module Gargantext.Components.Login where
import Prelude hiding (div) import Prelude hiding (div)
import Control.Monad.Aff (Aff, attempt) import Affjax (defaultRequest, printResponseFormatError, request)
import Control.Monad.Aff.Class (liftAff) import Affjax.RequestBody (RequestBody(..))
import Control.Monad.Aff.Console (log) import Affjax.RequestHeader (RequestHeader(..))
import Control.Monad.Eff (Eff) import Affjax.ResponseFormat as ResponseFormat
import Control.Monad.Eff.Class (liftEff) import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, jsonEmptyObject, stringify, (.?), (:=), (~>))
import Control.Monad.Eff.Console (CONSOLE)
import DOM (DOM)
import DOM.HTML (window)
import DOM.HTML.Window (localStorage)
import DOM.WebStorage.Storage (getItem, setItem)
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, jsonEmptyObject, (.?), (:=), (~>))
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.HTTP.Method (Method(..)) import Data.HTTP.Method (Method(..))
import Data.Lens (over) import Data.Lens (over)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.MediaType.Common (applicationJSON) import Data.MediaType.Common (applicationJSON)
import Effect (Effect)
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Effect.Console (log)
import Gargantext.Components.Modals.Modal (modalHide) import Gargantext.Components.Modals.Modal (modalHide)
import Network.HTTP.Affjax (AJAX, affjax, defaultRequest)
import Network.HTTP.RequestHeader (RequestHeader(..))
import React.DOM (a, button, div, h2, h4, h5, i, input, label, p, span, text) import React.DOM (a, button, div, h2, h4, h5, i, input, label, p, span, text)
import React.DOM.Props (_data, _id, _type, aria, className, href, maxLength, name, onClick, onInput, placeholder, role, target, value) import React.DOM.Props (_data, _id, _type, aria, className, href, maxLength, name, onClick, onInput, placeholder, role, target, value)
import Thermite (PerformAction, Render, Spec, _render, modifyState, simpleSpec) import Thermite (PerformAction, Render, Spec, _render, modifyState, simpleSpec)
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
import Web.HTML (window)
import Web.HTML.Window (localStorage)
import Web.Storage.Storage (getItem, setItem)
-- TODO: ask for login (modal) or account creation after 15 mn when user is not logged and has made one search at least -- TODO: ask for login (modal) or account creation after 15 mn when user is not logged and has made one search at least
...@@ -48,19 +46,12 @@ initialState = State ...@@ -48,19 +46,12 @@ initialState = State
} }
data Action data Action
= NoOp = Login
| Login
| SetUserName String | SetUserName String
| SetPassword String | SetPassword String
performAction :: forall eff props. PerformAction ( console :: CONSOLE performAction :: PerformAction State {} Action
, ajax :: AJAX
, dom :: DOM
| eff
) State props Action
performAction NoOp _ _ = void do
modifyState id
performAction (SetUserName usr) _ _ = void do performAction (SetUserName usr) _ _ = void do
modifyState \(State state) -> State $ state { username = usr } modifyState \(State state) -> State $ state { username = usr }
...@@ -71,9 +62,9 @@ performAction (SetPassword pwd) _ _ = void do ...@@ -71,9 +62,9 @@ performAction (SetPassword pwd) _ _ = void do
performAction Login _ (State state) = void do performAction Login _ _ = void do
--lift $ setHash "/search" --lift $ setHash "/search"
liftEff $ modalHide "loginModal" liftEffect $ modalHide "loginModal"
modifyState \(State state) -> State $ state {loginC = true} modifyState \(State state) -> State $ state {loginC = true}
-- res <- lift $ loginReq $ LoginReq { username : state.username, password : state.password } -- res <- lift $ loginReq $ LoginReq { username : state.username, password : state.password }
-- case res of -- case res of
...@@ -85,7 +76,7 @@ performAction Login _ (State state) = void do ...@@ -85,7 +76,7 @@ performAction Login _ (State state) = void do
-- modifyState \(State s) -> State $ s {response = r, errorMessage = ""} -- modifyState \(State s) -> State $ s {response = r, errorMessage = ""}
modalSpec :: forall eff props. Boolean -> String -> Spec eff State props Action -> Spec eff State props Action modalSpec :: forall props. Boolean -> String -> Spec State props Action -> Spec State props Action
modalSpec sm t = over _render \render d p s c -> modalSpec sm t = over _render \render d p s c ->
[ div [ _id "loginModal", className $ "modal myModal" <> if sm then "" else " fade" [ div [ _id "loginModal", className $ "modal myModal" <> if sm then "" else " fade"
, role "dialog" , role "dialog"
...@@ -113,13 +104,13 @@ modalSpec sm t = over _render \render d p s c -> ...@@ -113,13 +104,13 @@ modalSpec sm t = over _render \render d p s c ->
] ]
] ]
spec' :: forall eff props. Spec (console:: CONSOLE, ajax :: AJAX, dom :: DOM | eff) State props Action spec' :: Spec State {} Action
spec' = modalSpec true "Login" renderSpec spec' = modalSpec true "Login" renderSpec
renderSpec :: forall props eff . Spec (console::CONSOLE, ajax::AJAX, dom::DOM | eff) State props Action renderSpec :: Spec State {} Action
renderSpec = simpleSpec performAction render renderSpec = simpleSpec performAction render
where where
render :: Render State props Action render :: Render State {} Action
render dispatch _ (State state) _ = render dispatch _ (State state) _ =
[ [
div [className "row"] div [className "row"]
...@@ -149,13 +140,13 @@ renderSpec = simpleSpec performAction render ...@@ -149,13 +140,13 @@ renderSpec = simpleSpec performAction render
[ input [_type "hidden", [ input [_type "hidden",
name "csrfmiddlewaretoken", name "csrfmiddlewaretoken",
value "Wy52D2nor8kC1r1Y4GrsrSIxQ2eqW8UwkdiQQshMoRwobzU4uldknRUhP0j4WcEM" ] value "Wy52D2nor8kC1r1Y4GrsrSIxQ2eqW8UwkdiQQshMoRwobzU4uldknRUhP0j4WcEM" ]
[]
, div [className "form-group"] , div [className "form-group"]
[ p [] [text state.errorMessage] [ p [] [text state.errorMessage]
, input [className "form-control", _id "id_username",maxLength "254", name "username", placeholder "username", _type "text",value state.username, onInput \e -> dispatch (SetUserName (unsafeEventValue e))] [] , input [className "form-control", _id "id_username",maxLength "254", name "username", placeholder "username", _type "text",value state.username, onInput \e -> dispatch (SetUserName (unsafeEventValue e))]
] ]
, div [className "form-group"] , div [className "form-group"]
[ input [className "form-control", _id "id_password", name "password", placeholder "password", _type "password",value state.password,onInput \e -> dispatch (SetPassword (unsafeEventValue e))] [] [ input [className "form-control", _id "id_password", name "password", placeholder "password", _type "password",value state.password,onInput \e -> dispatch (SetPassword (unsafeEventValue e))]
, div [className "clearfix"] [] , div [className "clearfix"] []
] ]
, div [className "center"] , div [className "center"]
...@@ -163,8 +154,6 @@ renderSpec = simpleSpec performAction render ...@@ -163,8 +154,6 @@ renderSpec = simpleSpec performAction render
label [] [ label [] [
div [className "checkbox"] div [className "checkbox"]
[ input [_id "terms-accept", _type "checkbox", value "", className "checkbox"] [ input [_id "terms-accept", _type "checkbox", value "", className "checkbox"]
[
]
, text "I accept the terms of uses ", , text "I accept the terms of uses ",
a [href "http://gitlab.iscpif.fr/humanities/tofu/tree/master"] [text "[Read the terms of use]"] a [href "http://gitlab.iscpif.fr/humanities/tofu/tree/master"] [text "[Read the terms of use]"]
] ]
...@@ -219,14 +208,14 @@ unsafeEventValue e = (unsafeCoerce e).target.value ...@@ -219,14 +208,14 @@ unsafeEventValue e = (unsafeCoerce e).target.value
getDeviseID :: forall eff. Eff (dom :: DOM | eff) (Maybe String) getDeviseID :: Effect (Maybe String)
getDeviseID = do getDeviseID = do
w <- window w <- window
ls <- localStorage w ls <- localStorage w
getItem "token" ls getItem "token" ls
setToken :: forall e . String -> Eff (dom :: DOM | e) Unit setToken :: String -> Effect Unit
setToken s = do setToken s = do
w <- window w <- window
ls <- localStorage w ls <- localStorage w
...@@ -244,37 +233,37 @@ newtype LoginReq = LoginReq ...@@ -244,37 +233,37 @@ newtype LoginReq = LoginReq
, password :: String , password :: String
} }
loginReq :: forall eff. LoginReq -> Aff (console :: CONSOLE, ajax :: AJAX, dom :: DOM | eff) (Either String LoginRes) loginReq :: LoginReq -> Aff (Either String LoginRes)
loginReq encodeData = loginReq encodeData =
let let
setting = setting =
defaultRequest defaultRequest
{ url = "https://dev.gargantext.org/api/auth/token" { url = "https://dev.gargantext.org/api/auth/token"
, method = Left POST , method = Left POST
, responseFormat = ResponseFormat.json
, headers = , headers =
[ ContentType applicationJSON [ ContentType applicationJSON
, Accept applicationJSON , Accept applicationJSON
] ]
, content = Just $ encodeJson encodeData , content = Just $ Json $ encodeJson encodeData
} }
in in
do do
affResp <- liftAff $ attempt $ affjax setting affResp <- request setting
case affResp of case affResp.body of
Left err -> do Left err -> do
liftAff $ log $ show err liftEffect $ log $ printResponseFormatError err
pure $ Left $ show err pure $ Left $ printResponseFormatError err
Right a -> do Right json -> do
liftAff $ log $ "POST method Completed" liftEffect $ log $ "POST method Completed"
liftAff $ log $ "GET /api response: " <> show a.response liftEffect $ log $ "GET /api response: " <> stringify json
let res = decodeJson a.response let obj = decodeJson json
liftAff $ log $ "res: " <> show a.response case obj of
case res of
Left e -> Left e ->
liftAff $ log $ "Error Decoding : " <> show e liftEffect $ log $ "Error Decoding : " <> show e
Right (LoginRes res1) -> Right (LoginRes res1) ->
liftEff $ setToken res1.token liftEffect $ setToken res1.token
pure res pure obj
instance decodeLoginRes :: DecodeJson LoginRes where instance decodeLoginRes :: DecodeJson LoginRes where
decodeJson json = do decodeJson json = do
......
...@@ -2,8 +2,8 @@ module Gargantext.Components.Modals.Modal where ...@@ -2,8 +2,8 @@ module Gargantext.Components.Modals.Modal where
import Prelude (Unit) import Prelude (Unit)
import Control.Monad.Eff (Eff) import Effect (Effect)
foreign import modalShow :: forall eff. String -> Eff eff Unit foreign import modalShow :: String -> Effect Unit
foreign import modalHide :: forall eff. String -> Eff eff Unit foreign import modalHide :: String -> Effect Unit
...@@ -21,28 +21,29 @@ module Gargantext.Components.RandomText where ...@@ -21,28 +21,29 @@ module Gargantext.Components.RandomText where
import Prelude import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Random (RANDOM, randomInt)
import Data.Array (drop, dropEnd, filter, foldl, head, length, tail, take, takeEnd, (!!)) import Data.Array (drop, dropEnd, filter, foldl, head, length, tail, take, takeEnd, (!!))
import Data.Maybe (Maybe(Nothing, Just), fromJust) import Data.Maybe (Maybe(Nothing, Just), fromJust)
import Data.String (Pattern(..), fromCharArray, split, toCharArray) import Data.String (Pattern(..), split)
import Data.String.CodeUnits (fromCharArray, toCharArray)
import Effect (Effect)
import Effect.Random (randomInt)
import Partial (crash) import Partial (crash)
import Partial.Unsafe (unsafePartial) import Partial.Unsafe (unsafePartial)
------------------------------------------------------------------- -------------------------------------------------------------------
randomSentences :: forall a. String -> Eff ( random :: RANDOM | a ) String randomSentences :: String -> Effect String
randomSentences ss = case (length (sentences ss)) >= 5 of randomSentences ss = case (length (sentences ss)) >= 5 of
true -> foldl (\a b -> a <> "." <> b) "" <$> randomPart (sentences ss) true -> foldl (\a b -> a <> "." <> b) "" <$> randomPart (sentences ss)
_ -> pure ss _ -> pure ss
randomWords :: forall a. String -> Eff ( random :: RANDOM | a ) String randomWords :: String -> Effect String
randomWords ws = case (length (words ws)) >= 5 of randomWords ws = case (length (words ws)) >= 5 of
true -> foldl (\a b -> a <> " " <> b) "" <$> randomPart (words ws) true -> foldl (\a b -> a <> " " <> b) "" <$> randomPart (words ws)
_ -> pure ws _ -> pure ws
randomChars :: forall a. String -> Eff ( random :: RANDOM | a ) String randomChars :: String -> Effect String
randomChars word = case (length (toCharArray word)) >= 5 of randomChars word = case (length (toCharArray word)) >= 5 of
true -> fromCharArray <$> randomPart (toCharArray word) true -> fromCharArray <$> randomPart (toCharArray word)
_ -> pure word _ -> pure word
...@@ -61,7 +62,7 @@ data RandomWheel a = RandomWheel { before :: Array a ...@@ -61,7 +62,7 @@ data RandomWheel a = RandomWheel { before :: Array a
, after :: Array a , after :: Array a
} }
randomPart :: forall a b. Array b -> Eff ( random :: RANDOM | a ) (Array b) randomPart :: forall b. Array b -> Effect (Array b)
randomPart array = randomArrayPoly middle >>= \(middle') -> pure ( start <> middle' <> end) randomPart array = randomArrayPoly middle >>= \(middle') -> pure ( start <> middle' <> end)
where where
start = take 2 array start = take 2 array
...@@ -69,13 +70,13 @@ randomPart array = randomArrayPoly middle >>= \(middle') -> pure ( start <> midd ...@@ -69,13 +70,13 @@ randomPart array = randomArrayPoly middle >>= \(middle') -> pure ( start <> midd
end = takeEnd 2 array end = takeEnd 2 array
randomArrayPoly :: forall a b. Array a -> Eff ( random :: RANDOM | b ) (Array a) randomArrayPoly :: forall a. Array a -> Effect (Array a)
randomArrayPoly wheel = case head wheel of randomArrayPoly wheel = case head wheel of
Nothing -> pure [] Nothing -> pure []
Just wheel' -> randomWheel (RandomWheel { before:wheel, during:wheel', after:[]}) Just wheel' -> randomWheel (RandomWheel { before:wheel, during:wheel', after:[]})
>>= \(RandomWheel rand) -> (pure rand.after) >>= \(RandomWheel rand) -> (pure rand.after)
randomWheel :: forall a b. RandomWheel b -> Eff ( random :: RANDOM | a ) (RandomWheel b) randomWheel :: forall b. RandomWheel b -> Effect (RandomWheel b)
randomWheel (RandomWheel {before:[], during:d, after:a}) = randomWheel (RandomWheel {before:[], during:d, after:a}) =
pure (RandomWheel {before:[], during:d, after:a}) pure (RandomWheel {before:[], during:d, after:a})
...@@ -84,7 +85,7 @@ randomWheel (RandomWheel {before:b, during:d, after:a}) = do ...@@ -84,7 +85,7 @@ randomWheel (RandomWheel {before:b, during:d, after:a}) = do
randomWheel $ RandomWheel {before:b', during:d', after:(a <> [d'])} randomWheel $ RandomWheel {before:b', during:d', after:(a <> [d'])}
randomArray :: forall a b. Array b -> Eff ( random :: RANDOM | a ) (RandomWheel b) randomArray :: forall b. Array b -> Effect (RandomWheel b)
randomArray array = unsafePartial $ do randomArray array = unsafePartial $ do
n <- randomInt 0 (length array - 1) n <- randomInt 0 (length array - 1)
......
...@@ -9,13 +9,13 @@ import Data.Tuple (Tuple(..)) ...@@ -9,13 +9,13 @@ import Data.Tuple (Tuple(..))
import React (ReactElement) import React (ReactElement)
import React.DOM (a, div, nav, text) import React.DOM (a, div, nav, text)
import React.DOM.Props (className, onClick) import React.DOM.Props (className, onClick)
import Thermite (PerformAction, Render, Spec, _render, cotransform, focus, simpleSpec, withState) import Thermite (PerformAction, Render, Spec, _render, modifyState, focus, simpleSpec, withState)
type State = Int type State = Int
data Action = ChangeTab Int data Action = ChangeTab Int
tabs :: forall eff state props action . Lens' state State -> Prism' action Action -> List (Tuple String (Spec eff state props action)) -> Spec eff state props action tabs :: forall state props action . Lens' state State -> Prism' action Action -> List (Tuple String (Spec state props action)) -> Spec state props action
tabs l p ls = withState \st -> tabs l p ls = withState \st ->
fold fold
[ focus l p $ simpleSpec performAction (render (activeTab st) ls) [ focus l p $ simpleSpec performAction (render (activeTab st) ls)
...@@ -26,18 +26,17 @@ tabs l p ls = withState \st -> ...@@ -26,18 +26,17 @@ tabs l p ls = withState \st ->
wrapper = over _render \render d p s c -> wrapper = over _render \render d p s c ->
[div [className "tab-content"] $ render d p s c] [div [className "tab-content"] $ render d p s c]
tab :: forall eff state props action. Int -> Int -> Tuple String (Spec eff state props action) -> Spec eff state props action tab :: forall state props action. Int -> Int -> Tuple String (Spec state props action) -> Spec state props action
tab sid iid (Tuple name spec) = over _render tabRender spec tab sid iid (Tuple name spec) = over _render tabRender spec
where where
tabRender renderer d p s c = tabRender renderer d p s c =
[div [ className $ "tab-pane " <> if sid ==iid then " show active" else " fade"] $ renderer d p s c] [div [ className $ "tab-pane " <> if sid ==iid then " show active" else " fade"] $ renderer d p s c]
performAction :: forall eff props. PerformAction eff State props Action performAction :: forall props. PerformAction State props Action
performAction (ChangeTab i) _ _ = void do performAction (ChangeTab i) _ _ = void $ modifyState $ const i
cotransform \_ -> i
render :: forall eff state props action. State -> List (Tuple String (Spec eff state props action)) -> Render State props Action render :: forall state props action. State -> List (Tuple String (Spec state props action)) -> Render State props Action
render at ls d p s c = render at ls d p s c =
[ nav [] [ nav []
[ div [className "nav nav-tabs"] [ div [className "nav nav-tabs"]
......
This diff is collapsed.
{- | Main Configuration of Gargantext Front-End
The main function to use for internal link in the Front-End
developpement is : toUrl.
* Example usage (depending on your Config):
toUrl Back Corpus 1 == "http://localhost:8008/api/v1.0/corpus/1"
toUrl Front Corpus 1 == "http://localhost:2015/#/corpus/1"
-}
module Gargantext.Config where
import Prelude ( class Eq, class Ord, class Show
, compare, eq, show, (<>), identity)
import Data.Map (Map)
import Data.Map as DM
import Data.Maybe (maybe)
import Data.Tuple (Tuple(..))
endConfig :: EndConfig
endConfig = endConfig' V10
endConfig' :: ApiVersion -> EndConfig
endConfig' v = { front : frontCaddy
, back : backDev v }
-- | Default Root on shared database to develop
-- until authentication implementation
-- (Default Root will be given after authentication)
defaultRoot :: Int
defaultRoot = 347474
------------------------------------------------------------------------
frontCaddy :: Config
frontCaddy = { proto : "http://"
, port : 2015
, domain : "localhost"
, prePath : "/#/"
}
frontHaskell :: Config
frontHaskell = { proto : "http://"
, port : 8008
, domain : "localhost"
, prePath : "/index.html#/"
}
frontProd :: Config
frontProd = { proto : "https://"
, port : 8080
, domain : "gargantext.org"
, prePath : "/index.html#/"
}
------------------------------------------------------------------------
backDev :: ApiVersion -> Config
backDev v = { proto : "http://"
, port : 8008
, domain : "localhost"
, prePath : "/api/" <> show v <> "/"
}
backProd :: ApiVersion -> Config
backProd v = { proto : "https://"
, port : 8080
, domain : "gargantext.org"
, prePath : "/api/" <> show v <> "/"
}
------------------------------------------------------------------------
type EndConfig = { front :: Config
, back :: Config
}
type Config = { proto :: String
, port :: Int
, domain :: String
, prePath :: String
}
------------------------------------------------------------
type UrlBase = String
type UrlPath = String
type UrlParam = String
type Url = String
doUrl :: UrlBase -> UrlPath -> UrlParam -> Url
doUrl b p ps = b <> p <> ps
------------------------------------------------------------
endBaseUrl :: End -> EndConfig -> UrlBase
endBaseUrl Back c = baseUrl c.back
endBaseUrl Front c = baseUrl c.front
baseUrl :: Config -> UrlBase
baseUrl conf = conf.proto <> conf.domain <> ":" <> show conf.port
------------------------------------------------------------
endPathUrl :: End -> EndConfig -> NodeType -> Id -> UrlPath
endPathUrl Back c nt i = pathUrl c.back nt i
endPathUrl Front c nt i = pathUrl c.front nt i
pathUrl :: Config -> NodeType -> Id -> UrlPath
pathUrl c Children i = pathUrl c Node i <> "/" <> show Children
pathUrl c nt i = c.prePath <> urlConfig nt <> "/" <> show i
------------------------------------------------------------
toUrl :: End -> NodeType -> Id -> Url
toUrl e nt i = doUrl base path params
where
base = endBaseUrl e endConfig
path = endPathUrl e endConfig nt i
params = ""
------------------------------------------------------------
data NodeType = NodeUser
| Annuaire
| Children
| Corpus
| Dashboard
| Document
| Error
| Folder
| Graph
| Individu
| Node
| Tree
data End = Back | Front
type Id = Int
------------------------------------------------------------
data ApiVersion = V10 | V11
instance showApiVersion :: Show ApiVersion where
show V10 = "v1.0"
show V11 = "v1.1"
------------------------------------------------------------
------------------------------------------------------------
urlConfig :: NodeType -> Url
urlConfig Annuaire = show Annuaire
urlConfig Children = show Children
urlConfig Corpus = show Corpus
urlConfig Dashboard = show Dashboard
urlConfig Document = show Document
urlConfig Error = show Error
urlConfig Folder = show Folder
urlConfig Graph = show Graph
urlConfig Individu = show Individu
urlConfig Node = show Node
urlConfig NodeUser = show NodeUser
urlConfig Tree = show Tree
------------------------------------------------------------
instance showNodeType :: Show NodeType where
show Annuaire = "annuaire"
show Children = "children"
show Corpus = "corpus"
show Dashboard = "dashboard"
show Document = "document"
show Error = "ErrorNodeType"
show Folder = "folder"
show Graph = "graph"
show Individu = "individu"
show Node = "node"
show NodeUser = "user"
show Tree = "tree"
-- | TODO : where is the Read Class ?
-- instance readNodeType :: Read NodeType where
readNodeType :: String -> NodeType
readNodeType "Annuaire" = Annuaire
readNodeType "Children" = Children
readNodeType "Dashboard" = Dashboard
readNodeType "Document" = Document
readNodeType "Folder" = Folder
readNodeType "Graph" = Graph
readNodeType "Individu" = Individu
readNodeType "Node" = Node
readNodeType "NodeCorpus" = Corpus
readNodeType "NodeUser" = NodeUser
readNodeType "Tree" = Tree
readNodeType _ = Error
------------------------------------------------------------
instance ordNodeType :: Ord NodeType where
compare n1 n2 = compare (show n1) (show n2)
instance eqNodeType :: Eq NodeType where
eq n1 n2 = eq (show n1) (show n2)
------------------------------------------------------------
...@@ -2,31 +2,30 @@ module Gargantext.Config.REST where ...@@ -2,31 +2,30 @@ module Gargantext.Config.REST where
import Prelude import Prelude
import Control.Monad.Aff (Aff, attempt) import Affjax (defaultRequest, printResponseFormatError, request)
import Control.Monad.Aff.Class (liftAff) import Affjax.RequestHeader (RequestHeader(..))
import Control.Monad.Eff.Console (CONSOLE) import Affjax.ResponseFormat as ResponseFormat
import Data.Argonaut (class DecodeJson, decodeJson) import Data.Argonaut (class DecodeJson, decodeJson)
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.HTTP.Method (Method(..)) import Data.HTTP.Method (Method(..))
import Data.MediaType.Common (applicationJSON) import Data.MediaType.Common (applicationJSON)
import Network.HTTP.Affjax (AJAX, affjax, defaultRequest) import Effect.Aff (Aff)
import Network.HTTP.RequestHeader (RequestHeader(..))
get :: forall eff t2 t31. DecodeJson t31 => String -> get :: forall t31. DecodeJson t31 => String ->
Aff (console :: CONSOLE, ajax :: AJAX| eff) Aff (Either String t31)
(Either String t31)
get url = do get url = do
affResp <- liftAff $ attempt $ affjax defaultRequest affResp <- request defaultRequest
{ method = Left GET { method = Left GET
, url = url , url = url
, responseFormat = ResponseFormat.json
, headers = [ ContentType applicationJSON , headers = [ ContentType applicationJSON
, Accept applicationJSON , Accept applicationJSON
-- , RequestHeader "Authorization" $ "Bearer " <> token -- , RequestHeader "Authorization" $ "Bearer " <> token
] ]
} }
case affResp of case affResp.body of
Left err -> do Left err -> do
pure $ Left $ show err pure $ Left $ printResponseFormatError err
Right a -> do Right a -> do
let res = decodeJson a.response let res = decodeJson a
pure res pure res
module Gargantext.Folder where
import Prelude
import React.DOM (div, h1, text, p)
import Thermite (Render, Spec, simpleSpec, defaultPerformAction)
-- TODO : get REST informations
render :: Render {} {} Void
render dispatch _ state _ = [ h1 [] [text "Folder"]
, text "Some description of the folder here"
]
layoutFolder :: Spec {} {} Void
layoutFolder = simpleSpec defaultPerformAction render
This diff is collapsed.
module Gargantext.Pages.Corpus.Annuaire where
import Prelude
import Data.Array (concat)
import Data.Traversable (foldl)
import Control.Monad.Trans.Class (lift)
import Data.Either (Either(..))
import Data.Lens (Lens', Prism', lens, prism, (?~))
import Data.Maybe (Maybe(..), maybe)
import Effect.Class (liftEffect)
import React.DOM (div, h1, h3, hr, i, p, text)
import React.DOM.Props (className, style)
import Thermite (Render, Spec
, simpleSpec, defaultPerformAction
, PerformAction, modifyState)
import Effect.Console (log)
import Effect.Aff (Aff)
import Gargantext.Config (toUrl, NodeType(..), End(..))
import Gargantext.Config.REST (get)
import Gargantext.Pages.Corpus.User.Users.Types.Types (User(..))
import Gargantext.Utils.DecodeMaybe ((.?|))
import Data.Argonaut (class DecodeJson, decodeJson, (.?))
------------------------------------------------------------------------------
type State = { info :: Maybe AnnuaireInfo
, table :: Maybe AnnuaireTable
}
type Offset = Int
type Limit = Int
data Action = Load Int
-- | ChangePageSize PageSizes
-- | ChangePage Int
------------------------------------------------------------------------------
initialState :: State
initialState = { info : Nothing, table : Nothing }
defaultAnnuaireTable :: AnnuaireTable
defaultAnnuaireTable = AnnuaireTable { annuaireTable : [Nothing] }
defaultAnnuaireInfo :: AnnuaireInfo
defaultAnnuaireInfo = AnnuaireInfo { id : 0
, typename : 0
, userId : 0
, parentId : 0
, name : ""
, date : ""
, hyperdata : ""
}
------------------------------------------------------------------------------
toRows :: AnnuaireTable -> Array (Maybe User)
toRows (AnnuaireTable a) = a.annuaireTable
layoutAnnuaire :: Spec State {} Action
layoutAnnuaire = simpleSpec performAction render
render :: Render State {} Action
render dispatch _ state _ = [ div [className "row"]
[ div [className "col-md-3"] [ h3 [] [text info.name] ]
, div [className "col-md-9"] [ hr [style {height : "2px",backgroundColor : "black"}] ]
]
, div [className "row"] [ div [className "jumbotron1", style {padding : "12px 0px 20px 12px"}]
[ div [ className "col-md-8 content"]
[ p [] [ i [className "fa fa-globe"] []
, text info.name
]
]
, div [ className "col-md-4 content"]
[ p [] [ i [className "fa fa-calendar"] []
, text info.date
]
]
]
]
, p [] [text $ foldl (<>) " "
$ map (maybe "Nothing" (\(User u) -> show u.name))
$ maybe (toRows defaultAnnuaireTable) toRows state.table]
]
where
(AnnuaireInfo info) = maybe defaultAnnuaireInfo identity state.info
(AnnuaireTable table) = maybe defaultAnnuaireTable identity state.table
------------------------------------------------------------------------------
newtype AnnuaireInfo = AnnuaireInfo { id :: Int
, typename :: Int
, userId :: Int
, parentId :: Int
, name :: String
, date :: String
, hyperdata :: String
}
instance decodeAnnuaireInfo :: DecodeJson AnnuaireInfo where
decodeJson json = do
obj <- decodeJson json
id <- obj .? "id"
typename <- obj .? "typename"
userId <- obj .? "userId"
parentId <- obj .? "parentId"
name <- obj .? "name"
date <- obj .? "date"
hyperdata <- obj .? "hyperdata"
pure $ AnnuaireInfo { id : id
, typename : typename
, userId : userId
, parentId : parentId
, name : name
, date : date
, hyperdata: hyperdata
}
newtype AnnuaireTable = AnnuaireTable { annuaireTable :: Array (Maybe User)}
instance decodeAnnuaireTable :: DecodeJson AnnuaireTable where
decodeJson json = do
rows <- decodeJson json
pure $ AnnuaireTable { annuaireTable : rows}
------------------------------------------------------------------------
performAction :: PerformAction State {} Action
performAction (Load aId) _ _ = do
eitherTable <- lift $ getTable aId
liftEffect $ log "Feching Table"
_ <- case eitherTable of
(Right table') -> void $ modifyState $ _table ?~ table'
(Left err) -> do
liftEffect $ log err
eitherInfo <- lift $ getInfo aId
_ <- case eitherInfo of
(Right info') -> void $ modifyState $ _info ?~ info'
(Left err) -> do
liftEffect $ log err
liftEffect <<< log $ "Fetching annuaire page..."
performAction _ _ _ = pure unit
------------------------------------------------------------------------
getTable :: Int -> Aff (Either String AnnuaireTable)
getTable id = get $ toUrl Back Children id
getInfo :: Int -> Aff (Either String AnnuaireInfo)
getInfo id = get $ toUrl Back Node id
------------------------------------------------------------------------------
_table :: Lens' State (Maybe AnnuaireTable)
_table = lens (\s -> s.table) (\s ss -> s{table = ss})
_info :: Lens' State (Maybe AnnuaireInfo)
_info = lens (\s -> s.info) (\s ss -> s{info = ss})
------------------------------------------------------------------------------
...@@ -3,8 +3,8 @@ module Gargantext.Pages.Corpus.Doc.Annotation where ...@@ -3,8 +3,8 @@ module Gargantext.Pages.Corpus.Doc.Annotation where
import Prelude hiding (div) import Prelude hiding (div)
import React (ReactElement) import React (ReactElement)
import React.DOM (a, button, div, h4, h6, input, li, nav, option, p, select, span, text, ul) import React.DOM (a, button, div, h4, h6, input, li, nav, option, p, select, span, text, ul)
import React.DOM.Props (_data, _id, _type, aria, className, href, name, onChange, onInput, placeholder, role, selected, style, value) import React.DOM.Props (_data, _id, _type, aria, className, href, name, onChange, onInput, placeholder, role, style, value)
import Thermite (PerformAction, Render, Spec, cotransform, modifyState, simpleSpec) import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec)
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
...@@ -21,28 +21,25 @@ initialState = ...@@ -21,28 +21,25 @@ initialState =
data Action data Action
= NoOp = ChangeString String
| ChangeString String
| ChangeAnotherString String | ChangeAnotherString String
| SetInput String | SetInput String
performAction :: PerformAction _ State _ Action performAction :: PerformAction State {} Action
performAction NoOp _ _ = pure unit
performAction (ChangeString ps) _ _ = pure unit performAction (ChangeString ps) _ _ = pure unit
performAction (ChangeAnotherString ps) _ _ = pure unit performAction (ChangeAnotherString ps) _ _ = pure unit
performAction (SetInput ps) _ _ = void do performAction (SetInput ps) _ _ = void do
modifyState \( state) -> state { inputValue = ps } modifyState $ _ { inputValue = ps }
docview :: Spec _ State _ Action docview :: Spec State {} Action
docview = simpleSpec performAction render docview = simpleSpec performAction render
where where
render :: Render State _ Action render :: Render State {} Action
render dispatch _ state _ = render dispatch _ state _ =
[ [
div [className "container1"] div [className "container1"]
...@@ -76,7 +73,7 @@ docview = simpleSpec performAction render ...@@ -76,7 +73,7 @@ docview = simpleSpec performAction render
[ [
h6 [] [text "Add a free term to STOPLIST"] h6 [] [text "Add a free term to STOPLIST"]
, div [className "form-group"] , div [className "form-group"]
[ input [className "form-control", _id "id_password", name "password", placeholder "Any text", _type "value",value state.inputValue,onInput \e -> dispatch (SetInput (unsafeEventValue e))] [] [ input [className "form-control", _id "id_password", name "password", placeholder "Any text", _type "value",value state.inputValue,onInput \e -> dispatch (SetInput (unsafeEventValue e))]
, div [className "clearfix"] [] , div [className "clearfix"] []
] ]
, button [className "btn btn-primary", _type "button"] [text "Create and Add"] , button [className "btn btn-primary", _type "button"] [text "Create and Add"]
......
module Gargantext.Pages.Corpus.Doc.Body where
import Prelude hiding (div)
import Control.Monad.Eff.Console (CONSOLE)
import DOM (DOM)
import Data.Array (fold)
import Gargantext.Components.Charts.Options.ECharts (chart)
import Gargantext.Pages.Corpus.Doc.Facets.Dashboard (globalPublis)
import Gargantext.Pages.Corpus.Doc.Facets as Tab
import Network.HTTP.Affjax (AJAX)
import React.DOM (div, h3, hr, i, p, text)
import React.DOM.Props (className, style)
import Thermite (Render, Spec, defaultPerformAction, simpleSpec)
type State = Tab.State
type Action = Tab.Action
initialState :: State
initialState = Tab.initialState
spec' :: forall eff props. Spec (dom :: DOM, console :: CONSOLE, ajax :: AJAX | eff) Tab.State props Tab.Action
spec' = fold [ corpusAnalysisSpec
, Tab.tab1
]
corpusAnalysisSpec :: forall props eff . Spec eff Tab.State props Tab.Action
corpusAnalysisSpec = simpleSpec defaultPerformAction render
where
render :: Render Tab.State props Tab.Action
render dispatch _ state _ =
[ div [className "row"]
[ div [className "col-md-3"]
[ h3 [] [text "IMT Global publications"]
]
, div [className "col-md-9"]
[ hr [style {height : "2px",backgroundColor : "black"}] []
]
]
, div [className "row"]
[ div [className "jumbotron1", style {padding : "12px 0px 20px 12px"}]
[ div [ className "col-md-8 content"]
[ p [] [ i [className "fa fa-globe"] []
, text " Hal Database"
]
, p [] [ i [className "fab fa-searchengin"] []
, text " Query: all publications with all schools ids"
]
]
, div [ className "col-md-4 content"]
[ p [] [ i [className "fa fa-calendar"] []
, text " June. 26 2018, 10:59 am"
]
, p [] [ i [className "fa fa-user"] []
, text " Author(s): françois.pineau"
]
]
]
]
, chart globalPublis
]
This diff is collapsed.
module Gargantext.Pages.Corpus.Doc.Facets where module Gargantext.Pages.Corpus.Doc.Facets
( module Gargantext.Pages.Corpus.Doc.Facets.States
, module Gargantext.Pages.Corpus.Doc.Facets.Actions
, module Gargantext.Pages.Corpus.Doc.Facets.Specs
) where
import Prelude hiding (div) import Gargantext.Pages.Corpus.Doc.Facets.States
import Gargantext.Pages.Corpus.Doc.Facets.Actions
import Gargantext.Pages.Corpus.Doc.Facets.Specs
import Gargantext.Pages.Corpus.Doc.Facets.Authors as AV
import Control.Monad.Eff.Console (CONSOLE)
import DOM (DOM)
import Data.Either (Either(..))
import Data.Lens (Lens', Prism', lens, prism)
import Data.List (fromFoldable)
import Data.Tuple (Tuple(..))
import Gargantext.Pages.Corpus.Doc.Document as DV
import Gargantext.Components.Tab as Tab
import Network.HTTP.Affjax (AJAX)
import Gargantext.Pages.Corpus.Doc.Facets.Sources as SV
import Gargantext.Pages.Corpus.Doc.Facets.Terms as TV
import Thermite (Spec, focus)
data Action
= DocviewA DV.Action
| SourceviewA SV.Action
| AuthorviewA AV.Action
| TermsviewA TV.Action
| TabViewA Tab.Action
| NoOp
type State =
{ docview :: DV.State
, authorview :: AV.State
, sourceview :: SV.State
, termsview :: TV.State
, activeTab :: Int
}
initialState :: State
initialState =
{ docview : DV.tdata
, authorview : AV.initialState
, sourceview : SV.initialState
, termsview : TV.initialState
, activeTab : 0
}
_doclens :: Lens' State DV.State
_doclens = lens (\s -> s.docview) (\s ss -> s {docview = ss})
_docAction :: Prism' Action DV.Action
_docAction = prism DocviewA \ action ->
case action of
DocviewA laction -> Right laction
_-> Left action
docPageSpec :: forall eff props. Spec (dom :: DOM, console :: CONSOLE, ajax :: AJAX | eff) State props Action
docPageSpec = focus _doclens _docAction DV.layoutDocview
_authorlens :: Lens' State AV.State
_authorlens = lens (\s -> s.authorview) (\s ss -> s {authorview = ss})
_authorAction :: Prism' Action AV.Action
_authorAction = prism AuthorviewA \ action ->
case action of
AuthorviewA laction -> Right laction
_-> Left action
authorPageSpec :: forall eff props. Spec (dom :: DOM, console::CONSOLE, ajax :: AJAX | eff) State props Action
authorPageSpec = focus _authorlens _authorAction AV.authorspec'
_sourcelens :: Lens' State SV.State
_sourcelens = lens (\s -> s.sourceview) (\s ss -> s {sourceview = ss})
_sourceAction :: Prism' Action SV.Action
_sourceAction = prism SourceviewA \ action ->
case action of
SourceviewA laction -> Right laction
_-> Left action
sourcePageSpec :: forall eff props. Spec (dom :: DOM, console :: CONSOLE, ajax :: AJAX | eff) State props Action
sourcePageSpec = focus _sourcelens _sourceAction SV.sourcespec'
_termslens :: Lens' State TV.State
_termslens = lens (\s -> s.termsview) (\s ss -> s {termsview = ss})
_termsAction :: Prism' Action TV.Action
_termsAction = prism TermsviewA \ action ->
case action of
TermsviewA laction -> Right laction
_-> Left action
termsPageSpec :: forall eff props. Spec (dom :: DOM, console :: CONSOLE, ajax :: AJAX | eff) State props Action
termsPageSpec = focus _termslens _termsAction TV.termSpec'
_tablens :: Lens' State Tab.State
_tablens = lens (\s -> s.activeTab) (\s ss -> s {activeTab = ss})
_tabAction :: Prism' Action Tab.Action
_tabAction = prism TabViewA \ action ->
case action of
TabViewA laction -> Right laction
_-> Left action
tab1 :: forall eff props. Spec ( dom :: DOM, console :: CONSOLE, ajax :: AJAX| eff) State props Action
tab1 = Tab.tabs _tablens _tabAction $ fromFoldable [ Tuple "Doc View" docPageSpec
, Tuple "Author View" authorPageSpec
, Tuple "Source View" sourcePageSpec
, Tuple "Terms View" termsPageSpec
]
module Gargantext.Pages.Corpus.Doc.Facets.Actions where
import Data.Lens (Prism', prism)
import Data.Either (Either(..))
import Gargantext.Pages.Corpus.Doc.Facets.Documents as DV
import Gargantext.Pages.Corpus.Doc.Facets.Sources as SV
import Gargantext.Pages.Corpus.Doc.Facets.Authors as AV
import Gargantext.Pages.Corpus.Doc.Facets.Terms as TV
import Gargantext.Components.Tab as Tab
data Action
= DocviewA DV.Action
| SourceviewA SV.Action
| AuthorviewA AV.Action
| TermsviewA TV.Action
| TabViewA Tab.Action
_docAction :: Prism' Action DV.Action
_docAction = prism DocviewA \ action ->
case action of
DocviewA laction -> Right laction
_-> Left action
_authorAction :: Prism' Action AV.Action
_authorAction = prism AuthorviewA \ action ->
case action of
AuthorviewA laction -> Right laction
_-> Left action
_sourceAction :: Prism' Action SV.Action
_sourceAction = prism SourceviewA \ action ->
case action of
SourceviewA laction -> Right laction
_-> Left action
_termsAction :: Prism' Action TV.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
module Gargantext.Pages.Corpus.Doc.Facets.Authors where module Gargantext.Pages.Corpus.Doc.Facets.Authors where
import Control.Monad.Eff.Console (CONSOLE)
import DOM (DOM)
import Data.Array (fold) import Data.Array (fold)
import Gargantext.Pages.Corpus.Doc.Document as D import Gargantext.Pages.Corpus.Doc.Facets.Documents as D
import Network.HTTP.Affjax (AJAX)
import Prelude hiding (div) import Prelude hiding (div)
import React.DOM (h3, text) import React.DOM (h3, text)
import Thermite (PerformAction, Render, Spec, defaultPerformAction, modifyState, simpleSpec) import Thermite (PerformAction, Render, Spec, defaultPerformAction, simpleSpec)
type State = D.State type State = D.State
initialState :: State initialState :: State
initialState = D.tdata initialState = D.tdata
type Action = D.Action type Action = D.Action
authorSpec :: Spec State {} Action
authorSpec :: forall props eff . Spec ( console :: CONSOLE
, ajax :: AJAX
, dom :: DOM
| eff
) State props Action
authorSpec = simpleSpec defaultPerformAction render authorSpec = simpleSpec defaultPerformAction render
where where
render :: Render State props Action render :: Render State {} Action
render dispatch _ state _ = render dispatch _ state _ =
[ h3 [] [text "AuthorView"]] [ h3 [] [text "AuthorView"]]
authorspec' :: forall eff props. Spec (dom :: DOM, console :: CONSOLE, ajax :: AJAX | eff) State props Action authorspec' :: Spec State {} Action
authorspec' = fold [authorSpec, D.layoutDocview] authorspec' = fold [authorSpec, D.layoutDocview]
module Gargantext.Pages.Corpus.Doc.Facets.Sources where module Gargantext.Pages.Corpus.Doc.Facets.Sources where
import Control.Monad.Eff.Console (CONSOLE)
import DOM (DOM)
import Data.Array (fold) import Data.Array (fold)
import Gargantext.Pages.Corpus.Doc.Document as D import Gargantext.Pages.Corpus.Doc.Facets.Documents as D
import Network.HTTP.Affjax (AJAX)
import Prelude hiding (div) import Prelude hiding (div)
import React.DOM (h3, text) import React.DOM (h3, text)
import Thermite (Render, Spec, defaultPerformAction, simpleSpec) import Thermite (Render, Spec, defaultPerformAction, simpleSpec)
...@@ -19,16 +16,12 @@ initialState = D.tdata ...@@ -19,16 +16,12 @@ initialState = D.tdata
type Action = D.Action type Action = D.Action
sourceSpec :: forall props eff . Spec ( console :: CONSOLE sourceSpec :: Spec State {} Action
, ajax :: AJAX
, dom :: DOM
| eff
) State props Action
sourceSpec = simpleSpec defaultPerformAction render sourceSpec = simpleSpec defaultPerformAction render
where where
render :: Render State props Action render :: Render State {} Action
render dispatch _ state _ = render dispatch _ state _ =
[ h3 [] [text "Source view"]] [ h3 [] [text "Source view"]]
sourcespec' :: forall eff props. Spec (dom :: DOM, console :: CONSOLE, ajax :: AJAX | eff) State props Action sourcespec' :: Spec State {} Action
sourcespec' = fold [sourceSpec, D.layoutDocview] sourcespec' = fold [sourceSpec, D.layoutDocview]
module Gargantext.Pages.Corpus.Doc.Facets.Specs where
import Prelude hiding (div)
import Data.List (fromFoldable)
import Data.Tuple (Tuple(..))
import Gargantext.Pages.Corpus.Doc.Facets.States (State(), _doclens, _sourcelens, _authorlens, _termslens, _tablens, initialState)
import Gargantext.Pages.Corpus.Doc.Facets.Actions (Action(), _docAction, _sourceAction, _authorAction, _termsAction, _tabAction)
import Gargantext.Pages.Corpus.Doc.Facets.Documents as DV
import Gargantext.Pages.Corpus.Doc.Facets.Sources as SV
import Gargantext.Pages.Corpus.Doc.Facets.Authors as AV
import Gargantext.Pages.Corpus.Doc.Facets.Terms as TV
import Gargantext.Components.Tab as Tab
import Thermite (Spec, focus, hide)
pureTab1 :: Spec {} {} Void
pureTab1 = hide initialState statefulTab1
statefulTab1 :: Spec State {} Action
statefulTab1 =
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 DV.layoutDocview
authorPageSpec :: Spec State {} Action
authorPageSpec = focus _authorlens _authorAction AV.authorspec'
sourcePageSpec :: Spec State {} Action
sourcePageSpec = focus _sourcelens _sourceAction SV.sourcespec'
termsPageSpec :: Spec State {} Action
termsPageSpec = focus _termslens _termsAction TV.termSpec'
module Gargantext.Pages.Corpus.Doc.Facets.States where
import Data.Lens (Lens', lens)
import Gargantext.Pages.Corpus.Doc.Facets.Documents as DV
import Gargantext.Pages.Corpus.Doc.Facets.Sources as SV
import Gargantext.Pages.Corpus.Doc.Facets.Authors as AV
import Gargantext.Pages.Corpus.Doc.Facets.Terms as TV
import Gargantext.Components.Tab as Tab
type State =
{ docview :: DV.State
, authorview :: AV.State
, sourceview :: SV.State
, termsview :: TV.State
, activeTab :: Int
}
initialState :: State
initialState =
{ docview : DV.tdata
, authorview : AV.initialState
, sourceview : SV.initialState
, termsview : TV.initialState
, activeTab : 0
}
_doclens :: Lens' State DV.State
_doclens = lens (\s -> s.docview) (\s ss -> s {docview = ss})
_authorlens :: Lens' State AV.State
_authorlens = lens (\s -> s.authorview) (\s ss -> s {authorview = ss})
_sourcelens :: Lens' State SV.State
_sourcelens = lens (\s -> s.sourceview) (\s ss -> s {sourceview = ss})
_termslens :: Lens' State TV.State
_termslens = lens (\s -> s.termsview) (\s ss -> s {termsview = ss})
_tablens :: Lens' State Tab.State
_tablens = lens (\s -> s.activeTab) (\s ss -> s {activeTab = ss})
module Gargantext.Pages.Corpus.Doc.Facets.Terms where module Gargantext.Pages.Corpus.Doc.Facets.Terms where
import Control.Monad.Eff.Console (CONSOLE)
import DOM (DOM)
import Data.Array (fold) import Data.Array (fold)
import Gargantext.Pages.Corpus.Doc.Document as D import Gargantext.Pages.Corpus.Doc.Facets.Documents as D
import Network.HTTP.Affjax (AJAX)
import Prelude hiding (div) import Prelude hiding (div)
import React.DOM (h3, text) import React.DOM (h3, text)
import Thermite (PerformAction, Render, Spec, defaultPerformAction, modifyState, simpleSpec) import Thermite (PerformAction, Render, Spec, defaultPerformAction, simpleSpec)
...@@ -20,16 +17,12 @@ initialState = D.tdata ...@@ -20,16 +17,12 @@ initialState = D.tdata
type Action = D.Action type Action = D.Action
termsSpec :: forall props eff . Spec ( console :: CONSOLE termsSpec :: Spec State {} Action
, ajax :: AJAX
, dom :: DOM
| eff
) State props Action
termsSpec = simpleSpec defaultPerformAction render termsSpec = simpleSpec defaultPerformAction render
where where
render :: Render State props Action render :: Render State {} Action
render dispatch _ state _ = render dispatch _ state _ =
[ h3 [] [text "Terms view"]] [ h3 [] [text "Terms view"]]
termSpec' :: forall eff props. Spec (dom :: DOM, console :: CONSOLE, ajax :: AJAX | eff) State props Action termSpec' :: Spec State {} Action
termSpec' = fold [termsSpec, D.layoutDocview] termSpec' = fold [termsSpec, D.layoutDocview]
...@@ -2,20 +2,21 @@ module Gargantext.Pages.Corpus.Doc.Facets.Terms.NgramsItem where ...@@ -2,20 +2,21 @@ module Gargantext.Pages.Corpus.Doc.Facets.Terms.NgramsItem where
import Prelude import Prelude
import Control.Monad.Eff.Console (CONSOLE) import Data.Newtype (class Newtype, unwrap)
import DOM (DOM) import Data.Lens.Iso (re)
import Data.Newtype (class Newtype) import Data.Lens.Iso.Newtype (_Newtype)
import Network.HTTP.Affjax (AJAX)
import React (ReactElement) import React (ReactElement)
import React.DOM (input, span, td, text, tr) import React.DOM (input, span, td, text, tr)
import React.DOM.Props (_type, checked, className, onChange, style, title) import React.DOM.Props (_type, checked, className, onChange, style, title)
import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec) import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec, hide, focusState)
import Gargantext.Utils (getter, setter) import Gargantext.Utils (getter, setter)
newtype State = State newtype State = State
{ term :: Term { term :: Term
} }
derive instance newtypeState :: Newtype State _
initialState :: State initialState :: State
initialState = State {term : Term {id : 10, term : "hello", occurrence : 10, _type : None, children : []}} initialState = State {term : Term {id : 10, term : "hello", occurrence : 10, _type : None, children : []}}
...@@ -36,17 +37,19 @@ data Action ...@@ -36,17 +37,19 @@ data Action
= SetMap Boolean = SetMap Boolean
| SetStop Boolean | SetStop Boolean
performAction :: forall eff props. PerformAction ( console :: CONSOLE , ajax :: AJAX, dom :: DOM | eff ) State props Action performAction :: PerformAction State {} Action
performAction (SetMap b) _ _ = void do performAction (SetMap b) _ _ = void do
modifyState \(State s) -> State s {term = setter (_{_type = (if b then MapTerm else None)}) s.term} modifyState \(State s) -> State s {term = setter (_{_type = (if b then MapTerm else None)}) s.term}
performAction (SetStop b) _ _ = void do performAction (SetStop b) _ _ = void do
modifyState \(State s) -> State s {term = setter (_{_type = (if b then StopTerm else None)}) s.term} modifyState \(State s) -> State s {term = setter (_{_type = (if b then StopTerm else None)}) s.term}
ngramsItemSpec :: forall props eff . Spec (console::CONSOLE, ajax::AJAX, dom::DOM | eff) State props Action ngramsItemSpec :: Spec {} {} Void
ngramsItemSpec = simpleSpec performAction render ngramsItemSpec = hide (unwrap initialState) $
focusState (re _Newtype) $
simpleSpec performAction render
where where
render :: Render State props Action render :: Render State {} Action
render dispatch _ (State state) _ = render dispatch _ (State state) _ =
[ [
tr [] tr []
...@@ -63,7 +66,7 @@ ngramsItemSpec = simpleSpec performAction render ...@@ -63,7 +66,7 @@ ngramsItemSpec = simpleSpec performAction render
, checked $ getter _._type state.term == MapTerm , checked $ getter _._type state.term == MapTerm
, title "Mark as completed" , title "Mark as completed"
, onChange $ dispatch <<< ( const $ SetMap $ not (getter _._type state.term == MapTerm)) , onChange $ dispatch <<< ( const $ SetMap $ not (getter _._type state.term == MapTerm))
] [] ]
checkbox_stop = checkbox_stop =
input input
[ _type "checkbox" [ _type "checkbox"
...@@ -71,7 +74,7 @@ ngramsItemSpec = simpleSpec performAction render ...@@ -71,7 +74,7 @@ ngramsItemSpec = simpleSpec performAction render
, checked $ getter _._type state.term == StopTerm , checked $ getter _._type state.term == StopTerm
, title "Mark as completed" , title "Mark as completed"
, onChange $ dispatch <<< ( const $ SetStop $ not (getter _._type state.term == StopTerm)) , onChange $ dispatch <<< ( const $ SetStop $ not (getter _._type state.term == StopTerm))
] [] ]
dispTerm :: String -> TermType -> ReactElement dispTerm :: String -> TermType -> ReactElement
......
module Gargantext.Pages.Corpus.Doc.Facets.Terms.NgramsTable where module Gargantext.Pages.Corpus.Doc.Facets.Terms.NgramsTable where
import CSS.TextAlign (center, textAlign)
import Control.Monad.Eff.Console (CONSOLE) import Data.Array (filter, toUnfoldable)
import DOM (DOM)
import Data.Array (filter, fold, toUnfoldable)
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Newtype (class Newtype, unwrap)
import Data.Lens (Lens', Prism', lens, over, prism) import Data.Lens (Lens', Prism', lens, over, prism)
import Data.Lens.Iso (re)
import Data.Lens.Iso.Newtype (_Newtype)
import Data.List (List) import Data.List (List)
import Data.Tuple (Tuple(..), uncurry) import Data.Tuple (Tuple(..), uncurry)
import Network.HTTP.Affjax (AJAX) import Data.Void (Void)
import Data.Unit (Unit)
import Effect (Effect)
import Gargantext.Pages.Corpus.Doc.Facets.Terms.NgramsItem as NI import Gargantext.Pages.Corpus.Doc.Facets.Terms.NgramsItem as NI
import Prelude (class Eq, class Ord, class Show, Unit, bind, map, not, pure, show, void, ($), (*), (+), (-), (/), (<), (<$>), (<>), (==), (>), (>=), (>>=)) import Prelude (class Eq, class Ord, class Show, map, show, void, ($), (*), (+), (-), (/), (<), (<>), (==), (>), (>=), pure, unit)
import React (ReactElement) import React (ReactElement)
import React.DOM hiding (style) import React.DOM hiding (style, map)
import React.DOM.Props (_id, _type, className, href, name, onChange, onClick, onInput, placeholder, scope, selected, style, value) import React.DOM.Props (_id, _type, className, href, name, onChange, onClick, onInput, placeholder, scope, selected, style, value)
import Thermite (PerformAction, Spec, _render, cotransform, focus, foreach, modifyState, withState) import Thermite (PerformAction, Spec, _render, focus, foreach, modifyState, focusState, hide)
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
newtype State = State newtype State = State
{ items :: List NI.State { items :: List {}
, search :: String , search :: String
, selectString :: String , selectString :: String
, totalPages :: Int , totalPages :: Int
, currentPage :: Int , currentPage :: Int
...@@ -27,38 +30,39 @@ newtype State = State ...@@ -27,38 +30,39 @@ newtype State = State
, totalRecords :: Int , totalRecords :: Int
} }
derive instance newtypeState :: Newtype State _
initialState :: State initialState :: State
initialState = State { items : toUnfoldable [NI.initialState] initialState = State { items : toUnfoldable [{}]
, search : "" , search : ""
, selectString : "" , selectString : ""
,totalPages : 10 , totalPages : 10
, currentPage : 1 , currentPage : 1
, pageSize : PS10 , pageSize : PS10
, totalRecords : 100 , totalRecords : 100
} }
data Action data Action
= NoOp = ItemAction Int Void
| ItemAction Int NI.Action
| ChangeString String | ChangeString String
| SetInput String | SetInput String
| ChangePageSize PageSizes | ChangePageSize PageSizes
| ChangePage Int | ChangePage Int
_itemsList :: Lens' State (List NI.State) _itemsList :: Lens' State (List {})
_itemsList = lens (\(State s) -> s.items) (\(State s) v -> State s { items = v }) _itemsList = lens (\(State s) -> s.items) (\(State s) v -> State s { items = v })
_ItemAction :: Prism' Action (Tuple Int NI.Action) _ItemAction :: Prism' Action (Tuple Int Void)
_ItemAction = prism (uncurry ItemAction) \ta -> _ItemAction = prism (uncurry ItemAction) \ta ->
case ta of case ta of
ItemAction i a -> Right (Tuple i a) ItemAction i a -> Right (Tuple i a)
_ -> Left ta _ -> Left ta
performAction :: forall eff props. PerformAction ( console :: CONSOLE , ajax :: AJAX, dom :: DOM | eff ) State props Action type Dispatch = Action -> Effect Unit
performAction _ _ _ = void do
modifyState \(State state) -> State $ state performAction :: PerformAction State {} Action
performAction (ChangePageSize ps) _ _ = void (cotransform (\state -> changePageSize ps state )) performAction (ChangePageSize ps) _ _ = void $ modifyState $ changePageSize ps
performAction (ChangePage p) _ _ = void do performAction (ChangePage p) _ _ = void do
modifyState \(State state) -> State $ state {currentPage = p} modifyState \(State state) -> State $ state {currentPage = p}
...@@ -72,7 +76,9 @@ performAction (ChangeString c) _ _ = void do ...@@ -72,7 +76,9 @@ performAction (ChangeString c) _ _ = void do
performAction (SetInput s) _ _ = void do performAction (SetInput s) _ _ = void do
modifyState \(State state) -> State $ state { search = s } modifyState \(State state) -> State $ state { search = s }
tableSpec :: forall eff props .Spec eff State props Action -> Spec eff State props Action performAction _ _ _ = pure unit
tableSpec :: Spec State {} Action -> Spec State {} Action
tableSpec = over _render \render dispatch p (State s) c -> tableSpec = over _render \render dispatch p (State s) c ->
[div [className "container-fluid"] [div [className "container-fluid"]
[ [
...@@ -100,7 +106,7 @@ tableSpec = over _render \render dispatch p (State s) c -> ...@@ -100,7 +106,7 @@ tableSpec = over _render \render dispatch p (State s) c ->
, _type "value" , _type "value"
,value s.search ,value s.search
,onInput \e -> dispatch (SetInput (unsafeEventValue e)) ,onInput \e -> dispatch (SetInput (unsafeEventValue e))
] [] ]
] ]
...@@ -149,14 +155,17 @@ tableSpec = over _render \render dispatch p (State s) c -> ...@@ -149,14 +155,17 @@ tableSpec = over _render \render dispatch p (State s) c ->
] ]
] ]
ngramsTableSpec :: forall props eff . Spec (console::CONSOLE, ajax::AJAX, dom::DOM | eff) State props Action ngramsTableSpec :: Spec {} {} Void
ngramsTableSpec = container $ fold ngramsTableSpec =
[ tableSpec $ withState \st -> hide (unwrap initialState) $
focus _itemsList _ItemAction $ focusState (re _Newtype) $
foreach \_ -> NI.ngramsItemSpec container $
] tableSpec $
focus _itemsList _ItemAction $
container :: forall eff state props action. Spec eff state props action -> Spec eff state props action foreach $ \ _ ->
NI.ngramsItemSpec
container :: forall state props action. Spec state props action -> Spec state props action
container = over _render \render d p s c -> container = over _render \render d p s c ->
[ div [ className "container-fluid" ] $ [ div [ className "container-fluid" ] $
(render d p s c) (render d p s c)
...@@ -214,7 +223,7 @@ string2PageSize "50" = PS50 ...@@ -214,7 +223,7 @@ string2PageSize "50" = PS50
string2PageSize "100" = PS100 string2PageSize "100" = PS100
string2PageSize _ = PS10 string2PageSize _ = PS10
sizeDD :: PageSizes -> _ -> ReactElement sizeDD :: PageSizes -> Dispatch -> ReactElement
sizeDD ps d sizeDD ps d
= p [] = p []
[ text "Show : " [ text "Show : "
...@@ -237,7 +246,7 @@ textDescription currPage pageSize totalRecords ...@@ -237,7 +246,7 @@ textDescription currPage pageSize totalRecords
end = if end' > totalRecords then totalRecords else end' end = if end' > totalRecords then totalRecords else end'
pagination :: _ -> Int -> Int -> ReactElement pagination :: Dispatch -> Int -> Int -> ReactElement
pagination d tp cp pagination d tp cp
= span [] $ = span [] $
[ text "Pages: " [ text "Pages: "
...@@ -308,7 +317,7 @@ pagination d tp cp ...@@ -308,7 +317,7 @@ pagination d tp cp
lnums = map (\i -> fnmid d i) $ filter (lessthan 1) [cp - 2, cp - 1] lnums = map (\i -> fnmid d i) $ filter (lessthan 1) [cp - 2, cp - 1]
rnums = map (\i -> fnmid d i) $ filter (greaterthan tp) [cp + 1, cp + 2] rnums = map (\i -> fnmid d i) $ filter (greaterthan tp) [cp + 1, cp + 2]
fnmid :: _ -> Int -> ReactElement fnmid :: Dispatch -> Int -> ReactElement
fnmid d i fnmid d i
= span [] = span []
[ text " " [ text " "
......
module Gargantext.Pages.Corpus.User.Brevets where module Gargantext.Pages.Corpus.User.Brevets where
import Prelude
import Thermite (Render, Spec, defaultPerformAction, simpleSpec)
import Control.Monad.Eff.Console (CONSOLE) brevetsSpec :: Spec {} {} Void
import DOM (DOM) brevetsSpec = simpleSpec defaultPerformAction render
import Network.HTTP.Affjax (AJAX)
import Prelude (id, void)
import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec)
type State = String
initialState :: State
initialState = ""
data Action = NoOp
performAction :: forall eff props. PerformAction ( console :: CONSOLE
, ajax :: AJAX
, dom :: DOM
| eff
) State props Action
performAction NoOp _ _ = void do
modifyState id
brevetsSpec :: forall props eff . Spec ( console :: CONSOLE
, ajax :: AJAX
, dom :: DOM
| eff
) State props Action
brevetsSpec = simpleSpec performAction render
where where
render :: Render State props Action render :: Render {} {} Void
render dispatch _ state _ = render dispatch _ state _ =
[] []
...@@ -2,36 +2,29 @@ module Gargantext.Pages.Corpus.User.Users.API where ...@@ -2,36 +2,29 @@ module Gargantext.Pages.Corpus.User.Users.API where
import Prelude import Prelude
import Gargantext.Pages.Corpus.User.Users.Types (Action(..), State, User, _user)
import Control.Monad.Aff (Aff)
import Control.Monad.Aff.Console (CONSOLE, log)
import Control.Monad.Trans.Class (lift) import Control.Monad.Trans.Class (lift)
import DOM (DOM)
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Lens (set) import Data.Lens ((?~))
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Effect.Console (log)
import Gargantext.Config (toUrl, NodeType(..), End(..))
import Gargantext.Config.REST (get) import Gargantext.Config.REST (get)
import Network.HTTP.Affjax (AJAX) import Gargantext.Pages.Corpus.User.Users.Types (Action(..), State, User, _user)
import Thermite (PerformAction, modifyState) import Thermite (PerformAction, modifyState)
getUser :: forall eff. Int -> Aff getUser :: Int -> Aff (Either String User)
(console :: CONSOLE, ajax :: AJAX | eff) (Either String User) getUser id = get $ toUrl Back Node id
getUser id = get $ "http://localhost:8008/node/" <> show id
performAction :: forall eff props. PerformAction ( console :: CONSOLE performAction :: PerformAction State {} Action
, ajax :: AJAX performAction (FetchUser userId) _ _ = do
, dom :: DOM
| eff ) State props Action
performAction NoOp _ _ = void do
modifyState id
performAction (FetchUser userId) _ _ = void do
value <- lift $ getUser userId value <- lift $ getUser userId
_ <- case value of _ <- case value of
(Right user) -> modifyState \state -> set _user (Just user) state (Right user) -> void $ modifyState $ _user ?~ user
(Left err) -> do (Left err) -> do
_ <- lift $ log err liftEffect $ log err
modifyState id liftEffect <<< log $ "Fetching user..."
lift <<< log $ "Fetching user..." performAction _ _ _ = pure unit
performAction _ _ _ = void do
modifyState id
...@@ -5,19 +5,12 @@ module Gargantext.Pages.Corpus.User.Users.Specs ...@@ -5,19 +5,12 @@ module Gargantext.Pages.Corpus.User.Users.Specs
import Gargantext.Pages.Corpus.User.Users.Specs.Renders import Gargantext.Pages.Corpus.User.Users.Specs.Renders
import Control.Monad.Aff.Console (CONSOLE)
import DOM (DOM)
import Network.HTTP.Affjax (AJAX)
import Thermite (Spec, simpleSpec) import Thermite (Spec, simpleSpec)
import Gargantext.Pages.Corpus.User.Users.Actions import Gargantext.Pages.Corpus.User.Users.Actions
import Gargantext.Pages.Corpus.User.Users.States import Gargantext.Pages.Corpus.User.Users.States
import Gargantext.Pages.Corpus.User.Users.API (performAction) import Gargantext.Pages.Corpus.User.Users.API (performAction)
layoutUser :: forall props eff . Spec ( console :: CONSOLE layoutUser :: Spec State {} Action
, ajax :: AJAX
, dom :: DOM
| eff
) State props Action
layoutUser = simpleSpec performAction render layoutUser = simpleSpec performAction render
publicationSpec :: forall eff props. Spec (dom :: DOM, console :: CONSOLE, ajax :: AJAX | eff) State props Action publicationSpec :: forall eff props. Spec (dom :: DOM, console :: CONSOLE, ajax :: AJAX | eff) State props Action
......
module Gargantext.Pages.Corpus.User.Users.Specs.Documents where
import Prelude
import React.DOM (table, tbody, td, text, th, thead, tr)
import React.DOM.Props (className, scope)
import Thermite (Render, Spec, defaultPerformAction, simpleSpec)
publicationSpec :: Spec {} {} Void
publicationSpec = simpleSpec defaultPerformAction render
where
render :: Render {} {} Void
render dispatch _ state _ =
[ table [ className "table"]
[ thead [ className "thead-dark"]
[ tr []
[ th [ scope "col"] [ text "Date" ]
, th [ scope "col"] [ text "Description" ]
, th [ scope "col"] [ text "Projects" ]
, th [ scope "col"] [ text "Favorite" ]
, th [ scope "col"] [ text "Delete" ]
]
]
, tbody []
[ tr [] [ td [] [ text "2012/03/06"]
, td [] [ text "Big data and text mining"]
, td [] [ text "European funds"]
, td [] [ text "True"]
, td [] [ text "False"]
]
, tr [] [ td [] [ text "2013/03/06"]
, td [] [ text "Cryptography"]
, td [] [ text "French funds"]
, td [] [ text "True"]
, td [] [ text "False"]
]
, tr [] [ td [] [ text "2013/03/06"]
, td [] [ text "Artificial Intelligence"]
, td [] [ text "Not found"]
, td [] [ text "True"]
, td [] [ text "False"]
]
]
]
]
...@@ -11,12 +11,12 @@ import Data.Maybe (Maybe(..)) ...@@ -11,12 +11,12 @@ import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..), uncurry) import Data.Tuple (Tuple(..), uncurry)
import Prelude (($), (<<<), (<$>)) import Prelude (($), (<<<), (<$>))
import React (ReactElement) import React (ReactElement)
import React.DOM (div, h3, h1, li, span, text, ul, img) import React.DOM (div, h3, img, li, span, text, ul)
import React.DOM.Props (_id, className, src) import React.DOM.Props (_id, className, src)
import Thermite (Render) import Thermite (Render)
render :: forall props. Render State props Action render :: Render State {} Action
render dispatch _ state _ = render dispatch _ state _ =
[ [
div [className "col-md-12"] div [className "col-md-12"]
...@@ -25,7 +25,7 @@ render dispatch _ state _ = ...@@ -25,7 +25,7 @@ render dispatch _ state _ =
Nothing -> display "User not found" [] Nothing -> display "User not found" []
] ]
display :: forall props. String -> Array ReactElement -> Array ReactElement display :: String -> Array ReactElement -> Array ReactElement
display title elems = display title elems =
[ div [className "container-fluid"] [ div [className "container-fluid"]
[ div [className "row", _id "user-page-header"] [ div [className "row", _id "user-page-header"]
...@@ -37,7 +37,7 @@ display title elems = ...@@ -37,7 +37,7 @@ display title elems =
[ div [className "col-md-12"] [ div [className "col-md-12"]
[ div [className "row"] [ div [className "row"]
[ div [className "col-md-2"] [ div [className "col-md-2"]
[ img [src "/images/Gargantextuel-212x300.jpg"] [] ] [ img [src "/images/Gargantextuel-212x300.jpg"] ]
, div [className "col-md-1"] [] , div [className "col-md-1"] []
, div [className "col-md-8"] elems , div [className "col-md-8"] elems
] ]
...@@ -62,11 +62,11 @@ userInfos hyperdata = ...@@ -62,11 +62,11 @@ userInfos hyperdata =
listInfo :: String -> String -> ReactElement listInfo :: String -> String -> ReactElement
listInfo s ss = listElement $ infoRender s ss listInfo s ss = listElement $ infoRender s ss
listElement :: forall props. Array ReactElement -> ReactElement listElement :: Array ReactElement -> ReactElement
listElement = li [className "list-group-item justify-content-between"] listElement = li [className "list-group-item justify-content-between"]
infoRender :: forall props. String -> String -> Array ReactElement infoRender :: Tuple String String -> Array ReactElement
infoRender title content = infoRender (Tuple title content) =
[ span [] [text title] [ span [] [text title]
, span [className "badge badge-default badge-pill"] [text content] , span [className "badge badge-default badge-pill"] [text content]
] ]
module Gargantext.Pages.Corpus.User.Users.Types where module Gargantext.Pages.Corpus.User.Users.Types
(module Gargantext.Pages.Corpus.User.Users.Types.Types,
import Prelude (bind, pure, ($)) module Gargantext.Pages.Corpus.User.Users.Types.Lens,
module Gargantext.Pages.Corpus.User.Users.Types.States,
brevetSpec,
projectSpec,
facets
)
where
import Prelude
import Gargantext.Pages.Corpus.User.Users.Types.Lens
import Gargantext.Pages.Corpus.User.Users.Types.Types
import Gargantext.Pages.Corpus.User.Users.Types.States
import Gargantext.Pages.Corpus.User.Brevets as B import Gargantext.Pages.Corpus.User.Brevets as B
import Gargantext.Pages.Folder as PS
import Gargantext.Components.Tab (tabs)
import Gargantext.Utils.DecodeMaybe ((.?|))
import Data.Argonaut (class DecodeJson, decodeJson, (.?))
import Data.Map (Map, fromFoldable)
import Data.Maybe (Maybe)
import Data.List (fromFoldable) import Data.List (fromFoldable)
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
import Gargantext.Components.Tab (tabs)
import Control.Monad.Aff.Console (CONSOLE) import Thermite (Render, Spec, focus, noState, defaultPerformAction, simpleSpec)
import DOM (DOM)
import Network.HTTP.Affjax (AJAX) brevetSpec :: Spec State {} Action
import Thermite (Spec, focus) brevetSpec = noState B.brevetsSpec
newtype User = projets :: Spec {} {} Void
User { projets = simpleSpec defaultPerformAction render
id ::Int, where
typename :: Maybe Int, render :: Render {} {} Void
userId ::Int, render dispatch _ state _ =
parentId :: Int, []
name :: String,
date ::Maybe String, projectSpec :: Spec State {} Action
hyperdata :: Maybe HyperData projectSpec = noState projets
}
facets :: Spec State {} Action
instance decodeUser :: DecodeJson User where facets = tabs _tablens _tabAction $ fromFoldable
decodeJson json = do [ Tuple "Publications (12)" publicationSpec
obj <- decodeJson json , Tuple "Brevets (2)" brevetSpec
id <- obj .? "id" , Tuple "Projets IMT (5)" projectSpec
typename <- obj .?| "typename" ]
userId <- obj .? "userId"
parentId <- obj .? "parentId"
name <- obj .? "name"
date <- obj .?| "date"
hyperdata <- obj .?| "hyperdata"
pure $ User {id, typename, userId, parentId, name, date, hyperdata}
newtype HyperData = HyperData (Map String String)
instance decodeHyperData :: DecodeJson HyperData where
decodeJson json = do
obj <- decodeJObject json
pure <<< HyperData $ fromFoldable obj
module Gargantext.Pages.Corpus.User.Users.Types.Lens where
import Gargantext.Pages.Corpus.User.Brevets as B
import Data.Either (Either(..))
import Data.Lens (Lens', Prism', lens, prism)
import Data.Maybe (Maybe)
import Gargantext.Pages.Corpus.User.Users.Types.States (Action(..), State)
import Gargantext.Pages.Corpus.User.Users.Types.Types (User)
import Gargantext.Pages.Corpus.User.Users.Specs.Documents as P
import Gargantext.Components.Tab as Tab
import Thermite (Spec, noState)
_user :: Lens' State (Maybe User)
_user = lens (\s -> s.user) (\s ss -> s{user = ss})
_tablens :: Lens' State Tab.State
_tablens = lens (\s -> s.activeTab) (\s ss -> s {activeTab = ss})
_tabAction :: Prism' Action Tab.Action
_tabAction = prism TabA \ action ->
case action of
TabA laction -> Right laction
_-> Left action
publicationSpec :: Spec State {} Action
publicationSpec = noState P.publicationSpec
module Gargantext.Pages.Corpus.User.Users.Types.States where
import Data.Maybe (Maybe(..))
import Gargantext.Pages.Corpus.User.Users.Types.Types (User)
import Gargantext.Pages.Corpus.User.Users.Specs.Documents as P
import Gargantext.Components.Tab as Tab
data Action
= TabA Tab.Action
| FetchUser Int
type State =
{ activeTab :: Int
, user :: Maybe User
}
initialState :: State
initialState =
{ activeTab : 0
, user: Nothing
}
module Gargantext.Pages.Corpus.User.Users.Types.Types where
import Prelude
import Data.Argonaut (class DecodeJson, decodeJson, (.?))
import Data.Maybe (Maybe)
import Gargantext.Utils.DecodeMaybe ((.?|))
newtype User =
User { id :: Int
, typename :: Maybe Int
, userId :: Int
, parentId :: Int
, name :: String
, date :: Maybe String
, hyperdata :: HyperData
}
newtype HyperData =
HyperData
{ bureau :: Maybe String
, atel :: Maybe String
, fax :: Maybe String
, aprecision :: Maybe String
, service :: Maybe String
, service2 :: Maybe String
, groupe :: Maybe String
, lieu :: Maybe String
, pservice :: Maybe String
, date_modification :: Maybe String
, fonction :: Maybe String
, pfonction :: Maybe String
, url :: Maybe String
, prenom :: Maybe String
, nom :: Maybe String
, idutilentite :: Maybe String
, afonction :: Maybe String
, grprech :: Maybe String
, entite :: Maybe String
, entite2 :: Maybe String
, mail :: Maybe String
}
instance decodeUserHyperData :: DecodeJson HyperData where
decodeJson json = do
obj <- decodeJson json
bureau <- obj .?| "bureau"
atel <- obj .?| "atel"
fax <- obj .?| "fax"
aprecision <- obj .?| "aprecision"
service <- obj .?| "service"
service2 <- obj .?| "service2"
groupe <- obj .?| "groupe"
lieu <- obj .?| "lieu"
pservice <- obj .?| "pservice"
date_modification <- obj .?| "date_modification"
fonction <- obj .?| "fonction"
pfonction <- obj .?| "pfonction"
url <- obj .?| "url"
prenom <- obj .?| "prenom"
nom <- obj .?| "nom"
idutilentite <- obj .?| "idutilentite"
afonction <- obj .?| "afonction"
grprech <- obj .?| "grprech"
entite <- obj .?| "entite"
entite2 <- obj .?| "entite2"
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
}
instance decodeUser :: DecodeJson User where
decodeJson json = do
obj <- decodeJson json
id <- obj .? "id"
typename <- obj .?| "typename"
userId <- obj .? "userId"
parentId <- obj .? "parentId"
name <- obj .? "name"
date <- obj .?| "date"
hyperdata <- obj .? "hyperdata"
pure $ User { id, typename, userId
, parentId, name, date
, hyperdata
}
module Gargantext.Pages.Folder where
import Prelude (id, void)
import Control.Monad.Eff.Console (CONSOLE)
import DOM (DOM)
import Network.HTTP.Affjax (AJAX)
import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec)
type State = String
initialState :: State
initialState = ""
data Action = NoOp
performAction :: forall eff props. PerformAction ( console :: CONSOLE
, ajax :: AJAX
, dom :: DOM
| eff
) State props Action
performAction NoOp _ _ = void do
modifyState id
projets :: forall props eff . Spec ( console :: CONSOLE
, ajax :: AJAX
, dom :: DOM
| eff
) State props Action
projets = simpleSpec performAction render
where
render :: Render State props Action
render dispatch _ state _ =
[]
module Gargantext.Pages.Home.Actions where module Gargantext.Pages.Home.Actions where
import Prelude hiding (div) import Prelude hiding (div)
import Control.Monad.Cont.Trans (lift) import Effect.Class (liftEffect)
import Control.Monad.Eff.Console (CONSOLE) import Gargantext.Pages.Home.States (State)
import DOM (DOM) import Routing.Hash (setHash)
import Thermite (PerformAction)
import Gargantext.Components.Lang.Landing.EnUS as En
import Gargantext.Components.Lang.Landing.FrFR as Fr
import Gargantext.Components.Data.Landing (BlockText(..), BlockTexts(..), Button(..), LandingData(..))
import Gargantext.Components.Data.Lang (Lang(..))
import Gargantext.Pages.Home.States (State(..))
import Network.HTTP.Affjax (AJAX)
import React (ReactElement)
import React.DOM (a, div, h3, i, img, p, span, text)
import React.DOM.Props (Props, _id, aria, className, href, src, target, title)
import Routing.Hash.Aff (setHash)
import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec)
data Action data Action
= NoOp = Documentation
| Documentation
| Enter | Enter
| Login | Login
| SignUp | SignUp
performAction :: forall eff props. PerformAction ( console :: CONSOLE performAction :: PerformAction State {} Action
, ajax :: AJAX performAction Documentation _ _ = pure unit
, dom :: DOM
| eff
) State props Action
performAction NoOp _ _ = void do
modifyState \state -> state
performAction Documentation _ _ = void do
modifyState \state -> state
performAction Enter _ _ = void do performAction Enter _ _ = void do
lift $ setHash "/search" liftEffect $ setHash "/search"
modifyState \state -> state
performAction Login _ _ = void do performAction Login _ _ = void do
lift $ setHash "/login" liftEffect $ setHash "/login"
modifyState \state -> state
performAction SignUp _ _ = void do
modifyState \state -> state
performAction SignUp _ _ = pure unit
...@@ -2,45 +2,40 @@ module Gargantext.Pages.Home.Specs where ...@@ -2,45 +2,40 @@ module Gargantext.Pages.Home.Specs where
import Prelude hiding (div) import Prelude hiding (div)
import Control.Monad.Cont.Trans (lift) import Data.Lens (re)
import Control.Monad.Eff.Console (CONSOLE) import Data.Lens.Iso.Newtype (_Newtype)
import DOM (DOM) import Data.Newtype (unwrap)
import Gargantext.Components.Lang.Landing.EnUS as En import Gargantext.Components.Lang.Landing.EnUS as En
import Gargantext.Components.Lang.Landing.FrFR as Fr import Gargantext.Components.Lang.Landing.FrFR as Fr
import Gargantext.Components.Data.Landing (BlockText(..), BlockTexts(..), Button(..), LandingData(..)) import Gargantext.Components.Data.Landing (BlockText(..), BlockTexts(..), Button(..), LandingData(..))
import Gargantext.Components.Data.Lang (Lang(..)) import Gargantext.Components.Data.Lang (Lang(..))
import Gargantext.Pages.Home.States (State(..)) import Gargantext.Pages.Home.States (State, initialState)
import Gargantext.Pages.Home.Actions (Action(..), performAction) import Gargantext.Pages.Home.Actions (Action, performAction)
import Network.HTTP.Affjax (AJAX)
import React (ReactElement) import React (ReactElement)
import React.DOM (a, div, h3, i, img, p, span, text) import React.DOM (a, div, h3, i, img, p, span, text)
import React.DOM.Props (Props, _id, aria, className, href, src, target, title) import React.DOM.Props (Props, _id, aria, className, href, src, target, title)
import Routing.Hash.Aff (setHash) import Thermite (Render, Spec, simpleSpec, hide, focusState)
import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec)
-- Layout | -- Layout |
layoutLanding :: forall props eff . Lang -> Spec ( console :: CONSOLE landingData :: Lang -> LandingData
, ajax :: AJAX landingData FR = Fr.landingData
, dom :: DOM landingData EN = En.landingData
| eff
) State props Action layoutLanding :: Lang -> Spec {} {} Void
layoutLanding FR = layoutLanding' Fr.landingData layoutLanding = hide (unwrap initialState)
layoutLanding EN = layoutLanding' En.landingData <<< focusState (re _Newtype)
<<< layoutLanding' <<< landingData
------------------------------------------------------------------------ ------------------------------------------------------------------------
layoutLanding' :: forall props eff . LandingData -> Spec ( console :: CONSOLE layoutLanding' :: LandingData -> Spec State {} Action
, ajax :: AJAX
, dom :: DOM
| eff
) State props Action
layoutLanding' hd = simpleSpec performAction render layoutLanding' hd = simpleSpec performAction render
where where
render :: Render State props Action render :: Render State {} Action
render dispatch _ state _ = render dispatch _ state _ =
[ div [ className "container1" ] [ jumboTitle hd false ] [ div [ className "container1" ] [ jumboTitle hd false ]
, div [ className "container1" ] [] -- put research here , div [ className "container1" ] [] -- put research here
...@@ -83,11 +78,11 @@ jumboTitle :: LandingData -> Boolean -> ReactElement ...@@ -83,11 +78,11 @@ jumboTitle :: LandingData -> Boolean -> ReactElement
jumboTitle (LandingData hd) b = div jumbo jumboTitle (LandingData hd) b = div jumbo
[ div [className "row" ] [ div [className "row" ]
[ div [ className "col-md-8 content"] [ div [ className "col-md-8 content"]
[ p [ className "left" ] [ div [ className "left" ]
[ div [_id "logo-designed" ] [ div [_id "logo-designed" ]
[ img [ src "images/logo.png" [ img [ src "images/logo.png"
, title hd.logoTitle , title hd.logoTitle
] [] ]
] ]
] ]
] ]
...@@ -96,7 +91,7 @@ jumboTitle (LandingData hd) b = div jumbo ...@@ -96,7 +91,7 @@ jumboTitle (LandingData hd) b = div jumbo
, _id "funnyimg" , _id "funnyimg"
, title hd.imageTitle , title hd.imageTitle
] ]
[]
] ]
] ]
] ]
...@@ -113,6 +108,5 @@ imageEnter (LandingData hd) action = div [className "row"] ...@@ -113,6 +108,5 @@ imageEnter (LandingData hd) action = div [className "row"]
, title hd.imageTitle , title hd.imageTitle
, action , action
] ]
[]
] ]
] ]
module Gargantext.Pages.Home.States where module Gargantext.Pages.Home.States where
import Prelude hiding (div) import Data.Newtype (class Newtype)
import Control.Monad.Cont.Trans (lift)
import Control.Monad.Eff.Console (CONSOLE)
import DOM (DOM)
import Gargantext.Components.Lang.Landing.EnUS as En
import Gargantext.Components.Lang.Landing.FrFR as Fr
import Gargantext.Components.Data.Landing (BlockText(..), BlockTexts(..), Button(..), LandingData(..))
import Gargantext.Components.Data.Lang (Lang(..))
import Network.HTTP.Affjax (AJAX)
import React (ReactElement)
import React.DOM (a, div, h3, i, img, p, span, text)
import React.DOM.Props (Props, _id, aria, className, href, src, target, title)
import Routing.Hash.Aff (setHash)
import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec)
newtype State = State newtype State = State
{ userName :: String { userName :: String
, password :: String , password :: String
} }
derive instance newtypeState :: Newtype State _
initialState :: State initialState :: State
initialState = State initialState = State
{userName : "" { userName : ""
, password : "" , password : ""
} }
module Gargantext.Pages.Layout where module Gargantext.Pages.Layout where
import Prelude hiding (div) import Prelude hiding (div)
import Gargantext.Components.Login as LN -- import Gargantext.Components.Login as LN
import Gargantext.Pages.Layout.Actions (Action(..)) import Gargantext.Pages.Layout.Actions (Action(..))
import Gargantext.Pages.Corpus as AC import Gargantext.Pages.Layout.Specs.AddCorpus as AC
import Gargantext.Pages.Corpus.Doc.Annotation as D -- import Gargantext.Pages.Corpus.Doc.Facets as TV
import Gargantext.Pages.Corpus.Doc.Document as DV -- import Gargantext.Pages.Corpus.Doc.Annotation as D
import Gargantext.Pages.Corpus.Doc.Facets as TV
import Gargantext.Pages.Corpus.Doc.Facets.Graph as GE import Gargantext.Pages.Corpus.Doc.Facets.Documents as DV
import Gargantext.Pages.Corpus.Doc.Facets.Terms.NgramsTable as NG import Gargantext.Pages.Corpus.Doc.Facets.Graph as GE
-- import Gargantext.Pages.Corpus.Doc.Facets.Terms.NgramsTable as NG
import Gargantext.Pages.Corpus.User.Users as U import Gargantext.Pages.Corpus.User.Users as U
import Gargantext.Pages.Home as L import Gargantext.Pages.Corpus.Annuaire as Annuaire
import Gargantext.Pages.Search as S -- import Gargantext.Pages.Home as L
-- import Gargantext.Pages.Layout.Specs.Search as S
import Gargantext.Router (Routes(..)) import Gargantext.Router (Routes(..))
dispatchAction :: forall t115 t445 t447. dispatchAction :: forall ignored m.
Bind t445 => Applicative t445 => Monad m =>
(Action -> t445 t447) -> t115 -> Routes -> t445 Unit (Action -> m Unit) -> ignored -> Routes -> m Unit
dispatchAction dispatcher _ Home = do dispatchAction dispatcher _ Home = do
_ <- dispatcher Initialize dispatcher Initialize
_ <- dispatcher $ SetRoute Home dispatcher $ SetRoute Home
_ <- dispatcher $ LandingA L.NoOp -- dispatcher $ LandingA TODO
pure unit
dispatchAction dispatcher _ Login = do dispatchAction dispatcher _ Login = do
_ <- dispatcher Initialize dispatcher Initialize
_ <- dispatcher $ SetRoute Login dispatcher $ SetRoute Login
_ <- dispatcher $ LoginA LN.NoOp -- dispatcher $ LoginA TODO
pure unit
dispatchAction dispatcher _ AddCorpus = do dispatchAction dispatcher _ AddCorpus = do
_ <- dispatcher $ SetRoute AddCorpus dispatcher $ SetRoute AddCorpus
_ <- dispatcher $ AddCorpusA AC.LoadDatabaseDetails dispatcher $ AddCorpusA AC.LoadDatabaseDetails
pure unit
dispatchAction dispatcher _ DocView = do dispatchAction dispatcher _ (DocView n) = do
_ <- dispatcher $ SetRoute $ DocView dispatcher $ SetRoute (DocView n)
_ <- dispatcher $ DocViewA $ DV.LoadData dispatcher $ DocViewA $ DV.LoadData n
pure unit
dispatchAction dispatcher _ SearchView = do dispatchAction dispatcher _ SearchView = do
_ <- dispatcher $ SetRoute $ SearchView dispatcher $ SetRoute SearchView
_ <- dispatcher $ SearchA $ S.NoOp -- dispatcher $ SearchA TODO
pure unit
dispatchAction dispatcher _ (UserPage id) = do dispatchAction dispatcher _ (UserPage id) = do
_ <- dispatcher $ SetRoute $ UserPage id dispatcher $ SetRoute $ UserPage id
_ <- dispatcher $ UserPageA $ U.NoOp -- dispatcher $ UserPageA TODO
_ <- dispatcher $ UserPageA $ U.FetchUser id dispatcher $ UserPageA $ U.FetchUser id
pure unit
dispatchAction dispatcher _ (Annuaire id) = do
dispatcher $ SetRoute $ Annuaire id
dispatcher $ AnnuaireAction $ Annuaire.Load id
dispatchAction dispatcher _ (Folder id) = do
dispatcher $ SetRoute $ Folder id
dispatchAction dispatcher _ (DocAnnotation i) = do dispatchAction dispatcher _ (DocAnnotation i) = do
_ <- dispatcher $ SetRoute $ DocAnnotation i dispatcher $ SetRoute $ DocAnnotation i
_ <- dispatcher $ DocAnnotationViewA $ D.NoOp -- dispatcher $ DocAnnotationViewA TODO
pure unit
dispatchAction dispatcher _ Tabview = do dispatchAction dispatcher _ Tabview = do
_ <- dispatcher $ SetRoute $ Tabview dispatcher $ SetRoute Tabview
_ <- dispatcher $ TabViewA $ TV.NoOp -- dispatcher $ TabViewA TODO
pure unit
dispatchAction dispatcher _ CorpusAnalysis = do dispatchAction dispatcher _ CorpusAnalysis = do
_ <- dispatcher $ SetRoute $ CorpusAnalysis dispatcher $ SetRoute CorpusAnalysis
--_ <- dispatcher $ CorpusAnalysisA $ CA.NoOp -- dispatcher $ CorpusAnalysisA TODO
pure unit
dispatchAction dispatcher _ PGraphExplorer = do dispatchAction dispatcher _ PGraphExplorer = do
_ <- dispatcher $ SetRoute $ PGraphExplorer dispatcher $ SetRoute PGraphExplorer
_ <- dispatcher $ GraphExplorerA $ GE.LoadGraph "imtNew.json" dispatcher $ GraphExplorerA $ GE.LoadGraph "imtNew.json"
pure unit
dispatchAction dispatcher _ NGramsTable = do dispatchAction dispatcher _ NGramsTable = do
_ <- dispatcher $ SetRoute $ NGramsTable dispatcher $ SetRoute NGramsTable
_ <- dispatcher $ NgramsA $ NG.NoOp -- dispatcher $ NgramsA TODO
pure unit
dispatchAction dispatcher _ Dashboard = do dispatchAction dispatcher _ Dashboard = do
_ <- dispatcher $ SetRoute $ Dashboard dispatcher $ SetRoute Dashboard
pure unit
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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