Commit 2a668be5 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

Merge branch '300-dev-purescript-simple-json' into 311-tree-node-list-upload-file-as-json

parents 5f98197e b7f2c801
Pipeline #1631 canceled with stage
with (import <nixpkgs> {});
let
nodejs-with-packages = with nodePackages; [
bower
yarn
]; in
stdenv.mkDerivation rec {
name = "env";
env = buildEnv {
name = name;
paths = buildInputs;
};
buildInputs = [
nodejs-with-packages
yarn
yarn2nix
];
builder = builtins.toFile "builder.sh" ''
source $stdenv/setup
touch $out
'';
}
...@@ -14,6 +14,5 @@ ...@@ -14,6 +14,5 @@
<div id="app" class ="container-fluid"></div> <div id="app" class ="container-fluid"></div>
<div id="portal"></div> <div id="portal"></div>
<script src="bundle.js"></script> <script src="bundle.js"></script>
<script src='https://visio.gargantext.org/external_api.js'></script> <!-- FIXME to be removed -->
</body> </body>
</html> </html>
let upstream = let upstream =
https://github.com/purescript/package-sets/releases/download/psc-0.14.3-20210716/packages.dhall sha256:64d7b5a1921e8458589add8a1499a1c82168e726a87fc4f958b3f8760cca2efe https://github.com/purescript/package-sets/releases/download/psc-0.14.3-20210716/packages.dhall sha256:1f9af624ddfd5352455b7ac6df714f950d499e7e3c6504f62ff467eebd11042c
let overrides = let overrides =
{ globals = { globals =
...@@ -8,8 +8,8 @@ let overrides = ...@@ -8,8 +8,8 @@ let overrides =
, version = "v4.1.0" , version = "v4.1.0"
} }
, smolder = , smolder =
{ dependencies = [ { dependencies =
"bifunctors" [ "bifunctors"
, "catenable-lists" , "catenable-lists"
, "free" , "free"
, "ordered-collections" , "ordered-collections"
...@@ -17,7 +17,8 @@ let overrides = ...@@ -17,7 +17,8 @@ let overrides =
, "strings" , "strings"
, "test-unit" , "test-unit"
, "transformers" , "transformers"
, "tuples"] , "tuples"
]
, repo = "https://github.com/bodil/purescript-smolder" , repo = "https://github.com/bodil/purescript-smolder"
, version = "v12.3.0" , version = "v12.3.0"
} }
...@@ -81,8 +82,17 @@ let additions = ...@@ -81,8 +82,17 @@ let additions =
, repo = "https://github.com/nwolverson/purescript-dom-filereader" , repo = "https://github.com/nwolverson/purescript-dom-filereader"
, version = "v5.0.0" , version = "v5.0.0"
} }
, formula = , formula =
{ dependencies = [ "effect", "prelude", "reactix", "record", "toestand", "tuples", "typelevel-prelude", "typisch" ] { dependencies =
[ "effect"
, "prelude"
, "reactix"
, "record"
, "toestand"
, "tuples"
, "typelevel-prelude"
, "typisch"
]
, repo = "https://github.com/poorscript/purescript-formula" , repo = "https://github.com/poorscript/purescript-formula"
, version = "v0.2.1" , version = "v0.2.1"
} }
...@@ -103,47 +113,53 @@ let additions = ...@@ -103,47 +113,53 @@ let additions =
} }
, reactix = , reactix =
{ dependencies = { dependencies =
[ "aff" [ "aff"
, "arrays" , "arrays"
, "dom-simple" , "dom-simple"
, "effect" , "effect"
, "ffi-simple" , "ffi-simple"
, "foldable-traversable" , "foldable-traversable"
, "functions" , "functions"
, "maybe" , "maybe"
, "nullable" , "nullable"
, "prelude" , "prelude"
, "psci-support" , "psci-support"
, "refs" , "refs"
, "spec" , "spec"
, "spec-mocha" , "spec-mocha"
, "strings" , "strings"
, "tuples" , "tuples"
, "unfoldable" , "unfoldable"
, "unsafe-coerce" , "unsafe-coerce"
] ]
, repo = "https://github.com/poorscript/purescript-reactix" , repo = "https://github.com/poorscript/purescript-reactix"
, version = "v0.4.13" , version = "v0.4.13"
} }
, simple-json-generics = , simple-json-generics =
{ dependencies = { dependencies = [ "simple-json" ]
[ "simple-json" ]
, repo = "https://github.com/justinwoo/purescript-simple-json-generics" , repo = "https://github.com/justinwoo/purescript-simple-json-generics"
, version = "v0.1.0" , version = "v0.1.0"
} }
, toestand = , toestand =
{ dependencies = [ "effect", "reactix", "prelude", "record", "tuples", "typelevel-prelude", "typisch" ] { dependencies =
[ "effect"
, "reactix"
, "prelude"
, "record"
, "tuples"
, "typelevel-prelude"
, "typisch"
]
, repo = "https://github.com/poorscript/purescript-toestand" , repo = "https://github.com/poorscript/purescript-toestand"
, version = "v0.6.2" , version = "v0.6.2"
} }
, typisch = , typisch =
{ dependencies = [ "prelude" ] { dependencies = [ "prelude" ]
, repo = "https://github.com/poorscript/purescript-typisch" , repo = "https://github.com/poorscript/purescript-typisch"
, version = "v0.2.1" , version = "v0.2.1"
} }
, tuples-native = , tuples-native =
{ dependencies = { dependencies = [ "prelude", "typelevel", "unsafe-coerce" ]
[ "prelude", "typelevel", "unsafe-coerce" ]
, repo = "https://github.com/poorscript/purescript-tuples-native" , repo = "https://github.com/poorscript/purescript-tuples-native"
, version = "v2.2.0" , version = "v2.2.0"
} }
...@@ -180,10 +196,11 @@ let additions = ...@@ -180,10 +196,11 @@ let additions =
, repo = "https://github.com/alpacaaa/purescript-simplecrypto" , repo = "https://github.com/alpacaaa/purescript-simplecrypto"
, version = "v1.0.1" , version = "v1.0.1"
} }
, web-url =
{ dependencies = [ "prelude" ]
, repo = "https://github.com/mjepronk/purescript-web-url"
, version = "v1.0.2"
}
} }
--let localPackages = { in upstream // overrides // additions
-- reactix = ../../purescript-reactix/spago.dhall as Location
-- }
in upstream // overrides // additions -- // localPackages
...@@ -15,6 +15,9 @@ let ...@@ -15,6 +15,9 @@ let
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
echo "Installing JS Dependencies"
yarn
echo "Compiling" echo "Compiling"
#build-purs #build-purs
echo "Bundling" echo "Bundling"
......
...@@ -91,6 +91,7 @@ to generate this file without the comments in this block. ...@@ -91,6 +91,7 @@ to generate this file without the comments in this block.
, "web-file" , "web-file"
, "web-html" , "web-html"
, "web-storage" , "web-storage"
, "web-url"
, "web-xhr" , "web-xhr"
] ]
, packages = ./packages.dhall , packages = ./packages.dhall
......
module Gargantext.Components.Charts.Options.Data where module Gargantext.Components.Charts.Options.Data where
import Gargantext.Components.Charts.Options.Font (TextStyle, Icon, ItemStyle)
import Gargantext.Components.Charts.Options.Legend (SelectedMode)
import Gargantext.Types (class Optional)
import Record.Unsafe (unsafeSet) import Record.Unsafe (unsafeSet)
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Types (class Optional)
import Gargantext.Components.Charts.Options.Font (TextStyle, Icon, ItemStyle)
type DataLegend = type DataLegend =
{ name :: String { name :: String
...@@ -22,11 +23,15 @@ type RequiredData v o = ...@@ -22,11 +23,15 @@ type RequiredData v o =
} }
type OptionalData = type OptionalData =
( name :: String ( name :: String
, symbolSize :: Number , symbolSize :: Number
, itemStyle :: ItemStyle , itemStyle :: ItemStyle
-- ^ the style setting about single data point(bubble). -- ^ the style setting about single data point(bubble).
, label :: { show :: Boolean } , label :: { show :: Boolean }
, emphasis :: { itemStyle :: ItemStyle }
, selectedMode :: SelectedMode
, select :: { itemStyle :: ItemStyle }
-- ^ need "selectedMode" to be defined
) )
type DataSerie v = RequiredData v OptionalData type DataSerie v = RequiredData v OptionalData
......
...@@ -3,3 +3,31 @@ ...@@ -3,3 +3,31 @@
var ReactEcharts = require("echarts-for-react"); var ReactEcharts = require("echarts-for-react");
exports.eChartsClass = ReactEcharts.default; exports.eChartsClass = ReactEcharts.default;
/**
* @XXX "echarts-for-react" unsuitable to proper PureScript implementation
* regarding event listeners
* @name listenerFn1
* @param {function} fn
* @returns
*/
exports.listenerFn1 = function(fn) {
return function() {
var args = Array.prototype.slice.call(arguments);
fn(args[0])()
}
};
/**
* @link https://echarts.apache.org/en/api.html#echartsInstance.dispatchAction
* @name dispatchAction
* @param {object} eChartsInstance instanceof ECharts
* @param {object} opts
* @returns
*/
exports.dispatchAction = function(eChartsInstance) {
return function(opts) {
return function() {
eChartsInstance.dispatchAction(opts);
}
}
}
module Gargantext.Components.Charts.Options.ECharts where module Gargantext.Components.Charts.Options.ECharts where
import Prelude
import CSS.Common (normal) import CSS.Common (normal)
import CSS.FontStyle (FontStyle(..)) import CSS.FontStyle (FontStyle(..))
import Data.Maybe (Maybe(..))
import Data.Nullable (toMaybe)
import Effect (Effect)
import Gargantext.Components.Charts.Options.Color (transparent, violet, black) import Gargantext.Components.Charts.Options.Color (transparent, violet, black)
import Gargantext.Components.Charts.Options.Data (DataLegend, dataSerie) import Gargantext.Components.Charts.Options.Data (DataLegend, dataSerie)
import Gargantext.Components.Charts.Options.Font (IconOptions(..), Shape(..), TextStyle, chartFontStyle, chartFontWeight, icon, mkTooltip, Tooltip, mkToolBox) import Gargantext.Components.Charts.Options.Font (IconOptions(..), Shape(..), TextStyle, chartFontStyle, chartFontWeight, icon, mkTooltip, Tooltip, mkToolBox)
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, seriesPieD1) import Gargantext.Components.Charts.Options.Series (Series, seriesPieD1)
import Gargantext.Components.Charts.Options.Type (DataZoom, Echarts, Legend, Option, Title, XAxis, YAxis, xAxis, yAxis) import Gargantext.Components.Charts.Options.Type (DataZoom, EChartsInstance, Echarts, Legend, MouseEvent, Option, Title, XAxis, YAxis, EChartRef, xAxis, yAxis)
import Gargantext.Utils.Reactix as R2
import Prelude
import React (ReactClass, unsafeCreateElementDynamic) import React (ReactClass, unsafeCreateElementDynamic)
import Reactix as R import Reactix as R
import Gargantext.Utils.Reactix as R2 import Record.Extra as RX
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
foreign import eChartsClass :: ReactClass Echarts foreign import eChartsClass :: ReactClass Echarts
foreign import listenerFn1 :: forall evt. (evt -> Effect Unit) -> Effect Unit
-- | @XXX some eCharts "actions" not working ("select", ...)
-- | https://echarts.apache.org/en/api.html#echartsInstance.dispatchAction
foreign import dispatchAction :: forall payload. EChartsInstance -> payload -> Effect Unit
chart :: Options -> R.Element chart :: Options -> R.Element
chart = echarts <<< chartWith <<< opts chart = echarts <<< chartWith
chartWith :: Option -> Echarts chartWith :: Options -> Echarts
chartWith option = chartWith options =
{ option { option : opts options
--, className : Nothing --, className : Nothing
--, style : Nothing --, style : Nothing
--, theme : Nothing --, theme : Nothing
...@@ -35,8 +42,24 @@ chartWith option = ...@@ -35,8 +42,24 @@ chartWith option =
--, optsLoading: Nothing --, optsLoading: Nothing
--, onReady : Nothing --, onReady : Nothing
--, resizable : Nothing --, resizable : Nothing
--, onEvents : Nothing , onEvents : getEvents options
, ref : refListener options
} }
where
getEvents (Options { onClick }) =
{ click: listenerFn1 \e -> case onClick of
-- sanitize parsing (see MouseEvent comment)
Just fn -> RX.pick (e :: MouseEvent) # fn
Nothing -> pure unit
}
refListener (Options { onInit }) = case onInit of
Nothing -> pure unit
Just fn -> listenerFn1 (_ # fn # execOnInit)
execOnInit fn = toMaybe >>> case _ of
Nothing -> pure unit
Just (ref :: Record EChartRef) -> pure unit -- fn =<< ref.getEchartsInstance
echarts :: Echarts -> R.Element echarts :: Echarts -> R.Element
echarts c = R2.buff $ unsafeCreateElementDynamic (unsafeCoerce eChartsClass) c [] echarts c = R2.buff $ unsafeCreateElementDynamic (unsafeCoerce eChartsClass) c []
...@@ -155,6 +178,20 @@ data Options = Options ...@@ -155,6 +178,20 @@ data Options = Options
, series :: Array Series , series :: Array Series
, addZoom :: Boolean , addZoom :: Boolean
, tooltip :: Tooltip , tooltip :: Tooltip
, onClick :: Maybe (MouseEvent -> Effect Unit)
-- (?) `onInit` custom listener
--
-- * in addition of the already existing `onReady` native listener
-- which is executed on chart mount, but does not provide any arg
-- * the React library also contained another native listener as
-- `ref`, which adds the React Ref of the mounted chart
-- * this additional `onInit` is executed after the "Apache Echarts"
-- has been "initialised" (see more details [1]),
-- it intends to return the `eChartsInstance` used for every
-- library actions
--
-- [1] https://echarts.apache.org/en/api.html#echarts.init
, onInit :: Maybe (EChartsInstance -> Effect Unit)
} }
tooltipTriggerAxis :: Tooltip tooltipTriggerAxis :: Tooltip
......
module Gargantext.Components.Charts.Options.Series where module Gargantext.Components.Charts.Options.Series where
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, (.:), (~>), (:=))
import Data.Argonaut.Core (jsonEmptyObject)
import Data.Array (foldl) import Data.Array (foldl)
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..), maybe) import Data.Maybe (Maybe(..), maybe)
import Data.Newtype (class Newtype) import Data.Newtype (class Newtype)
import Data.Symbol (SProxy(..)) import Data.Symbol (SProxy(..))
import Record as Record import Gargantext.Components.Charts.Options.Data (DataD1, DataD2)
import Gargantext.Components.Charts.Options.Data (DataD1, DataD2)
import Gargantext.Components.Charts.Options.Font (ItemStyle, Tooltip)
import Gargantext.Components.Charts.Options.Font (ItemStyle, Tooltip)
import Gargantext.Components.Charts.Options.Legend (SelectedMode)
import Gargantext.Prelude
import Gargantext.Types (class Optional)
import Prelude (class Eq, class Show, bind, map, pure, show, ($), (+), (<<<), (<>), eq)
import Record as Record
import Record.Unsafe (unsafeSet) import Record.Unsafe (unsafeSet)
import Simple.JSON as JSON import Simple.JSON as JSON
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Prelude
import Gargantext.Types (class Optional)
import Gargantext.Components.Charts.Options.Font (ItemStyle, Tooltip)
import Gargantext.Components.Charts.Options.Data (DataD1, DataD2)
newtype SeriesType = SeriesType String newtype SeriesType = SeriesType String
...@@ -59,13 +64,16 @@ seriesType = SeriesType <<< show ...@@ -59,13 +64,16 @@ seriesType = SeriesType <<< show
-- | Scatter Dimension 2 data -- | Scatter Dimension 2 data
type OptionalSeries = type OptionalSeries =
( name :: String ( name :: String
, symbolSize :: Number , symbolSize :: Number
, itemStyle :: ItemStyle , itemStyle :: ItemStyle
-- ^ Graphic style of, *emphasis* is the style when it is highlighted, like being hovered by mouse, or highlighted via legend connect. -- ^ Graphic style of, *emphasis* is the style when it is highlighted, like being hovered by mouse, or highlighted via legend connect.
-- https://ecomfe.github.io/echarts-doc/public/en/option.html#series-scatter.itemStyle -- https://ecomfe.github.io/echarts-doc/public/en/option.html#series-scatter.itemStyle
, tooltip :: Tooltip , tooltip :: Tooltip
, emphasis :: { itemStyle :: ItemStyle }
, selectedMode :: SelectedMode
, select :: { itemStyle :: ItemStyle }
-- ^ need "selectedMode" to be defined
-- many more... -- many more...
) )
...@@ -217,5 +225,3 @@ labelP = SProxy :: SProxy "label" ...@@ -217,5 +225,3 @@ labelP = SProxy :: SProxy "label"
-- | TODO -- | TODO
-- https://ecomfe.github.io/echarts-examples/public/data/asset/data/life-expectancy-table.json -- 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 -- https://ecomfe.github.io/echarts-examples/public/editor.html?c=scatter3D-dataset&gl=1
...@@ -2,6 +2,8 @@ module Gargantext.Components.Charts.Options.Type where ...@@ -2,6 +2,8 @@ module Gargantext.Components.Charts.Options.Type where
import Prelude import Prelude
import Data.Nullable (Nullable)
import Effect (Effect)
import Gargantext.Components.Charts.Options.Color (Color) import Gargantext.Components.Charts.Options.Color (Color)
import Gargantext.Components.Charts.Options.Data (DataLegend) import Gargantext.Components.Charts.Options.Data (DataLegend)
import Gargantext.Components.Charts.Options.Font (TextStyle, Tooltip, ToolBox) import Gargantext.Components.Charts.Options.Font (TextStyle, Tooltip, ToolBox)
...@@ -12,6 +14,9 @@ import Gargantext.Types (class Optional) ...@@ -12,6 +14,9 @@ import Gargantext.Types (class Optional)
import React as R import React as R
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
-- | https://echarts.apache.org/en/api.html#echartsInstance
foreign import data EChartsInstance :: Type
newtype ChartAlign = ChartAlign String newtype ChartAlign = ChartAlign String
-- TODO: Maybe is not working here => use Optional -- TODO: Maybe is not working here => use Optional
...@@ -29,7 +34,8 @@ type Echarts = ...@@ -29,7 +34,8 @@ type Echarts =
--, 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 :: OnEvents -- PropTypes.object
, ref :: Effect Unit
} }
type Option = type Option =
...@@ -160,3 +166,53 @@ type AxisLabel = ...@@ -160,3 +166,53 @@ type AxisLabel =
} }
type Rich = {} type Rich = {}
---
-- | @XXX "echarts-for-react" third party library does not have an event
-- | dictionary
-- | these values had been picked from what we gather in the dist file
-- | "echarts/dist/echarts.common.js" and
-- | https://echarts.apache.org/en/api.html#events
type OnEvents =
{ click :: Effect Unit
-- ...
}
-- | @XXX "echarts-for-react" third party library bases on "apache-echarts"
-- | does not have strongly typed signature, nor determined arity
-- | (actual runtime event contains more key than what their docs describe)
-- |
-- | https://echarts.apache.org/en/api.html#events.Mouse%20events
type MouseEvent =
{ borderColor :: Nullable String
, color :: String
, componentIndex :: Int
, componentSubType :: String
, componentTyp :: String
-- , data :: -- Object
, dataIndex :: Int
, dataType :: Nullable String
-- , dimensionNames :: -- Array
-- , encore :: -- Object
-- , event :: -- instanceof Event
-- , marker :: -- String
, name :: String
, seriesId :: Nullable String
, seriesIndex :: Int
, seriesName :: String
, seriesType :: String
, type :: String
, value :: String -- or Array ??
}
----
-- | @XXX partial definition given by the third library author
-- | POJO containing a mix of ReactElement field and custom method attached
-- |
-- | https://github.com/hustcc/echarts-for-react#component-api--echarts-api
type EChartRef =
( getEchartsInstance :: Effect EChartsInstance
-- ...
)
-- TODO: this module should be replaced by FacetsTable -- TODO: this module should be replaced by FacetsTable
module Gargantext.Components.DocsTable where module Gargantext.Components.DocsTable where
import DOM.Simple.Console (log2)
import DOM.Simple.Event as DE
import Data.Argonaut (class EncodeJson, jsonEmptyObject, (:=), (~>))
import Data.Array as A import Data.Array as A
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Lens ((^.)) import Data.Lens ((^.))
import Data.Lens.At (at) import Data.Lens.At (at)
import Data.Lens.Record (prop) import Data.Lens.Record (prop)
import Data.Map as Map
import Data.Maybe (Maybe(..), fromMaybe, isJust, maybe) import Data.Maybe (Maybe(..), fromMaybe, isJust, maybe)
import Data.Map as Map
import Data.Newtype (class Newtype) import Data.Newtype (class Newtype)
import Data.Ord.Down (Down(..)) import Data.Ord.Down (Down(..))
import Data.Set (Set) import Data.Set (Set)
import Data.Set as Set import Data.Set as Set
import Data.String as Str import Data.String as Str
import Data.Symbol (SProxy(..)) import Data.Symbol (SProxy(..))
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
import DOM.Simple.Console (log2)
import DOM.Simple.Event as DE
import Effect (Effect) import Effect (Effect)
import Effect.Aff (Aff, launchAff_) import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Reactix as R
import Reactix.DOM.HTML as H
import Simple.JSON as JSON
import Toestand as T
import Gargantext.Prelude
import Gargantext.Components.Category (rating) import Gargantext.Components.Category (rating)
import Gargantext.Components.Category.Types (Star(..)) import Gargantext.Components.Category.Types (Star(..))
import Gargantext.Components.DocsTable.Types import Gargantext.Components.DocsTable.Types (DocumentsView(..), Hyperdata(..), LocalUserScore, Query, Response(..), Year, sampleData)
( DocumentsView(..), Hyperdata(..), LocalUserScore, Query, Response(..), sampleData )
import Gargantext.Components.Table.Types as TT
import Gargantext.Components.Nodes.Lists.Types as NT import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Nodes.Texts.Types as TextsT import Gargantext.Components.Nodes.Texts.Types as TextsT
import Gargantext.Components.Table as TT import Gargantext.Components.Table as TT
import Gargantext.Components.Table.Types as TT
import Gargantext.Ends (Frontends, url) import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoader, useLoaderWithCacheAPI, HashedResponse(..)) import Gargantext.Hooks.Loader (useLoader, useLoaderWithCacheAPI, HashedResponse(..))
import Gargantext.Routes as Routes import Gargantext.Prelude
import Gargantext.Prelude (class Ord, Unit, bind, const, discard, identity, mempty, otherwise, pure, show, unit, ($), (/=), (<$>), (<<<), (<>), (==))
import Gargantext.Routes (SessionRoute(NodeAPI)) import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Routes as Routes
import Gargantext.Sessions (Session, sessionId, get, delete) import Gargantext.Sessions (Session, sessionId, get, delete)
import Gargantext.Types (ListId, NodeID, NodeType(..), OrderBy(..), SidePanelState(..), TableResult, TabSubType, TabType, showTabType') import Gargantext.Types (ListId, NodeID, NodeType(..), OrderBy(..), SidePanelState(..), TableResult, TabSubType, TabType, showTabType')
import Gargantext.Utils (sortWith) import Gargantext.Utils (sortWith)
import Gargantext.Utils.CacheAPI as GUC import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.QueryString (joinQueryStrings, mQueryParamS, queryParam, queryParamS) import Gargantext.Utils.QueryString (joinQueryStrings, mQueryParam, mQueryParamS, queryParam, queryParamS)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
import Prelude
import Reactix as R
import Reactix.DOM.HTML as H
import Simple.JSON as JSON
import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.DocsTable" here = R2.here "Gargantext.Components.DocsTable"
...@@ -72,7 +72,8 @@ type CommonProps = ...@@ -72,7 +72,8 @@ type CommonProps =
, tabType :: TabType , tabType :: TabType
-- ^ tabType is not ideal here since it is too much entangled with tabs and -- ^ tabType is not ideal here since it is too much entangled with tabs and
-- ngramtable. Let's see how this evolves. ) -- ngramtable. Let's see how this evolves. )
, totalRecords :: Int , totalRecords :: Int
, yearFilter :: T.Box (Maybe Year)
) )
type LayoutProps = type LayoutProps =
...@@ -128,6 +129,7 @@ docViewCpt = here.component "docView" cpt where ...@@ -128,6 +129,7 @@ docViewCpt = here.component "docView" cpt where
, sidePanelState , sidePanelState
, tabType , tabType
, totalRecords , totalRecords
, yearFilter
} }
, params , params
, query , query
...@@ -153,6 +155,7 @@ docViewCpt = here.component "docView" cpt where ...@@ -153,6 +155,7 @@ docViewCpt = here.component "docView" cpt where
, sidePanelState , sidePanelState
, tabType , tabType
, totalRecords , totalRecords
, yearFilter
} [] ] ] ] } [] ] ] ]
type SearchBarProps = type SearchBarProps =
...@@ -209,12 +212,13 @@ mock :: Boolean ...@@ -209,12 +212,13 @@ mock :: Boolean
mock = false mock = false
type PageParams = { type PageParams = {
listId :: Int listId :: Int
, mCorpusId :: Maybe Int , mCorpusId :: Maybe Int
, nodeId :: Int , nodeId :: Int
, tabType :: TabType , tabType :: TabType
, query :: Query , query :: Query
, params :: TT.Params , params :: TT.Params
, yearFilter :: Maybe Year
} }
getPageHash :: Session -> PageParams -> Aff String getPageHash :: Session -> PageParams -> Aff String
...@@ -249,6 +253,12 @@ filterDocs query docs = A.filter filterFunc docs ...@@ -249,6 +253,12 @@ filterDocs query docs = A.filter filterFunc docs
filterFunc (Response { hyperdata: Hyperdata { title } }) = filterFunc (Response { hyperdata: Hyperdata { title } }) =
isJust $ Str.indexOf (Str.Pattern $ Str.toLower query) $ Str.toLower title isJust $ Str.indexOf (Str.Pattern $ Str.toLower query) $ Str.toLower title
filterDocsByYear :: Year -> Array Response -> Array Response
filterDocsByYear year docs = A.filter filterFunc docs
where
filterFunc :: Response -> Boolean
filterFunc (Response { hyperdata: Hyperdata { pub_year } }) = eq year $ show pub_year
pageLayout :: R2.Component PageLayoutProps pageLayout :: R2.Component PageLayoutProps
pageLayout = R.createElement pageLayoutCpt pageLayout = R.createElement pageLayoutCpt
...@@ -263,19 +273,30 @@ pageLayoutCpt = here.component "pageLayout" cpt where ...@@ -263,19 +273,30 @@ pageLayoutCpt = here.component "pageLayout" cpt where
, query , query
, session , session
, sidePanel , sidePanel
, tabType } _ = do , tabType
, yearFilter
} _ = do
cacheState' <- T.useLive T.unequal cacheState cacheState' <- T.useLive T.unequal cacheState
yearFilter' <- T.useLive T.unequal yearFilter
let path = { listId, mCorpusId, nodeId, params, query, tabType } let path = { listId, mCorpusId, nodeId, params, query, tabType, yearFilter: yearFilter' }
handleResponse :: HashedResponse (TableResult Response) -> Tuple Int (Array DocumentsView) handleResponse :: HashedResponse (TableResult Response) -> Tuple Int (Array DocumentsView)
handleResponse (HashedResponse { hash, value: res }) = ret handleResponse (HashedResponse { hash, value: res }) = ret
where where
docs = res2corpus <$> filterDocs query res.docs
filters = filterDocs query
>>> \res' -> case yearFilter' of
Nothing -> res'
Just year -> filterDocsByYear year res'
docs = res2corpus <$> filters res.docs
ret = if mock then ret = if mock then
--Tuple 0 (take limit $ drop offset sampleData) --Tuple 0 (take limit $ drop offset sampleData)
Tuple 0 sampleData Tuple 0 sampleData
else else
Tuple res.count docs Tuple res.count docs
case cacheState' of case cacheState' of
NT.CacheOn -> do NT.CacheOn -> do
let paint (Tuple count docs) = page { documents: docs let paint (Tuple count docs) = page { documents: docs
...@@ -527,9 +548,10 @@ tableRouteWithPage :: forall row. ...@@ -527,9 +548,10 @@ tableRouteWithPage :: forall row.
, params :: TT.Params , params :: TT.Params
, query :: Query , query :: Query
, tabType :: TabType , tabType :: TabType
, yearFilter :: Maybe Year
| row } -> SessionRoute | row } -> SessionRoute
tableRouteWithPage { listId, nodeId, params: { limit, offset, orderBy, searchType }, query, tabType } = tableRouteWithPage { listId, nodeId, params: { limit, offset, orderBy, searchType }, query, tabType, yearFilter } =
NodeAPI Node (Just nodeId) $ "table" <> joinQueryStrings [tt, lst, lmt, odb, ofs, st, q] NodeAPI Node (Just nodeId) $ "table" <> joinQueryStrings [tt, lst, lmt, odb, ofs, st, q, y]
where where
lmt = queryParam "limit" limit lmt = queryParam "limit" limit
lst = queryParam "list" listId lst = queryParam "list" listId
...@@ -538,6 +560,7 @@ tableRouteWithPage { listId, nodeId, params: { limit, offset, orderBy, searchTyp ...@@ -538,6 +560,7 @@ tableRouteWithPage { listId, nodeId, params: { limit, offset, orderBy, searchTyp
st = queryParam "searchType" searchType st = queryParam "searchType" searchType
tt = queryParamS "tabType" (showTabType' tabType) tt = queryParamS "tabType" (showTabType' tabType)
q = queryParamS "query" query q = queryParamS "query" query
y = mQueryParam "year" yearFilter
deleteAllDocuments :: Session -> Int -> Aff (Array Int) deleteAllDocuments :: Session -> Int -> Aff (Array Int)
deleteAllDocuments session = delete session <<< documentsRoute deleteAllDocuments session = delete session <<< documentsRoute
......
...@@ -97,6 +97,7 @@ instance JSON.ReadForeign Hyperdata where ...@@ -97,6 +97,7 @@ instance JSON.ReadForeign Hyperdata where
type LocalCategories = Map Int Category type LocalCategories = Map Int Category
type LocalUserScore = Map Int Star type LocalUserScore = Map Int Star
type Query = String type Query = String
type Year = String
--------------------------------------------------------- ---------------------------------------------------------
sampleData' :: DocumentsView sampleData' :: DocumentsView
......
...@@ -54,14 +54,9 @@ graph = R.createElement graphCpt ...@@ -54,14 +54,9 @@ graph = R.createElement graphCpt
graphCpt :: forall s fa2. R.Component (Props s fa2) graphCpt :: forall s fa2. R.Component (Props s fa2)
graphCpt = here.component "graph" cpt where graphCpt = here.component "graph" cpt where
cpt props@{ elRef cpt props@{ elRef
, mCamera
, multiSelectEnabledRef
, selectedNodeIds
, showEdges , showEdges
, sigmaRef , sigmaRef
, stage , stage } _ = do
, startForceAtlas
, transformedGraph } _ = do
showEdges' <- T.useLive T.unequal showEdges showEdges' <- T.useLive T.unequal showEdges
stage' <- T.useLive T.unequal stage stage' <- T.useLive T.unequal stage
...@@ -83,8 +78,16 @@ graphCpt = here.component "graph" cpt where ...@@ -83,8 +78,16 @@ graphCpt = here.component "graph" cpt where
Nothing -> RH.div {} [] Nothing -> RH.div {} []
Just el -> R.createPortal [] el Just el -> R.createPortal [] el
stageHooks props@{ elRef, mCamera, multiSelectEnabledRef, selectedNodeIds, forceAtlas2Settings: fa2, graph: graph' stageHooks { elRef
, sigmaRef, stage, stage': Init, startForceAtlas } = do , mCamera
, multiSelectEnabledRef
, selectedNodeIds
, forceAtlas2Settings: fa2
, graph: graph'
, sigmaRef
, stage
, stage': Init
, startForceAtlas } = do
R.useEffectOnce' $ do R.useEffectOnce' $ do
let rSigma = R.readRef sigmaRef let rSigma = R.readRef sigmaRef
...@@ -126,7 +129,7 @@ graphCpt = here.component "graph" cpt where ...@@ -126,7 +129,7 @@ graphCpt = here.component "graph" cpt where
Sigma.updateCamera sig { ratio, x, y } Sigma.updateCamera sig { ratio, x, y }
pure unit pure unit
Just sig -> do Just _sig -> do
pure unit pure unit
T.write Ready stage T.write Ready stage
...@@ -145,7 +148,9 @@ graphCpt = here.component "graph" cpt where ...@@ -145,7 +148,9 @@ graphCpt = here.component "graph" cpt where
Sigmax.performDiff sigma transformedGraph Sigmax.performDiff sigma transformedGraph
Sigmax.updateEdges sigma tEdgesMap Sigmax.updateEdges sigma tEdgesMap
Sigmax.updateNodes sigma tNodesMap Sigmax.updateNodes sigma tNodesMap
Sigmax.setEdges sigma (not $ SigmaxTypes.edgeStateHidden showEdges') let edgesState = not $ SigmaxTypes.edgeStateHidden showEdges'
here.log2 "[graphCpt] edgesState" edgesState
Sigmax.setEdges sigma edgesState
stageHooks _ = pure unit stageHooks _ = pure unit
...@@ -300,13 +305,15 @@ sigmaSettings = ...@@ -300,13 +305,15 @@ sigmaSettings =
, zoomMin : 0.0 , zoomMin : 0.0
, zoomingRatio : 1.4 , zoomingRatio : 1.4
} }
type ForceAtlas2Settings = type ForceAtlas2Settings =
( adjustSizes :: Boolean ( adjustSizes :: Boolean
, barnesHutOptimize :: Boolean , barnesHutOptimize :: Boolean
-- , barnesHutTheta :: Number -- , barnesHutTheta :: Number
, batchEdgesDrawing :: Boolean
, edgeWeightInfluence :: Number , edgeWeightInfluence :: Number
-- , fixedY :: Boolean -- , fixedY :: Boolean
, hideEdgesOnMove :: Boolean
, gravity :: Number , gravity :: Number
, includeHiddenEdges :: Boolean , includeHiddenEdges :: Boolean
, includeHiddenNodes :: Boolean , includeHiddenNodes :: Boolean
...@@ -324,19 +331,21 @@ type ForceAtlas2Settings = ...@@ -324,19 +331,21 @@ type ForceAtlas2Settings =
forceAtlas2Settings :: {|ForceAtlas2Settings} forceAtlas2Settings :: {|ForceAtlas2Settings}
forceAtlas2Settings = forceAtlas2Settings =
{ adjustSizes : true { adjustSizes : true
, barnesHutOptimize : true , barnesHutOptimize : true
, edgeWeightInfluence : 1.0 , batchEdgesDrawing : true
-- fixedY : false , edgeWeightInfluence : 1.0
, gravity : 0.01 -- fixedY : false
, includeHiddenEdges: false , gravity : 0.01
, includeHiddenNodes: true , hideEdgesOnMove : true
, iterationsPerRender : 50.0 -- 10.0 , includeHiddenEdges : false
, linLogMode : false -- false , includeHiddenNodes : true
, outboundAttractionDistribution: false , iterationsPerRender : 50.0 -- 10.0
, scalingRatio : 1000.0 , linLogMode : false -- false
, skipHidden: false , outboundAttractionDistribution : false
, slowDown : 1.0 , scalingRatio : 1000.0
, startingIterations : 10.0 , skipHidden : false
, strongGravityMode : false , slowDown : 1.0
, startingIterations : 10.0
, strongGravityMode : false
} }
...@@ -78,9 +78,8 @@ explorerWriteGraph :: R2.Component GraphWriteProps ...@@ -78,9 +78,8 @@ explorerWriteGraph :: R2.Component GraphWriteProps
explorerWriteGraph = R.createElement explorerWriteGraphCpt explorerWriteGraph = R.createElement explorerWriteGraphCpt
explorerWriteGraphCpt :: R.Component GraphWriteProps explorerWriteGraphCpt :: R.Component GraphWriteProps
explorerWriteGraphCpt = here.component "explorerWriteGraph" cpt where explorerWriteGraphCpt = here.component "explorerWriteGraph" cpt where
cpt props@{ boxes: { sidePanelGraph, sidePanelState } cpt props@{ boxes: { sidePanelGraph }
, graph , graph
, hyperdataGraph
, mMetaData' } _ = do , mMetaData' } _ = do
R.useEffectOnce' $ do R.useEffectOnce' $ do
T.write_ (Just { mGraph: Just graph T.write_ (Just { mGraph: Just graph
...@@ -99,13 +98,13 @@ explorer = R.createElement explorerCpt ...@@ -99,13 +98,13 @@ explorer = R.createElement explorerCpt
explorerCpt :: R.Component Props explorerCpt :: R.Component Props
explorerCpt = here.component "explorer" cpt explorerCpt = here.component "explorer" cpt
where where
cpt props@{ boxes: boxes@{ graphVersion, handed, reloadForest, showTree, sidePanelGraph, sidePanelState } cpt { boxes: { graphVersion, handed, reloadForest, showTree, sidePanelGraph, sidePanelState }
, graph , graph
, graphId , graphId
, hyperdataGraph , hyperdataGraph
, session , session
} _ = do } _ = do
{ mMetaData, sideTab } <- GEST.focusedSidePanel sidePanelGraph { mMetaData } <- GEST.focusedSidePanel sidePanelGraph
graphVersion' <- T.useLive T.unequal graphVersion graphVersion' <- T.useLive T.unequal graphVersion
handed' <- T.useLive T.unequal handed handed' <- T.useLive T.unequal handed
mMetaData' <- T.useLive T.unequal mMetaData mMetaData' <- T.useLive T.unequal mMetaData
...@@ -318,7 +317,10 @@ transformGraph graph { edgeConfluence' ...@@ -318,7 +317,10 @@ transformGraph graph { edgeConfluence'
hasSelection = not $ Set.isEmpty selectedNodeIds' hasSelection = not $ Set.isEmpty selectedNodeIds'
newEdges' = Seq.filter edgeFilter $ Seq.map ( newEdges' = Seq.filter edgeFilter $ Seq.map (
edgeHideWeight <<< edgeHideConfluence <<< edgeShowFilter <<< edgeMarked -- NOTE We don't use edgeShowFilter anymore because of
-- https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/304
-- edgeHideWeight <<< edgeHideConfluence <<< edgeShowFilter <<< edgeMarked
edgeHideWeight <<< edgeHideConfluence <<< edgeMarked
) edges ) edges
newNodes = Seq.filter nodeFilter $ Seq.map (nodeMarked <<< nodeHideSize) nodes newNodes = Seq.filter nodeFilter $ Seq.map (nodeMarked <<< nodeHideSize) nodes
newEdges = Seq.filter (edgeInGraph $ Set.fromFoldable $ Seq.map _.id newNodes) newEdges' newEdges = Seq.filter (edgeInGraph $ Set.fromFoldable $ Seq.map _.id newNodes) newEdges'
......
...@@ -85,7 +85,6 @@ controlsCpt = here.component "controls" cpt ...@@ -85,7 +85,6 @@ controlsCpt = here.component "controls" cpt
, showControls , showControls
, showEdges , showEdges
, showLouvain , showLouvain
, showTree
, sidePanelState , sidePanelState
, sideTab , sideTab
, sigmaRef } _ = do , sigmaRef } _ = do
...@@ -112,8 +111,9 @@ controlsCpt = here.component "controls" cpt ...@@ -112,8 +111,9 @@ controlsCpt = here.component "controls" cpt
-- Handle automatic edge hiding when FA is running (to prevent flickering). -- Handle automatic edge hiding when FA is running (to prevent flickering).
-- TODO Commented temporarily: this breaks forceatlas rendering after reset -- TODO Commented temporarily: this breaks forceatlas rendering after reset
-- R.useEffect2' sigmaRef forceAtlasState' $ do -- NOTE This is a hack anyways. It's force atlas that should be fixed.
-- T.modify_ (SigmaxT.forceAtlasEdgeState forceAtlasState') showEdges R.useEffect2' sigmaRef forceAtlasState' $ do
T.modify_ (SigmaxT.forceAtlasEdgeState forceAtlasState') showEdges
-- Automatic opening of sidebar when a node is selected (but only first time). -- Automatic opening of sidebar when a node is selected (but only first time).
R.useEffect' $ do R.useEffect' $ do
......
...@@ -2,31 +2,32 @@ ...@@ -2,31 +2,32 @@
module Gargantext.Components.Nodes.Annuaire.Tabs where module Gargantext.Components.Nodes.Annuaire.Tabs where
import Prelude hiding (div) import Prelude hiding (div)
import Effect.Aff (Aff)
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Show.Generic (genericShow) import Data.Show.Generic (genericShow)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Tuple (fst) import Data.Tuple (fst)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Reactix as R import Effect.Aff (Aff)
import Record as Record
import Record.Extra as RX
import Toestand as T
import Gargantext.AsyncTasks as GAT import Gargantext.AsyncTasks as GAT
import Gargantext.Components.DocsTable as DT import Gargantext.Components.DocsTable as DT
import Gargantext.Components.DocsTable.Types (Year)
import Gargantext.Components.NgramsTable as NT import Gargantext.Components.NgramsTable as NT
import Gargantext.Components.NgramsTable.Core as NTC import Gargantext.Components.NgramsTable.Core as NTC
import Gargantext.Components.Nodes.Texts.Types as TextsT
import Gargantext.Components.Tab as Tab
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (ContactData) import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (ContactData)
import Gargantext.Components.Nodes.Lists.Types as LTypes import Gargantext.Components.Nodes.Lists.Types as LTypes
import Gargantext.Components.Nodes.Texts.Types as TTypes import Gargantext.Components.Nodes.Texts.Types as TTypes
import Gargantext.Components.Nodes.Texts.Types as TextsT
import Gargantext.Components.Tab as Tab
import Gargantext.Ends (Frontends) import Gargantext.Ends (Frontends)
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (CTabNgramType(..), PTabNgramType(..), SidePanelState, TabType(..), TabSubType(..)) import Gargantext.Types (CTabNgramType(..), PTabNgramType(..), SidePanelState, TabType(..), TabSubType(..))
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
import Reactix as R
import Record as Record
import Record.Extra as RX
import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs" here = R2.here "Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs"
...@@ -71,9 +72,10 @@ tabsCpt :: R.Component TabsProps ...@@ -71,9 +72,10 @@ tabsCpt :: R.Component TabsProps
tabsCpt = here.component "tabs" cpt where tabsCpt = here.component "tabs" cpt where
cpt props _ = do cpt props _ = do
activeTab <- T.useBox 0 activeTab <- T.useBox 0
yearFilter <- T.useBox (Nothing :: Maybe Year)
pure $ Tab.tabs { activeTab, tabs: tabs' props } pure $ Tab.tabs { activeTab, tabs: tabs' yearFilter props }
tabs' props@{ sidePanel, sidePanelState } = tabs' yearFilter props@{ sidePanel, sidePanelState } =
[ "Documents" /\ docs [ "Documents" /\ docs
, "Patents" /\ ngramsView (viewProps Patents) , "Patents" /\ ngramsView (viewProps Patents)
, "Books" /\ ngramsView (viewProps Books) , "Books" /\ ngramsView (viewProps Books)
...@@ -92,6 +94,7 @@ tabsCpt = here.component "tabs" cpt where ...@@ -92,6 +94,7 @@ tabsCpt = here.component "tabs" cpt where
, showSearch: true , showSearch: true
, tabType: TabPairing TabDocs , tabType: TabPairing TabDocs
, totalRecords , totalRecords
, yearFilter
} }
type DTCommon = type DTCommon =
......
...@@ -2,27 +2,28 @@ ...@@ -2,27 +2,28 @@
module Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs where module Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs where
import Prelude hiding (div) import Prelude hiding (div)
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Show.Generic (genericShow) import Data.Show.Generic (genericShow)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Tuple (fst) import Data.Tuple (fst)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Reactix as R
import Toestand as T
import Gargantext.AsyncTasks as GAT import Gargantext.AsyncTasks as GAT
import Gargantext.Components.DocsTable as DT import Gargantext.Components.DocsTable as DT
import Gargantext.Components.DocsTable.Types (Year)
import Gargantext.Components.NgramsTable as NT import Gargantext.Components.NgramsTable as NT
import Gargantext.Components.NgramsTable.Core as NTC import Gargantext.Components.NgramsTable.Core as NTC
import Gargantext.Components.Tab as Tab
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (ContactData') import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (ContactData')
import Gargantext.Components.Nodes.Lists.Types as LTypes import Gargantext.Components.Nodes.Lists.Types as LTypes
import Gargantext.Components.Nodes.Texts.Types as TTypes import Gargantext.Components.Nodes.Texts.Types as TTypes
import Gargantext.Components.Tab as Tab
import Gargantext.Ends (Frontends) import Gargantext.Ends (Frontends)
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (CTabNgramType(..), PTabNgramType(..), SidePanelState, TabType(..), TabSubType(..)) import Gargantext.Types (CTabNgramType(..), PTabNgramType(..), SidePanelState, TabType(..), TabSubType(..))
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
import Reactix as R
import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs" here = R2.here "Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs"
...@@ -78,10 +79,11 @@ tabsCpt = here.component "tabs" cpt ...@@ -78,10 +79,11 @@ tabsCpt = here.component "tabs" cpt
, sidePanelState , sidePanelState
, reloadForest } _ = do , reloadForest } _ = do
activeTab <- T.useBox 0 activeTab <- T.useBox 0
yearFilter <- T.useBox (Nothing :: Maybe Year)
pure $ Tab.tabs { activeTab, tabs: tabs' } pure $ Tab.tabs { activeTab, tabs: tabs' yearFilter }
where where
tabs' = tabs' yearFilter =
[ "Documents" /\ docs [ "Documents" /\ docs
, "Patents" /\ ngramsView patentsView [] , "Patents" /\ ngramsView patentsView []
, "Books" /\ ngramsView booksView [] , "Books" /\ ngramsView booksView []
...@@ -127,6 +129,7 @@ tabsCpt = here.component "tabs" cpt ...@@ -127,6 +129,7 @@ tabsCpt = here.component "tabs" cpt
, sidePanelState , sidePanelState
, tabType: TabPairing TabDocs , tabType: TabPairing TabDocs
, totalRecords , totalRecords
, yearFilter
} }
......
...@@ -34,11 +34,11 @@ metricsLoadView p = R.createElement metricsLoadViewCpt p [] ...@@ -34,11 +34,11 @@ metricsLoadView p = R.createElement metricsLoadViewCpt p []
metricsLoadViewCpt :: forall a. Eq a => R.Component (MetricsLoadViewProps a) metricsLoadViewCpt :: forall a. Eq a => R.Component (MetricsLoadViewProps a)
metricsLoadViewCpt = here.component "metricsLoadView" cpt metricsLoadViewCpt = here.component "metricsLoadView" cpt
where where
cpt { getMetrics, loaded, path, reload, session } _ = do cpt { getMetrics, loaded, path, reload, session, onClick, onInit } _ = do
reload' <- T.useLive T.unequal reload reload' <- T.useLive T.unequal reload
useLoader (reload' /\ path) (getMetrics session) $ \l -> useLoader (reload' /\ path) (getMetrics session) $ \l ->
loaded { path, reload, session } l loaded { path, reload, session, onClick, onInit } l
type MetricsWithCacheLoadViewProps res ret = ( type MetricsWithCacheLoadViewProps res ret = (
getMetricsHash :: Session -> ReloadPath -> Aff Hash getMetricsHash :: Session -> ReloadPath -> Aff Hash
...@@ -58,11 +58,11 @@ metricsWithCacheLoadViewCpt :: forall res ret. ...@@ -58,11 +58,11 @@ metricsWithCacheLoadViewCpt :: forall res ret.
R.Component (MetricsWithCacheLoadViewProps res ret) R.Component (MetricsWithCacheLoadViewProps res ret)
metricsWithCacheLoadViewCpt = here.component "metricsWithCacheLoadView" cpt metricsWithCacheLoadViewCpt = here.component "metricsWithCacheLoadView" cpt
where where
cpt { getMetricsHash, handleResponse, loaded, mkRequest, path, reload, session } _ = do cpt { getMetricsHash, handleResponse, loaded, mkRequest, path, reload, session, onClick, onInit } _ = do
reload' <- T.useLive T.unequal reload reload' <- T.useLive T.unequal reload
useLoaderWithCacheAPI { cacheEndpoint: (getMetricsHash session) useLoaderWithCacheAPI { cacheEndpoint: (getMetricsHash session)
, handleResponse , handleResponse
, mkRequest , mkRequest
, path: (reload' /\ path) , path: (reload' /\ path)
, renderer: loaded { path, reload, session } } , renderer: loaded { path, reload, session, onClick, onInit } }
module Gargantext.Components.Nodes.Corpus.Chart.Histo where module Gargantext.Components.Nodes.Corpus.Chart.Histo where
import Data.Generic.Rep (class Generic)
import Data.Eq.Generic (genericEq) import Data.Eq.Generic (genericEq)
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Newtype (class Newtype) import Data.Newtype (class Newtype)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Reactix as R
import Reactix.DOM.HTML as H
import Simple.JSON as JSON
import Toestand as T
import Gargantext.Prelude (class Eq, bind, map, pure, ($), (==))
import Gargantext.Components.Charts.Options.Color (grey) import Gargantext.Components.Charts.Options.Color (grey)
import Gargantext.Components.Charts.Options.Color (grey, blue, green)
import Gargantext.Components.Charts.Options.Data (dataSerie) import Gargantext.Components.Charts.Options.Data (dataSerie)
import Gargantext.Components.Charts.Options.ECharts (Options(..), chart, xAxis', yAxis') import Gargantext.Components.Charts.Options.ECharts (Options(..), chart, xAxis', yAxis')
import Gargantext.Components.Charts.Options.Font (itemStyle, mkTooltip, templateFormatter) import Gargantext.Components.Charts.Options.Font (itemStyle, mkTooltip, templateFormatter)
import Gargantext.Components.Charts.Options.Legend (LegendMode(..), selectedMode)
import Gargantext.Components.Charts.Options.Series (seriesBarD1) import Gargantext.Components.Charts.Options.Series (seriesBarD1)
import Gargantext.Components.Nodes.Corpus.Chart.Common (metricsWithCacheLoadView) import Gargantext.Components.Nodes.Corpus.Chart.Common (metricsWithCacheLoadView)
import Gargantext.Components.Nodes.Corpus.Chart.Types (MetricsProps, Path, Props, ReloadPath) import Gargantext.Components.Nodes.Corpus.Chart.Types (MetricsProps, Path, Props, ReloadPath)
import Gargantext.Hooks.Loader (HashedResponse(..)) import Gargantext.Hooks.Loader (HashedResponse(..))
import Gargantext.Prelude (class Eq, bind, map, pure, ($), (==))
import Gargantext.Routes (SessionRoute(..)) import Gargantext.Routes (SessionRoute(..))
import Gargantext.Sessions (Session, get) import Gargantext.Sessions (Session, get)
import Gargantext.Types (ChartType(..)) import Gargantext.Types (ChartType(..))
import Gargantext.Utils.CacheAPI as GUC import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
import Reactix as R
import Reactix.DOM.HTML as H
import Simple.JSON as JSON
import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Corpus.Chart.Histo" here = R2.here "Gargantext.Components.Nodes.Corpus.Chart.Histo"
...@@ -48,16 +48,32 @@ derive newtype instance JSON.WriteForeign HistoMetrics ...@@ -48,16 +48,32 @@ derive newtype instance JSON.WriteForeign HistoMetrics
type Loaded = HistoMetrics type Loaded = HistoMetrics
chartOptions :: HistoMetrics -> Options chartOptions :: Record MetricsProps -> HistoMetrics -> Options
chartOptions (HistoMetrics { dates: dates', count: count'}) = Options chartOptions { onClick, onInit } (HistoMetrics { dates: dates', count: count'}) = Options
{ mainTitle : "Histogram" { mainTitle : "Histogram"
, subTitle : "Distribution of publications over time" , subTitle : "Distribution of publications over time"
, xAxis : xAxis' dates' , xAxis : xAxis' dates'
, yAxis : yAxis' { position: "left", show: true, min:0} , yAxis : yAxis' { position: "left", show: true, min:0}
, addZoom : true , addZoom : true
, tooltip : mkTooltip { formatter: templateFormatter "{b0}" } , tooltip : mkTooltip { formatter: templateFormatter "{b0}" }
, series : [seriesBarD1 {name: "Number of publication / year"} $ , series
map (\n -> dataSerie {value: n, itemStyle : itemStyle {color:grey}}) count'] } , onClick
, onInit
}
where
mapSeriesBar n = dataSerie
{ value: n
, itemStyle: itemStyle { color: grey }
, emphasis: { itemStyle: itemStyle { color: blue } }
-- @XXX "select" action not working
-- , selectedMode: selectedMode Single
, select: { itemStyle: itemStyle { color: green }}
}
series =
[ seriesBarD1 {name: "Number of publication / year"} $
map mapSeriesBar count'
]
getMetricsHash :: Session -> ReloadPath -> Aff String getMetricsHash :: Session -> ReloadPath -> Aff String
getMetricsHash session (_ /\ { corpusId, limit, listId, tabType }) = do getMetricsHash session (_ /\ { corpusId, limit, listId, tabType }) = do
...@@ -82,7 +98,7 @@ histo props = R.createElement histoCpt props [] ...@@ -82,7 +98,7 @@ histo props = R.createElement histoCpt props []
histoCpt :: R.Component Props histoCpt :: R.Component Props
histoCpt = here.component "histo" cpt histoCpt = here.component "histo" cpt
where where
cpt { path, session } _ = do cpt { path, session, onClick, onInit } _ = do
reload <- T.useBox T2.newReload reload <- T.useBox T2.newReload
pure $ metricsWithCacheLoadView { pure $ metricsWithCacheLoadView {
...@@ -93,13 +109,15 @@ histoCpt = here.component "histo" cpt ...@@ -93,13 +109,15 @@ histoCpt = here.component "histo" cpt
, path , path
, reload , reload
, session , session
, onClick
, onInit
} }
loaded :: Record MetricsProps -> HistoMetrics -> R.Element loaded :: Record MetricsProps -> HistoMetrics -> R.Element
loaded { path, reload, session } l = loaded p@{ path, reload, session } l =
H.div {} [ H.div {} [
{- U.reloadButton reload {- U.reloadButton reload
, U.chartUpdateButton { chartType: Histo, path, reload, session } , U.chartUpdateButton { chartType: Histo, path, reload, session }
, -} chart $ chartOptions l , -} chart $ chartOptions p l
] ]
-- TODO: parametrize ngramsType above -- TODO: parametrize ngramsType above
...@@ -57,8 +57,8 @@ derive newtype instance JSON.ReadForeign Metrics ...@@ -57,8 +57,8 @@ derive newtype instance JSON.ReadForeign Metrics
type Loaded = Array Metric type Loaded = Array Metric
scatterOptions :: Array Metric -> Options scatterOptions :: Record MetricsProps -> Array Metric -> Options
scatterOptions metrics' = Options scatterOptions { onClick, onInit } metrics' = Options
{ mainTitle : "Ngrams Selection Metrics" { mainTitle : "Ngrams Selection Metrics"
, subTitle : "Local metrics (Inc/Exc, Spe/Gen), Global metrics (TFICF maillage)" , subTitle : "Local metrics (Inc/Exc, Spe/Gen), Global metrics (TFICF maillage)"
, xAxis : xAxis { min: -1 } , xAxis : xAxis { min: -1 }
...@@ -66,6 +66,8 @@ scatterOptions metrics' = Options ...@@ -66,6 +66,8 @@ scatterOptions metrics' = Options
, series : map2series $ metric2map metrics' , series : map2series $ metric2map metrics'
, addZoom : false , addZoom : false
, tooltip : mkTooltip { formatter: templateFormatter "{b0}" } , tooltip : mkTooltip { formatter: templateFormatter "{b0}" }
, onClick
, onInit
} }
where where
metric2map :: Array Metric -> Map TermList (Array Metric) metric2map :: Array Metric -> Map TermList (Array Metric)
...@@ -110,7 +112,7 @@ metrics props = R.createElement metricsCpt props [] ...@@ -110,7 +112,7 @@ metrics props = R.createElement metricsCpt props []
metricsCpt :: R.Component Props metricsCpt :: R.Component Props
metricsCpt = here.component "etrics" cpt metricsCpt = here.component "etrics" cpt
where where
cpt {path, session} _ = do cpt {path, session, onClick, onInit } _ = do
reload <- T.useBox T2.newReload reload <- T.useBox T2.newReload
pure $ metricsWithCacheLoadView { pure $ metricsWithCacheLoadView {
...@@ -121,13 +123,15 @@ metricsCpt = here.component "etrics" cpt ...@@ -121,13 +123,15 @@ metricsCpt = here.component "etrics" cpt
, path , path
, reload , reload
, session , session
, onClick
, onInit
} }
loaded :: Record MetricsProps -> Loaded -> R.Element loaded :: Record MetricsProps -> Loaded -> R.Element
loaded { path, reload, session } loaded' = loaded p@{ path, reload, session } loaded' =
H.div {} [ H.div {} [
{- U.reloadButton reload {- U.reloadButton reload
, U.chartUpdateButton { chartType: Scatter, path, reload, session } , U.chartUpdateButton { chartType: Scatter, path, reload, session }
, -} chart $ scatterOptions loaded' , -} chart $ scatterOptions p loaded'
] ]
...@@ -55,8 +55,8 @@ derive newtype instance JSON.WriteForeign HistoMetrics ...@@ -55,8 +55,8 @@ derive newtype instance JSON.WriteForeign HistoMetrics
type Loaded = HistoMetrics type Loaded = HistoMetrics
chartOptionsBar :: HistoMetrics -> Options chartOptionsBar :: Record MetricsProps -> HistoMetrics -> Options
chartOptionsBar (HistoMetrics { dates: dates', count: count'}) = Options chartOptionsBar { onClick, onInit } (HistoMetrics { dates: dates', count: count'}) = Options
{ mainTitle : "Bar" { mainTitle : "Bar"
, subTitle : "Count of MapTerm" , subTitle : "Count of MapTerm"
, xAxis : xAxis' $ map (\t -> joinWith " " $ map (take 3) $ A.take 3 $ filter (\s -> length s > 3) $ split (Pattern " ") t) dates' , xAxis : xAxis' $ map (\t -> joinWith " " $ map (take 3) $ A.take 3 $ filter (\s -> length s > 3) $ split (Pattern " ") t) dates'
...@@ -64,10 +64,12 @@ chartOptionsBar (HistoMetrics { dates: dates', count: count'}) = Options ...@@ -64,10 +64,12 @@ chartOptionsBar (HistoMetrics { dates: dates', count: count'}) = Options
, series : [seriesBarD1 {name: "Number of publication / year"} $ map (\n -> dataSerie {name: "", itemStyle: itemStyle {color:blue}, value: n }) count'] , series : [seriesBarD1 {name: "Number of publication / year"} $ map (\n -> dataSerie {name: "", itemStyle: itemStyle {color:blue}, value: n }) count']
, addZoom : false , addZoom : false
, tooltip : mkTooltip { formatter: templateFormatter "{b0}" } , tooltip : mkTooltip { formatter: templateFormatter "{b0}" }
, onClick
, onInit
} }
chartOptionsPie :: HistoMetrics -> Options chartOptionsPie :: Record MetricsProps -> HistoMetrics -> Options
chartOptionsPie (HistoMetrics { dates: dates', count: count'}) = Options chartOptionsPie { onClick, onInit } (HistoMetrics { dates: dates', count: count'}) = Options
{ mainTitle : "Pie" { mainTitle : "Pie"
, subTitle : "Distribution by MapTerm" , subTitle : "Distribution by MapTerm"
, xAxis : xAxis' [] , xAxis : xAxis' []
...@@ -76,6 +78,8 @@ chartOptionsPie (HistoMetrics { dates: dates', count: count'}) = Options ...@@ -76,6 +78,8 @@ chartOptionsPie (HistoMetrics { dates: dates', count: count'}) = Options
-- , series : [seriesBarD1 {name: "Number of publication / year"} $ map (\n -> dataSerie {name: "", value: n }) count'] -- , series : [seriesBarD1 {name: "Number of publication / year"} $ map (\n -> dataSerie {name: "", value: n }) count']
, addZoom : false , addZoom : false
, tooltip : mkTooltip { formatter: templateFormatter "{b0}" } , tooltip : mkTooltip { formatter: templateFormatter "{b0}" }
, onClick
, onInit
} }
getMetricsHash :: Session -> ReloadPath -> Aff String getMetricsHash :: Session -> ReloadPath -> Aff String
...@@ -101,7 +105,7 @@ pie props = R.createElement pieCpt props [] ...@@ -101,7 +105,7 @@ pie props = R.createElement pieCpt props []
pieCpt :: R.Component Props pieCpt :: R.Component Props
pieCpt = here.component "pie" cpt pieCpt = here.component "pie" cpt
where where
cpt { path, session } _ = do cpt { path, session, onClick, onInit } _ = do
reload <- T.useBox T2.newReload reload <- T.useBox T2.newReload
pure $ metricsWithCacheLoadView { pure $ metricsWithCacheLoadView {
...@@ -112,14 +116,16 @@ pieCpt = here.component "pie" cpt ...@@ -112,14 +116,16 @@ pieCpt = here.component "pie" cpt
, path , path
, reload , reload
, session , session
, onClick
, onInit
} }
loadedPie :: Record MetricsProps -> HistoMetrics -> R.Element loadedPie :: Record MetricsProps -> HistoMetrics -> R.Element
loadedPie { path, reload, session } loaded = loadedPie p@{ path, reload, session } loaded =
H.div {} [ H.div {} [
{- U.reloadButton reload {- U.reloadButton reload
, U.chartUpdateButton { chartType: ChartPie, path, reload, session } , U.chartUpdateButton { chartType: ChartPie, path, reload, session }
, -} chart $ chartOptionsPie loaded , -} chart $ chartOptionsPie p loaded
] ]
...@@ -129,7 +135,7 @@ bar props = R.createElement barCpt props [] ...@@ -129,7 +135,7 @@ bar props = R.createElement barCpt props []
barCpt :: R.Component Props barCpt :: R.Component Props
barCpt = here.component "bar" cpt barCpt = here.component "bar" cpt
where where
cpt {path, session} _ = do cpt {path, session, onClick, onInit} _ = do
reload <- T.useBox T2.newReload reload <- T.useBox T2.newReload
pure $ metricsWithCacheLoadView { pure $ metricsWithCacheLoadView {
...@@ -140,12 +146,14 @@ barCpt = here.component "bar" cpt ...@@ -140,12 +146,14 @@ barCpt = here.component "bar" cpt
, path , path
, reload , reload
, session , session
, onClick
, onInit
} }
loadedBar :: Record MetricsProps -> Loaded -> R.Element loadedBar :: Record MetricsProps -> Loaded -> R.Element
loadedBar { path, reload, session } loaded = loadedBar p@{ path, reload, session } loaded =
H.div {} [ H.div {} [
{- U.reloadButton reload {- U.reloadButton reload
, U.chartUpdateButton { chartType: ChartBar, path, reload, session } , U.chartUpdateButton { chartType: ChartBar, path, reload, session }
, -} chart $ chartOptionsBar loaded , -} chart $ chartOptionsBar p loaded
] ]
module Gargantext.Components.Nodes.Corpus.Chart.Predefined where module Gargantext.Components.Nodes.Corpus.Chart.Predefined where
import Gargantext.Prelude import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson)
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..), fromMaybe) import Data.Maybe (Maybe(..), fromMaybe)
import Data.Nullable (Nullable)
import Data.Ord.Generic (genericCompare) import Data.Ord.Generic (genericCompare)
import Data.Show.Generic (genericShow) import Data.Show.Generic (genericShow)
import Effect (Effect)
import Gargantext.Components.Charts.Options.Type (EChartsInstance, MouseEvent)
import Gargantext.Components.Nodes.Corpus.Chart.Histo (histo) import Gargantext.Components.Nodes.Corpus.Chart.Histo (histo)
import Gargantext.Components.Nodes.Corpus.Chart.Metrics (metrics) import Gargantext.Components.Nodes.Corpus.Chart.Metrics (metrics)
import Gargantext.Components.Nodes.Corpus.Chart.Pie (pie) import Gargantext.Components.Nodes.Corpus.Chart.Pie (pie)
import Gargantext.Components.Nodes.Corpus.Chart.Tree (tree) import Gargantext.Components.Nodes.Corpus.Chart.Tree (tree)
import Gargantext.Prelude
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (NodeID, Mode(..), TabSubType(..), TabType(..), modeTabType) import Gargantext.Types (NodeID, Mode(..), TabSubType(..), TabType(..), modeTabType)
import Reactix as R import Reactix as R
...@@ -58,45 +61,43 @@ type Params = ...@@ -58,45 +61,43 @@ type Params =
-- optinal params -- optinal params
, limit :: Maybe Int , limit :: Maybe Int
, listId :: Maybe Int , listId :: Maybe Int
, onClick :: Maybe (MouseEvent -> Effect Unit)
, onInit :: Maybe (EChartsInstance -> Effect Unit)
) )
render :: PredefinedChart -> Record Params -> R.Element render :: PredefinedChart -> Record Params -> R.Element
render CDocsHistogram { corpusId, listId, session } = histo { path, session } render CDocsHistogram { corpusId, listId, session, onClick, onInit } = histo { path, session, onClick, onInit }
where where
path = { corpusId path = { corpusId
, listId: fromMaybe 0 listId , listId: fromMaybe 0 listId
, limit: Nothing , limit: Nothing
, tabType: TabCorpus TabDocs , tabType: TabCorpus TabDocs
} }
render CAuthorsPie { corpusId, listId, session } = pie { path, session } render CAuthorsPie { corpusId, listId, session, onClick, onInit } = pie { path, session, onClick, onInit }
where where
path = { corpusId path = { corpusId
, listId: fromMaybe 0 listId , listId: fromMaybe 0 listId
, limit: Nothing , limit: Nothing
, tabType: TabCorpus (TabNgramType $ modeTabType Authors) , tabType: TabCorpus (TabNgramType $ modeTabType Authors)
} }
render CInstitutesTree { corpusId, limit, listId, session } = tree { path, session } render CInstitutesTree { corpusId, limit, listId, session, onClick, onInit } = tree { path, session, onClick, onInit }
where where
path = { corpusId path = { corpusId
, limit , limit
, listId: fromMaybe 0 listId , listId: fromMaybe 0 listId
, tabType: TabCorpus (TabNgramType $ modeTabType Institutes) , tabType: TabCorpus (TabNgramType $ modeTabType Institutes)
} }
render CTermsMetrics { corpusId, limit, listId, session } = metrics { path, session } render CTermsMetrics { corpusId, limit, listId, session, onClick, onInit } = metrics { path, session, onClick, onInit }
where where
path = { corpusId path = { corpusId
, limit , limit
, listId: fromMaybe 0 listId , listId: fromMaybe 0 listId
, tabType: TabCorpus (TabNgramType $ modeTabType Terms) , tabType: TabCorpus (TabNgramType $ modeTabType Terms)
} }
render CSourcesBar { corpusId, limit, listId, session } = metrics { path, session } render CSourcesBar { corpusId, limit, listId, session, onClick, onInit } = metrics { path, session, onClick, onInit }
where where
path = { corpusId path = { corpusId
, limit , limit
, listId: fromMaybe 0 listId , listId: fromMaybe 0 listId
, tabType: TabCorpus (TabNgramType $ modeTabType Sources) , tabType: TabCorpus (TabNgramType $ modeTabType Sources)
} }
...@@ -38,8 +38,8 @@ derive newtype instance JSON.WriteForeign Metrics ...@@ -38,8 +38,8 @@ derive newtype instance JSON.WriteForeign Metrics
type Loaded = Array TreeNode type Loaded = Array TreeNode
scatterOptions :: Array TreeNode -> Options scatterOptions :: Record MetricsProps -> Array TreeNode -> Options
scatterOptions nodes = Options scatterOptions { onClick, onInit } nodes = Options
{ mainTitle : "Tree" { mainTitle : "Tree"
, subTitle : "Tree Sub Title" , subTitle : "Tree Sub Title"
, xAxis : xAxis' [] , xAxis : xAxis' []
...@@ -47,6 +47,8 @@ scatterOptions nodes = Options ...@@ -47,6 +47,8 @@ scatterOptions nodes = Options
, series : [ mkTree TreeMap nodes] , series : [ mkTree TreeMap nodes]
, addZoom : false , addZoom : false
, tooltip : mkTooltip { formatter: templateFormatter "{b0}" } , tooltip : mkTooltip { formatter: templateFormatter "{b0}" }
, onClick
, onInit
-- TODO improve the formatter: -- TODO improve the formatter:
-- https://ecomfe.github.io/echarts-examples/public/editor.html?c=treemap-obama -- https://ecomfe.github.io/echarts-examples/public/editor.html?c=treemap-obama
...@@ -75,7 +77,7 @@ tree props = R.createElement treeCpt props [] ...@@ -75,7 +77,7 @@ tree props = R.createElement treeCpt props []
treeCpt :: R.Component Props treeCpt :: R.Component Props
treeCpt = here.component "tree" cpt treeCpt = here.component "tree" cpt
where where
cpt {path, session} _ = do cpt {path, session, onClick, onInit} _ = do
reload <- T.useBox T2.newReload reload <- T.useBox T2.newReload
pure $ metricsWithCacheLoadView { pure $ metricsWithCacheLoadView {
...@@ -86,12 +88,14 @@ treeCpt = here.component "tree" cpt ...@@ -86,12 +88,14 @@ treeCpt = here.component "tree" cpt
, path , path
, reload , reload
, session , session
, onClick
, onInit
} }
loaded :: Record MetricsProps -> Loaded -> R.Element loaded :: Record MetricsProps -> Loaded -> R.Element
loaded { path, reload, session } loaded' = loaded p@{ path, reload, session } loaded' =
H.div {} [ H.div {} [
{- U.reloadButton reload {- U.reloadButton reload
, U.chartUpdateButton { chartType: ChartTree, path, reload, session } , U.chartUpdateButton { chartType: ChartTree, path, reload, session }
, -} chart (scatterOptions loaded') , -} chart (scatterOptions p loaded')
] ]
...@@ -2,7 +2,9 @@ module Gargantext.Components.Nodes.Corpus.Chart.Types where ...@@ -2,7 +2,9 @@ module Gargantext.Components.Nodes.Corpus.Chart.Types where
import Data.Maybe (Maybe) import Data.Maybe (Maybe)
import Data.Tuple (Tuple) import Data.Tuple (Tuple)
import Effect (Effect)
import Gargantext.Components.Charts.Options.Type (EChartsInstance, MouseEvent)
import Gargantext.Prelude (Unit)
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (TabType) import Gargantext.Types (TabType)
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
...@@ -15,8 +17,10 @@ type Path = ( ...@@ -15,8 +17,10 @@ type Path = (
) )
type Props = ( type Props = (
path :: Record Path path :: Record Path
, session :: Session , session :: Session
, onClick :: Maybe (MouseEvent -> Effect Unit)
, onInit :: Maybe (EChartsInstance -> Effect Unit)
) )
type MetricsProps = ( type MetricsProps = (
......
...@@ -228,6 +228,8 @@ renderChartCpt = here.component "renderChart" cpt ...@@ -228,6 +228,8 @@ renderChartCpt = here.component "renderChart" cpt
, limit: Just 1000 , limit: Just 1000
, listId: Just defaultListId , listId: Just defaultListId
, session , session
, onClick: Nothing
, onInit: Nothing
} }
-- aSchool school = H.div {className: "col-md-4 content"} [ chart $ focus school ] -- aSchool school = H.div {className: "col-md-4 content"} [ chart $ focus school ]
......
module Gargantext.Components.Nodes.Corpus.Types where module Gargantext.Components.Nodes.Corpus.Types where
import Data.Generic.Rep (class Generic) import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, (.:), (:=), (~>), jsonEmptyObject)
import Data.Eq.Generic (genericEq) import Data.Eq.Generic (genericEq)
import Data.List as List import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..)) import Data.List as List
import Data.Newtype (class Newtype) import Data.Maybe (Maybe(..))
import Record as Record import Data.Newtype (class Newtype)
import Simple.JSON as JSON
import Gargantext.Prelude
import Gargantext.Components.Node (NodePoly) import Gargantext.Components.Node (NodePoly)
import Gargantext.Components.Nodes.Types (FTFieldList(..), Field(..), FieldType(..), isJSON) import Gargantext.Components.Nodes.Types (FTField, Field(..), FieldType(..), FTField, FTFieldList(..), isJSON)
import Gargantext.Prelude
import Reactix as R
import Record as Record
import Simple.JSON as JSON
import Toestand as T
newtype Hyperdata = newtype Hyperdata =
Hyperdata { fields :: FTFieldList } Hyperdata { fields :: FTFieldList }
......
...@@ -8,12 +8,15 @@ import Data.Eq.Generic (genericEq) ...@@ -8,12 +8,15 @@ import Data.Eq.Generic (genericEq)
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Newtype (class Newtype) import Data.Newtype (class Newtype)
import Data.Nullable (Nullable, null, toMaybe)
import Data.Show.Generic (genericShow) import Data.Show.Generic (genericShow)
import DOM.Simple as DOM
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Simple.JSON as JSON import Simple.JSON as JSON
import Toestand as T import Toestand as T
import Web.URL as WURL
import Gargantext.Components.FolderView as FV import Gargantext.Components.FolderView as FV
import Gargantext.Components.Node (NodePoly(..)) import Gargantext.Components.Node (NodePoly(..))
...@@ -21,6 +24,7 @@ import Gargantext.Hooks.Loader (useLoader) ...@@ -21,6 +24,7 @@ import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes (SessionRoute(NodeAPI)) import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Sessions (Session, get, sessionId) import Gargantext.Sessions (Session, get, sessionId)
import Gargantext.Types (NodeType(..)) import Gargantext.Types (NodeType(..))
import Gargantext.Utils.JitsiMeet as JM
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
...@@ -48,7 +52,6 @@ type KeyProps = ...@@ -48,7 +52,6 @@ type KeyProps =
frameLayout :: R2.Leaf Props frameLayout :: R2.Leaf Props
frameLayout props = R.createElement frameLayoutCpt props [] frameLayout props = R.createElement frameLayoutCpt props []
frameLayoutCpt :: R.Component Props frameLayoutCpt :: R.Component Props
frameLayoutCpt = here.component "frameLayout" cpt where frameLayoutCpt = here.component "frameLayout" cpt where
cpt { nodeId, nodeType, session } _ = do cpt { nodeId, nodeType, session } _ = do
...@@ -58,7 +61,6 @@ frameLayoutCpt = here.component "frameLayout" cpt where ...@@ -58,7 +61,6 @@ frameLayoutCpt = here.component "frameLayout" cpt where
frameLayoutWithKey :: R2.Leaf KeyProps frameLayoutWithKey :: R2.Leaf KeyProps
frameLayoutWithKey props = R.createElement frameLayoutWithKeyCpt props [] frameLayoutWithKey props = R.createElement frameLayoutWithKeyCpt props []
frameLayoutWithKeyCpt :: R.Component KeyProps frameLayoutWithKeyCpt :: R.Component KeyProps
frameLayoutWithKeyCpt = here.component "frameLayoutWithKey" cpt where frameLayoutWithKeyCpt = here.component "frameLayoutWithKey" cpt where
cpt { nodeId, session, nodeType} _ = do cpt { nodeId, session, nodeType} _ = do
...@@ -85,29 +87,63 @@ hframeUrl NodeFrameCalc base frame_id = base <> "/" <> frame_id ...@@ -85,29 +87,63 @@ hframeUrl NodeFrameCalc base frame_id = base <> "/" <> frame_id
hframeUrl NodeFrameVisio base frame_id = base <> "/" <> frame_id hframeUrl NodeFrameVisio base frame_id = base <> "/" <> frame_id
hframeUrl _ base frame_id = base <> "/" <> frame_id <> "?view" -- "?both" hframeUrl _ base frame_id = base <> "/" <> frame_id <> "?view" -- "?both"
frameLayoutView :: Record ViewProps -> R.Element frameLayoutView :: R2.Leaf ViewProps
frameLayoutView props = R.createElement frameLayoutViewCpt props [] frameLayoutView props = R.createElement frameLayoutViewCpt props []
frameLayoutViewCpt :: R.Component ViewProps frameLayoutViewCpt :: R.Component ViewProps
frameLayoutViewCpt = here.component "frameLayoutView" cpt frameLayoutViewCpt = here.component "frameLayoutView" cpt
where where
cpt { frame: (NodePoly { hyperdata: Hyperdata { base, frame_id }}) cpt { frame: NodePoly { hyperdata: Hyperdata { base, frame_id }}
, nodeId , nodeId
, nodeType , nodeType
, reload , reload
, session } _ = , session } _ = do
pure $ H.div{} [ case nodeType of
FV.backButton NodeFrameVisio ->
, FV.homeButton case WURL.fromAbsolute base of
, H.div { className : "frame" Nothing -> pure $ H.div {} [ H.text $ "Wrong base url: " <> base ]
, rows: "100%,*" } Just url -> pure $ nodeFrameVisio { frame_id, reload, url }
_ ->
pure $ H.div{} [
FV.backButton
, FV.homeButton
, H.div { className : "frame"
, rows: "100%,*" }
[ -- H.script { src: "https://visio.gargantext.org/external_api.js"} [], [ -- H.script { src: "https://visio.gargantext.org/external_api.js"} [],
H.iframe { src: hframeUrl nodeType base frame_id H.iframe { src: hframeUrl nodeType base frame_id
, width: "100%" , width: "100%"
, height: "100%" , height: "100%"
} [] } []
] ]
] ]
type NodeFrameVisioProps =
( frame_id :: String
, reload :: T2.ReloadS
, url :: WURL.URL
)
nodeFrameVisio :: R2.Leaf NodeFrameVisioProps
nodeFrameVisio props = R.createElement nodeFrameVisioCpt props []
nodeFrameVisioCpt :: R.Component NodeFrameVisioProps
nodeFrameVisioCpt = here.component "nodeFrameVisio" cpt
where
cpt { frame_id
, reload
, url } _ = do
-- api = new JitsiMeetExternalAPI("visio.gargantext.org", {roomName: frame_id})
api <- T.useBox (Nothing :: Maybe JM.JitsiMeet)
ref <- R.useRef (null :: Nullable DOM.Element)
R.useEffect' $ do
here.log2 "[nodeFrameVisio] ref" $ R.readRef ref
here.log2 "[nodeFrameVisio] JM.api" JM._api
case toMaybe (R.readRef ref) of
Nothing -> pure unit
Just r -> do
api <- JM.jitsiMeetAPI (WURL.host url) { parentNode: r, roomName: frame_id }
here.log2 "[nodeFrameVisio] api" api
pure $ H.div { ref } [ H.text $ WURL.host url ]
type LoadProps = ( nodeId :: Int type LoadProps = ( nodeId :: Int
, session :: Session ) , session :: Session )
......
module Gargantext.Components.Nodes.Lists.Tabs where module Gargantext.Components.Nodes.Lists.Tabs where
import Gargantext.Prelude (bind, pure, unit, ($), (<>)) import Gargantext.Components.Nodes.Lists.Types
import Data.Array as A import Data.Array as A
import Data.Maybe (Maybe(..), fromMaybe) import Data.Maybe (Maybe(..), fromMaybe)
import Data.Tuple (fst) import Data.Tuple (fst)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
import Record.Extra as RX
import Toestand as T
import Gargantext.AsyncTasks as GAT import Gargantext.AsyncTasks as GAT
import Gargantext.Components.NgramsTable as NT import Gargantext.Components.NgramsTable as NT
import Gargantext.Components.NgramsTable.Core as NTC import Gargantext.Components.NgramsTable.Core as NTC
import Gargantext.Components.Nodes.Corpus.Types (CorpusData)
import Gargantext.Components.Nodes.Corpus.Chart.Metrics (metrics) import Gargantext.Components.Nodes.Corpus.Chart.Metrics (metrics)
import Gargantext.Components.Nodes.Corpus.Chart.Pie (pie, bar) import Gargantext.Components.Nodes.Corpus.Chart.Pie (pie, bar)
import Gargantext.Components.Nodes.Corpus.Chart.Tree (tree) import Gargantext.Components.Nodes.Corpus.Chart.Tree (tree)
import Gargantext.Components.Nodes.Corpus.Chart.Utils (mNgramsTypeFromTabType) import Gargantext.Components.Nodes.Corpus.Chart.Utils (mNgramsTypeFromTabType)
import Gargantext.Components.Nodes.Lists.Types import Gargantext.Components.Nodes.Corpus.Types (CorpusData)
import Gargantext.Components.Search as S import Gargantext.Components.Search as S
import Gargantext.Components.Tab as Tab import Gargantext.Components.Tab as Tab
import Gargantext.Prelude (bind, pure, unit, ($), (<>))
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types import Gargantext.Types (ChartType(..), CTabNgramType(..), Mode(..), TabSubType(..), TabType(..), modeTabType)
( ChartType(..), CTabNgramType(..), Mode(..), TabSubType(..), TabType(..), modeTabType )
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
import Record.Extra as RX
import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Lists.Tabs" here = R2.here "Gargantext.Components.Nodes.Lists.Tabs"
...@@ -163,7 +161,7 @@ ngramsViewCpt = here.component "ngramsView" cpt where ...@@ -163,7 +161,7 @@ ngramsViewCpt = here.component "ngramsView" cpt where
] ]
charts params _ = [ chart params mode ] charts params _ = [ chart params mode ]
chart path Authors = pie { path, session } chart path Authors = pie { path, session, onClick: Nothing, onInit: Nothing }
chart path Institutes = tree { path, session } chart path Institutes = tree { path, session, onClick: Nothing, onInit: Nothing }
chart path Sources = bar { path, session } chart path Sources = bar { path, session, onClick: Nothing, onInit: Nothing }
chart path Terms = metrics { path, session } chart path Terms = metrics { path, session, onClick: Nothing, onInit: Nothing }
module Gargantext.Components.Nodes.Texts where module Gargantext.Components.Nodes.Texts where
import DOM.Simple.Console (log2)
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Show.Generic (genericShow)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Show.Generic (genericShow)
import Data.Symbol (SProxy(..))
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Effect.Aff (launchAff_) import Effect.Aff (launchAff_)
import Reactix as R import Gargantext.Components.Charts.Options.ECharts (dispatchAction)
import Reactix.DOM.HTML as H import Gargantext.Components.Charts.Options.Type (EChartsInstance)
import Toestand as T
import Gargantext.Prelude
import Gargantext.Components.DocsTable as DT import Gargantext.Components.DocsTable as DT
import Gargantext.Components.DocsTable.Types (Year)
import Gargantext.Components.NgramsTable.Loader (clearCache) import Gargantext.Components.NgramsTable.Loader (clearCache)
import Gargantext.Components.Node (NodePoly(..)) import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.Nodes.Corpus (loadCorpusWithChild) import Gargantext.Components.Nodes.Corpus (loadCorpusWithChild)
import Gargantext.Components.Nodes.Corpus.Chart.Histo (histo) import Gargantext.Components.Nodes.Corpus.Chart.Histo (histo)
import Gargantext.Components.Nodes.Corpus.Document as D import Gargantext.Components.Nodes.Corpus.Document as D
import Gargantext.Components.Nodes.Corpus.Types (CorpusData, Hyperdata(..), getCorpusInfo, CorpusInfo(..)) import Gargantext.Components.Nodes.Corpus.Types (CorpusData, CorpusInfo(..), Hyperdata(..), getCorpusInfo)
import Gargantext.Components.Nodes.Lists.Types as LT import Gargantext.Components.Nodes.Lists.Types as LT
import Gargantext.Components.Nodes.Texts.Types as TT import Gargantext.Components.Nodes.Texts.Types as TT
import Gargantext.Components.Tab as Tab import Gargantext.Components.Tab as Tab
import Gargantext.Components.Table as Table import Gargantext.Components.Table as Table
import Gargantext.Ends (Frontends) import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Sessions (WithSession, WithSessionContext, Session, sessionId, getCacheState) import Gargantext.Prelude
import Gargantext.Sessions (WithSession, Session, getCacheState)
import Gargantext.Types (CTabNgramType(..), ListId, NodeID, SidePanelState(..), TabSubType(..), TabType(..)) import Gargantext.Types (CTabNgramType(..), ListId, NodeID, SidePanelState(..), TabSubType(..), TabType(..))
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
import Record (set)
import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Texts" here = R2.here "Gargantext.Components.Nodes.Texts"
...@@ -81,6 +85,10 @@ textsLayoutWithKeyCpt = here.component "textsLayoutWithKey" cpt ...@@ -81,6 +85,10 @@ textsLayoutWithKeyCpt = here.component "textsLayoutWithKey" cpt
cacheState <- T.useBox $ getCacheState LT.CacheOff session nodeId cacheState <- T.useBox $ getCacheState LT.CacheOff session nodeId
cacheState' <- T.useLive T.unequal cacheState cacheState' <- T.useLive T.unequal cacheState
yearFilter <- T.useBox (Nothing :: Maybe Year)
eChartsInstance <- T.useBox (Nothing :: Maybe EChartsInstance)
R.useEffectOnce' $ do R.useEffectOnce' $ do
T.listen (\{ new } -> afterCacheStateChange new) cacheState T.listen (\{ new } -> afterCacheStateChange new) cacheState
...@@ -89,6 +97,7 @@ textsLayoutWithKeyCpt = here.component "textsLayoutWithKey" cpt ...@@ -89,6 +97,7 @@ textsLayoutWithKeyCpt = here.component "textsLayoutWithKey" cpt
let NodePoly { date, hyperdata: Hyperdata h, name } = corpusNode let NodePoly { date, hyperdata: Hyperdata h, name } = corpusNode
CorpusInfo { authors, desc, query } = getCorpusInfo h.fields CorpusInfo { authors, desc, query } = getCorpusInfo h.fields
title = "Corpus " <> name title = "Corpus " <> name
R.fragment R.fragment
[ Table.tableHeaderLayout { cacheState [ Table.tableHeaderLayout { cacheState
, date , date
...@@ -103,7 +112,10 @@ textsLayoutWithKeyCpt = here.component "textsLayoutWithKey" cpt ...@@ -103,7 +112,10 @@ textsLayoutWithKeyCpt = here.component "textsLayoutWithKey" cpt
, frontends , frontends
, session , session
, sidePanel , sidePanel
, sidePanelState } , sidePanelState
, yearFilter
, eChartsInstance
}
] ]
where where
afterCacheStateChange cacheState = do afterCacheStateChange cacheState = do
...@@ -126,13 +138,15 @@ modeTabType MoreLikeFav = CTabAuthors -- TODO ...@@ -126,13 +138,15 @@ modeTabType MoreLikeFav = CTabAuthors -- TODO
modeTabType MoreLikeTrash = CTabSources -- TODO modeTabType MoreLikeTrash = CTabSources -- TODO
type TabsProps = type TabsProps =
( cacheState :: T.Box LT.CacheState ( cacheState :: T.Box LT.CacheState
, corpusData :: CorpusData , corpusData :: CorpusData
, corpusId :: NodeID , corpusId :: NodeID
, frontends :: Frontends , frontends :: Frontends
, session :: Session , session :: Session
, sidePanel :: T.Box (Maybe (Record TT.SidePanel)) , sidePanel :: T.Box (Maybe (Record TT.SidePanel))
, sidePanelState :: T.Box SidePanelState , sidePanelState :: T.Box SidePanelState
, yearFilter :: T.Box (Maybe Year)
, eChartsInstance :: T.Box (Maybe EChartsInstance)
) )
tabs :: Record TabsProps -> R.Element tabs :: Record TabsProps -> R.Element
...@@ -141,8 +155,23 @@ tabs props = R.createElement tabsCpt props [] ...@@ -141,8 +155,23 @@ tabs props = R.createElement tabsCpt props []
tabsCpt :: R.Component TabsProps tabsCpt :: R.Component TabsProps
tabsCpt = here.component "tabs" cpt tabsCpt = here.component "tabs" cpt
where where
cpt { cacheState, corpusId, corpusData, frontends, session, sidePanel, sidePanelState } _ = do cpt { cacheState, corpusId, corpusData, frontends, session, sidePanel, sidePanelState, yearFilter, eChartsInstance } _ = do
let path = initialPath
let
path = initialPath
onInit = Just \i -> T.write_ (Just i) eChartsInstance
onClick = Just \opts@{ name } -> do
T.write_ (Just name) yearFilter
T.read eChartsInstance >>= case _ of
Nothing -> pure unit
Just i -> do
-- @XXX due to lack of support for "echart.select" action,
-- have to manually rely on a set/unset selection
-- targeting the "echart.emphasis" action
dispatchAction i { type: "downplay" }
dispatchAction i $ set (SProxy :: SProxy "type") "highlight" opts
activeTab <- T.useBox 0 activeTab <- T.useBox 0
...@@ -150,7 +179,7 @@ tabsCpt = here.component "tabs" cpt ...@@ -150,7 +179,7 @@ tabsCpt = here.component "tabs" cpt
activeTab activeTab
, tabs: [ , tabs: [
"Documents" /\ R.fragment [ "Documents" /\ R.fragment [
histo { path, session } histo { path, session, onClick, onInit }
, docView' path TabDocs , docView' path TabDocs
] ]
, "Trash" /\ docView' path TabTrash , "Trash" /\ docView' path TabTrash
...@@ -173,7 +202,9 @@ tabsCpt = here.component "tabs" cpt ...@@ -173,7 +202,9 @@ tabsCpt = here.component "tabs" cpt
, session , session
, tabType , tabType
, sidePanel , sidePanel
, sidePanelState } [] , sidePanelState
, yearFilter
} []
type DocViewProps a = ( type DocViewProps a = (
cacheState :: T.Box LT.CacheState cacheState :: T.Box LT.CacheState
...@@ -186,6 +217,7 @@ type DocViewProps a = ( ...@@ -186,6 +217,7 @@ type DocViewProps a = (
, tabType :: TabSubType a , tabType :: TabSubType a
, sidePanel :: T.Box (Maybe (Record TT.SidePanel)) , sidePanel :: T.Box (Maybe (Record TT.SidePanel))
, sidePanelState :: T.Box SidePanelState , sidePanelState :: T.Box SidePanelState
, yearFilter :: T.Box (Maybe Year)
) )
docView :: forall a. R2.Component (DocViewProps a) docView :: forall a. R2.Component (DocViewProps a)
...@@ -205,7 +237,9 @@ docViewLayoutRec { cacheState ...@@ -205,7 +237,9 @@ docViewLayoutRec { cacheState
, session , session
, tabType: TabDocs , tabType: TabDocs
, sidePanel , sidePanel
, sidePanelState } = , sidePanelState
, yearFilter
} =
{ cacheState { cacheState
, chart : H.div {} [] , chart : H.div {} []
, frontends , frontends
...@@ -219,6 +253,7 @@ docViewLayoutRec { cacheState ...@@ -219,6 +253,7 @@ docViewLayoutRec { cacheState
, sidePanelState , sidePanelState
, tabType: TabCorpus TabDocs , tabType: TabCorpus TabDocs
, totalRecords: 4737 , totalRecords: 4737
, yearFilter
} }
docViewLayoutRec { cacheState docViewLayoutRec { cacheState
, corpusId , corpusId
...@@ -227,7 +262,9 @@ docViewLayoutRec { cacheState ...@@ -227,7 +262,9 @@ docViewLayoutRec { cacheState
, session , session
, tabType: TabMoreLikeFav , tabType: TabMoreLikeFav
, sidePanel , sidePanel
, sidePanelState } = , sidePanelState
, yearFilter
} =
{ cacheState { cacheState
, chart : H.div {} [] , chart : H.div {} []
, frontends , frontends
...@@ -241,6 +278,7 @@ docViewLayoutRec { cacheState ...@@ -241,6 +278,7 @@ docViewLayoutRec { cacheState
, sidePanelState , sidePanelState
, tabType: TabCorpus TabMoreLikeFav , tabType: TabCorpus TabMoreLikeFav
, totalRecords: 4737 , totalRecords: 4737
, yearFilter
} }
docViewLayoutRec { cacheState docViewLayoutRec { cacheState
, corpusId , corpusId
...@@ -249,7 +287,9 @@ docViewLayoutRec { cacheState ...@@ -249,7 +287,9 @@ docViewLayoutRec { cacheState
, session , session
, tabType: TabMoreLikeTrash , tabType: TabMoreLikeTrash
, sidePanel , sidePanel
, sidePanelState } = , sidePanelState
, yearFilter
} =
{ cacheState { cacheState
, chart : H.div {} [] , chart : H.div {} []
, frontends , frontends
...@@ -263,6 +303,7 @@ docViewLayoutRec { cacheState ...@@ -263,6 +303,7 @@ docViewLayoutRec { cacheState
, sidePanelState , sidePanelState
, tabType: TabCorpus TabMoreLikeTrash , tabType: TabCorpus TabMoreLikeTrash
, totalRecords: 4737 , totalRecords: 4737
, yearFilter
} }
docViewLayoutRec { cacheState docViewLayoutRec { cacheState
, corpusId , corpusId
...@@ -271,7 +312,9 @@ docViewLayoutRec { cacheState ...@@ -271,7 +312,9 @@ docViewLayoutRec { cacheState
, session , session
, tabType: TabTrash , tabType: TabTrash
, sidePanel , sidePanel
, sidePanelState } = , sidePanelState
, yearFilter
} =
{ cacheState { cacheState
, chart : H.div {} [] , chart : H.div {} []
, frontends , frontends
...@@ -285,6 +328,7 @@ docViewLayoutRec { cacheState ...@@ -285,6 +328,7 @@ docViewLayoutRec { cacheState
, sidePanelState , sidePanelState
, tabType: TabCorpus TabTrash , tabType: TabCorpus TabTrash
, totalRecords: 4737 , totalRecords: 4737
, yearFilter
} }
-- DUMMY -- DUMMY
docViewLayoutRec { cacheState docViewLayoutRec { cacheState
...@@ -294,7 +338,9 @@ docViewLayoutRec { cacheState ...@@ -294,7 +338,9 @@ docViewLayoutRec { cacheState
, session , session
, tabType , tabType
, sidePanel , sidePanel
, sidePanelState } = , sidePanelState
, yearFilter
} =
{ cacheState { cacheState
, chart : H.div {} [] , chart : H.div {} []
, frontends , frontends
...@@ -308,6 +354,7 @@ docViewLayoutRec { cacheState ...@@ -308,6 +354,7 @@ docViewLayoutRec { cacheState
, sidePanelState , sidePanelState
, tabType: TabCorpus TabTrash , tabType: TabCorpus TabTrash
, totalRecords: 4737 , totalRecords: 4737
, yearFilter
} }
......
...@@ -6,7 +6,6 @@ import DOM.Simple.Types (Element) ...@@ -6,7 +6,6 @@ import DOM.Simple.Types (Element)
import Data.Array as A import Data.Array as A
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Maybe (Maybe) import Data.Maybe (Maybe)
import Data.Nullable (null)
import Data.Sequence as Seq import Data.Sequence as Seq
import Data.Set as Set import Data.Set as Set
import Data.Traversable (traverse_) import Data.Traversable (traverse_)
...@@ -48,7 +47,7 @@ sigma = runEffectFn3 _sigma Left Right ...@@ -48,7 +47,7 @@ sigma = runEffectFn3 _sigma Left Right
-- | Kill a sigmajs instance. -- | Kill a sigmajs instance.
kill :: Sigma -> Effect Unit kill :: Sigma -> Effect Unit
kill sigma = pure $ sigma ... "kill" $ [] kill s = pure $ s ... "kill" $ []
-- | Call the `refresh()` method on a sigmajs instance. -- | Call the `refresh()` method on a sigmajs instance.
refresh :: Sigma -> Effect Unit refresh :: Sigma -> Effect Unit
......
...@@ -2,10 +2,8 @@ module Gargantext.Hooks.Sigmax.Sigmajs where ...@@ -2,10 +2,8 @@ module Gargantext.Hooks.Sigmax.Sigmajs where
import Prelude import Prelude
import Data.Nullable (Nullable)
import Effect (Effect) import Effect (Effect)
import Effect.Uncurried (EffectFn1, runEffectFn1) import Effect.Uncurried (EffectFn1, runEffectFn1)
import React (SyntheticEventHandler)
import React.Ref as RR import React.Ref as RR
import Record.Unsafe (unsafeGet) import Record.Unsafe (unsafeGet)
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
......
...@@ -173,6 +173,8 @@ toggleForceAtlasState Killed = InitialRunning ...@@ -173,6 +173,8 @@ toggleForceAtlasState Killed = InitialRunning
-- | Custom state for show edges. Normally it is EShow or EHide (show/hide -- | Custom state for show edges. Normally it is EShow or EHide (show/hide
-- | edges). However, edges are temporarily turned off when forceAtlas is -- | edges). However, edges are temporarily turned off when forceAtlas is
-- | running. -- | running.
-- | NOTE ETempHiddenThenShow state is a hack for force atlas
-- | flickering. Ideally it should be removed from here.
data ShowEdgesState = EShow | EHide | ETempHiddenThenShow data ShowEdgesState = EShow | EHide | ETempHiddenThenShow
derive instance Generic ShowEdgesState _ derive instance Generic ShowEdgesState _
......
module Gargantext.Types where module Gargantext.Types where
import Data.Array as A import Data.Array as A
import Data.Generic.Rep (class Generic)
import Data.Eq.Generic (genericEq) import Data.Eq.Generic (genericEq)
import Data.Ord.Generic (genericCompare) import Data.Generic.Rep (class Generic)
import Data.Int (toNumber)
import Data.Maybe (Maybe(..), fromMaybe, maybe)
import Data.Newtype (class Newtype) import Data.Newtype (class Newtype)
import Data.Ord.Generic (genericCompare)
import Data.Show.Generic (genericShow) import Data.Show.Generic (genericShow)
import Data.Int (toNumber)
import Data.Maybe (Maybe(..), maybe)
import Effect.Aff (Aff)
import Foreign as F
import Data.String as S import Data.String as S
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Foreign as F
import Gargantext.Components.Lang (class Translate, Lang(..))
import Gargantext.Prelude
import Gargantext.Utils.Glyphicon (classNamePrefix, glyphiconToCharCode)
import Prim.Row (class Union) import Prim.Row (class Union)
import Reactix as R import Reactix as R
import Simple.JSON as JSON import Simple.JSON as JSON
import Simple.JSON.Generics as JSONG import Simple.JSON.Generics as JSONG
import URI.Query (Query) import URI.Query (Query)
import Gargantext.Prelude
import Gargantext.Components.Lang (class Translate, Lang(..))
import Gargantext.Utils.Glyphicon (classNamePrefix, glyphiconToCharCode)
data Handed = LeftHanded | RightHanded data Handed = LeftHanded | RightHanded
switchHanded :: forall a. a -> a -> Handed -> a switchHanded :: forall a. a -> a -> Handed -> a
......
'use strict';
var API = require('../../src/external-deps/JitsiMeetAPI.js');
console.log('API', API);
exports._api = API;
exports._jitsiMeetAPI = function(host, options) {
return new API(host, options);
};
module Gargantext.Utils.JitsiMeet where
import Data.Function.Uncurried (Fn2, runFn2)
import DOM.Simple as DOM
import Effect (Effect)
import Effect.Uncurried (EffectFn2, runEffectFn2)
foreign import data JitsiMeet :: Type
type Jitsi =
{ parentNode :: DOM.Element
, roomName :: String }
foreign import _api :: JitsiMeet
foreign import _jitsiMeetAPI :: EffectFn2 String Jitsi JitsiMeet
jitsiMeetAPI :: String -> Jitsi -> Effect JitsiMeet
jitsiMeetAPI = runEffectFn2 _jitsiMeetAPI
--jitsiMeetAPIFn :: String -> Jitsi -> JitsiMeet
--jitsiMeetAPIFn = runFn2 _jitsiMeetAPI
This diff is collapsed.
...@@ -1975,11 +1975,16 @@ bootstrap-dark@^1.0.3: ...@@ -1975,11 +1975,16 @@ bootstrap-dark@^1.0.3:
dependencies: dependencies:
bootstrap ">=4.3" bootstrap ">=4.3"
bootstrap@>=4.3, bootstrap@^5.0.2: bootstrap@>=4.3:
version "5.0.2" version "5.0.2"
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-5.0.2.tgz#aff23d5e0e03c31255ad437530ee6556e78e728e" resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-5.0.2.tgz#aff23d5e0e03c31255ad437530ee6556e78e728e"
integrity sha512-1Ge963tyEQWJJ+8qtXFU6wgmAVj9gweEjibUdbmcCEYsn38tVwRk8107rk2vzt6cfQcRr3SlZ8aQBqaD8aqf+Q== integrity sha512-1Ge963tyEQWJJ+8qtXFU6wgmAVj9gweEjibUdbmcCEYsn38tVwRk8107rk2vzt6cfQcRr3SlZ8aQBqaD8aqf+Q==
bootstrap@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-4.6.0.tgz#97b9f29ac98f98dfa43bf7468262d84392552fd7"
integrity sha512-Io55IuQY3kydzHtbGvQya3H+KorS/M9rSNyfCGCg9WZ4pyT/lCxIlpJgG1GXW/PswzC84Tr2fBYi+7+jFVQQBw==
boxen@1.3.0: boxen@1.3.0:
version "1.3.0" version "1.3.0"
resolved "https://registry.yarnpkg.com/boxen/-/boxen-1.3.0.tgz#55c6c39a8ba58d9c61ad22cd877532deb665a20b" resolved "https://registry.yarnpkg.com/boxen/-/boxen-1.3.0.tgz#55c6c39a8ba58d9c61ad22cd877532deb665a20b"
...@@ -2986,9 +2991,9 @@ ejs@^2.6.1: ...@@ -2986,9 +2991,9 @@ ejs@^2.6.1:
integrity sha512-7vmuyh5+kuUyJKePhQfRQBhXV5Ce+RnaeeQArKu1EAMpL3WbgMt5WG6uQZpEVvYSSsxMXRKOewtDk9RaTKXRlA== integrity sha512-7vmuyh5+kuUyJKePhQfRQBhXV5Ce+RnaeeQArKu1EAMpL3WbgMt5WG6uQZpEVvYSSsxMXRKOewtDk9RaTKXRlA==
electron-to-chromium@^1.3.723: electron-to-chromium@^1.3.723:
version "1.3.778" version "1.3.775"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.778.tgz#bf01048736c95b78f2988e88005e0ebb385942a4" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.775.tgz#046517d1f2cea753e06fff549995b9dc45e20082"
integrity sha512-Lw04qJaPtWdq0d7qKHJTgkam+FhFi3hm/scf1EyqJWdjO3ZIGUJhNmZJRXWb7yb/bRYXQyVGSpa9RqVpjjWMQw== integrity sha512-EGuiJW4yBPOTj2NtWGZcX93ZE8IGj33HJAx4d3ouE2zOfW2trbWU+t1e0yzLr1qQIw81++txbM3BH52QwSRE6Q==
elliptic@^6.5.2, elliptic@^6.5.3: elliptic@^6.5.2, elliptic@^6.5.3:
version "6.5.4" version "6.5.4"
......
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