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
140
Issues
140
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
gargantext
purescript-gargantext
Commits
f1330411
Commit
f1330411
authored
Jul 22, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-graph' into dev-merge
parents
a0df81cd
8c37dc08
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
89 additions
and
22 deletions
+89
-22
CodeEditor.css
dist/styles/CodeEditor.css
+4
-0
CodeEditor.sass
dist/styles/CodeEditor.sass
+3
-0
CodeEditor.purs
src/Gargantext/Components/CodeEditor.purs
+15
-2
GraphExplorer.purs
src/Gargantext/Components/GraphExplorer.purs
+6
-4
Controls.purs
src/Gargantext/Components/GraphExplorer/Controls.purs
+1
-1
Sidebar.purs
src/Gargantext/Components/GraphExplorer/Sidebar.purs
+3
-3
Types.purs
src/Gargantext/Components/GraphExplorer/Types.purs
+3
-3
Corpus.purs
src/Gargantext/Components/Nodes/Corpus.purs
+27
-7
Types.purs
src/Gargantext/Components/Nodes/Corpus/Types.purs
+27
-2
No files found.
dist/styles/CodeEditor.css
View file @
f1330411
...
...
@@ -109,6 +109,10 @@
font-family
:
Fira
code
,
Fira
Mono
,
Consolas
,
Menlo
,
Courier
,
monospace
;
white-space
:
pre
;
}
.code-editor
.editor
.html.language-python
{
font-family
:
Fira
code
,
Fira
Mono
,
Consolas
,
Menlo
,
Courier
,
monospace
;
white-space
:
pre
;
}
.code-editor
.editor
.html.language-json
{
font-family
:
Fira
code
,
Fira
Mono
,
Consolas
,
Menlo
,
Courier
,
monospace
;
white-space
:
pre
;
...
...
dist/styles/CodeEditor.sass
View file @
f1330411
...
...
@@ -89,6 +89,9 @@
&
.language-haskell
font-family
:
Fira
code
,
Fira
Mono
,
Consolas
,
Menlo
,
Courier
,
monospace
white-space
:
pre
&
.language-python
font-family
:
Fira
code
,
Fira
Mono
,
Consolas
,
Menlo
,
Courier
,
monospace
white-space
:
pre
&
.language-json
font-family
:
Fira
code
,
Fira
Mono
,
Consolas
,
Menlo
,
Courier
,
monospace
white-space
:
pre
...
...
src/Gargantext/Components/CodeEditor.purs
View file @
f1330411
...
...
@@ -28,7 +28,8 @@ type Code = String
type Html = String
type Error = String
data CodeType = Haskell | JSON | Markdown
data CodeType = Haskell | JSON | Markdown | Python
derive instance genericCodeType :: Generic CodeType _
instance eqCodeType :: Eq CodeType where
eq = genericEq
...
...
@@ -56,6 +57,7 @@ codeNlFix _ c = if endsWith "\n" c then (c <> " ") else c
render :: CodeType -> Code -> Either Error Html
render Haskell code = Right $ renderHaskell $ codeNlFix Haskell code
render Python code = Right $ renderPython $ codeNlFix Python code
render JSON code = result
where
parsedE = jsonParser code
...
...
@@ -67,8 +69,13 @@ render Markdown code = Right $ renderMd $ codeNlFix Markdown code
previewPostProcess :: CodeType -> Element -> Effect Unit
previewPostProcess Haskell htmlEl = do
HLJS.highlightBlock htmlEl
previewPostProcess Python htmlEl = do
HLJS.highlightBlock htmlEl
previewPostProcess JSON htmlEl = do
HLJS.highlightBlock htmlEl
previewPostProcess Markdown _ = pure unit
-- TODO Replace with markdown-it?
...
...
@@ -84,6 +91,10 @@ renderMd = renderMd' MD.defaultToMarkupOptions
renderHaskell :: String -> String
renderHaskell s = s
renderPython :: String -> String
renderPython s = s
codeEditor :: Record Props -> R.Element
codeEditor p = R.createElement codeEditorCpt p []
...
...
@@ -144,6 +155,7 @@ codeEditorCpt = R.hooksComponent "G.C.CE.CodeEditor" cpt
langClass Haskell = " language-haskell"
langClass JSON = " language-json"
langClass Markdown = " language-md"
langClass Python = " language-python"
previewHidden :: ViewType -> String
previewHidden Preview = ""
...
...
@@ -244,7 +256,7 @@ codeTypeSelectorCpt = R.hooksComponent "G.C.CE.CodeTypeSelector" cpt
, on: { change: onSelectChange codeType onChange }
, style: { width: "150px" }
}
(option <$> [
Haskell, JSON, Markdow
n])
(option <$> [
JSON, Markdown, Haskell, Pytho
n])
option :: CodeType -> R.Element
option value = H.option { value: show value } [ H.text $ show value ]
...
...
@@ -255,6 +267,7 @@ codeTypeSelectorCpt = R.hooksComponent "G.C.CE.CodeTypeSelector" cpt
"Haskell" -> Haskell
"JSON" -> JSON
"Markdown" -> Markdown
"Python" -> Python
_ -> Markdown
setCodeType $ const codeType
onChange codeType
...
...
src/Gargantext/Components/GraphExplorer.purs
View file @
f1330411
...
...
@@ -116,9 +116,9 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
RH.div
{ id: "graph-explorer" }
[ rowToggle
[ col [
pullLeft [ Toggle.treeToggleButton controls.showTree ]
]
, col [
Toggle.controlsToggleButton controls.showControls
]
, col [
pullRight [ Toggle.sidebarToggleButton controls.showSidePanel ]
]
[ col [
spaces [ Toggle.treeToggleButton controls.showTree ]
]
, col [
spaces [ Toggle.controlsToggleButton controls.showControls ]
]
, col [
spaces [ Toggle.sidebarToggleButton controls.showSidePanel ]
]
], R2.row
[ outer
[ inner
...
...
@@ -158,8 +158,10 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
rowToggle = RH.div { id: "toggle-container" }
rowControls = RH.div { id: "controls-container" }
col = RH.div { className: "col-md-4" }
pullLeft = RH.div { className: "pull-left" }
pullLeft = RH.div { className: "pull-left"
}
pullRight = RH.div { className: "pull-right" }
spaces = RH.div { className: "flex-space-between" }
tree :: Record TreeProps -> R.Element
tree { show: false } = RH.div { id: "tree" } []
...
...
src/Gargantext/Components/GraphExplorer/Controls.purs
View file @
f1330411
...
...
@@ -94,7 +94,7 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
-- Automatic opening of sidebar when a node is selected (but only first time).
R.useEffect' $ do
if fst props.showSidePanel == GET.InitialClosed && (not Set.isEmpty $ fst props.selectedNodeIds) then
snd props.showSidePanel $ \_ -> GET.Opened GET.SideTab
Selection
snd props.showSidePanel $ \_ -> GET.Opened GET.SideTab
Data
else
pure unit
...
...
src/Gargantext/Components/GraphExplorer/Sidebar.purs
View file @
f1330411
...
...
@@ -57,7 +57,7 @@ sidebarCpt = R.hooksComponent "Sidebar" cpt
pure $ RH.div {} []
cpt props@{metaData, showSidePanel} _children = do
pure $ RH.div { id: "sp-container" }
[ sideTabNav showSidePanel [SideTabLegend, SideTab
Selection, SideTabPairing
]
[ sideTabNav showSidePanel [SideTabLegend, SideTab
Data, SideTabCommunity
]
, sideTab (fst showSidePanel) props
]
...
...
@@ -83,7 +83,7 @@ sideTab (Opened SideTabLegend) props@{metaData} =
let (GET.MetaData {legend}) = metaData
in Legend.legend { items: Seq.fromFoldable legend}
sideTab (Opened SideTab
Selection
) props =
sideTab (Opened SideTab
Data
) props =
RH.div {} [ R2.row [ R2.col 12
[ RH.ul { id: "myTab", className: "nav nav-tabs", role: "tablist"}
[ RH.div { className: "tab-content" }
...
...
@@ -99,7 +99,7 @@ sideTab (Opened SideTabSelection) props =
, removeButton "Move as stop" StopTerm props nodesMap
]
]
]
, RH.div { className: "col-md-12", id: "query" }
[ query props.frontends
...
...
src/Gargantext/Components/GraphExplorer/Types.purs
View file @
f1330411
...
...
@@ -192,13 +192,13 @@ intColor i = unsafePartial $ fromJust $ defaultPalette !! (i `mod` length defaul
data SidePanelState = InitialClosed | Opened SideTab | Closed
derive instance eqSidePanelState :: Eq SidePanelState
data SideTab = SideTabLegend | SideTab
Selection | SideTabPairing
data SideTab = SideTabLegend | SideTab
Data | SideTabCommunity
derive instance eqSideTab :: Eq SideTab
instance showSideTab :: Show SideTab where
show SideTabLegend = "Legend"
show SideTab
Selection = "Navigation
"
show SideTab
Pairing = "Pairing
"
show SideTab
Data = "Data
"
show SideTab
Community = "Community
"
...
...
src/Gargantext/Components/Nodes/Corpus.purs
View file @
f1330411
...
...
@@ -20,7 +20,7 @@ import Gargantext.Prelude
import Gargantext.Components.CodeEditor as CE
import Gargantext.Components.Node (NodePoly(..), HyperdataList)
import Gargantext.Components.Nodes.Corpus.Types (CorpusData, FTField, Field(..), FieldType(..), Hash, Hyperdata(..), defaultField, defaultHaskell', defaultJSON', defaultMarkdown')
import Gargantext.Components.Nodes.Corpus.Types (CorpusData, FTField, Field(..), FieldType(..), Hash, Hyperdata(..), defaultField, defaultHaskell', default
Python', default
JSON', defaultMarkdown')
import Gargantext.Data.Array as GDA
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes (SessionRoute(NodeAPI, Children))
...
...
@@ -312,25 +312,45 @@ fieldCodeEditorCpt = R.hooksComponent "G.C.N.C.fieldCodeEditorCpt" cpt
where
cpt {field: Field {typ: typ@(Haskell {haskell})}, onChange} _ = do
pure $ CE.codeEditor {code: haskell, defaultCodeType: CE.Haskell, onChange: changeCode onChange typ}
cpt {field: Field {typ: typ@(Python {python})}, onChange} _ = do
pure $ CE.codeEditor {code: python, defaultCodeType: CE.Python, onChange: changeCode onChange typ}
cpt {field: Field {typ: typ@(JSON j)}, onChange} _ = do
pure $ CE.codeEditor {code, defaultCodeType: CE.JSON, onChange: changeCode onChange typ}
where
code = R2.stringify (encodeJson j) 2
cpt {field: Field {typ: typ@(Markdown {text})}, onChange} _ = do
pure $ CE.codeEditor {code: text, defaultCodeType: CE.Markdown, onChange: changeCode onChange typ}
-- Per
of
rms the matrix of code type changes
-- Per
fo
rms the matrix of code type changes
-- (FieldType -> Effect Unit) is the callback function for fields array
-- FieldType is the current element that we will modify
-- CE.CodeType is the editor code type (might have been the cause of the trigger)
-- CE.Code is the editor code (might have been the cause of the trigger)
changeCode :: (FieldType -> Effect Unit) -> FieldType -> CE.CodeType -> CE.Code -> Effect Unit
changeCode onc (Haskell hs) CE.Haskell c = onc $ Haskell $ hs { haskell = c }
changeCode onc (Haskell {haskell}) CE.JSON c = onc $ JSON $ defaultJSON' { desc = haskell }
changeCode onc (Haskell hs) CE.Haskell c = onc $ Haskell $ hs { haskell = c }
changeCode onc (Haskell hs) CE.Python c = onc $ Python $ defaultPython' { python = c }
changeCode onc (Haskell {haskell}) CE.JSON c = onc $ JSON $ defaultJSON' { desc = haskell }
changeCode onc (Haskell {haskell}) CE.Markdown c = onc $ Markdown $ defaultMarkdown' { text = haskell }
changeCode onc (Python hs) CE.Python c = onc $ Python $ hs { python = c }
changeCode onc (Python hs) CE.Haskell c = onc $ Haskell $ defaultHaskell' { haskell = c }
changeCode onc (Python {python}) CE.JSON c = onc $ JSON $ defaultJSON' { desc = python }
changeCode onc (Python {python}) CE.Markdown c = onc $ Markdown $ defaultMarkdown' { text = python }
changeCode onc (Markdown md) CE.Haskell c = onc $ Haskell $ defaultHaskell' { haskell = c }
changeCode onc (Markdown md) CE.Python c = onc $ Python $ defaultPython' { python = c }
changeCode onc (Markdown md) CE.JSON c = onc $ Markdown $ defaultMarkdown' { text = c }
changeCode onc (Markdown md) CE.Markdown c = onc $ Markdown $ md { text = c }
changeCode onc (JSON j@{desc}) CE.Haskell c = onc $ Haskell $ defaultHaskell' { haskell = haskell }
where
haskell = R2.stringify (encodeJson j) 2
changeCode onc (JSON j@{desc}) CE.Python c = onc $ Python $ defaultPython' { python = toCode }
where
toCode = R2.stringify (encodeJson j) 2
changeCode onc (JSON j) CE.JSON c = do
case jsonParser c of
Left err -> log2 "[fieldCodeEditor'] cannot parse json" c
...
...
@@ -340,9 +360,9 @@ changeCode onc (JSON j) CE.JSON c = do
changeCode onc (JSON j) CE.Markdown c = onc $ Markdown $ defaultMarkdown' { text = text }
where
text = R2.stringify (encodeJson j) 2
changeCode onc (Markdown md) CE.Haskell c = onc $ Haskell $ defaultHaskell' { haskell = c }
changeCode onc (Markdown md) CE.JSON c = onc $ Markdown $ defaultMarkdown' { text = c }
changeCode onc (Markdown md) CE.Markdown c = onc $ Markdown $ md { text = c }
type LoadProps =
( nodeId :: Int
...
...
src/Gargantext/Components/Nodes/Corpus/Types.purs
View file @
f1330411
...
...
@@ -52,6 +52,10 @@ data FieldType =
Haskell { haskell :: HaskellCode
, tag :: Tag
}
| Python { python :: HaskellCode
, tag :: Tag
}
| JSON { authors :: Author
, desc :: Description
, query :: Query
...
...
@@ -103,6 +107,12 @@ instance decodeFTField :: DecodeJson (Field FieldType) where
haskell <- data_ .: "haskell"
tag <- data_ .: "tag"
pure $ Haskell {haskell, tag}
"Python" -> do
python <- data_ .: "python"
tag <- data_ .: "tag"
pure $ Python {python, tag}
"JSON" -> do
authors <- data_ .: "authors"
desc <- data_ .: "desc"
...
...
@@ -124,8 +134,9 @@ instance encodeFTField :: EncodeJson (Field FieldType) where
~> "type" := typ' typ
~> jsonEmptyObject
where
typ' (Haskell _) = "Haskell"
typ' (JSON _) = "JSON"
typ' (Haskell _) = "Haskell"
typ' (Python _) = "Python"
typ' (JSON _) = "JSON"
typ' (Markdown _) = "Markdown"
instance encodeFieldType :: EncodeJson FieldType where
...
...
@@ -133,6 +144,12 @@ instance encodeFieldType :: EncodeJson FieldType where
"haskell" := haskell
~> "tag" := "HaskellField"
~> jsonEmptyObject
encodeJson (Python {python}) =
"python" := python
~> "tag" := "PythonField"
~> jsonEmptyObject
encodeJson (JSON {authors, desc, query, tag, title}) =
"authors" := authors
~> "desc" := desc
...
...
@@ -145,6 +162,14 @@ instance encodeFieldType :: EncodeJson FieldType where
~> "text" := text
~> jsonEmptyObject
defaultPython :: FieldType
defaultPython = Python defaultPython'
defaultPython' :: { python :: String, tag :: String }
defaultPython' = { python: "import Foo"
, tag : "PythonField"
}
defaultHaskell :: FieldType
defaultHaskell = Haskell defaultHaskell'
...
...
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