Commit 23cc8537 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

Merge branch 'dev' into dev-dashboard-charts

parents 1eae92d9 6eb24204
...@@ -88,8 +88,15 @@ Some options: ...@@ -88,8 +88,15 @@ Some options:
Once you have node and yarn installed, you may install deps with: Once you have node and yarn installed, you may install deps with:
```shell ```shell
yarn install && yarn install-ps yarn install && yarn add psc-package && yarn install-ps && yarn build
``` ```
You need to copy index.html:
```shell
cp src/index.html dist/
```
(Be careful, to update or upgrade your install, maybe you need to remove
old files in node_modules).
### Development ### Development
......
...@@ -13,53 +13,76 @@ dockerrun(){ ...@@ -13,53 +13,76 @@ dockerrun(){
sudo docker run -u "$UID" -e PATH="$P" -v $PWD:/app -w /app "$@" sudo docker run -u "$UID" -e PATH="$P" -v $PWD:/app -w /app "$@"
} }
NODE=node:buster-garg
dockerrunnode(){
dockerrun "$NODE" "$@"
}
unalias npm yarn bower pulp repl &>/dev/null || : unalias npm yarn bower pulp repl &>/dev/null || :
unset npm yarn bower pulp repl &>/dev/null || : unset npm yarn bower pulp repl &>/dev/null || :
npm(){ npm(){
dockerrun node npm "$@" dockerrunnode npm "$@"
} }
yarn(){ yarn(){
dockerrun node yarn "$@" dockerrunnode yarn "$@"
} }
bower(){ bower(){
dockerrun node bower "$@" dockerrunnode bower "$@"
} }
dependencies(){ dependencies(){
dockerrun node psc-dependencies "$@" dockerrunnode psc-dependencies "$@"
} }
package(){ package(){
dockerrun node psc-package "$@" dockerrunnode psc-package "$@"
} }
pulp(){ pulp(){
dockerrun node pulp --psc-package "$@" dockerrunnode pulp --psc-package "$@"
} }
repl(){ repl(){
dockerrun -ti node pulp --psc-package repl "$@" dockerrun -ti "$NODE" pulp --psc-package repl "$@"
}
sass(){
dockerrunnode yarn sass
} }
check(){ check(){
pulp test "$@" pulp test "$@"
} }
pscpackagehack(){
cp $HOME/bin/psc-package node_modules/.bin
}
setup(){ setup(){
yarn install && yarn install &&
yarn rebuild-set && yarn rebuild-set &&
pscpackagehack &&
yarn install-ps yarn install-ps
} }
build(){ build(){
pulp browserify --to dist/bundle.js echo prefer: compile
yarn build
#pulp browserify --to dist/bundle.js
}
compile(){
yarn compile
} }
serve(){ serve(){
dockerrun node http-server -p 2015 --cors dist #yarn dev
#dockerrunnode http-server -p 2015 --cors dist
dockerrunnode webpack-dev-server --env dev --mode development
} }
dev(){ dev(){
......
...@@ -204,7 +204,7 @@ type SigmaSettings = ...@@ -204,7 +204,7 @@ type SigmaSettings =
-- selected nodes <=> special label -- selected nodes <=> special label
sigmaSettings :: {|SigmaSettings} sigmaSettings :: {|SigmaSettings}
sigmaSettings = sigmaSettings =
{ animationsTime: 5500.0 { animationsTime: 30000.0
, autoRescale: true , autoRescale: true
, autoResize: true , autoResize: true
, batchEdgesDrawing: true , batchEdgesDrawing: true
...@@ -217,7 +217,7 @@ sigmaSettings = ...@@ -217,7 +217,7 @@ sigmaSettings =
, defaultLabelSize: 8.0 -- (old tina: showLabelsIfZoom) , defaultLabelSize: 8.0 -- (old tina: showLabelsIfZoom)
, defaultNodeBorderColor : "#000" -- <- if nodeBorderColor = 'default' , defaultNodeBorderColor : "#000" -- <- if nodeBorderColor = 'default'
, defaultNodeColor: "#FFF" , defaultNodeColor: "#FFF"
, doubleClickEnabled: false , doubleClickEnabled: false -- indicates whether or not the graph can be zoomed on double-click
, drawEdgeLabels: true , drawEdgeLabels: true
, drawEdges: true , drawEdges: true
, drawLabels: true , drawLabels: true
...@@ -228,12 +228,12 @@ sigmaSettings = ...@@ -228,12 +228,12 @@ sigmaSettings =
, edgeHoverPrecision: 2.0 , edgeHoverPrecision: 2.0
, edgeHoverSizeRatio: 2.0 , edgeHoverSizeRatio: 2.0
, enableHovering: true , enableHovering: true
, font: "Droid Sans" -- font params , font: "arial" -- font params
, fontStyle: "bold" , fontStyle: "bold"
, hideEdgesOnMove: true , hideEdgesOnMove: true
, labelSize : "fixed" , labelSize : "proportional" -- alt : proportional
, labelSizeRatio: 2.0 -- label size in ratio of node size , labelSizeRatio: 2.0 -- label size in ratio of node size
, labelThreshold: 5.0 -- min node cam size to start showing label , labelThreshold: 7.0 -- min node cam size to start showing label
, maxEdgeSize: 1.0 , maxEdgeSize: 1.0
, maxNodeSize: 8.0 , maxNodeSize: 8.0
, minEdgeSize: 0.5 -- in fact used in tina as edge size , minEdgeSize: 0.5 -- in fact used in tina as edge size
...@@ -256,7 +256,7 @@ sigmaSettings = ...@@ -256,7 +256,7 @@ sigmaSettings =
, verbose : true , verbose : true
, zoomMax: 1.7 , zoomMax: 1.7
, zoomMin: 0.0 , zoomMin: 0.0
, zoomingRatio: 3.2 , zoomingRatio: 1.7
} }
type ForceAtlas2Settings = type ForceAtlas2Settings =
...@@ -280,17 +280,17 @@ type ForceAtlas2Settings = ...@@ -280,17 +280,17 @@ type ForceAtlas2Settings =
forceAtlas2Settings :: {|ForceAtlas2Settings} forceAtlas2Settings :: {|ForceAtlas2Settings}
forceAtlas2Settings = forceAtlas2Settings =
{ adjustSizes : false { adjustSizes : true
, barnesHutOptimize : true , barnesHutOptimize : true
, edgeWeightInfluence : 0.0 , edgeWeightInfluence : 1.0
-- fixedY : false -- fixedY : false
, gravity : 1.0 , gravity : 1.0
, iterationsPerRender : 4.0 , iterationsPerRender : 10.0
, linLogMode : true -- false , linLogMode : false -- false
, outboundAttractionDistribution: false , outboundAttractionDistribution: false
, scalingRatio : 4.0 , scalingRatio : 10.0
, skipHidden: false , skipHidden: false
, slowDown : 0.7 , slowDown : 1.0
, startingIterations : 2.0 , startingIterations : 10.0
, strongGravityMode : false , strongGravityMode : false
} }
...@@ -6,7 +6,6 @@ module Gargantext.Components.GraphExplorer.Search ...@@ -6,7 +6,6 @@ module Gargantext.Components.GraphExplorer.Search
import Prelude import Prelude
import Data.Sequence as Seq import Data.Sequence as Seq
import Data.Set as Set import Data.Set as Set
import Data.String as S
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log2) import DOM.Simple.Console (log2)
import Effect (Effect) import Effect (Effect)
...@@ -14,6 +13,7 @@ import Reactix as R ...@@ -14,6 +13,7 @@ import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Gargantext.Components.InputWithAutocomplete (inputWithAutocomplete) import Gargantext.Components.InputWithAutocomplete (inputWithAutocomplete)
import Gargantext.Utils (queryMatchesLabel)
import Gargantext.Hooks.Sigmax.Types as SigmaxT import Gargantext.Hooks.Sigmax.Types as SigmaxT
type Props = ( type Props = (
...@@ -24,9 +24,7 @@ type Props = ( ...@@ -24,9 +24,7 @@ type Props = (
-- | Whether a node matches a search string -- | Whether a node matches a search string
nodeMatchesSearch :: String -> Record SigmaxT.Node -> Boolean nodeMatchesSearch :: String -> Record SigmaxT.Node -> Boolean
nodeMatchesSearch s n = S.contains (S.Pattern $ normalize s) (normalize n.label) nodeMatchesSearch s n = queryMatchesLabel s n.label
where
normalize = S.toLower
searchNodes :: String -> Seq.Seq (Record SigmaxT.Node) -> Seq.Seq (Record SigmaxT.Node) searchNodes :: String -> Seq.Seq (Record SigmaxT.Node) -> Seq.Seq (Record SigmaxT.Node)
searchNodes "" _ = Seq.empty searchNodes "" _ = Seq.empty
......
...@@ -6,7 +6,7 @@ module Gargantext.Components.NgramsTable ...@@ -6,7 +6,7 @@ module Gargantext.Components.NgramsTable
import Prelude import Prelude
( class Show, Unit, bind, const, discard, identity, map, mempty, not ( class Show, Unit, bind, const, discard, identity, map, mempty, not
, pure, show, unit, (#), ($), (&&), (+), (/=), (<$>), (<<<), (<>), (=<<) , pure, show, unit, (#), ($), (&&), (+), (/=), (<$>), (<<<), (<>), (=<<)
, (==), (||), otherwise ) , (==), (||), otherwise, when )
import Data.Array as A import Data.Array as A
import Data.FunctorWithIndex (mapWithIndex) import Data.FunctorWithIndex (mapWithIndex)
import Data.Lens (Lens', to, view, (%~), (.~), (^.), (^..), (^?)) import Data.Lens (Lens', to, view, (%~), (.~), (^.), (^..), (^?))
...@@ -18,7 +18,7 @@ import Data.Lens.Record (prop) ...@@ -18,7 +18,7 @@ import Data.Lens.Record (prop)
import Data.List as List import Data.List as List
import Data.Map (Map) import Data.Map (Map)
import Data.Map as Map import Data.Map as Map
import Data.Maybe (Maybe(..), maybe, isNothing) import Data.Maybe (Maybe(..), maybe, isJust)
import Data.Monoid.Additive (Additive(..)) import Data.Monoid.Additive (Additive(..))
import Data.Ord.Down (Down(..)) import Data.Ord.Down (Down(..))
import Data.Set (Set) import Data.Set (Set)
...@@ -31,7 +31,8 @@ import Reactix as R ...@@ -31,7 +31,8 @@ import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import React (ReactClass, ReactElement, Children) import React (ReactClass, ReactElement, Children)
import React.DOM (a, i, input, li, span, text, ul) import React.DOM (a, i, input, li, span, text, ul)
import React.DOM.Props (_type, checked, className, onChange, onClick, style) import React.DOM.Props ( _type, checked, className, onChange, onClick, style
, readOnly)
import React.DOM.Props as DOM import React.DOM.Props as DOM
import Thermite as Thermite import Thermite as Thermite
import Thermite (modifyState_) import Thermite (modifyState_)
...@@ -50,6 +51,7 @@ import Gargantext.Components.NgramsTable.Core ...@@ -50,6 +51,7 @@ import Gargantext.Components.NgramsTable.Core
import Gargantext.Components.Loader (loader) import Gargantext.Components.Loader (loader)
import Gargantext.Components.Table as T import Gargantext.Components.Table as T
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Utils (queryMatchesLabel)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
...@@ -327,7 +329,7 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render ...@@ -327,7 +329,7 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render
pt = singletonNgramsTablePatch parent pe pt = singletonNgramsTablePatch parent pe
render :: Thermite.Render State (Record LoadedNgramsTableProps) Action render :: Thermite.Render State (Record LoadedNgramsTableProps) Action
render dispatch { path: path@({scoreType, params} /\ setPath) render dispatch { path: path@({searchQuery, scoreType, params, termListFilter} /\ setPath)
, versioned: Versioned { data: initTable } , versioned: Versioned { data: initTable }
, tabNgramType } , tabNgramType }
state@{ ngramsParent, ngramsChildren, ngramsLocalPatch state@{ ngramsParent, ngramsChildren, ngramsLocalPatch
...@@ -375,7 +377,7 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render ...@@ -375,7 +377,7 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render
<<< _Just <<< _Just
) =<< ngramsParent ) =<< ngramsParent
displayRow (NgramsElement {ngrams, root}) = displayRow (NgramsElement {ngrams, root, list}) =
root == Nothing root == Nothing
-- ^ Display only nodes without parents -- ^ Display only nodes without parents
&& ngramsChildren ^. at ngrams /= Just true && ngramsChildren ^. at ngrams /= Just true
...@@ -384,8 +386,14 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render ...@@ -384,8 +386,14 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render
-- ^ and which are not our new parent -- ^ and which are not our new parent
&& Just ngrams /= ngramsParentRoot && Just ngrams /= ngramsParentRoot
-- ^ and which are not the root of our new parent -- ^ and which are not the root of our new parent
|| -- Unless they are scheduled to be removed. && queryMatchesLabel searchQuery (ngramsTermText ngrams)
ngramsChildren ^. at ngrams == Just false -- ^ and which matches the search query.
&& maybe true (_ == list) termListFilter
-- ^ and which matches the ListType filter.
|| ngramsChildren ^. at ngrams == Just false
-- ^ unless they are scheduled to be removed.
|| tablePatchHasNgrams ngramsLocalPatch ngrams
-- ^ unless they are being processed at the moment.
convertRow (Tuple ngrams ngramsElement) = convertRow (Tuple ngrams ngramsElement) =
{ row: R2.buff <$> renderNgramsItem { ngramsTable, ngrams, { row: R2.buff <$> renderNgramsItem { ngramsTable, ngrams,
ngramsLocalPatch, ngramsLocalPatch,
...@@ -501,7 +509,15 @@ renderNgramsItem { ngramsTable, ngrams, ngramsElement, ngramsParent ...@@ -501,7 +509,15 @@ renderNgramsItem { ngramsTable, ngrams, ngramsElement, ngramsParent
termList = ngramsElement ^. _NgramsElement <<< _list termList = ngramsElement ^. _NgramsElement <<< _list
ngramsStyle = [termStyle termList ngramsOpacity] ngramsStyle = [termStyle termList ngramsOpacity]
ngramsEdit = Just <<< dispatch <<< SetParentResetChildren <<< Just <<< view _ngrams ngramsEdit = Just <<< dispatch <<< SetParentResetChildren <<< Just <<< view _ngrams
ngramsClick = Just <<< dispatch <<< cycleTermListItem <<< view _ngrams ngramsClick
= Just <<< dispatch <<< cycleTermListItem <<< view _ngrams
-- ^ This is the old behavior it is nicer to use since one can
-- rapidly change the ngram list without waiting for confirmation.
-- However this might expose bugs. One of them can be reproduced
-- by clicking a multiple times on the same ngram, sometimes it stays
-- transient.
-- | ngramsTransient = const Nothing
-- | otherwise = Just <<< dispatch <<< cycleTermListItem <<< view _ngrams
selected = selected =
input input
[ _type "checkbox" [ _type "checkbox"
...@@ -517,16 +533,22 @@ renderNgramsItem { ngramsTable, ngrams, ngramsElement, ngramsParent ...@@ -517,16 +533,22 @@ renderNgramsItem { ngramsTable, ngrams, ngramsElement, ngramsParent
[ _type "checkbox" [ _type "checkbox"
, className "checkbox" , className "checkbox"
, checked chkd , checked chkd
, onChange $ const $ dispatch $ , readOnly ngramsTransient
, onChange $ const $ when (not ngramsTransient) $ dispatch $
setTermListA ngrams (replace termList termList'') setTermListA ngrams (replace termList termList'')
] ]
ngramsOpacity ngramsTransient = tablePatchHasNgrams ngramsLocalPatch ngrams
| isNothing (ngramsLocalPatch.ngramsPatches ^. _PatchMap <<< at ngrams) = 1.0
-- ^ TODO here we do not look at ngramsNewElems, shall we? -- ^ TODO here we do not look at ngramsNewElems, shall we?
| otherwise = 0.5 ngramsOpacity
| ngramsTransient = 0.5
| otherwise = 1.0
cycleTermListItem n = setTermListA n (replace termList (nextTermList termList)) cycleTermListItem n = setTermListA n (replace termList (nextTermList termList))
tablePatchHasNgrams :: NgramsTablePatch -> NgramsTerm -> Boolean
tablePatchHasNgrams ngramsTablePatch ngrams =
isJust $ ngramsTablePatch.ngramsPatches ^. _PatchMap <<< at ngrams
termStyle :: TermList -> Number -> DOM.Props termStyle :: TermList -> Number -> DOM.Props
termStyle GraphTerm opacity = style {color: "green", opacity} termStyle GraphTerm opacity = style {color: "green", opacity}
termStyle StopTerm opacity = style {color: "red", opacity, textDecoration: "line-through"} termStyle StopTerm opacity = style {color: "red", opacity, textDecoration: "line-through"}
......
...@@ -169,14 +169,14 @@ sessionPath (R.CorpusMetrics {tabType, listId, limit} i) = ...@@ -169,14 +169,14 @@ sessionPath (R.CorpusMetrics {tabType, listId, limit} i) =
$ "metrics" $ "metrics"
<> "?ngrams=" <> show listId <> "?ngrams=" <> show listId
<> "&ngramsType=" <> showTabType' tabType <> "&ngramsType=" <> showTabType' tabType
<> maybe "" (\x -> "&limit=" <> show x) limit <> maybe "" limitUrl limit
-- TODO fix this url path -- TODO fix this url path
sessionPath (R.Chart {chartType, tabType} i) = sessionPath (R.Chart {chartType, tabType} i) =
sessionPath $ R.NodeAPI Corpus i sessionPath $ R.NodeAPI Corpus i
$ show chartType $ show chartType
<> "?ngramsType=" <> showTabType' tabType <> "?ngramsType=" <> showTabType' tabType
<> "&listType=GraphTerm" -- <> show listId <> "&listType=GraphTerm" -- <> show listId
-- <> maybe "" (\x -> "&limit=" <> show x) limit -- <> maybe "" limitUrl limit
-- sessionPath (R.NodeAPI (NodeContact s a i) i) = sessionPath $ "annuaire/" <> show a <> "/contact/" <> show i -- sessionPath (R.NodeAPI (NodeContact s a i) i) = sessionPath $ "annuaire/" <> show a <> "/contact/" <> show i
------- misc routing stuff ------- misc routing stuff
......
...@@ -5,7 +5,7 @@ import Data.Lens (Lens', lens) ...@@ -5,7 +5,7 @@ import Data.Lens (Lens', lens)
import Data.Newtype (class Newtype, unwrap, wrap) import Data.Newtype (class Newtype, unwrap, wrap)
import Data.Set as Set import Data.Set as Set
import Data.Set (Set) import Data.Set (Set)
import Data.String (length) import Data.String as S
-- | Astonishingly, not in the prelude -- | Astonishingly, not in the prelude
id :: forall a. a -> a id :: forall a. a -> a
...@@ -62,7 +62,12 @@ glyphiconActive icon b = glyphicon icon <> if b then " active" else "" ...@@ -62,7 +62,12 @@ glyphiconActive icon b = glyphicon icon <> if b then " active" else ""
zeroPad :: Int -> Int -> String zeroPad :: Int -> Int -> String
zeroPad pad num = zeros <> (show num) zeroPad pad num = zeros <> (show num)
where where
numDigits = length $ show num numDigits = S.length $ show num
zeros = if numDigits < pad then zeros' (pad - numDigits) else "" zeros = if numDigits < pad then zeros' (pad - numDigits) else ""
zeros' 0 = "" zeros' 0 = ""
zeros' n = "0" <> (zeros' (n - 1)) zeros' n = "0" <> (zeros' (n - 1))
queryMatchesLabel :: String -> String -> Boolean
queryMatchesLabel q l = S.contains (S.Pattern $ normalize q) (normalize l)
where
normalize = S.toLower
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