Commit 6f1bdce0 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

Merge branch 'dev' into 476-dev-rest-error-when-adding-ngrams

parents 04fb96c2 5cbaadcc
Pipeline #3462 failed with stage
in 0 seconds
{
"name": "Gargantext",
"version": "0.0.6.8.5.1",
"version": "0.0.6.8.5.7",
"scripts": {
"generate-purs-packages-nix": "./nix/generate-purs-packages.nix",
"generate-psc-packages-nix": "./nix/generate-packages-json.bash",
......@@ -58,7 +58,7 @@
"react-dom": "^17.0.2",
"react-tooltip": "^4.2.8",
"secp256k1": "^4.0.2",
"sigma": "^2.3.1",
"sigma": "^2.4.0",
"twgl.js": "^5.0.4"
},
"devDependencies": {
......@@ -77,6 +77,6 @@
"xhr2": "^0.2.1"
},
"optionalDependencies": {
"purescript-language-server": "^0.15.2"
"purescript-language-server": "^0.17.1"
}
}
let upstream =
https://github.com/garganscript/package-sets/releases/download/v0.1.6/release.dhall sha256:443a37602d5b9353c4daf4349079a77d5dddf07a7b35219016b167404d1e1138
https://github.com/garganscript/package-sets/releases/download/v0.1.7/release.dhall sha256:52886309e1f0158a85427f80c1e3d47ce747c5f14fcec671a81fe5c2c711a6db
let overrides =
{ graphql-client =
......@@ -98,7 +98,7 @@ let overrides =
, "typelevel-prelude"
]
, repo = "https://github.com/justinwoo/purescript-record-extra"
, version = "0.15.0-starter-kit"
, version = "v5.0.1"
}
}
......
......@@ -124,6 +124,7 @@ pkgs.mkShell {
pkgs.esbuild
pkgs.minify
pkgs.nodejs
#pkgs.nodePackages.purescript-language-server
pkgs.python # needed for msgpack etc
repl
serve
......
......@@ -70,6 +70,7 @@ to generate this file without the comments in this block.
, "record"
, "record-extra"
, "routing"
, "sequences"
, "simple-json"
, "simple-json-generics"
, "simplecrypto"
......
......@@ -143,6 +143,45 @@ component = R.hooksComponent "documentFormCreation" cpt where
]
]
,
-- Language
H.div
{ className: intercalate " "
[ "form-group"
, (fv.hasError' "language") ?
"form-group--error" $
mempty
]
}
[
H.div { className: "form-group__label"}
[
H.label {} [ H.text "Language" ]
]
,
H.div { className: "form-group__field" }
[
B.formSelect (
bindStateKey "language"
)
[
H.option
{value: "EN"}
[ H.text "EN"]
,
H.option
{ value: "FR" }
[ H.text "FR"]
,
H.option
{ value: "Nothing" }
[ H.text "Nothing"]
, H.option
{ value: "All" }
[ H.text "All"]
]
]
]
,
-- Date
H.div
{ className: intercalate " "
......@@ -218,6 +257,7 @@ type FormData =
, authors :: String
, date :: String
, abstract :: String
, language :: String
)
defaultData :: Record FormData
......@@ -227,6 +267,7 @@ defaultData =
, authors : ""
, date : ""
, abstract : ""
, language : "EN"
}
documentFormValidation :: Record FormData -> Effect VForm
......@@ -236,6 +277,7 @@ documentFormValidation r = foldl append mempty rules
[ FV.nonEmpty "title" r.title
, FV.nonEmpty "source" r.source
, FV.nonEmpty "authors" r.authors
, FV.nonEmpty "language" r.language
, FV.date "date" r.date
]
......
......@@ -10,10 +10,14 @@ import Gargantext.Prelude
import Data.Either (Either(..))
import Data.Maybe (Maybe(..))
import Data.Nullable (Nullable)
import Data.Tuple (Tuple(..))
import Data.Sequence as Seq
import Data.Set as Set
import Data.Traversable (traverse_)
import Data.Tuple (Tuple(..), fst, snd)
import DOM.Simple (window)
import DOM.Simple.Types (Element)
import Effect.Class.Console as ECC
import Effect.Timer (setTimeout)
import Gargantext.Components.App.Store as AppStore
import Gargantext.Components.GraphExplorer.Store as GraphStore
import Gargantext.Components.GraphExplorer.Types as GET
......@@ -45,10 +49,10 @@ type Props sigma forceatlas2 =
drawGraph :: forall s fa2. R2.Leaf (Props s fa2)
drawGraph = R2.leaf drawGraphCpt
drawGraphCpt :: forall s fa2. R.Memo (Props s fa2)
drawGraphCpt = R.memo' $ here.component "graph" cpt where
-- drawGraphCpt :: forall s fa2. R.Component (Props s fa2)
-- drawGraphCpt = here.component "graph" cpt where
-- drawGraphCpt :: forall s fa2. R.Memo (Props s fa2)
-- drawGraphCpt = R.memo' $ here.component "drawGraph" cpt where
drawGraphCpt :: forall s fa2. R.Component (Props s fa2)
drawGraphCpt = here.component "drawGraph" cpt where
-- | Component
-- |
cpt { elRef
......@@ -75,10 +79,10 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where
showEdges' <- R2.useLive' showEdges
edgeConfluence' <- R2.useLive' edgeConfluence
edgeWeight' <- R2.useLive' edgeWeight
forceAtlasState' <- R2.useLive' forceAtlasState
forceAtlasState' <- R2.useLive' forceAtlasState
graphStage' <- R2.useLive' graphStage
startForceAtlas' <- R2.useLive' startForceAtlas
hyperdataGraph' <- R2.useLive' hyperdataGraph
--hyperdataGraph' <- R2.useLive' hyperdataGraph
-- | Hooks
-- |
......@@ -99,9 +103,10 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where
here.log "[drawGraph (Cleanup)] sigma killed"
-- Stage Init
R.useEffect2' hyperdataGraph' graphStage' $ case graphStage' of
R.useEffect1' graphStage' $ case graphStage' of
GET.Init -> do
hyperdataGraph' <- T.read hyperdataGraph
let mCamera = getter _.mCamera hyperdataGraph'
let rSigma = R.readRef sigmaRef
......@@ -193,18 +198,26 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where
let tEdgesMap = SigmaxTypes.edgesGraphMap transformedGraph
let tNodesMap = SigmaxTypes.nodesGraphMap transformedGraph
Sigmax.dependOnSigma (R.readRef sigmaRef) "[drawGraph (Ready)] no sigma" $ \sigma -> do
Sigmax.performDiff sigma transformedGraph
-- Sigmax.updateEdges sigma tEdgesMap
-- Sigmax.updateNodes sigma tNodesMap
let edgesState = not $ SigmaxTypes.edgeStateHidden showEdges'
-- here.log2 "[graphCpt] edgesState" edgesState
Sigmax.setSigmaEdgesVisibility sigma { edgeConfluence: edgeConfluence'
, edgeWeight: edgeWeight'
, showEdges: showEdges' }
let updateSigma _ = do
Sigmax.dependOnSigma (R.readRef sigmaRef) "[drawGraph (Ready)] no sigma" $ \sigma -> do
Sigmax.performDiff sigma transformedGraph
-- Sigmax.updateEdges sigma tEdgesMap
-- Sigmax.updateNodes sigma tNodesMap
let edgesState = not $ SigmaxTypes.edgeStateHidden showEdges'
-- here.log2 "[graphCpt] edgesState" edgesState
Sigmax.setSigmaEdgesVisibility sigma { edgeConfluence: edgeConfluence'
, edgeWeight: edgeWeight'
, showEdges: showEdges' }
-- TODO This is a temporary solution that seems to fix
-- blank page of graph when there are too many edges. It
-- still throws error though, just in another thread.
_ <- setTimeout 100 $ updateSigma unit
pure unit
case Tuple forceAtlasState' graphStage' of
--Tuple SigmaxTypes.InitialLoading GET.Ready -> updateGraph
Tuple SigmaxTypes.InitialRunning GET.Ready -> updateGraph
Tuple SigmaxTypes.Paused GET.Ready -> updateGraph
......
......@@ -101,7 +101,6 @@ sidebarCpt = here.component "sidebar" cpt where
sideTabLegend :: R2.Leaf Props
sideTabLegend = R2.leaf sideTabLegendCpt
sideTabLegendCpt :: R.Component Props
sideTabLegendCpt = here.component "sideTabLegend" cpt where
cpt { metaData: GET.MetaData { legend } } _ = do
......@@ -165,11 +164,9 @@ sideTabDataCpt = here.component "sideTabData" cpt where
cpt props _ = do
-- States
{ selectedNodeIds
, graph
} <- GraphStore.use
selectedNodeIds' <- R2.useLive' selectedNodeIds
graph' <- R2.useLive' graph
-- Computed
let
......@@ -186,39 +183,57 @@ sideTabDataCpt = here.component "sideTabData" cpt where
-- No result
false ->
B.caveat
{}
[
H.text "Select one or more nodes to get their informations"
]
sideTabDataNoSelection {}
-- Nodes have been selected
true ->
sideTabDataWithSelection props
]
R.fragment
[
selectedNodes $
{ nodesMap: SigmaxT.nodesGraphMap graph'
} `Record.merge` props
,
sideBarTabSeparator
,
neighborhood
{}
,
sideBarTabSeparator
,
docListWrapper
{ metaData: props.metaData
}
]
sideTabDataNoSelection :: R2.Leaf ()
sideTabDataNoSelection = R2.leaf sideTabDataNoSelectionCpt
sideTabDataNoSelectionCpt :: R.Component ()
sideTabDataNoSelectionCpt = here.component "sideTabDataNoSelection" cpt where
cpt {} _ = do
pure $ B.caveat
{}
[
H.text "Select one or more nodes to get their informations"
]
sideTabDataWithSelection :: R2.Leaf Props
sideTabDataWithSelection = R2.leaf sideTabDataWithSelectionCpt
sideTabDataWithSelectionCpt :: R.Component Props
sideTabDataWithSelectionCpt = here.component "sideTabDataWithSelection" cpt where
cpt props _ = do
-- States
{ graph
} <- GraphStore.use
graph' <- R2.useLive' graph
pure $
R.fragment [
selectedNodes $
{ nodesMap: SigmaxT.nodesGraphMap graph'
} `Record.merge` props
,
sideBarTabSeparator
,
neighborhood
{}
,
sideBarTabSeparator
,
docListWrapper
{ metaData: props.metaData
}
]
------------------------------------------------------------
sideTabCommunity :: R2.Leaf Props
sideTabCommunity = R2.leaf sideTabCommunityCpt
sideTabCommunityCpt :: R.Component Props
sideTabCommunityCpt = here.component "sideTabCommunity" cpt where
cpt props _ = do
......@@ -244,33 +259,52 @@ sideTabCommunityCpt = here.component "sideTabCommunity" cpt where
-- No result
false ->
B.caveat
{}
[
H.text "Select one or more nodes to get their informations"
]
sideTabCommunityNoSelection {}
-- Nodes have been selection
true ->
sideTabCommunityWithSelection props
]
R.fragment
[
selectedNodes $
{ nodesMap: SigmaxT.nodesGraphMap graph'
} `Record.merge` props
,
sideBarTabSeparator
,
neighborhood
{}
,
sideBarTabSeparator
,
contactListWrapper
{ metaData: props.metaData
}
]
sideTabCommunityNoSelection :: R2.Leaf ()
sideTabCommunityNoSelection = R2.leaf sideTabCommunityNoSelectionCpt
sideTabCommunityNoSelectionCpt :: R.Component ()
sideTabCommunityNoSelectionCpt = here.component "sideTabCommunityNoSelection" cpt where
cpt {} _ = do
pure $ B.caveat
{}
[
H.text "Select one or more nodes to get their informations"
]
sideTabCommunityWithSelection :: R2.Leaf Props
sideTabCommunityWithSelection = R2.leaf sideTabCommunityWithSelectionCpt
sideTabCommunityWithSelectionCpt :: R.Component Props
sideTabCommunityWithSelectionCpt = here.component "sideTabCommunityWithSelection" cpt where
cpt props _ = do
{ graph
} <- GraphStore.use
graph' <- R2.useLive' graph
pure $
R.fragment
[
selectedNodes $
{ nodesMap: SigmaxT.nodesGraphMap graph'
} `Record.merge` props
,
sideBarTabSeparator
,
neighborhood
{}
,
sideBarTabSeparator
,
contactListWrapper
{ metaData: props.metaData
}
]
-------------------------------------------
......@@ -295,7 +329,6 @@ type SelectedNodesProps =
selectedNodes :: R2.Leaf SelectedNodesProps
selectedNodes = R2.leaf selectedNodesCpt
selectedNodesCpt :: R.Component SelectedNodesProps
selectedNodesCpt = here.component "selectedNodes" cpt where
cpt props _ = do
......
......@@ -42,10 +42,12 @@ type Store =
-- Controls
, multiSelectEnabled :: T.Box Boolean
, edgeConfluence :: T.Box Range.NumberRange
, edgeConfluenceRange :: T.Box Range.NumberRange
, edgeWeight :: T.Box Range.NumberRange
, forceAtlasState :: T.Box SigmaxT.ForceAtlasState
, graphStage :: T.Box GET.Stage
, nodeSize :: T.Box Range.NumberRange
, nodeSizeRange :: T.Box Range.NumberRange
, showEdges :: T.Box SigmaxT.ShowEdgesState
, showLouvain :: T.Box Boolean
, labelSize :: T.Box Number
......@@ -73,10 +75,12 @@ type State =
-- Controls
, multiSelectEnabled :: Boolean
, edgeConfluence :: Range.NumberRange
, edgeConfluenceRange :: Range.NumberRange
, edgeWeight :: Range.NumberRange
, forceAtlasState :: SigmaxT.ForceAtlasState
, graphStage :: GET.Stage
, nodeSize :: Range.NumberRange
, nodeSizeRange :: Range.NumberRange
, showEdges :: SigmaxT.ShowEdgesState
, showLouvain :: Boolean
, labelSize :: Number
......
......@@ -205,6 +205,7 @@ pauseForceAtlasButtonCpt = here.component "pauseForceAtlasButtonButton" cpt
vrt SigmaxTypes.Running = ButtonVariant Secondary
vrt _ = OutlinedButtonVariant Secondary
--icn SigmaxTypes.InitialLoading = "pause"
icn SigmaxTypes.InitialRunning = "pause"
icn SigmaxTypes.InitialStopped = "play"
icn SigmaxTypes.Running = "pause"
......
......@@ -51,6 +51,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
-- | States
-- |
{ edgeConfluence
, edgeConfluenceRange
, edgeWeight
, forceAtlasState
, graph
......@@ -60,6 +61,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
, mouseSelectorSize
, multiSelectEnabled
, nodeSize
, nodeSizeRange
, selectedNodeIds
, showEdges
, showLouvain
......@@ -68,11 +70,13 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
} <- GraphStore.use
forceAtlasState' <- R2.useLive' forceAtlasState
graph' <- R2.useLive' graph
graphStage' <- R2.useLive' graphStage
selectedNodeIds' <- R2.useLive' selectedNodeIds
showSidebar' <- R2.useLive' showSidebar
edgeConfluenceRange' <- R2.useLive' edgeConfluenceRange
nodeSizeRange' <- R2.useLive' nodeSizeRange
session <- useSession
-- ref to track automatic FA pausing
......@@ -116,41 +120,19 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
-- Timer to turn off the initial FA. This is because FA eats up lot of
-- CPU, has memory leaks etc.
R.useEffect1' forceAtlasState' $ do
if forceAtlasState' == SigmaxT.InitialRunning then do
timeoutId <- setTimeout 9000 $ do
case forceAtlasState' of
SigmaxT.InitialRunning ->
T.write_ SigmaxT.Paused forceAtlasState
_ -> pure unit
R.setRef mFAPauseRef Nothing
R.setRef mFAPauseRef $ Just timeoutId
pure unit
else
case forceAtlasState' of
SigmaxT.InitialRunning -> do
timeoutId <- setTimeout 9000 $ do
case forceAtlasState' of
SigmaxT.InitialRunning ->
T.write_ SigmaxT.Paused forceAtlasState
_ -> pure unit
R.setRef mFAPauseRef Nothing
R.setRef mFAPauseRef $ Just timeoutId
pure unit
_ -> pure unit
-- | Computed
-- |
let edgesConfluenceSorted = A.sortWith (_.confluence) $ Seq.toUnfoldable $ SigmaxT.graphEdges graph'
let edgeConfluenceMin = maybe 0.0 _.confluence $ A.head edgesConfluenceSorted
let edgeConfluenceMax = maybe 100.0 _.confluence $ A.last edgesConfluenceSorted
let edgeConfluenceRange = Range.Closed { min: edgeConfluenceMin, max: edgeConfluenceMax }
--let edgesWeightSorted = A.sortWith (_.weight) $ Seq.toUnfoldable $ SigmaxT.graphEdges graph
--let edgeWeightMin = maybe 0.0 _.weight $ A.head edgesWeightSorted
--let edgeWeightMax = maybe 100.0 _.weight $ A.last edgesWeightSorted
--let edgeWeightRange = Range.Closed { min: edgeWeightMin, max: edgeWeightMax }
let edgeWeightRange = Range.Closed {
min: 0.0
, max: I.toNumber $ Seq.length $ SigmaxT.graphEdges graph'
}
let nodesSorted = A.sortWith (_.size) $ Seq.toUnfoldable $ SigmaxT.graphNodes graph'
let nodeSizeMin = maybe 0.0 _.size $ A.head nodesSorted
let nodeSizeMax = maybe 100.0 _.size $ A.last nodesSorted
let nodeSizeRange = Range.Closed { min: nodeSizeMin, max: nodeSizeMax }
let gap = H.span { className: "graph-toolbar__gap" } []
-- | Render
......@@ -250,7 +232,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
[
edgeConfluenceControl
{ forceAtlasState
, range: edgeConfluenceRange
, range: edgeConfluenceRange'
, state: edgeConfluence }
{- ,
edgeWeightControl
......@@ -281,7 +263,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
-- labels size: 1-4
nodeSizeControl
{ forceAtlasState
, range: nodeSizeRange
, range: nodeSizeRange'
, state: nodeSize }
]
......
......@@ -10,6 +10,7 @@ module Gargantext.Components.NgramsTable
import Gargantext.Prelude
import DOM.Simple.Console (log)
import Data.Array as A
import Data.Either (Either(..))
import Data.FunctorWithIndex (mapWithIndex)
......@@ -42,7 +43,7 @@ import Gargantext.Components.NgramsTable.Tree (renderNgramsItem, renderNgramsTre
import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Table (changePage)
import Gargantext.Components.Table as TT
import Gargantext.Components.Table.Types (Params)
import Gargantext.Components.Table.Types (Params, orderByToGTOrderBy)
import Gargantext.Components.Table.Types as TT
import Gargantext.Config.REST (AffRESTError, RESTError, logRESTError)
import Gargantext.Core.NgramsTable.Functions (addNewNgramA, applyNgramsPatches, chartsAfterSync, commitPatch, convOrderBy, coreDispatch, filterTermSize, ngramsRepoElementToNgramsElement, normNgram, patchSetFromMap, singletonNgramsTablePatch, tablePatchHasNgrams, toVersioned)
......@@ -56,6 +57,7 @@ import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Seq as Seq
import Gargantext.Utils.Toestand as T2
import Reactix (useEffect)
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
......@@ -1014,19 +1016,18 @@ mainNgramsTableCacheOffCpt = here.component "mainNgramsTableCacheOff" cpt where
loader :: PageParams -> AffRESTError VersionedWithCountNgramsTable
loader { listIds
, nodeId
, params: { limit, offset }
, params: { limit, offset, orderBy }
, searchQuery
, session
, tabType
, termListFilter
, termSizeFilter
} =
get session $ Routes.GetNgrams params (Just nodeId)
} = get session $ Routes.GetNgrams params (Just nodeId)
where
params = { limit
, listIds
, offset: Just offset
, orderBy: Nothing -- TODO
, orderBy: orderByToGTOrderBy orderBy
, searchQuery
, tabType
, termListFilter
......
......@@ -4,12 +4,13 @@ module Gargantext.Components.Nodes.Graph
import Gargantext.Prelude
import DOM.Simple (document, querySelector)
import Data.Array as A
import Data.Int as I
import Data.Maybe (Maybe(..), fromMaybe, isJust, maybe)
import Data.Sequence as Seq
import Data.Tuple (Tuple(..))
import Data.Tuple.Nested ((/\))
import DOM.Simple (document, querySelector)
import Gargantext.Components.App.Store as AppStore
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.GraphExplorer.API as GraphAPI
......@@ -56,7 +57,7 @@ nodeCpt = here.component "node" cpt where
-- | Computed
-- |
let errorHandler = logRESTError here "[explorerLayout]"
let errorHandler = logRESTError here "[node]"
-- | Hooks
-- |
......@@ -151,6 +152,7 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where
forceAtlasState
= if startForceAtlas
--then SigmaxT.InitialLoading
then SigmaxT.InitialRunning
else SigmaxT.InitialStopped
......@@ -160,6 +162,29 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where
sigmaRef <- Sigmax.initSigma >>= R.useRef
fa2Ref <- R.useRef (Nothing :: Maybe ForceAtlas.FA2Layout)
-- | Precompute some values
-- |
let edgesConfluenceSorted = A.sortWith (_.confluence) $ Seq.toUnfoldable $ SigmaxT.graphEdges graph
let edgeConfluenceMin = maybe 0.0 _.confluence $ A.head edgesConfluenceSorted
let edgeConfluenceMax = maybe 100.0 _.confluence $ A.last edgesConfluenceSorted
let edgeConfluenceRange = Range.Closed { min: edgeConfluenceMin, max: edgeConfluenceMax }
--let edgesWeightSorted = A.sortWith (_.weight) $ Seq.toUnfoldable $ SigmaxT.graphEdges graph
--let edgeWeightMin = maybe 0.0 _.weight $ A.head edgesWeightSorted
--let edgeWeightMax = maybe 100.0 _.weight $ A.last edgesWeightSorted
--let edgeWeightRange = Range.Closed { min: edgeWeightMin, max: edgeWeightMax }
let edgeWeightRange = Range.Closed {
min: 0.0
, max: I.toNumber $ Seq.length $ SigmaxT.graphEdges graph
}
let nodesSorted = A.sortWith (_.size) $ Seq.toUnfoldable $ SigmaxT.graphNodes graph
let nodeSizeMin = maybe 0.0 _.size $ A.head nodesSorted
let nodeSizeMax = maybe 100.0 _.size $ A.last nodesSorted
let nodeSizeRange = Range.Closed { min: nodeSizeMin, max: nodeSizeMax }
-- Hydrate GraphStore
(state :: Record GraphStore.State) <- pure $
-- Data
......@@ -174,6 +199,8 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where
{ min: 0.0
, max: I.toNumber $ Seq.length $ SigmaxT.graphEdges graph
}
, edgeConfluenceRange
, nodeSizeRange
-- (cache options)
, expandSelection: getter _.expandSelection cacheParams
, expandNeighborhood: getter _.expandNeighborhood cacheParams
......
module Gargantext.Components.Table.Types where
import Data.Generic.Rep (class Generic)
import Data.Show.Generic (genericShow)
import Data.Maybe (Maybe)
import Data.Maybe (Maybe(..))
import Data.Sequence as Seq
import Data.Show.Generic (genericShow)
import Gargantext.Components.Search (SearchType)
import Gargantext.Types as GT
import Prelude (class Eq, class Show, (<>))
import Reactix as R
import Toestand as T
import Prelude (class Eq, class Show, (<>))
import Gargantext.Components.Search (SearchType)
type Params = { limit :: Int
, offset :: Int
, orderBy :: OrderBy
......@@ -28,6 +27,20 @@ orderByToForm :: OrderByDirection ColumnName -> String
orderByToForm (ASC (ColumnName x)) = x <> "Asc"
orderByToForm (DESC (ColumnName x)) = x <> "Desc"
orderByToGTOrderBy :: OrderBy -> Maybe GT.OrderBy
orderByToGTOrderBy (Just (ASC (ColumnName "Date"))) = Just GT.DateAsc
orderByToGTOrderBy (Just (DESC (ColumnName "Date"))) = Just GT.DateDesc
orderByToGTOrderBy (Just (ASC (ColumnName "Title"))) = Just GT.TitleAsc
orderByToGTOrderBy (Just (DESC (ColumnName "Title"))) = Just GT.TitleDesc
orderByToGTOrderBy (Just (ASC (ColumnName "Score"))) = Just GT.ScoreAsc
orderByToGTOrderBy (Just (DESC (ColumnName "Score"))) = Just GT.ScoreDesc
orderByToGTOrderBy (Just (ASC (ColumnName "Terms"))) = Just GT.TermAsc
orderByToGTOrderBy (Just (DESC (ColumnName "Terms"))) = Just GT.TermDesc
orderByToGTOrderBy (Just (ASC (ColumnName "Source"))) = Just GT.SourceAsc
orderByToGTOrderBy (Just (DESC (ColumnName "Source"))) = Just GT.SourceDesc
orderByToGTOrderBy (Just _) = Nothing
orderByToGTOrderBy Nothing = Nothing
newtype ColumnName = ColumnName String
derive instance Generic ColumnName _
instance Show ColumnName where
......
......@@ -16,7 +16,7 @@ import Data.Tuple.Nested ((/\))
import DOM.Simple.Types (Element)
import Effect (Effect)
import Effect.Class.Console (error)
import Effect.Timer (TimeoutId, clearTimeout)
import Effect.Timer (TimeoutId, clearTimeout, setTimeout)
import FFI.Simple ((.=))
import Gargantext.Hooks.Sigmax.ForceAtlas2 as ForceAtlas
import Gargantext.Hooks.Sigmax.Graphology as Graphology
......@@ -24,6 +24,7 @@ import Gargantext.Hooks.Sigmax.Sigma as Sigma
import Gargantext.Hooks.Sigmax.Types as ST
import Gargantext.Utils.Console as C
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Seq as GSeq
import Gargantext.Utils.Set as GSet
import Prelude (Unit, bind, discard, flip, map, not, pure, unit, ($), (&&), (*>), (<<<), (<>), (>>=), (+), (>), negate, (/=), (==), (<$>))
import Reactix as R
......@@ -229,7 +230,9 @@ performDiff sigma g = do
-- console.log2 "[performDiff] removeNodes" removeNodes
-- console.log2 "[performDiff] removeEdges" removeEdges
traverse_ (Graphology.addNode sigmaGraph) addNodes
traverse_ (Graphology.addEdge sigmaGraph) addEdges
--traverse_ (Graphology.addEdge sigmaGraph) addEdges
-- insert edges in batches, otherwise a maximum recursion error is thrown
traverse_ (\edges -> setTimeout 100 $ traverse_ (Graphology.addEdge sigmaGraph) edges) $ GSeq.groupBy 5000 addEdges
traverse_ (Graphology.removeEdge sigmaGraph) removeEdges
traverse_ (Graphology.removeNode sigmaGraph) removeNodes
traverse_ (Graphology.updateEdge sigmaGraph) updateEdges
......@@ -249,7 +252,6 @@ performDiff sigma g = do
, update: Tuple updateEdges updateNodes } = sigmaDiff sigmaGraph g
-- | Compute a diff between current sigma graph and whatever is set via custom controls
sigmaDiff :: Graphology.Graph -> ST.SGraph -> Record ST.SigmaDiff
sigmaDiff sigmaGraph gControls = { add, remove, update }
......@@ -282,12 +284,17 @@ sigmaDiff sigmaGraph gControls = { add, remove, update }
removeNodes = Set.difference sigmaNodeIds (Set.fromFoldable gcNodeIds)
commonNodeIds = Set.intersection sigmaNodeIds $ Set.fromFoldable gcNodeIds
commonNodes = Seq.filter (\n -> Set.member n.id commonNodeIds) sigmaNodes
commonEdgeIds = Set.intersection sigmaEdgeIds $ Set.fromFoldable gcEdgeIds
sigmaNodeIdsMap = Map.fromFoldable $ Seq.map (\n -> Tuple n.id n) sigmaNodes
sigmaEdgeIdsMap = Map.fromFoldable $ Seq.map (\e -> Tuple e.id e) sigmaEdges
updateEdges = Seq.filter (\e -> Just e /= Map.lookup e.id sigmaEdgeIdsMap) gcEdges
commonEdges = Seq.filter (\e -> Set.member e.id commonEdgeIds) sigmaEdges
sigmaNodeIdsMap = Map.fromFoldable $ Seq.map (\n -> Tuple n.id n) commonNodes --sigmaNodes
sigmaEdgeIdsMap = Map.fromFoldable $ Seq.map (\e -> Tuple e.id e) commonEdges --sigmaEdges
-- updateEdges = Seq.filter (\e -> Just e /= Map.lookup e.id sigmaEdgeIdsMap) gcEdges
updateEdges = Seq.empty
-- Find nodes for which `ST.compareNodes` returns `false`, i.e. nodes differ
updateNodes = Seq.filter (\n -> (ST.compareNodes n <$> (Map.lookup n.id sigmaNodeIdsMap)) == Just false) gcNodes
-- updateEdges = Seq.empty
-- updateNodes = Seq.empty
-- DEPRECATED
......
......@@ -25,7 +25,9 @@ newtype Graph n e = Graph { edges :: Seq.Seq {|e}, nodes :: Seq.Seq {|n} }
derive instance Generic (Graph n e) _
instance (Eq (Record n), Eq (Record e)) => Eq (Graph n e) where
eq = genericEq
--eq = genericEq
eq (Graph { edges: e1, nodes: n1 }) (Graph { edges: e2, nodes: n2 }) =
(Seq.length e1 == Seq.length e2) && (Seq.length n1 == Seq.length n2)
--instance Eq Graph where
-- eq (Graph {nodes: n1, edges: e1}) (Graph {nodes: n2, edges: e2}) = n1 == n2 && e1 == e2
......@@ -162,13 +164,14 @@ eqGraph (Graph {nodes: n1, edges: e1}) (Graph {nodes: n2, edges: e2}) = (n1 == n
-- however when graph is loaded initially, forceAtlas is running for a couple of
-- seconds and then stops (unless the user alters this by clicking the toggle
-- button).
data ForceAtlasState = InitialRunning | InitialStopped | Running | Paused | Killed
data ForceAtlasState = {- InitialLoading | -} InitialRunning | InitialStopped | Running | Paused | Killed
derive instance Generic ForceAtlasState _
instance Eq ForceAtlasState where
eq = genericEq
toggleForceAtlasState :: ForceAtlasState -> ForceAtlasState
-- toggleForceAtlasState InitialLoading = InitialRunning
toggleForceAtlasState InitialRunning = Paused
toggleForceAtlasState InitialStopped = InitialRunning
toggleForceAtlasState Running = Paused
......@@ -177,6 +180,7 @@ toggleForceAtlasState Killed = InitialRunning
forceAtlasComponentStatus :: ForceAtlasState -> ComponentStatus
-- forceAtlasComponentStatus InitialLoading = Disabled
forceAtlasComponentStatus InitialRunning = Disabled
forceAtlasComponentStatus InitialStopped = Enabled
forceAtlasComponentStatus Running = Disabled
......@@ -212,6 +216,7 @@ toggleShowEdgesState s =
-- | Return state in which showEdges should be depending on forceAtlasState
forceAtlasEdgeState :: ForceAtlasState -> ShowEdgesState -> ShowEdgesState
-- forceAtlasEdgeState InitialLoading _ = ETempHiddenThenShow
forceAtlasEdgeState InitialRunning EShow = ETempHiddenThenShow
forceAtlasEdgeState InitialRunning es = es
forceAtlasEdgeState InitialStopped es = es
......
module Gargantext.Utils.Seq (mapMaybe) where
module Gargantext.Utils.Seq (groupBy, mapMaybe) where
import Data.Array ((:))
import Data.Maybe (Maybe, maybe)
import Data.Sequence (Seq, concatMap, empty, singleton)
import Data.Sequence (Seq, concatMap, empty, null, singleton, splitAt)
import Data.Tuple (Tuple(..))
import Gargantext.Prelude ((<<<))
mapMaybe :: forall a b. (a -> Maybe b) -> Seq a -> Seq b
mapMaybe f = concatMap (maybe empty singleton <<< f)
-- | Group a given `Seq` into list of `Seq`'s of length `n` (last one can be shorter)
groupBy :: forall a. Int -> Seq a -> Array (Seq a)
groupBy n s =
if null s
then []
else
let (Tuple hd tl) = splitAt n s in
(hd:groupBy n tl)
module Data.Sequence where
module Data.SequenceArr where
import Prelude
import Data.Array as A
......@@ -27,4 +27,3 @@ singleton = A.singleton
splitAt idx seq = Tuple s.before s.after
where
s = A.splitAt idx seq
......@@ -8577,14 +8577,15 @@ punycode@^2.1.0, punycode@^2.1.1:
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
purescript-language-server@^0.15.2:
version "0.15.4"
resolved "https://registry.yarnpkg.com/purescript-language-server/-/purescript-language-server-0.15.4.tgz#0707891b0b91a72453d3bfda6a62f29f06b0d32f"
integrity sha512-llUv605I8yvraO98rb5RmmqPdpWBno7IpIlgNlX3Nq3Q4lvB7G0OxGK89JuAoVZ8T/xkTzhjyuzw0sty0DoY3Q==
purescript-language-server@^0.17.1:
version "0.17.1"
resolved "https://registry.yarnpkg.com/purescript-language-server/-/purescript-language-server-0.17.1.tgz#1240dbdf750b9d34fe394560b51d70a5d019e224"
integrity sha512-o/YpvFMOXp5/UqfFjed8+pwZwttg1QpI3iqkHlMB16AW8MRYGVwTAw1zV8MGqazFFat5j3+IJEUHhaeFON0EfA==
dependencies:
shell-quote "^1.7.2"
uuid "^3.3.2"
vscode-languageserver "^6.1.1"
vscode-jsonrpc "^8.0.0-next.2"
vscode-languageserver "^8.0.0-next.2"
vscode-languageserver-textdocument "^1.0.1"
vscode-uri "^2.1.1"
which "^2.0.2"
......@@ -9471,10 +9472,10 @@ side-channel@^1.0.4:
get-intrinsic "^1.0.2"
object-inspect "^1.9.0"
sigma@^2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/sigma/-/sigma-2.3.1.tgz#69fd9165479fa49ed84348afcd0432215fdf935f"
integrity sha512-YfQsVZf78CeIUv8EYLqp/yvhMwwBXGrbpy+rD1N2X9IqtJ11+VfQRjWfVqHDhjM8oPfWPsaJMtpWFQ8pIflvCA==
sigma@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/sigma/-/sigma-2.4.0.tgz#efa213c82e8561138c9237c3a87cf15c0bbaee76"
integrity sha512-spi4C+c3cjlhCklT+RvAxJJcarMmjRpF6RPNvBIBYDduALq8iSNm7FwSpijQNGtI+ryeZ2EfvyBNLp36OFaZiw==
dependencies:
"@yomguithereal/helpers" "^1.1.1"
events "^3.3.0"
......@@ -10694,7 +10695,12 @@ vscode-jsonrpc@6.0.0:
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-6.0.0.tgz#108bdb09b4400705176b957ceca9e0880e9b6d4e"
integrity sha512-wnJA4BnEjOSyFMvjZdpiOwhSq9uDoK8e/kpRJDTaMYzwlkrhG1fwDIZI94CLsLzlCK5cIbMMtFlJlfR57Lavmg==
vscode-languageserver-protocol@3.16.0, vscode-languageserver-protocol@^3.15.3:
vscode-jsonrpc@8.0.2, vscode-jsonrpc@^8.0.0-next.2:
version "8.0.2"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-8.0.2.tgz#f239ed2cd6004021b6550af9fd9d3e47eee3cac9"
integrity sha512-RY7HwI/ydoC1Wwg4gJ3y6LpU9FJRZAUnTYMXthqhFXXu77ErDd/xkREpGuk4MyYkk4a+XDWAMqe0S3KkelYQEQ==
vscode-languageserver-protocol@3.16.0:
version "3.16.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.16.0.tgz#34135b61a9091db972188a07d337406a3cdbe821"
integrity sha512-sdeUoAawceQdgIfTI+sdcwkiK2KU+2cbEYA0agzM2uqaUy2UpnnGHtWTHVEtS0ES4zHU0eMFRGN+oQgDxlD66A==
......@@ -10702,6 +10708,14 @@ vscode-languageserver-protocol@3.16.0, vscode-languageserver-protocol@^3.15.3:
vscode-jsonrpc "6.0.0"
vscode-languageserver-types "3.16.0"
vscode-languageserver-protocol@3.17.2:
version "3.17.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.2.tgz#beaa46aea06ed061576586c5e11368a9afc1d378"
integrity sha512-8kYisQ3z/SQ2kyjlNeQxbkkTNmVFoQCqkmGrzLH6A9ecPlgTbp3wDTnUNqaUxYr4vlAcloxx8zwy7G5WdguYNg==
dependencies:
vscode-jsonrpc "8.0.2"
vscode-languageserver-types "3.17.2"
vscode-languageserver-textdocument@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.1.tgz#178168e87efad6171b372add1dea34f53e5d330f"
......@@ -10712,12 +10726,10 @@ vscode-languageserver-types@3.16.0:
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.16.0.tgz#ecf393fc121ec6974b2da3efb3155644c514e247"
integrity sha512-k8luDIWJWyenLc5ToFQQMaSrqCHiLwyKPHKPQZ5zz21vM+vIVUSvsRpcbiECH4WR88K2XZqc4ScRcZ7nk/jbeA==
vscode-languageserver@^6.1.1:
version "6.1.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-6.1.1.tgz#d76afc68172c27d4327ee74332b468fbc740d762"
integrity sha512-DueEpkUAkD5XTR4MLYNr6bQIp/UFR0/IPApgXU3YfCBCB08u2sm9hRCs6DxYZELkk++STPjpcjksR2H8qI3cDQ==
dependencies:
vscode-languageserver-protocol "^3.15.3"
vscode-languageserver-types@3.17.2:
version "3.17.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz#b2c2e7de405ad3d73a883e91989b850170ffc4f2"
integrity sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA==
vscode-languageserver@^7.0.0:
version "7.0.0"
......@@ -10726,6 +10738,13 @@ vscode-languageserver@^7.0.0:
dependencies:
vscode-languageserver-protocol "3.16.0"
vscode-languageserver@^8.0.0-next.2:
version "8.0.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-8.0.2.tgz#cfe2f0996d9dfd40d3854e786b2821604dfec06d"
integrity sha512-bpEt2ggPxKzsAOZlXmCJ50bV7VrxwCS5BI4+egUmure/oI/t4OlFzi/YNtVvY24A2UDOZAgwFGgnZPwqSJubkA==
dependencies:
vscode-languageserver-protocol "3.17.2"
vscode-uri@^2.1.1:
version "2.1.2"
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-2.1.2.tgz#c8d40de93eb57af31f3c715dd650e2ca2c096f1c"
......
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