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
e0d243ad
Commit
e0d243ad
authored
Jun 13, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[REFACT] split upload types
parent
bd3b48f2
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
91 additions
and
63 deletions
+91
-63
Tree.purs
src/Gargantext/Components/Forest/Tree.purs
+2
-2
Action.purs
src/Gargantext/Components/Forest/Tree/Node/Action.purs
+15
-38
CopyFrom.purs
...rgantext/Components/Forest/Tree/Node/Action/CopyFrom.purs
+38
-20
Search.purs
...Gargantext/Components/Forest/Tree/Node/Action/Search.purs
+1
-1
Upload.purs
...Gargantext/Components/Forest/Tree/Node/Action/Upload.purs
+2
-1
Types.purs
...text/Components/Forest/Tree/Node/Action/Upload/Types.purs
+31
-0
Box.purs
src/Gargantext/Components/Forest/Tree/Node/Box.purs
+2
-1
No files found.
src/Gargantext/Components/Forest/Tree.purs
View file @
e0d243ad
...
@@ -11,7 +11,7 @@ import Effect.Class (liftEffect)
...
@@ -11,7 +11,7 @@ import Effect.Class (liftEffect)
import Gargantext.AsyncTasks as GAT
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Gargantext.Components.Forest.Tree.Node.Action.Add (AddNodeValue(..), addNode)
import Gargantext.Components.Forest.Tree.Node.Action.Add (AddNodeValue(..), addNode)
import Gargantext.Components.Forest.Tree.Node.Action.CopyFrom (
loadNod
e)
import Gargantext.Components.Forest.Tree.Node.Action.CopyFrom (
getNodeTre
e)
import Gargantext.Components.Forest.Tree.Node.Action.Delete (deleteNode)
import Gargantext.Components.Forest.Tree.Node.Action.Delete (deleteNode)
import Gargantext.Components.Forest.Tree.Node.Action.Rename (RenameValue(..), rename)
import Gargantext.Components.Forest.Tree.Node.Action.Rename (RenameValue(..), rename)
import Gargantext.Components.Forest.Tree.Node.Action.Share (ShareValue(..), share)
import Gargantext.Components.Forest.Tree.Node.Action.Share (ShareValue(..), share)
...
@@ -82,7 +82,7 @@ treeLoadView p = R.createElement treeLoadViewCpt p []
...
@@ -82,7 +82,7 @@ treeLoadView p = R.createElement treeLoadViewCpt p []
, openNodes
, openNodes
, reload
, reload
} _children = do
} _children = do
let fetch _ =
loadNod
e session root
let fetch _ =
getNodeTre
e session root
let paint loaded = loadedTreeView { asyncTasks
let paint loaded = loadedTreeView { asyncTasks
, frontends
, frontends
, mCurrentRoute
, mCurrentRoute
...
...
src/Gargantext/Components/Forest/Tree/Node/Action.purs
View file @
e0d243ad
...
@@ -9,8 +9,7 @@ import Gargantext.Prelude (class Eq, class Show, class Read, Unit)
...
@@ -9,8 +9,7 @@ import Gargantext.Prelude (class Eq, class Show, class Read, Unit)
import Gargantext.Sessions (Session)
import Gargantext.Sessions (Session)
import Gargantext.Types as GT
import Gargantext.Types as GT
import Gargantext.Components.Forest.Tree.Node (NodeAction(..), glyphiconNodeAction)
import Gargantext.Components.Forest.Tree.Node (NodeAction(..), glyphiconNodeAction)
import Gargantext.Components.Forest.Tree.Node.Action.Upload.Types (FileType, UploadFileContents)
import Data.Maybe (Maybe(..))
type Props =
type Props =
( dispatch :: Action -> Aff Unit
( dispatch :: Action -> Aff Unit
...
@@ -21,65 +20,43 @@ type Props =
...
@@ -21,65 +20,43 @@ type Props =
data Action = AddNode String GT.NodeType
data Action = AddNode String GT.NodeType
| DeleteNode
| DeleteNode
| UpdateNode GT.AsyncTaskWithType
| RenameNode String
| RenameNode String
| UpdateNode GT.AsyncTaskWithType
| ShareNode String
| DoSearch GT.AsyncTaskWithType
| DoSearch GT.AsyncTaskWithType
| UploadFile GT.NodeType FileType (Maybe String) UploadFileContents
| UploadFile GT.NodeType FileType (Maybe String) UploadFileContents
| RefreshTree
| RefreshTree
| ShareNode String
instance showShow :: Show Action where
instance showShow :: Show Action where
show (AddNode _ _ )= "AddNode"
show DeleteNode = "DeleteNode"
show DeleteNode = "DeleteNode"
show RefreshTree = "RefreshTree"
show (ShareNode _ )= "ShareNode"
show (UpdateNode _ )= "UpdateNode"
show (RenameNode _ )= "RenameNode"
show (RenameNode _ )= "RenameNode"
show (UpdateNode _ )= "UpdateNode"
show (ShareNode _ )= "ShareNode"
show (DoSearch _ )= "SearchQuery"
show (DoSearch _ )= "SearchQuery"
show (AddNode _ _ )= "AddNode"
show (UploadFile _ _ _ _)= "UploadFile"
show (UploadFile _ _ _ _)= "UploadFile"
show RefreshTree = "RefreshTree"
-----------------------------------------------------------------------
-----------------------------------------------------------------------
icon :: Action -> String
icon :: Action -> String
icon (AddNode _ _) = glyphiconNodeAction (Add [])
icon (AddNode _ _) = glyphiconNodeAction (Add [])
icon DeleteNode = glyphiconNodeAction Delete
icon DeleteNode = glyphiconNodeAction Delete
icon (UpdateNode _) = glyphiconNodeAction Refresh
icon (RenameNode _) = glyphiconNodeAction Config
icon (RenameNode _) = glyphiconNodeAction Config
icon (UpdateNode _) = glyphiconNodeAction Refresh
icon (ShareNode _) = glyphiconNodeAction Share
icon (DoSearch _) = glyphiconNodeAction SearchBox
icon (DoSearch _) = glyphiconNodeAction SearchBox
icon (UploadFile _ _ _ _) = glyphiconNodeAction Upload
icon (UploadFile _ _ _ _) = glyphiconNodeAction Upload
icon RefreshTree = glyphiconNodeAction Refresh
icon RefreshTree = glyphiconNodeAction Refresh
icon (ShareNode _) = glyphiconNodeAction Share
-- icon _ = "hand-o-right"
-- icon _ = "hand-o-right"
text :: Action -> String
text :: Action -> String
text DeleteNode = "Delete !"
text RefreshTree = "Refresh Tree !"
text (AddNode _ _ )= "Add !"
text (AddNode _ _ )= "Add !"
text
(UpdateNode _ )= "Upda
te !"
text
DeleteNode = "Dele
te !"
text (RenameNode _ )= "Rename !"
text (RenameNode _ )= "Rename !"
text (
DoSearch _ )= "Launch search
!"
text (
UpdateNode _ )= "Update
!"
text (ShareNode _ )= "Share !"
text (ShareNode _ )= "Share !"
text (DoSearch _ )= "Launch search !"
text (UploadFile _ _ _ _)= "Upload File !"
text (UploadFile _ _ _ _)= "Upload File !"
text RefreshTree = "Refresh Tree !"
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-- TODO move code below elsewhere
data FileType = CSV | CSV_HAL | WOS | PresseRIS
derive instance genericFileType :: Generic FileType _
instance eqFileType :: Eq FileType where
eq = genericEq
instance showFileType :: Show FileType where
show = genericShow
instance readFileType :: Read FileType where
read :: String -> Maybe FileType
read "CSV" = Just CSV
read "CSV_HAL" = Just CSV_HAL
read "PresseRIS" = Just PresseRIS
read "WOS" = Just WOS
read _ = Nothing
newtype UploadFileContents = UploadFileContents String
src/Gargantext/Components/Forest/Tree/Node/Action/CopyFrom.purs
View file @
e0d243ad
...
@@ -15,8 +15,9 @@ import Reactix as R
...
@@ -15,8 +15,9 @@ import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
loadNode :: Session -> GT.ID -> Aff FTree
------------------------------------------------------------------------
loadNode session nodeId = get session $ GR.NodeAPI GT.Tree (Just nodeId) ""
getNodeTree :: Session -> GT.ID -> Aff FTree
getNodeTree session nodeId = get session $ GR.NodeAPI GT.Tree (Just nodeId) ""
copyFromCorpusView :: Record Props -> R.Element
copyFromCorpusView :: Record Props -> R.Element
copyFromCorpusView props = R.createElement copyFromCorpusViewCpt props []
copyFromCorpusView props = R.createElement copyFromCorpusViewCpt props []
...
@@ -24,10 +25,22 @@ copyFromCorpusView props = R.createElement copyFromCorpusViewCpt props []
...
@@ -24,10 +25,22 @@ copyFromCorpusView props = R.createElement copyFromCorpusViewCpt props []
copyFromCorpusViewCpt :: R.Component Props
copyFromCorpusViewCpt :: R.Component Props
copyFromCorpusViewCpt = R.hooksComponent "G.C.F.T.N.A.U.copyFromCorpusView" cpt
copyFromCorpusViewCpt = R.hooksComponent "G.C.F.T.N.A.U.copyFromCorpusView" cpt
where
where
cpt {dispatch, id, nodeType, session} _ = do
cpt { dispatch
useLoader session loadCorporaTree $
, id
\tree ->
, nodeType
copyFromCorpusViewLoaded {dispatch, id, nodeType, session, tree}
, session
} _ =
do
useLoader session loadCorporaTree $
\tree ->
copyFromCorpusViewLoaded { dispatch
, id
, nodeType
, session
, tree
}
------------------------------------------------------------------------
type CorpusTreeProps =
type CorpusTreeProps =
( tree :: FTree
( tree :: FTree
...
@@ -41,9 +54,10 @@ copyFromCorpusViewLoadedCpt :: R.Component CorpusTreeProps
...
@@ -41,9 +54,10 @@ copyFromCorpusViewLoadedCpt :: R.Component CorpusTreeProps
copyFromCorpusViewLoadedCpt = R.hooksComponent "G.C.F.T.N.A.U.copyFromCorpusViewLoadedCpt" cpt
copyFromCorpusViewLoadedCpt = R.hooksComponent "G.C.F.T.N.A.U.copyFromCorpusViewLoadedCpt" cpt
where
where
cpt p@{dispatch, id, nodeType, session, tree} _ = do
cpt p@{dispatch, id, nodeType, session, tree} _ = do
pure $ H.div { className: "copy-from-corpus" } [
pure $ H.div { className: "copy-from-corpus" }
H.div { className: "tree" } [copyFromCorpusTreeView p]
[ H.div { className: "tree" }
]
[copyFromCorpusTreeView p]
]
copyFromCorpusTreeView :: Record CorpusTreeProps -> R.Element
copyFromCorpusTreeView :: Record CorpusTreeProps -> R.Element
copyFromCorpusTreeView props = R.createElement copyFromCorpusTreeViewCpt props []
copyFromCorpusTreeView props = R.createElement copyFromCorpusTreeViewCpt props []
...
@@ -53,11 +67,13 @@ copyFromCorpusTreeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.copyFromCorpusTreeVi
...
@@ -53,11 +67,13 @@ copyFromCorpusTreeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.copyFromCorpusTreeVi
where
where
cpt p@{id, tree: NTree (LNode { id: sourceId, name, nodeType }) ary} _ = do
cpt p@{id, tree: NTree (LNode { id: sourceId, name, nodeType }) ary} _ = do
pure $ {- H.div {} [ H.h5 { className: GT.fldr nodeType true} []
pure $ {- H.div {} [ H.h5 { className: GT.fldr nodeType true} []
, -} H.div { className: "node" } ([ H.span { className: "name " <> clickable
, -} H.div { className: "node" }
, on: { click: onClick }
( [ H.span { className: "name " <> clickable
} [ H.text name ]
, on: { click: onClick }
} [ H.text name ]
] <> children)
] <> children
)
-- ]
-- ]
where
where
children = map (\c -> copyFromCorpusTreeView (p { tree = c })) ary
children = map (\c -> copyFromCorpusTreeView (p { tree = c })) ary
...
@@ -77,10 +93,12 @@ loadCorporaTree session = getCorporaTree session treeId
...
@@ -77,10 +93,12 @@ loadCorporaTree session = getCorporaTree session treeId
getCorporaTree :: Session -> Int -> Aff FTree
getCorporaTree :: Session -> Int -> Aff FTree
getCorporaTree session treeId = get session $ GR.NodeAPI GT.Tree (Just treeId) nodeTypes
getCorporaTree session treeId = get session $ GR.NodeAPI GT.Tree (Just treeId) nodeTypes
where
where
nodeTypes = A.foldl (\a b -> a <> "type=" <> show b <> "&") "?" [ GT.FolderPrivate
nodeTypes = A.foldl (\a b -> a <> "type=" <> show b <> "&") "?" typesList
, GT.FolderShared
typesList = [ GT.FolderPrivate
, GT.Team
, GT.FolderShared
, GT.FolderPublic
, GT.Team
, GT.Folder
, GT.FolderPublic
, GT.Corpus
, GT.Folder
, GT.NodeList]
, GT.Corpus
, GT.NodeList
]
src/Gargantext/Components/Forest/Tree/Node/Action/Search.purs
View file @
e0d243ad
...
@@ -23,7 +23,7 @@ actionSearch :: Session
...
@@ -23,7 +23,7 @@ actionSearch :: Session
-> Maybe NodePopup
-> Maybe NodePopup
-> R.Hooks R.Element
-> R.Hooks R.Element
actionSearch session id dispatch nodePopup = do
actionSearch session id dispatch nodePopup = do
search
<- R.useState' $ defaultSearch { node_id = id }
search <- R.useState' $ defaultSearch { node_id = id }
pure $ R.fragment [ H.p {"style": {"margin" :"10px"}}
pure $ R.fragment [ H.p {"style": {"margin" :"10px"}}
[ H.text $ "Search and create a private "
[ H.text $ "Search and create a private "
<> "corpus with the search query as corpus name." ]
<> "corpus with the search query as corpus name." ]
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Upload.purs
View file @
e0d243ad
...
@@ -7,7 +7,8 @@ import Data.Tuple.Nested ((/\))
...
@@ -7,7 +7,8 @@ import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect (Effect)
import Effect.Aff (Aff, launchAff)
import Effect.Aff (Aff, launchAff)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..), Props, FileType(..), UploadFileContents(..))
import Gargantext.Components.Forest.Tree.Node.Action (Action(..), Props)
import Gargantext.Components.Forest.Tree.Node.Action.Upload.Types (FileType(..), UploadFileContents(..))
import Gargantext.Components.Forest.Tree.Node.Tools (fragmentPT)
import Gargantext.Components.Forest.Tree.Node.Tools (fragmentPT)
import Gargantext.Components.Lang (Lang(..))
import Gargantext.Components.Lang (Lang(..))
import Gargantext.Prelude (class Show, Unit, discard, bind, const, id, map, pure, show, unit, void, ($), read)
import Gargantext.Prelude (class Show, Unit, discard, bind, const, id, map, pure, show, unit, void, ($), read)
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Upload/Types.purs
0 → 100644
View file @
e0d243ad
module Gargantext.Components.Forest.Tree.Node.Action.Upload.Types where
import Gargantext.Prelude (class Read, class Show, class Eq)
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Eq (genericEq)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..), fromMaybe, maybe)
data FileType = CSV | CSV_HAL | WOS | PresseRIS
derive instance genericFileType :: Generic FileType _
instance eqFileType :: Eq FileType where
eq = genericEq
instance showFileType :: Show FileType where
show = genericShow
instance readFileType :: Read FileType where
read :: String -> Maybe FileType
read "CSV" = Just CSV
read "CSV_HAL" = Just CSV_HAL
read "PresseRIS" = Just PresseRIS
read "WOS" = Just WOS
read _ = Nothing
newtype UploadFileContents = UploadFileContents String
src/Gargantext/Components/Forest/Tree/Node/Box.purs
View file @
e0d243ad
...
@@ -8,7 +8,8 @@ import Effect.Aff (Aff, launchAff)
...
@@ -8,7 +8,8 @@ import Effect.Aff (Aff, launchAff)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Effect.Uncurried (mkEffectFn1)
import Effect.Uncurried (mkEffectFn1)
import Gargantext.Components.Forest.Tree.Node (NodeAction(..), SettingsBox(..), glyphiconNodeAction, settingsBox)
import Gargantext.Components.Forest.Tree.Node (NodeAction(..), SettingsBox(..), glyphiconNodeAction, settingsBox)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..), FileType(..), UploadFileContents(..))
import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Gargantext.Components.Forest.Tree.Node.Action.Upload.Types (FileType(..), UploadFileContents(..))
import Gargantext.Components.Forest.Tree.Node.Action.Add (NodePopup(..), addNodeView)
import Gargantext.Components.Forest.Tree.Node.Action.Add (NodePopup(..), addNodeView)
import Gargantext.Components.Forest.Tree.Node.Action.CopyFrom (copyFromCorpusView)
import Gargantext.Components.Forest.Tree.Node.Action.CopyFrom (copyFromCorpusView)
import Gargantext.Components.Forest.Tree.Node.Action.Documentation (actionDoc)
import Gargantext.Components.Forest.Tree.Node.Action.Documentation (actionDoc)
...
...
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