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
62f1d05e
Commit
62f1d05e
authored
Jan 03, 2023
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ngrams] list CSV/JSON download options
parent
00cf0b5f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
18 deletions
+50
-18
Download.purs
...rgantext/Components/Forest/Tree/Node/Action/Download.purs
+45
-14
Box.purs
src/Gargantext/Components/Forest/Tree/Node/Box.purs
+3
-3
Tools.purs
src/Gargantext/Components/Forest/Tree/Node/Tools.purs
+2
-1
No files found.
src/Gargantext/Components/Forest/Tree/Node/Action/Download.purs
View file @
62f1d05e
...
...
@@ -58,41 +58,70 @@ actionDownloadGraphCpt = here.component "actionDownloadGraph" cpt where
href = url session $ Routes.NodeAPI GT.Graph (Just id) "gexf"
info = "Info about the Graph as GEXF format"
data NodeListDownloadFormat = NL_CSV | NL_JSON
derive instance Eq NodeListDownloadFormat
derive instance Generic NodeListDownloadFormat _
instance Show NodeListDownloadFormat
where
show NL_CSV = "CSV"
show NL_JSON = "JSON"
readNodeListDownloadFormat :: String -> NodeListDownloadFormat
readNodeListDownloadFormat "CSV" = NL_CSV
readNodeListDownloadFormat "JSON" = NL_JSON
readNodeListDownloadFormat _ = NL_JSON
actionDownloadNodeList :: R2.Component ActionDownload
actionDownloadNodeList = R.createElement actionDownloadNodeListCpt
actionDownloadNodeListCpt :: R.Component ActionDownload
actionDownloadNodeListCpt = here.component "actionDownloadNodeList" cpt where
cpt { id, session } _ = do
pure $ panel [ H.div {} [H.text info] ]
(submitButtonHref DownloadNode href)
downloadFormat <- T.useBox NL_JSON
downloadFormat' <- T.useLive T.unequal downloadFormat
pure $ panel
[ R2.select { className: "form-control"
, defaultValue: show downloadFormat'
, on: { change: onChange downloadFormat } }
[ opt NL_CSV downloadFormat
, opt NL_JSON downloadFormat ]
, H.div {} [ H.text $ info downloadFormat' ]
]
(submitButtonHref DownloadNode $ href downloadFormat')
where
href = url session $ Routes.NodeAPI GT.NodeList (Just id) ""
info = "Info about the List as JSON format"
opt t downloadFormat = H.option { value: show t } [ H.text $ show t ]
where
onClick _ = T.write_ t downloadFormat
onChange downloadFormat e = T.write_ (readNodeListDownloadFormat $ R.unsafeEventValue e) downloadFormat
href :: NodeListDownloadFormat -> String
href t = url session $ Routes.NodeAPI GT.NodeList (Just id) (toLower $ show t)
info :: NodeListDownloadFormat -> String
info t = "Info about the Documents as " <> show t <> " format"
data NodeTextsDownloadFormat =
CSV |
JSON
data NodeTextsDownloadFormat =
NT_CSV | NT_
JSON
derive instance Eq NodeTextsDownloadFormat
derive instance Generic NodeTextsDownloadFormat _
instance Show NodeTextsDownloadFormat where show = genericShow
readDownloadFormat :: String -> NodeTextsDownloadFormat
read
DownloadFormat "CSV" =
CSV
read
DownloadFormat "JSON" =
JSON
read
DownloadFormat _ =
JSON
read
NodeTexts
DownloadFormat :: String -> NodeTextsDownloadFormat
read
NodeTextsDownloadFormat "CSV" = NT_
CSV
read
NodeTextsDownloadFormat "JSON" = NT_
JSON
read
NodeTextsDownloadFormat _ = NT_
JSON
actionDownloadNodeTexts :: R2.Component ActionDownload
actionDownloadNodeTexts = R.createElement actionDownloadNodeTextsCpt
actionDownloadNodeTextsCpt :: R.Component ActionDownload
actionDownloadNodeTextsCpt = here.component "actionDownloadNodeTexts" cpt where
cpt { id, session } _ = do
downloadFormat <- T.useBox JSON
downloadFormat <- T.useBox
NT_
JSON
downloadFormat' <- T.useLive T.unequal downloadFormat
pure $ panel
[ R2.select { className: "form-control"
, defaultValue: show downloadFormat'
, on: { change: onChange downloadFormat } }
[ opt CSV downloadFormat
, opt JSON downloadFormat ]
[ opt
NT_
CSV downloadFormat
, opt
NT_
JSON downloadFormat ]
, H.div {} [ H.text $ info downloadFormat' ]
]
(submitButtonHref DownloadNode $ href downloadFormat')
...
...
@@ -100,8 +129,10 @@ actionDownloadNodeTextsCpt = here.component "actionDownloadNodeTexts" cpt where
opt t downloadFormat = H.option { value: show t } [ H.text $ show t ]
where
onClick _ = T.write_ t downloadFormat
onChange downloadFormat e = T.write_ (readDownloadFormat $ R.unsafeEventValue e) downloadFormat
onChange downloadFormat e = T.write_ (readNodeTextsDownloadFormat $ R.unsafeEventValue e) downloadFormat
href :: NodeTextsDownloadFormat -> String
href t = url session $ Routes.NodeAPI GT.NodeTexts (Just id) ("export/" <> (toLower $ show t))
info :: NodeTextsDownloadFormat -> String
info t = "Info about the Documents as " <> show t <> " format"
{-
...
...
src/Gargantext/Components/Forest/Tree/Node/Box.purs
View file @
62f1d05e
...
...
@@ -47,9 +47,9 @@ type CommonProps =
)
nodePopupView :: R2.Leaf NodePopupProps
nodePopupView = R2.leafComponent nodePopupCpt
nodePopupCpt :: R.Component NodePopupProps
nodePopupCpt = here.component "nodePopupView" cpt where
nodePopupView = R2.leafComponent nodePopup
View
Cpt
nodePopup
View
Cpt :: R.Component NodePopupProps
nodePopup
View
Cpt = here.component "nodePopupView" cpt where
cpt p@{ id, name, nodeType } _ = do
renameIsOpen <- T.useBox false
open <- T.useLive T.unequal renameIsOpen
...
...
src/Gargantext/Components/Forest/Tree/Node/Tools.purs
View file @
62f1d05e
...
...
@@ -212,7 +212,8 @@ type Href = String
submitButtonHref :: Action -> Href -> R.Element
submitButtonHref action href =
H.a { className, href, target: "_blank" } [ H.text $ " " <> text action ] where
H.a { className, href, target: "_blank" } [ H.text $ " " <> text action ]
where
className = "btn btn-primary fa fa-" <> icon action
------------------------------------------------------------------------
...
...
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