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
ae8c3ae1
Commit
ae8c3ae1
authored
Jan 27, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[LANG] upload WIP
parent
1d04806e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
32 deletions
+71
-32
Action.purs
src/Gargantext/Components/Forest/Tree/Node/Action.purs
+11
-10
Upload.purs
...Gargantext/Components/Forest/Tree/Node/Action/Upload.purs
+58
-21
Box.purs
src/Gargantext/Components/Forest/Tree/Node/Box.purs
+2
-1
No files found.
src/Gargantext/Components/Forest/Tree/Node/Action.purs
View file @
ae8c3ae1
...
@@ -10,6 +10,7 @@ import Effect.Aff (Aff)
...
@@ -10,6 +10,7 @@ import Effect.Aff (Aff)
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Sessions (Session, get, put, post, delete)
import Gargantext.Sessions (Session, get, put, post, delete)
import Gargantext.Types (NodeType(..), AsyncTask(..))
import Gargantext.Types (NodeType(..), AsyncTask(..))
import Gargantext.Components.Search.Types (Lang(..))
import Prelude hiding (div)
import Prelude hiding (div)
data Action = Submit String
data Action = Submit String
...
@@ -20,7 +21,7 @@ data Action = Submit String
...
@@ -20,7 +21,7 @@ data Action = Submit String
-----------------------------------------------------
-----------------------------------------------------
-- UploadFile Action
-- UploadFile Action
-- file upload types
-- file upload types
data FileType = CSV | CSV_HAL | PresseRIS
data FileType = CSV | CSV_HAL |
WOS |
PresseRIS
derive instance genericFileType :: Generic FileType _
derive instance genericFileType :: Generic FileType _
...
@@ -31,14 +32,16 @@ instance showFileType :: Show FileType where
...
@@ -31,14 +32,16 @@ instance showFileType :: Show FileType where
show = genericShow
show = genericShow
readFileType :: String -> Maybe FileType
readFileType :: String -> Maybe FileType
readFileType "CSV_HAL" = Just CSV_HAL
readFileType "CSV" = Just CSV
readFileType "CSV" = Just CSV
readFileType "CSV_HAL" = Just CSV_HAL
readFileType "PresseRIS" = Just PresseRIS
readFileType "PresseRIS" = Just PresseRIS
readFileType "WOS" = Just WOS
readFileType _ = Nothing
readFileType _ = Nothing
data DroppedFile = DroppedFile {
data DroppedFile = DroppedFile {
contents :: UploadFileContents
contents :: UploadFileContents
, fileType :: Maybe FileType
, fileType :: Maybe FileType
, lang :: Maybe Lang
}
}
type FileHash = String
type FileHash = String
...
@@ -48,7 +51,6 @@ type Reload = Int
...
@@ -48,7 +51,6 @@ type Reload = Int
newtype UploadFileContents = UploadFileContents String
newtype UploadFileContents = UploadFileContents String
createNode :: Session -> ID -> CreateValue -> Aff (Array ID)
createNode :: Session -> ID -> CreateValue -> Aff (Array ID)
createNode session parentId = post session $ NodeAPI Node (Just parentId) ""
createNode session parentId = post session $ NodeAPI Node (Just parentId) ""
...
@@ -91,7 +93,6 @@ type Tree = { tree :: FTree, asyncTasks :: Array AsyncTask }
...
@@ -91,7 +93,6 @@ type Tree = { tree :: FTree, asyncTasks :: Array AsyncTask }
instance ntreeFunctor :: Functor NTree where
instance ntreeFunctor :: Functor NTree where
map f (NTree x ary) = NTree (f x) (map (map f) ary)
map f (NTree x ary) = NTree (f x) (map (map f) ary)
newtype LNode = LNode { id :: ID
newtype LNode = LNode { id :: ID
, name :: Name
, name :: Name
, nodeType :: NodeType
, nodeType :: NodeType
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Upload.purs
View file @
ae8c3ae1
...
@@ -13,7 +13,7 @@ import Reactix as R
...
@@ -13,7 +13,7 @@ import Reactix as R
import Reactix.DOM.HTML as H
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.Components.Search.Types (readLang, Lang(..))
import Gargantext.Components.Forest.Tree.Node.Action
import Gargantext.Components.Forest.Tree.Node.Action
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Sessions (Session, postWwwUrlencoded)
import Gargantext.Sessions (Session, postWwwUrlencoded)
...
@@ -36,18 +36,35 @@ uploadFileViewCpt d = R.hooksComponent "UploadFileView" cpt
...
@@ -36,18 +36,35 @@ uploadFileViewCpt d = R.hooksComponent "UploadFileView" cpt
cpt {id} _ = do
cpt {id} _ = 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)
pure $ H.div {} [
pure $ H.div {} [
H.div {} [ H.text "Upload file!" ]
H.div {} [ H.text "Upload file!" ]
, H.div {} [ H.input {type: "file", placeholder: "Choose file", on: {change: onChangeContents mContents}} ]
, H.div {}
, H.div {} [ H.input { type: "file"
[ R2.select {className: "col-md-12 form-control"
, placeholder: "Choose file"
, on: {change: onChangeContents mContents}
}
]
, H.div {} [ R2.select {className: "col-md-12 form-control"
, on: {change: onChangeFileType fileType}
, on: {change: onChangeFileType fileType}
}
}
(map renderOption [CSV, CSV_HAL])
( map renderOption [ CSV
, CSV_HAL
, WOS
, PresseRIS
]
]
, H.div {}
)
[ uploadButton d id mContents fileType ]
]
, H.div {} [ R2.select {className: "col-md-12 form-control"
, on: {change: onChangeLang lang}
} (map renderOption [EN, FR])
]
, H.div {} [ uploadButton d id mContents fileType lang ]
]
]
renderOption opt = H.option {} [ H.text $ show opt ]
renderOption opt = H.option {} [ H.text $ show opt ]
...
@@ -62,10 +79,26 @@ uploadFileViewCpt d = R.hooksComponent "UploadFileView" cpt
...
@@ -62,10 +79,26 @@ uploadFileViewCpt d = R.hooksComponent "UploadFileView" cpt
setMContents $ const $ Just $ UploadFileContents contents
setMContents $ const $ Just $ UploadFileContents contents
onChangeFileType (fileType /\ setFileType) e = do
onChangeFileType (fileType /\ setFileType) e = do
setFileType $ const $ unsafePartial $ fromJust $ readFileType $ R2.unsafeEventValue e
setFileType $ const
$ unsafePartial
uploadButton :: (Action -> Aff Unit) -> Int -> R.State (Maybe UploadFileContents) -> R.State FileType -> R.Element
$ fromJust
uploadButton d id (mContents /\ setMContents) (fileType /\ setFileType) =
$ readFileType
$ R2.unsafeEventValue e
onChangeLang (lang /\ setLang) e = do
setLang $ const
$ unsafePartial
$ readLang
$ R2.unsafeEventValue e
uploadButton :: (Action -> Aff Unit)
-> Int
-> R.State (Maybe UploadFileContents)
-> R.State FileType
-> R.State (Maybe Lang)
-> R.Element
uploadButton d id (mContents /\ setMContents) (fileType /\ setFileType) (lang /\ setLang) =
H.button {className: "btn btn-primary", disabled, on: {click: onClick}} [ H.text "Upload" ]
H.button {className: "btn btn-primary", disabled, on: {click: onClick}} [ H.text "Upload" ]
where
where
disabled = case mContents of
disabled = case mContents of
...
@@ -79,6 +112,7 @@ uploadButton d id (mContents /\ setMContents) (fileType /\ setFileType) =
...
@@ -79,6 +112,7 @@ uploadButton d id (mContents /\ setMContents) (fileType /\ setFileType) =
liftEffect $ do
liftEffect $ do
setMContents $ const $ Nothing
setMContents $ const $ Nothing
setFileType $ const $ CSV
setFileType $ const $ CSV
setLang $ const $ Just EN
-- START File Type View
-- START File Type View
type FileTypeProps =
type FileTypeProps =
...
@@ -127,11 +161,14 @@ fileTypeView d p (Just (DroppedFile {contents, fileType}) /\ setDroppedFile) (_
...
@@ -127,11 +161,14 @@ fileTypeView d p (Just (DroppedFile {contents, fileType}) /\ setDroppedFile) (_
[ R2.select {className: "col-md-12 form-control"
[ R2.select {className: "col-md-12 form-control"
, on: {change: onChange}
, on: {change: onChange}
}
}
(map renderOption [CSV, CSV_HAL])
(map renderOption [CSV, CSV_HAL
, WOS
])
]
]
where
where
onChange e =
onChange e l =
setDroppedFile $ const $ Just $ DroppedFile $ {contents, fileType: readFileType $ R2.unsafeEventValue e}
setDroppedFile $ const $ Just $ DroppedFile $ { contents
, fileType: readFileType $ R2.unsafeEventValue e
, lang : readLang $ R2.unsafeEventValue l
}
renderOption opt = H.option {} [ H.text $ show opt ]
renderOption opt = H.option {} [ H.text $ show opt ]
panelFooter =
panelFooter =
H.div {className: "panel-footer"}
H.div {className: "panel-footer"}
...
...
src/Gargantext/Components/Forest/Tree/Node/Box.purs
View file @
ae8c3ae1
...
@@ -22,7 +22,7 @@ import Gargantext.Components.Forest.Tree.Node.Action.Add (NodePopup(..), createN
...
@@ -22,7 +22,7 @@ import Gargantext.Components.Forest.Tree.Node.Action.Add (NodePopup(..), createN
import Gargantext.Components.Forest.Tree.Node.Action.Rename (renameBox)
import Gargantext.Components.Forest.Tree.Node.Action.Rename (renameBox)
import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadFileView, fileTypeView)
import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadFileView, fileTypeView)
import Gargantext.Components.Forest.Tree.Node.ProgressBar (asyncProgressBar)
import Gargantext.Components.Forest.Tree.Node.ProgressBar (asyncProgressBar)
import Gargantext.Components.Search.Types (allLangs)
import Gargantext.Components.Search.Types (allLangs
, Lang(EN)
)
import Gargantext.Components.Search.SearchBar (searchBar)
import Gargantext.Components.Search.SearchBar (searchBar)
import Gargantext.Components.Search.SearchField (Search, defaultSearch, isIsTex)
import Gargantext.Components.Search.SearchField (Search, defaultSearch, isIsTex)
...
@@ -132,6 +132,7 @@ nodeMainSpan d p folderOpen session frontends = R.createElement el p []
...
@@ -132,6 +132,7 @@ nodeMainSpan d p folderOpen session frontends = R.createElement el p []
$ Just
$ Just
$ DroppedFile { contents: (UploadFileContents contents)
$ DroppedFile { contents: (UploadFileContents contents)
, fileType: Just CSV
, fileType: Just CSV
, lang: Just EN
}
}
onDragOverHandler (_ /\ setIsDragOver) e = do
onDragOverHandler (_ /\ setIsDragOver) e = do
-- prevent redirection when file is dropped
-- prevent redirection when file is dropped
...
...
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