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
142
Issues
142
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
3b8f6267
Commit
3b8f6267
authored
Feb 25, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into dev-user-page
parents
9e228236
0e052718
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
324 additions
and
111 deletions
+324
-111
Login.css
dist/styles/Login.css
+11
-0
Login.sass
dist/styles/Login.sass
+11
-0
Tree.purs
src/Gargantext/Components/Forest/Tree.purs
+1
-1
Node.purs
src/Gargantext/Components/Forest/Tree/Node.purs
+5
-0
Upload.purs
...Gargantext/Components/Forest/Tree/Node/Action/Upload.purs
+145
-12
Box.purs
src/Gargantext/Components/Forest/Tree/Node/Box.purs
+151
-98
No files found.
dist/styles/Login.css
View file @
3b8f6267
...
@@ -211,4 +211,15 @@ a:focus, a:hover {
...
@@ -211,4 +211,15 @@ a:focus, a:hover {
cursor
:
pointer
;
cursor
:
pointer
;
}
}
.copy-from-corpus
.tree
.node
{
padding-left
:
10px
;
}
.copy-from-corpus
.tree
.node
.name.clickable
{
color
:
#337ab7
;
cursor
:
pointer
;
}
.copy-from-corpus
.tree
.node
.name.clickable
:hover
{
text-decoration
:
underline
;
}
/*# sourceMappingURL=Login.css.map */
/*# sourceMappingURL=Login.css.map */
dist/styles/Login.sass
View file @
3b8f6267
...
@@ -197,3 +197,14 @@ li
...
@@ -197,3 +197,14 @@ li
a
:focus
,
a
:hover
a
:focus
,
a
:hover
cursor
:
pointer
cursor
:
pointer
.copy-from-corpus
.tree
.node
padding-left
:
10px
.name
&
.clickable
color
:
#337ab7
cursor
:
pointer
&
:hover
text-decoration
:
underline
src/Gargantext/Components/Forest/Tree.purs
View file @
3b8f6267
src/Gargantext/Components/Forest/Tree/Node.purs
View file @
3b8f6267
...
@@ -22,6 +22,7 @@ data NodeAction = Documentation NodeType
...
@@ -22,6 +22,7 @@ data NodeAction = Documentation NodeType
| Move | Clone | Delete
| Move | Clone | Delete
| Share | Link NodeType
| Share | Link NodeType
| Add (Array NodeType)
| Add (Array NodeType)
| CopyFromCorpus
instance eqNodeAction :: Eq NodeAction where
instance eqNodeAction :: Eq NodeAction where
...
@@ -36,6 +37,7 @@ instance eqNodeAction :: Eq NodeAction where
...
@@ -36,6 +37,7 @@ instance eqNodeAction :: Eq NodeAction where
eq Share Share = true
eq Share Share = true
eq (Link x) (Link y) = true && (x == y)
eq (Link x) (Link y) = true && (x == y)
eq (Add x) (Add y) = true && (x == y)
eq (Add x) (Add y) = true && (x == y)
eq CopyFromCorpus CopyFromCorpus = true
eq _ _ = false
eq _ _ = false
instance showNodeAction :: Show NodeAction where
instance showNodeAction :: Show NodeAction where
...
@@ -50,6 +52,7 @@ instance showNodeAction :: Show NodeAction where
...
@@ -50,6 +52,7 @@ instance showNodeAction :: Show NodeAction where
show Share = "Share"
show Share = "Share"
show (Link x) = "Link to " <> show x
show (Link x) = "Link to " <> show x
show (Add xs) = foldl (\a b -> a <> show b) "Add " xs
show (Add xs) = foldl (\a b -> a <> show b) "Add " xs
show CopyFromCorpus = "Copy from corpus"
glyphiconNodeAction :: NodeAction -> String
glyphiconNodeAction :: NodeAction -> String
...
@@ -60,6 +63,7 @@ glyphiconNodeAction SearchBox = "search"
...
@@ -60,6 +63,7 @@ glyphiconNodeAction SearchBox = "search"
glyphiconNodeAction Upload = "upload"
glyphiconNodeAction Upload = "upload"
glyphiconNodeAction (Link _) = "transfer"
glyphiconNodeAction (Link _) = "transfer"
glyphiconNodeAction Download = "download"
glyphiconNodeAction Download = "download"
glyphiconNodeAction CopyFromCorpus = "random"
glyphiconNodeAction _ = ""
glyphiconNodeAction _ = ""
...
@@ -183,6 +187,7 @@ settingsBox NodeList = SettingsBox {
...
@@ -183,6 +187,7 @@ settingsBox NodeList = SettingsBox {
, edit : false
, edit : false
, doc : Documentation NodeList
, doc : Documentation NodeList
, buttons : [ Upload
, buttons : [ Upload
, CopyFromCorpus
, Download
, Download
, Delete
, Delete
]
]
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Upload.purs
View file @
3b8f6267
module Gargantext.Components.Forest.Tree.Node.Action.Upload where
module Gargantext.Components.Forest.Tree.Node.Action.Upload where
import
Prelude (class Show, Unit, bind, const, discard, map, pure, show, void, ($))
import
Data.Array as A
import Data.Maybe (Maybe(..), fromJust)
import Data.Maybe (Maybe(..), fromJust)
import Data.Newtype (class Newtype)
import Data.Newtype (class Newtype)
import Data.Tuple (Tuple(..))
import Data.Tuple (Tuple(..)
, fst, snd
)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log2)
import Effect.Aff (Aff, launchAff)
import Effect.Aff (Aff, launchAff)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Effect (Effect)
import Partial.Unsafe (unsafePartial)
import Partial.Unsafe (unsafePartial)
import React.SyntheticEvent as E
import React.SyntheticEvent as E
import Reactix as R
import Reactix as R
...
@@ -14,36 +16,38 @@ import Reactix.DOM.HTML as H
...
@@ -14,36 +16,38 @@ import Reactix.DOM.HTML as H
import URI.Extra.QueryPairs as QP
import URI.Extra.QueryPairs as QP
import Web.File.FileReader.Aff (readAsText)
import Web.File.FileReader.Aff (readAsText)
import Gargantext.Prelude
import Gargantext.Components.Data.Lang (readLang, Lang(..))
import Gargantext.Components.Data.Lang (readLang, Lang(..))
import Gargantext.Components.Forest.Tree.Node.Action
import Gargantext.Components.Forest.Tree.Node.Action
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes as GR
import Gargantext.Routes as GR
import Gargantext.Sessions (Session
, postWwwUrlencoded
)
import Gargantext.Sessions (Session
(..), postWwwUrlencoded, get
)
import Gargantext.Types as GT
import Gargantext.Types as GT
import Gargantext.Utils (id)
import Gargantext.Utils (id)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
type Props =
type Props =
( id :: Int
( dispatch :: Action -> Aff Unit
, id :: Int
, nodeType :: GT.NodeType
, nodeType :: GT.NodeType
, session :: Session
, session :: Session
)
)
uploadFileView ::
(Action -> Aff Unit) ->
Record Props -> R.Element
uploadFileView :: Record Props -> R.Element
uploadFileView
d props = R.createElement (uploadFileViewCpt d)
props []
uploadFileView
props = R.createElement uploadFileViewCpt
props []
uploadFileViewCpt ::
(Action -> Aff Unit) ->
R.Component Props
uploadFileViewCpt :: R.Component Props
uploadFileViewCpt
d = R.hooksComponent "
UploadFileView" cpt
uploadFileViewCpt
= R.hooksComponent "G.C.F.T.N.A.U.
UploadFileView" cpt
where
where
cpt {id, nodeType} _ = do
cpt {
dispatch: d,
id, nodeType} _ = do
mContents :: R.State (Maybe UploadFileContents) <- R.useState' Nothing
mContents :: R.State (Maybe UploadFileContents) <- R.useState' Nothing
fileType :: R.State FileType <- R.useState' CSV
fileType :: R.State FileType <- R.useState' CSV
lang :: R.State (Maybe Lang) <- R.useState' (Just EN)
lang :: R.State (Maybe Lang) <- R.useState' (Just EN)
pure $ H.div {} [
pure $ H.div {} [
H.div {} [ H.text "Upload file!" ]
H.div {} [ H.input { type: "file"
, H.div {} [ H.input { type: "file"
, placeholder: "Choose file"
, placeholder: "Choose file"
, on: {change: onChangeContents mContents}
, on: {change: onChangeContents mContents}
}
}
...
@@ -75,6 +79,7 @@ uploadFileViewCpt d = R.hooksComponent "UploadFileView" cpt
...
@@ -75,6 +79,7 @@ uploadFileViewCpt d = R.hooksComponent "UploadFileView" cpt
renderOptionLang :: Lang -> R.Element
renderOptionLang :: Lang -> R.Element
renderOptionLang opt = H.option {} [ H.text $ show opt ]
renderOptionLang opt = H.option {} [ H.text $ show opt ]
onChangeContents :: forall e. R.State (Maybe UploadFileContents) -> E.SyntheticEvent_ e -> Effect Unit
onChangeContents (mContents /\ setMContents) e = do
onChangeContents (mContents /\ setMContents) e = do
blob <- R2.inputFileBlob e
blob <- R2.inputFileBlob e
E.preventDefault e
E.preventDefault e
...
@@ -84,6 +89,7 @@ uploadFileViewCpt d = R.hooksComponent "UploadFileView" cpt
...
@@ -84,6 +89,7 @@ uploadFileViewCpt d = R.hooksComponent "UploadFileView" cpt
liftEffect $ do
liftEffect $ do
setMContents $ const $ Just $ UploadFileContents contents
setMContents $ const $ Just $ UploadFileContents contents
onChangeFileType :: forall e. R.State FileType -> e -> Effect Unit
onChangeFileType (fileType /\ setFileType) e = do
onChangeFileType (fileType /\ setFileType) e = do
setFileType $ const
setFileType $ const
$ unsafePartial
$ unsafePartial
...
@@ -91,6 +97,7 @@ uploadFileViewCpt d = R.hooksComponent "UploadFileView" cpt
...
@@ -91,6 +97,7 @@ uploadFileViewCpt d = R.hooksComponent "UploadFileView" cpt
$ readFileType
$ readFileType
$ R2.unsafeEventValue e
$ R2.unsafeEventValue e
onChangeLang :: forall e. R.State (Maybe Lang) -> e -> Effect Unit
onChangeLang (lang /\ setLang) e = do
onChangeLang (lang /\ setLang) e = do
setLang $ const
setLang $ const
$ unsafePartial
$ unsafePartial
...
@@ -234,3 +241,129 @@ uploadFile session nodeType id fileType (UploadFileContents fileContents) = do
...
@@ -234,3 +241,129 @@ uploadFile session nodeType id fileType (UploadFileContents fileContents) = do
Tuple "_wf_data" (Just fileContents)
Tuple "_wf_data" (Just fileContents)
, Tuple "_wf_filetype" (Just $ show fileType)
, Tuple "_wf_filetype" (Just $ show fileType)
]
]
uploadTermListView :: Record Props -> R.Element
uploadTermListView props = R.createElement uploadTermListViewCpt props []
uploadTermListViewCpt :: R.Component Props
uploadTermListViewCpt = R.hooksComponent "G.C.F.T.N.A.U.UploadTermListView" cpt
where
cpt {dispatch, id, nodeType} _ = do
mContents :: R.State (Maybe UploadFileContents) <- R.useState' Nothing
pure $ H.div {} [
H.div {} [ H.input { type: "file"
, placeholder: "Choose file"
, on: {change: onChangeContents mContents}
}
]
, H.div {} [ uploadTermButton { dispatch, id, mContents, nodeType } ]
]
onChangeContents :: forall e. R.State (Maybe UploadFileContents) -> E.SyntheticEvent_ e -> Effect Unit
onChangeContents (mContents /\ setMContents) e = do
blob <- R2.inputFileBlob e
E.preventDefault e
E.stopPropagation e
void $ launchAff do
contents <- readAsText blob
liftEffect $ do
setMContents $ const $ Just $ UploadFileContents contents
type UploadTermButtonProps =
(
dispatch :: Action -> Aff Unit
, id :: Int
, mContents :: R.State (Maybe UploadFileContents)
, nodeType :: GT.NodeType
)
uploadTermButton :: Record UploadTermButtonProps -> R.Element
uploadTermButton props = R.createElement uploadTermButtonCpt props []
uploadTermButtonCpt :: R.Component UploadTermButtonProps
uploadTermButtonCpt = R.hooksComponent "G.C.F.T.N.A.U.uploadTermButton" cpt
where
cpt {dispatch, id, mContents: (mContents /\ setMContents), nodeType} _ = do
pure $ H.button {className: "btn btn-primary", disabled, on: {click: onClick}} [ H.text "Upload" ]
where
disabled = case mContents of
Nothing -> "1"
Just _ -> ""
onClick e = do
let contents = unsafePartial $ fromJust mContents
void $ launchAff do
_ <- dispatch $ UploadFile nodeType CSV contents
liftEffect $ do
setMContents $ const $ Nothing
copyFromCorpusView :: Record Props -> R.Element
copyFromCorpusView props = R.createElement copyFromCorpusViewCpt props []
copyFromCorpusViewCpt :: R.Component Props
copyFromCorpusViewCpt = R.hooksComponent "G.C.F.T.N.A.U.copyFromCorpusView" cpt
where
cpt {dispatch, id, nodeType, session} _ = do
useLoader session loadCorporaTree $
\tree ->
copyFromCorpusViewLoaded {dispatch, id, nodeType, session, tree}
type CorpusTreeProps =
(
tree :: FTree
| Props
)
copyFromCorpusViewLoaded :: Record CorpusTreeProps -> R.Element
copyFromCorpusViewLoaded props = R.createElement copyFromCorpusViewLoadedCpt props []
copyFromCorpusViewLoadedCpt :: R.Component CorpusTreeProps
copyFromCorpusViewLoadedCpt = R.hooksComponent "G.C.F.T.N.A.U.copyFromCorpusViewLoadedCpt" cpt
where
cpt p@{dispatch, id, nodeType, session, tree} _ = do
pure $ H.div { className: "copy-from-corpus" } [
H.div { className: "tree" } [copyFromCorpusTreeView p]
]
copyFromCorpusTreeView :: Record CorpusTreeProps -> R.Element
copyFromCorpusTreeView props = R.createElement copyFromCorpusTreeViewCpt props []
copyFromCorpusTreeViewCpt :: R.Component CorpusTreeProps
copyFromCorpusTreeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.copyFromCorpusTreeViewCpt" cpt
where
cpt p@{id, tree: NTree (LNode { id: sourceId, name, nodeType }) ary} _ = do
pure $ {- H.div {} [ H.h5 { className: GT.fldr nodeType true} []
, -} H.div { className: "node" } ([ H.span { className: "name " <> clickable
, on: { click: onClick }
} [ H.text name ]
] <> children)
-- ]
where
children = map (\c -> copyFromCorpusTreeView (p { tree = c })) ary
validNodeType = (A.elem nodeType [GT.NodeList]) && (id /= sourceId)
clickable = if validNodeType then "clickable" else ""
onClick _ = case validNodeType of
false -> pure unit
true -> do
log2 "[copyFromCorpusTreeViewCpt] issue copy into" id
log2 "[copyFromCorpusTreeViewCpt] issue copy from" sourceId
loadCorporaTree :: Session -> Aff FTree
loadCorporaTree session = getCorporaTree session treeId
where
Session { treeId } = session
getCorporaTree :: Session -> Int -> Aff FTree
getCorporaTree session treeId = get session $ GR.NodeAPI GT.Tree (Just treeId) nodeTypes
where
nodeTypes = A.foldl (\a b -> a <> "type=" <> show b <> "&") "?" [ GT.FolderPrivate
, GT.FolderShared
, GT.Team
, GT.FolderPublic
, GT.Folder
, GT.Corpus
, GT.NodeList]
src/Gargantext/Components/Forest/Tree/Node/Box.purs
View file @
3b8f6267
This diff is collapsed.
Click to expand it.
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