Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
612500c8
Commit
612500c8
authored
Apr 15, 2022
by
arturo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
>>> continue
parent
2478b7c2
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
226 additions
and
48 deletions
+226
-48
ErrorsView.purs
src/Gargantext/Components/ErrorsView.purs
+3
-3
FacetsTable.purs
src/Gargantext/Components/FacetsTable.purs
+2
-2
Resources.purs
src/Gargantext/Components/GraphExplorer/Resources.purs
+1
-1
Sidebar.purs
src/Gargantext/Components/GraphExplorer/Sidebar.purs
+1
-1
ListSelection.purs
src/Gargantext/Components/ListSelection.purs
+2
-2
Login.purs
src/Gargantext/Components/Login.purs
+1
-1
Corpus.purs
src/Gargantext/Components/Nodes/Corpus.purs
+3
-3
Common.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Common.purs
+1
-1
Code.purs
src/Gargantext/Components/Nodes/Corpus/Code.purs
+1
-1
Dashboard.purs
src/Gargantext/Components/Nodes/Corpus/Dashboard.purs
+1
-1
Table.purs
src/Gargantext/Components/Table.purs
+5
-5
REST.purs
src/Gargantext/Config/REST.purs
+3
-3
Utils.purs
src/Gargantext/Config/Utils.purs
+1
-1
Sigmax.purs
src/Gargantext/Hooks/Sigmax.purs
+19
-16
Console.js
src/Gargantext/Utils/Console.js
+8
-0
Console.purs
src/Gargantext/Utils/Console.purs
+144
-0
Reactix.purs
src/Gargantext/Utils/Reactix.purs
+30
-7
No files found.
src/Gargantext/Components/ErrorsView.purs
View file @
612500c8
...
...
@@ -35,7 +35,7 @@ errorsViewCpt = here.component "errorsView" cpt
, variant: "danger" } [ H.text error ]
where
onClose = do
here.
log
2 "click!" error
here.
error
2 "click!" error
T.modify_ (\es -> case deleteAt i es of
Nothing -> es
Just es' -> es'
...
...
@@ -46,7 +46,7 @@ errorsViewCpt = here.component "errorsView" cpt
, variant: "danger" } [ H.text $ show error ]
where
onClose = do
here.
log
2 "click!" error
here.
error
2 "click!" error
T.modify_ (\es -> case deleteAt i es of
Nothing -> es
Just es' -> es'
...
...
@@ -57,7 +57,7 @@ errorsViewCpt = here.component "errorsView" cpt
, variant: "danger" } [ H.text $ show error ]
where
onClose = do
here.
log
2 "click!" error
here.
error
2 "click!" error
T.modify_ (\es -> case deleteAt i es of
Nothing -> es
Just es' -> es'
...
...
src/Gargantext/Components/FacetsTable.purs
View file @
612500c8
...
...
@@ -311,9 +311,9 @@ pageLayoutCpt = here.component "pageLayout" cpt
, path: path'
, render: \rowsLoaded -> page { container, deletions, frontends, path, rowsLoaded, session, totalRecords } [] }
errorHandler err = do
here.
log
2 "[pageLayout] RESTError" err
here.
warn
2 "[pageLayout] RESTError" err
case err of
ReadJSONError err' -> here.
log
2 "[pageLayout] ReadJSONError" $ show err'
ReadJSONError err' -> here.
warn
2 "[pageLayout] ReadJSONError" $ show err'
_ -> pure unit
page :: R2.Component PageProps
...
...
src/Gargantext/Components/GraphExplorer/Resources.purs
View file @
612500c8
...
...
@@ -102,7 +102,7 @@ graphCpt = R.memo' $ here.component "graph" cpt where
theme <- T.read boxes.theme
eSigma <- Sigma.sigma {settings: sigmaSettings theme}
case eSigma of
Left err -> here.
log
2 "[graphCpt] error creating sigma" err
Left err -> here.
warn
2 "[graphCpt] error creating sigma" err
Right sig -> do
Sigmax.writeSigma rSigma $ Just sig
...
...
src/Gargantext/Components/GraphExplorer/Sidebar.purs
View file @
612500c8
...
...
@@ -562,7 +562,7 @@ sendPatches { errors, metaData, nodes, reloadForest, session, termList } = do
Nothing -> pure unit
Just (Left err) -> liftEffect $ do
T.modify_ (A.cons $ FRESTError { error: err }) errors
here.
log
2 "[sendPatches] RESTError" err
here.
warn
2 "[sendPatches] RESTError" err
Just (Right (NTC.Versioned _patch)) -> do
liftEffect $ T2.reload reloadForest
...
...
src/Gargantext/Components/ListSelection.purs
View file @
612500c8
...
...
@@ -128,8 +128,8 @@ listTreeChildrenCpt = here.component "listTreeChildren" cpt where
, session } [] }
where
errorHandler err = case err of
ReadJSONError err' -> here.
log
2 "[listTreeChildren] ReadJSONError" $ show err'
_ -> here.
log
2 "[listTreeChildren] RESTError" err
ReadJSONError err' -> here.
warn
2 "[listTreeChildren] ReadJSONError" $ show err'
_ -> here.
warn
2 "[listTreeChildren] RESTError" err
type ListTreeChildrenLoadedProps =
( loaded :: Array NodeSimple
...
...
src/Gargantext/Components/Login.purs
View file @
612500c8
...
...
@@ -125,7 +125,7 @@ clearCacheButton =
launchAff_
$ GHL.clearCache unit
*> NTL.clearCache unit
*> liftEffect (here.
log
"cache cleared")
*> liftEffect (here.
info
"cache cleared")
renderBackend :: forall b. T.Write b (Maybe Backend) => b -> Backend -> R.Element
renderBackend cursor backend@(Backend {name, baseUrl, backendType}) =
...
...
src/Gargantext/Components/Nodes/Corpus.purs
View file @
612500c8
...
...
@@ -346,12 +346,12 @@ changeCode onc (JSON j) CE.Python _ = onc $ Python $ defaultPython' { python = t
toCode = R2.stringify (JSON.writeImpl j) 2
changeCode onc _ CE.JSON c = do
case JSON.readJSON c of
Left err -> here.
log
2 "[fieldCodeEditor'] cannot parse json" c -- TODO Refactor?
Left err -> here.
warn
2 "[fieldCodeEditor'] cannot parse json" c -- TODO Refactor?
Right j' -> onc $ JSON j'
-- case jsonParser c of
-- Left err -> here.
log
2 "[fieldCodeEditor'] cannot parse json" c
-- Left err -> here.
warn
2 "[fieldCodeEditor'] cannot parse json" c
-- Right j' -> case decodeJson j' of
-- Left err -> here.
log
2 "[fieldCodeEditor'] cannot decode json" j'
-- Left err -> here.
warn
2 "[fieldCodeEditor'] cannot decode json" j'
-- Right j'' -> onc $ JSON j''
changeCode onc (JSON j) CE.Markdown _ = onc $ Markdown $ defaultMarkdown' { text = text }
where
...
...
src/Gargantext/Components/Nodes/Corpus/Chart/Common.purs
View file @
612500c8
...
...
@@ -50,7 +50,7 @@ metricsLoadViewCpt = here.component "metricsLoadView" cpt
where
errorHandler error = do
T.modify_ (A.cons $ FRESTError { error }) errors
here.
log
2 "RESTError" error
here.
warn
2 "RESTError" error
type MetricsWithCacheLoadViewProps res ret =
( getMetricsHash :: Session -> ReloadPath -> AffRESTError Hash
...
...
src/Gargantext/Components/Nodes/Corpus/Code.purs
View file @
612500c8
...
...
@@ -141,7 +141,7 @@ corpusCodeViewCpt = here.component "corpusCodeView" cpt where
, session }
liftEffect $ do
_ <- case res of
Left err -> here.
log
2 "[corpusLayoutView] onClickSave RESTError" err
Left err -> here.
warn
2 "[corpusLayoutView] onClickSave RESTError" err
_ -> pure unit
T2.reload reload
...
...
src/Gargantext/Components/Nodes/Corpus/Dashboard.purs
View file @
612500c8
...
...
@@ -79,7 +79,7 @@ dashboardLayoutWithKeyCpt = here.component "dashboardLayoutWithKey" cpt
, session }
liftEffect $ do
_ <- case res of
Left err -> here.
log
2 "[dashboardLayoutWithKey] onChange RESTError" err
Left err -> here.
warn
2 "[dashboardLayoutWithKey] onChange RESTError" err
_ -> pure unit
T2.reload reload
...
...
src/Gargantext/Components/Table.purs
View file @
612500c8
...
...
@@ -195,7 +195,7 @@ save {fields, session, nodeId} = do
res <- saveCorpus $ {hyperdata: Hyperdata {fields}, session, nodeId}
liftEffect $ do
_ <- case res of
Left err -> here.
log
2 "[corpusLayoutView] onClickSave RESTError" err
Left err -> here.
warn
2 "[corpusLayoutView] onClickSave RESTError" err
_ -> pure unit
pure unit
...
...
@@ -205,7 +205,7 @@ saveCorpusName {name, session, nodeId} = do
res <- rename session nodeId $ RenameValue {text: name}
liftEffect $ do
_ <- case res of
Left err -> here.
log
2 "[corpusLayoutView] onClickSave RESTError" err
Left err -> here.
warn
2 "[corpusLayoutView] onClickSave RESTError" err
_ -> pure unit
pure unit
...
...
src/Gargantext/Config/REST.purs
View file @
612500c8
...
...
@@ -45,9 +45,9 @@ instance Eq RESTError where
eq _ _ = false
logRESTError :: R2.Here -> String -> RESTError -> Effect Unit
logRESTError here prefix (SendResponseError e) = here.
log
2 (prefix <> " SendResponseError ") e -- TODO: No show
logRESTError here prefix (ReadJSONError e) = here.
log
2 (prefix <> " ReadJSONError ") $ show e
logRESTError here prefix (CustomError e) = here.
log
2 (prefix <> " CustomError ") $ e
logRESTError here prefix (SendResponseError e) = here.
warn
2 (prefix <> " SendResponseError ") e -- TODO: No show
logRESTError here prefix (ReadJSONError e) = here.
warn
2 (prefix <> " ReadJSONError ") $ show e
logRESTError here prefix (CustomError e) = here.
warn
2 (prefix <> " CustomError ") $ e
type AffRESTError a = Aff (Either RESTError a)
...
...
src/Gargantext/Config/Utils.purs
View file @
612500c8
...
...
@@ -24,7 +24,7 @@ handleRESTError :: forall a.
-> Aff Unit
handleRESTError errors (Left error) _ = liftEffect $ do
T.modify_ (A.cons $ FRESTError { error }) errors
here.
log
2 "[handleTaskError] RESTError" error
here.
warn
2 "[handleTaskError] RESTError" error
handleRESTError _ (Right task) handler = handler task
handleErrorInAsyncProgress :: T.Box (Array FrontendError)
...
...
src/Gargantext/Hooks/Sigmax.purs
View file @
612500c8
module Gargantext.Hooks.Sigmax
where
import Prelude
( Unit, bind, discard, flip, map, not, pure, unit
, ($), (&&), (*>), (<<<), (<>), (>>=))
import DOM.Simple.Types (Element)
import Data.Array as A
import Data.Either (either)
import Data.Foldable (sequence_, foldl)
...
...
@@ -15,19 +13,18 @@ import Data.Sequence as Seq
import Data.Set as Set
import Data.Traversable (traverse_)
import Data.Tuple (Tuple(..))
import Data.Tuple.Nested((/\))
import DOM.Simple.Console (log, log2)
import DOM.Simple.Types (Element)
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect.Class.Console (error)
import Effect.Timer (TimeoutId, clearTimeout)
import FFI.Simple ((.=))
import Reactix as R
import Toestand as T
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 Prelude (Unit, bind, discard, flip, map, not, pure, unit, ($), (&&), (*>), (<<<), (<>), (>>=))
import Reactix as R
import Toestand as T
type Sigma =
{ sigma :: R.Ref (Maybe Sigma.Sigma)
...
...
@@ -37,6 +34,12 @@ type Sigma =
type Data n e = { graph :: R.Ref (ST.Graph n e) }
moduleName :: R2.Module
moduleName = "Gargantext.Hooks.Sigmax"
console :: C.Console
console = C.encloseContext C.Main moduleName
initSigma :: R.Hooks Sigma
initSigma = do
s <- R2.nothingRef
...
...
@@ -69,21 +72,21 @@ cleanupSigma sigma context = traverse_ kill (readSigma sigma)
killSigma = Sigma.killSigma sig >>= report
runCleanups = sequence_ (R.readRef sigma.cleanup)
emptyOut = writeSigma sigma Nothing *> R.setRef sigma.cleanup Seq.empty
report = either (
log2 errorMsg) (\_ ->
log successMsg)
report = either (
console.log2 errorMsg) (\_ -> console.
log successMsg)
prefix = "[" <> context <> "] "
errorMsg = prefix <> "Error killing sigma:"
successMsg = prefix <> "Killed sigma"
refreshData :: forall n e. Sigma.Sigma -> Sigma.Graph n e -> Effect Unit
refreshData sigma graph
= log clearingMsg
=
console.
log clearingMsg
*> Sigma.clear sigmaGraph
*> log readingMsg
*>
console.
log readingMsg
*> Sigma.graphRead sigmaGraph graph
>>= either (log2 errorMsg) refresh
>>= either (
console.
log2 errorMsg) refresh
where
sigmaGraph = Sigma.graph sigma
refresh _ = log refreshingMsg *> Sigma.refresh sigma
refresh _ =
console.
log refreshingMsg *> Sigma.refresh sigma
clearingMsg = "[refreshData] Clearing existing graph data"
readingMsg = "[refreshData] Reading graph data"
refreshingMsg = "[refreshData] Refreshing graph"
...
...
@@ -98,13 +101,13 @@ sigmafy (ST.Graph g) = {nodes,edges}
dependOnSigma :: Sigma -> String -> (Sigma.Sigma -> Effect Unit) -> Effect Unit
dependOnSigma sigma notFoundMsg f = do
case readSigma sigma of
Nothing ->
log
notFoundMsg
Nothing ->
console.warn
notFoundMsg
Just sig -> f sig
dependOnContainer :: R.Ref (Nullable Element) -> String -> (Element -> Effect Unit) -> Effect Unit
dependOnContainer container notFoundMsg f = do
case R.readNullableRef container of
Nothing ->
log
notFoundMsg
Nothing ->
console.warn
notFoundMsg
Just c -> f c
...
...
src/Gargantext/Utils/Console.js
0 → 100644
View file @
612500c8
"use strict"
;
/**
* Get Creation Date
* @return {string}
*/
exports
.
getCreationDate
=
function
()
{
return
new
Date
().
toLocaleTimeString
()
}
src/Gargantext/Utils/Console.purs
0 → 100644
View file @
612500c8
module Gargantext.Utils.Console
( Console
, encloseContext
, CalleeType(..)
, LogType(..)
, print, print2, print3
) where
import Gargantext.Prelude
import DOM.Simple.Console (log5, log6, log7)
import Data.Array (unsafeIndex)
import Data.String (Pattern(..), Replacement(..), replace)
import Effect (Effect)
import Partial.Unsafe (unsafePartial)
foreign import getCreationDate :: Effect String -- @TODO not using FFI
type CalleeName = String
data CalleeType
= Main
data LogType
= Log
| Error
| Warn
| Info
derive instance eqLogType :: Eq LogType
type Console =
{ log :: forall a. a -> Effect Unit
, error :: forall a. a -> Effect Unit
, warn :: forall a. a -> Effect Unit
, info :: forall a. a -> Effect Unit
, log2 :: forall a b. a -> b -> Effect Unit
, error2 :: forall a b. a -> b -> Effect Unit
, warn2 :: forall a b. a -> b -> Effect Unit
, info2 :: forall a b. a -> b -> Effect Unit
, log3 :: forall a b c. a -> b -> c -> Effect Unit
, error3 :: forall a b c. a -> b -> c -> Effect Unit
, warn3 :: forall a b c. a -> b -> c -> Effect Unit
, info3 :: forall a b c. a -> b -> c -> Effect Unit
}
-- | Logging as JavaScript fancy way
-- |
-- | Enclose the appling context
-- | ```purescript
-- | console :: Console
-- | console = encloseContext "page" "reactix"
-- | ```
-- |
-- | And reuse it as a native JavaScript call
-- | ```purescript
-- | console.log2 "catch something" somethingRecord
-- | ```
encloseContext :: CalleeType -> CalleeName -> Console
encloseContext a b =
{ log : print a b Log
, error : print a b Error
, warn : print a b Warn
, info : print a b Info
, log2 : print2 a b Log
, error2 : print2 a b Error
, warn2 : print2 a b Warn
, info2 : print2 a b Info
, log3 : print3 a b Log
, error3 : print3 a b Error
, warn3 : print3 a b Warn
, info3 : print3 a b Info
}
bulletContent :: LogType -> String
bulletContent Log = "▷"
bulletContent _ = "▶"
bulletStyle :: LogType -> String
bulletStyle s = replace (Pattern "%s") (Replacement s') bulletCSS
where
s' = case s of
Error -> "#BF3F3F"
Warn -> "#D4CC5B"
Info -> "#69A1F0"
Log -> "#A9A9A9"
calleeStyle :: CalleeType -> String
calleeStyle s = replace (Pattern "%s") (Replacement s') calleeCSS
where
s' = case s of
Main -> "#E9ECEF"
print :: forall a. CalleeType -> CalleeName -> LogType -> a -> Effect Unit
print s s' s'' a = do
cells <- mkCells s s' s''
log5 (unsafePartial $ unsafeIndex cells 0)
(unsafePartial $ unsafeIndex cells 1)
(unsafePartial $ unsafeIndex cells 2)
(unsafePartial $ unsafeIndex cells 3)
a
print2 :: forall a b. CalleeType -> CalleeName -> LogType -> a -> b -> Effect Unit
print2 s s' s'' a b = do
cells <- mkCells s s' s''
log6 (unsafePartial $ unsafeIndex cells 0)
(unsafePartial $ unsafeIndex cells 1)
(unsafePartial $ unsafeIndex cells 2)
(unsafePartial $ unsafeIndex cells 3)
a b
print3 :: forall a b c. CalleeType -> CalleeName -> LogType -> a -> b -> c -> Effect Unit
print3 s s' s'' a b c = do
cells <- mkCells s s' s''
log7 (unsafePartial $ unsafeIndex cells 0)
(unsafePartial $ unsafeIndex cells 1)
(unsafePartial $ unsafeIndex cells 2)
(unsafePartial $ unsafeIndex cells 3)
a b c
mkCells :: CalleeType -> CalleeName -> LogType -> Effect (Array String)
mkCells calleeType calleeName logType = do
date <- getCreationDate
-- First cell: containing a concatenation of string with style signs "%c"
cell1 <- pure $ ("%c" <> bulletContent logType <> "%c" <> date <> "%c" <> calleeName)
-- Second cell: providing style for the first "%c"
cell2 <- pure $ bulletStyle $ logType
-- Third cell: idem
cell3 <- pure $ creationDateCSS
-- Fourth cell: idem
cell4 <- pure $ calleeStyle calleeType
pure $ [ cell1, cell2, cell3, cell4 ]
-- Next cells can either be in couple (content + style) or content one only
--------------------------------------------------------------------
bulletCSS :: String
bulletCSS = "color: %s; padding: 4px 5px; font-weight: bold;"
calleeCSS :: String
calleeCSS = "color: #495057; background: %s; padding: 4px 5px; font-size: 10px;"
creationDateCSS :: String
creationDateCSS = "font-size: 9px; padding: 4px 5px;"
src/Gargantext/Utils/Reactix.purs
View file @
612500c8
...
...
@@ -24,6 +24,7 @@ import Effect.Class (liftEffect)
import Effect.Exception (error)
import Effect.Uncurried (EffectFn1, EffectFn3, mkEffectFn1, mkEffectFn2, runEffectFn1, runEffectFn3)
import FFI.Simple (applyTo, args2, args3, defineProperty, delay, getProperty, (..), (...), (.=))
import Gargantext.Utils.Console as Console
import Partial.Unsafe (unsafePartial)
import React (class ReactPropFields, Children, ReactClass, ReactElement)
import React as React
...
...
@@ -88,16 +89,38 @@ type Module = String
type Here =
{ component :: forall p. String -> R.HooksComponent p -> R.Component p
, log :: forall l. l -> Effect Unit
, log2 :: forall l. String -> l -> Effect Unit
, ntComponent :: forall p. String -> NTHooksComponent p -> NTComponent p }
, ntComponent :: forall p. String -> NTHooksComponent p -> NTComponent p
, log :: forall a. a -> Effect Unit
, error :: forall a. a -> Effect Unit
, warn :: forall a. a -> Effect Unit
, info :: forall a. a -> Effect Unit
, log2 :: forall a b. a -> b -> Effect Unit
, error2 :: forall a b. a -> b -> Effect Unit
, warn2 :: forall a b. a -> b -> Effect Unit
, info2 :: forall a b. a -> b -> Effect Unit
, log3 :: forall a b c. a -> b -> c -> Effect Unit
, error3 :: forall a b c. a -> b -> c -> Effect Unit
, warn3 :: forall a b c. a -> b -> c -> Effect Unit
, info3 :: forall a b c. a -> b -> c -> Effect Unit
}
here :: Module -> Here
here mod =
{ component: R.hooksComponentWithModule mod
, log: log2 ("[" <> mod <> "]")
, log2: \msg -> log2 ("[" <> mod <> "] " <> msg)
, ntComponent: ntHooksComponentWithModule mod }
, ntComponent: ntHooksComponentWithModule mod
, log: Console.print Console.Main mod Console.Log
, log2: Console.print2 Console.Main mod Console.Log
, log3: Console.print3 Console.Main mod Console.Log
, error: Console.print Console.Main mod Console.Error
, error2: Console.print2 Console.Main mod Console.Error
, error3: Console.print3 Console.Main mod Console.Error
, warn: Console.print Console.Main mod Console.Warn
, warn2: Console.print2 Console.Main mod Console.Warn
, warn3: Console.print3 Console.Main mod Console.Warn
, info: Console.print Console.Main mod Console.Info
, info2: Console.print2 Console.Main mod Console.Info
, info3: Console.print3 Console.Main mod Console.Info
}
-- newtypes
type NTHooksComponent props = props -> Array R.Element -> R.Hooks R.Element
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment