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
1923ea43
Verified
Commit
1923ea43
authored
Apr 19, 2023
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[nlp] add languages from backend to file upload dialog
parent
719f499f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
19 deletions
+50
-19
Search.purs
...Gargantext/Components/Forest/Tree/Node/Action/Search.purs
+5
-14
Upload.purs
...Gargantext/Components/Forest/Tree/Node/Action/Upload.purs
+26
-4
Utils.purs
src/Gargantext/Components/Forest/Tree/Node/Action/Utils.purs
+19
-0
Lang.purs
src/Gargantext/Components/Lang.purs
+0
-1
No files found.
src/Gargantext/Components/Forest/Tree/Node/Action/Search.purs
View file @
1923ea43
...
...
@@ -3,7 +3,6 @@ module Gargantext.Components.Forest.Tree.Node.Action.Search where
import Gargantext.Prelude
import Data.Array as A
import Data.Map as Map
import Data.Maybe (Maybe)
import Effect (Effect)
import Effect.Aff (Aff, launchAff)
...
...
@@ -11,7 +10,7 @@ import Gargantext.Components.App.Store (Boxes)
import Gargantext.Components.Forest.Tree.Node.Action.Search.SearchBar (searchBar)
import Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField (defaultSearch)
import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..))
import Gargantext.Components.
GraphQL.Endpoints (get
Languages)
import Gargantext.Components.
Forest.Tree.Node.Action.Utils (load
Languages)
import Gargantext.Components.Lang (allLangs, Lang)
import Gargantext.Config.REST (RESTError(..), AffRESTError)
import Gargantext.Hooks.Loader (useLoader)
...
...
@@ -47,20 +46,12 @@ actionSearchCpt = here.component "actionSearch" cpt where
actionSearchWithLangs (Record.merge props { langs }) [] }
where
errorHandler err = case err of
ReadJSONError err' -> here.warn2 "[listTreeChildren] ReadJSONError" $ show err'
_ -> here.warn2 "[listTreeChildren] RESTError" err
loadLanguages :: { session :: Session } -> AffRESTError (Array Lang)
loadLanguages { session } = do
eLangsMap <- getLanguages session
pure $ A.fromFoldable <$> Map.keys <$> eLangsMap
ReadJSONError err' -> here.warn2 "[actionSearch] ReadJSONError" $ show err'
_ -> here.warn2 "[actionSearch] RESTError" err
type PropsWithLangs =
( boxes :: Boxes
, dispatch :: Action -> Aff Unit
, id :: Maybe ID
, langs :: Array Lang
, session :: Session )
( langs :: Array Lang
| Props )
-- | Action : Search
actionSearchWithLangs :: R2.Component PropsWithLangs
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Upload.purs
View file @
1923ea43
...
...
@@ -22,12 +22,14 @@ import Gargantext.Components.Bootstrap.Types (ComponentStatus(..))
import Gargantext.Components.Forest.Tree.Node.Action (Props)
import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..))
import Gargantext.Components.Forest.Tree.Node.Action.Upload.Types (FileFormat(..), FileType(..), UploadFileBlob(..), readUFBAsBase64, readUFBAsText)
import Gargantext.Components.Forest.Tree.Node.Action.Utils (loadLanguages)
import Gargantext.Components.Forest.Tree.Node.Tools (fragmentPT, formChoiceSafe, panel)
import Gargantext.Components.Lang (Lang(..), langReader)
import Gargantext.Components.ListSelection as ListSelection
import Gargantext.Components.ListSelection.Types (Selection(..))
import Gargantext.Components.ListSelection.Types as ListSelection
import Gargantext.Config.REST (AffRESTError, RESTError)
import Gargantext.Config.REST (AffRESTError, RESTError(..))
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes as GR
import Gargantext.Sessions (Session, postWwwUrlencoded, post)
import Gargantext.Types (ID, NodeType(..))
...
...
@@ -37,6 +39,7 @@ import Partial.Unsafe (unsafePartial, unsafeCrashWith)
import React.SyntheticEvent as E
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
import Toestand as T
import URI.Extra.QueryPairs as QP
import Web.File.FileReader.Aff (readAsDataURL)
...
...
@@ -103,9 +106,28 @@ type UploadFile =
uploadFileView :: R2.Leaf Props
uploadFileView = R2.leaf uploadFileViewCpt
uploadFileViewCpt :: R.Component Props
uploadFileViewCpt = here.component "uploadFileView" cpt
uploadFileViewCpt = here.component "uploadFileView" cpt where
cpt props@({ session }) _ = do
useLoader { errorHandler
, loader: loadLanguages
, path: { session }
, render: \langs ->
uploadFileViewWithLangs (Record.merge props { langs }) }
where
errorHandler err = case err of
ReadJSONError err' -> here.warn2 "[uploadFileView] ReadJSONError" $ show err'
_ -> here.warn2 "[uploadFileView] RESTError" err
type PropsWithLangs =
( langs :: Array Lang
| Props )
uploadFileViewWithLangs :: R2.Leaf PropsWithLangs
uploadFileViewWithLangs = R2.leaf uploadFileViewWithLangsCpt
uploadFileViewWithLangsCpt :: R.Component PropsWithLangs
uploadFileViewWithLangsCpt = here.component "uploadFileViewWithLangs" cpt
where
cpt { dispatch, id, nodeType, session } _ = do
cpt { dispatch, id,
langs,
nodeType, session } _ = do
-- mFile :: R.State (Maybe UploadFile) <- R.useState' Nothing
mFile <- T.useBox (Nothing :: Maybe UploadFile)
fileType <- T.useBox CSV
...
...
@@ -147,7 +169,7 @@ uploadFileViewCpt = here.component "uploadFileView" cpt
]
, R2.row
[ H.div {className:"col-6 flex-space-around"}
[ formChoiceSafe { items:
[EN, FR, DE, ES, IT, PL, CN,
No_extraction]
[ formChoiceSafe { items:
langs <> [
No_extraction]
, default: EN
, callback: setLang'
, print: show
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Utils.purs
0 → 100644
View file @
1923ea43
module Gargantext.Components.Forest.Tree.Node.Action.Utils where
import Data.Array as A
import Data.Map as Map
import Gargantext.Components.GraphQL.Endpoints (getLanguages)
import Gargantext.Components.Lang (Lang)
import Gargantext.Config.REST (AffRESTError)
import Gargantext.Prelude
import Gargantext.Sessions (Session)
import Gargantext.Utils.Reactix as R2
here :: R2.Here
here = R2.here "Gargantext.Components.Forest.Tree.Node.Action.Utils"
loadLanguages :: { session :: Session } -> AffRESTError (Array Lang)
loadLanguages { session } = do
eLangsMap <- getLanguages session
pure $ A.fromFoldable <$> Map.keys <$> eLangsMap
src/Gargantext/Components/Lang.purs
View file @
1923ea43
...
...
@@ -98,7 +98,6 @@ type LangSwitcherProps = (
langSwitcher :: R2.Component LangSwitcherProps
langSwitcher = R.createElement langSwitcherCpt
langSwitcherCpt :: R.Component LangSwitcherProps
langSwitcherCpt = here.component "langSwitcher" cpt
where
...
...
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