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
6563ea3f
Commit
6563ea3f
authored
Jun 01, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[REFACT|Tree/Action] split upload
parent
c7ebcbab
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
70 additions
and
52 deletions
+70
-52
Forest.purs
src/Gargantext/Components/Forest.purs
+1
-3
Tree.purs
src/Gargantext/Components/Forest/Tree.purs
+5
-1
Action.purs
src/Gargantext/Components/Forest/Tree/Node/Action.purs
+22
-0
Add.purs
src/Gargantext/Components/Forest/Tree/Node/Action/Add.purs
+6
-6
CopyFrom.purs
...rgantext/Components/Forest/Tree/Node/Action/CopyFrom.purs
+2
-2
Rename.purs
...Gargantext/Components/Forest/Tree/Node/Action/Rename.purs
+7
-2
Update.purs
...Gargantext/Components/Forest/Tree/Node/Action/Update.purs
+3
-3
Upload.purs
...Gargantext/Components/Forest/Tree/Node/Action/Upload.purs
+16
-28
Box.purs
src/Gargantext/Components/Forest/Tree/Node/Box.purs
+4
-3
ProgressBar.purs
src/Gargantext/Components/Forest/Tree/Node/ProgressBar.purs
+1
-2
Types.purs
src/Gargantext/Types.purs
+3
-2
No files found.
src/Gargantext/Components/Forest.purs
View file @
6563ea3f
...
...
@@ -3,21 +3,19 @@ module Gargantext.Components.Forest where
import Gargantext.Prelude
import Data.Array as A
import Data.Map as Map
import Data.Maybe (Maybe(..))
import Data.Set as Set
import Data.Tuple (fst)
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.Forest.Tree (treeView)
import Gargantext.Components.Forest.Tree.Node.Action (Reload)
import Gargantext.Ends (Frontends)
import Gargantext.Routes (AppRoute)
import Gargantext.Sessions (Session(..), Sessions, OpenNodes, unSessions)
import Gargantext.Types (Reload)
import Gargantext.Utils.Reactix as R2
type Props =
...
...
src/Gargantext/Components/Forest/Tree.purs
View file @
6563ea3f
...
...
@@ -16,16 +16,20 @@ import Record as Record
import Record.Extra as RecordE
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.Forest.Tree.Node.Action (Action(..), FTree, ID, LNode(..), NTree(..), Reload, RenameValue(..), Tree, deleteNode, loadNode, renameNode)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..),deleteNode)
import Gargantext.Components.Forest.Tree.Node.Action.CopyFrom (loadNode)
import Gargantext.Components.Forest.Tree.Node.Action.Add (AddNodeValue(..), addNode)
import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadFile)
import Gargantext.Components.Forest.Tree.Node.Action.Rename (RenameValue(..), renameNode)
import Gargantext.Components.Forest.Tree.Node.Box (nodeMainSpan, Tasks, tasksStruct)
import Gargantext.Components.Forest.Tree.Node.FTree (FTree, LNode(..), NTree(..), Tree)
import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (Unit, bind, const, discard, map, pure, void, ($), (+), (/=), (<>), identity)
import Gargantext.Routes (AppRoute)
import Gargantext.Sessions (OpenNodes, Session, mkNodeId)
import Gargantext.Types as GT
import Gargantext.Types (ID, Reload)
------------------------------------------------------------------------
...
...
src/Gargantext/Components/Forest/Tree/Node/Action.purs
View file @
6563ea3f
...
...
@@ -28,3 +28,25 @@ data Action = CreateSubmit String GT.NodeType
deleteNode :: Session -> GT.ID -> Aff GT.ID
deleteNode session nodeId = delete session $ NodeAPI GT.Node (Just nodeId) ""
-----------------------------------------------------------------------
type Props =
( dispatch :: Action -> Aff Unit
, id :: Int
, nodeType :: GT.NodeType
, session :: Session
)
-- TODO remove these types from here
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
newtype UploadFileContents = UploadFileContents String
src/Gargantext/Components/Forest/Tree/Node/Action/Add.purs
View file @
6563ea3f
...
...
@@ -7,7 +7,7 @@ import Data.Maybe (Maybe(..), fromMaybe)
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff, launchAff)
import Effect.Uncurried (mkEffectFn1)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..)
, ID, Name
)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Gargantext.Components.Forest.Tree.Node (SettingsBox(..), settingsBox)
import Gargantext.Types (NodeType(..), readNodeType)
import Gargantext.Utils.Reactix as R2
...
...
@@ -19,11 +19,11 @@ import Reactix as R
import Reactix.DOM.HTML as H
----------------------------------------------------------------------
addNode :: Session ->
ID -> AddNodeValue -> Aff (Array
ID)
addNode :: Session ->
GT.ID -> AddNodeValue -> Aff (Array GT.
ID)
addNode session parentId = post session $ GR.NodeAPI GT.Node (Just parentId) ""
addNodeAsync :: Session
-> ID
->
GT.
ID
-> AddNodeValue
-> Aff GT.AsyncTaskWithType
addNodeAsync session parentId q = do
...
...
@@ -35,7 +35,7 @@ addNodeAsync session parentId q = do
----------------------------------------------------------------------
-- TODO AddNodeParams
newtype AddNodeValue = AddNodeValue
{ name :: Name
{ name ::
GT.
Name
, nodeType :: GT.NodeType
}
...
...
@@ -49,9 +49,9 @@ instance encodeJsonAddNodeValue :: EncodeJson AddNodeValue where
data NodePopup = CreatePopup | NodePopup
type CreateNodeProps =
( id :: ID
( id ::
GT.
ID
, dispatch :: Action -> Aff Unit
, name :: Name
, name ::
GT.
Name
, nodeType :: NodeType
, nodeTypes :: Array NodeType
)
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/CopyFrom.purs
View file @
6563ea3f
...
...
@@ -19,7 +19,7 @@ import Web.File.FileReader.Aff (readAsText)
import Gargantext.Prelude (class Show, Unit, bind, const, discard, map, pure, show, unit, void, ($), (&&), (/=), (<>))
import Gargantext.Components.Lang (readLang, Lang(..))
import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Gargantext.Components.Forest.Tree.Node.Action (Action(..)
, Props
)
import Gargantext.Components.Forest.Tree.Node.FTree (FTree, ID, LNode(..), NTree(..))
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes as GR
...
...
@@ -30,7 +30,7 @@ import Gargantext.Utils.Reactix as R2
loadNode :: Session -> GT.ID -> Aff FTree
loadNode session nodeId = get session $ NodeAPI GT.Tree (Just nodeId) ""
loadNode session nodeId = get session $
GR.
NodeAPI GT.Tree (Just nodeId) ""
copyFromCorpusView :: Record Props -> R.Element
copyFromCorpusView props = R.createElement copyFromCorpusViewCpt props []
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Rename.purs
View file @
6563ea3f
module Gargantext.Components.Forest.Tree.Node.Action.Rename where
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, jsonEmptyObject, (.:), (:=), (~>))
import Data.Maybe (Maybe(..))
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff, launchAff)
import Effect.Uncurried (mkEffectFn1)
...
...
@@ -8,13 +10,16 @@ import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Components.Forest.Tree.Node.Action
import Gargantext.Types (NodeType)
import Gargantext.Types as GT
import Gargantext.Types (NodeType, ID, Name)
import Gargantext.Routes as GR
import Gargantext.Utils.Reactix as R2
import Gargantext.Sessions (Session, get, put, post, delete)
renameNode :: Session -> ID -> RenameValue -> Aff (Array ID)
renameNode session renameNodeId =
put session $ NodeAPI GT.Node (Just renameNodeId) "rename"
put session $
GR.
NodeAPI GT.Node (Just renameNodeId) "rename"
newtype RenameValue = RenameValue
{ name :: Name }
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Update.purs
View file @
6563ea3f
...
...
@@ -7,7 +7,7 @@ import Data.Maybe (Maybe(..), fromMaybe)
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff, launchAff)
import Effect.Uncurried (mkEffectFn1)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..)
, ID, Name
)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Gargantext.Components.Forest.Tree.Node (SettingsBox(..), settingsBox)
import Gargantext.Types (NodeType(..), readNodeType)
import Gargantext.Utils.Reactix as R2
...
...
@@ -41,9 +41,9 @@ instance encodeJsonUpdateNodeParams :: EncodeJson UpdateNodeParams
----------------------------------------------------------------------
type UpdateNodeProps =
( id :: ID
( id ::
GT.
ID
, dispatch :: Action -> Aff Unit
, name :: Name
, name ::
GT.
Name
, nodeType :: NodeType
, params :: UpdateNodeParams
)
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Upload.purs
View file @
6563ea3f
...
...
@@ -19,7 +19,7 @@ import Web.File.FileReader.Aff (readAsText)
import Gargantext.Prelude (class Show, Unit, bind, const, discard, map, pure, show, unit, void, ($), (&&), (/=), (<>))
import Gargantext.Components.Lang (readLang, Lang(..))
import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Gargantext.Components.Forest.Tree.Node.Action (Action(..)
, Props, FileType(..), UploadFileContents(..)
)
import Gargantext.Components.Forest.Tree.Node.FTree (FTree, ID, LNode(..), NTree(..))
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes as GR
...
...
@@ -30,23 +30,6 @@ import Gargantext.Utils.Reactix as R2
-- UploadFile Action
-- file upload types
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
readFileType :: String -> Maybe FileType
readFileType "CSV" = Just CSV
readFileType "CSV_HAL" = Just CSV_HAL
readFileType "PresseRIS" = Just PresseRIS
readFileType "WOS" = Just WOS
readFileType _ = Nothing
data DroppedFile =
DroppedFile { contents :: UploadFileContents
, fileType :: Maybe FileType
...
...
@@ -55,18 +38,12 @@ data DroppedFile =
type FileHash = String
newtype UploadFileContents = UploadFileContents String
type UploadFile =
{ contents :: UploadFileContents
, name :: String
}
type Props =
( dispatch :: Action -> Aff Unit
, id :: Int
, nodeType :: GT.NodeType
, session :: Session
)
uploadFileView :: Record Props -> R.Element
uploadFileView props = R.createElement uploadFileViewCpt props []
...
...
@@ -141,7 +118,7 @@ uploadFileViewCpt = R.hooksComponent "G.C.F.T.N.A.U.UploadFileView" cpt
type UploadButtonProps =
( dispatch ::
Dispatch
( dispatch ::
Action -> Aff Unit
, fileType :: R.State FileType
, id :: GT.ID
, lang :: R.State (Maybe Lang)
...
...
@@ -173,7 +150,7 @@ uploadButtonCpt = R.hooksComponent "G.C.F.T.N.A.U.uploadButton" cpt
-- START File Type View
type FileTypeProps =
( dispatch ::
Dispatch
( dispatch ::
Action -> Aff Unit
, droppedFile :: R.State (Maybe DroppedFile)
, id :: ID
, isDragOver :: R.State Boolean
...
...
@@ -315,7 +292,7 @@ uploadTermListViewCpt = R.hooksComponent "G.C.F.T.N.A.U.UploadTermListView" cpt
type UploadTermButtonProps =
( dispatch ::
Dispatch
( dispatch ::
Action -> Aff Unit
, id :: Int
, mFile :: R.State (Maybe UploadFile)
, nodeType :: GT.NodeType
...
...
@@ -341,3 +318,14 @@ uploadTermButtonCpt = R.hooksComponent "G.C.F.T.N.A.U.uploadTermButton" cpt
liftEffect $ do
setMFile $ const $ Nothing
-- | UTils
readFileType :: String -> Maybe FileType
readFileType "CSV" = Just CSV
readFileType "CSV_HAL" = Just CSV_HAL
readFileType "PresseRIS" = Just PresseRIS
readFileType "WOS" = Just WOS
readFileType _ = Nothing
src/Gargantext/Components/Forest/Tree/Node/Box.purs
View file @
6563ea3f
...
...
@@ -27,11 +27,12 @@ import Gargantext.Prelude
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.Forest.Tree.Node (NodeAction(..), SettingsBox(..), glyphiconNodeAction, settingsBox)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..),
DroppedFile(..), FileType(..), ID, Name, Reload
, UploadFileContents(..))
import Gargantext.Components.Forest.Tree.Node.Action (Action(..),
FileType(..)
, UploadFileContents(..))
import Gargantext.Components.Forest.Tree.Node.Action.Add (NodePopup(..), addNodeView)
import Gargantext.Components.Forest.Tree.Node.Action.Rename (renameBox)
import Gargantext.Components.Forest.Tree.Node.Action.Update
import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadFileView, fileTypeView, uploadTermListView, copyFromCorpusView)
import Gargantext.Components.Forest.Tree.Node.Action.Upload (DroppedFile(..), uploadFileView, fileTypeView, uploadTermListView)
import Gargantext.Components.Forest.Tree.Node.Action.CopyFrom (copyFromCorpusView)
import Gargantext.Components.Forest.Tree.Node.ProgressBar (asyncProgressBar, BarType(..))
import Gargantext.Components.GraphExplorer.API as GraphAPI
import Gargantext.Components.Lang (allLangs, Lang(EN))
...
...
@@ -44,7 +45,7 @@ import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes as Routes
import Gargantext.Sessions (Session, sessionId, post)
import Gargantext.Types (NodeType(..))
import Gargantext.Types (NodeType(..)
, ID, Name, Reload
)
import Gargantext.Types as GT
import Gargantext.Utils (glyphicon, glyphiconActive)
import Gargantext.Utils.Popover as Popover
...
...
src/Gargantext/Components/Forest/Tree/Node/ProgressBar.purs
View file @
6563ea3f
...
...
@@ -9,7 +9,6 @@ import Effect (Effect)
import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect)
import Effect.Timer (clearInterval, setInterval)
import Gargantext.Components.Forest.Tree.Node.Action (ID)
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Sessions (Session, get)
import Gargantext.Types as GT
...
...
@@ -26,7 +25,7 @@ type Props =
(
asyncTask :: GT.AsyncTaskWithType
, barType :: BarType
, corpusId :: ID
, corpusId ::
GT.
ID
, onFinish :: Unit -> Effect Unit
, session :: Session
)
...
...
src/Gargantext/Types.purs
View file @
6563ea3f
...
...
@@ -17,6 +17,7 @@ import URI.Query (Query)
type ID = Int
type Name = String
type Reload = Int
newtype SessionId = SessionId String
type NodeID = Int
...
...
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