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
5b770057
Commit
5b770057
authored
Jun 12, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[REFACT] instances of class Read
parent
8864fe75
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
59 additions
and
69 deletions
+59
-69
Action.purs
src/Gargantext/Components/Forest/Tree/Node/Action.purs
+14
-3
SearchBar.purs
.../Components/Forest/Tree/Node/Action/Search/SearchBar.purs
+2
-6
SearchField.purs
...omponents/Forest/Tree/Node/Action/Search/SearchField.purs
+10
-15
Types.purs
...text/Components/Forest/Tree/Node/Action/Search/Types.purs
+16
-17
Upload.purs
...Gargantext/Components/Forest/Tree/Node/Action/Upload.purs
+6
-14
Lang.purs
src/Gargantext/Components/Lang.purs
+7
-9
Prelude.purs
src/Gargantext/Prelude.purs
+4
-1
Types.purs
src/Gargantext/Types.purs
+0
-4
No files found.
src/Gargantext/Components/Forest/Tree/Node/Action.purs
View file @
5b770057
...
@@ -5,11 +5,13 @@ import Data.Generic.Rep.Eq (genericEq)
...
@@ -5,11 +5,13 @@ import Data.Generic.Rep.Eq (genericEq)
import Data.Generic.Rep.Show (genericShow)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe)
import Data.Maybe (Maybe)
import Effect.Aff (Aff)
import Effect.Aff (Aff)
import Gargantext.Prelude
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 Data.Maybe (Maybe(..))
type Props =
type Props =
( dispatch :: Action -> Aff Unit
( dispatch :: Action -> Aff Unit
, id :: Int
, id :: Int
...
@@ -71,4 +73,13 @@ instance eqFileType :: Eq FileType where
...
@@ -71,4 +73,13 @@ instance eqFileType :: Eq FileType where
instance showFileType :: Show FileType where
instance showFileType :: Show FileType where
show = genericShow
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
newtype UploadFileContents = UploadFileContents String
src/Gargantext/Components/Forest/Tree/Node/Action/Search/SearchBar.purs
View file @
5b770057
...
@@ -3,14 +3,10 @@ module Gargantext.Components.Forest.Tree.Node.Action.Search.SearchBar
...
@@ -3,14 +3,10 @@ module Gargantext.Components.Forest.Tree.Node.Action.Search.SearchBar
) where
) where
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Data.Nullable (Nullable)
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Components.Forest.Tree.Node.Action.Search.Types -- (Database, SearchQuery(..), defaultSearchQuery, performSearch, Lang(..))
import Effect (Effect)
import Effect (Effect)
import Gargantext.Components.Lang (Lang)
import Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField (Search, searchField)
import Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField (Search, searchField)
import Gargantext.Components.Forest.Tree.Node.Action.Search.Types -- (Database, SearchQuery(..), defaultSearchQuery, performSearch, Lang(..))
import Gargantext.Components.Lang (Lang)
import Gargantext.Prelude (Unit, pure, ($))
import Gargantext.Prelude (Unit, pure, ($))
import Gargantext.Sessions (Session)
import Gargantext.Sessions (Session)
import Gargantext.Types as GT
import Gargantext.Types as GT
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Search/SearchField.purs
View file @
5b770057
module Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField
module Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField
( Search, Props, defaultSearch, searchField, searchFieldComponent, isIsTex, isIsTex_Advanced) where
( Search, Props, defaultSearch, searchField, searchFieldComponent, isIsTex, isIsTex_Advanced) where
import Data.Maybe (Maybe(..), maybe, fromMaybe, isJust)
import DOM.Simple.Console (log, log2)
import Data.Maybe (Maybe(..), maybe, fromMaybe)
import Data.Newtype (over)
import Data.Newtype (over)
import Data.String (length)
import Data.Set as Set
import Data.Set as Set
import Data.String (length)
import Data.Tuple (fst)
import Data.Tuple (fst)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Data.Nullable (Nullable, toMaybe)
import Effect.Console (logShow)
import DOM.Simple.Console (log, log2)
import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect)
import Effect (Effect)
import Effect (Effect)
import Reactix as R
import Effect.Aff (launchAff_)
import Reactix.DOM.HTML as H
import Effect.Class (liftEffect)
import Gargantext.Components.Forest.Tree.Node.Action.Search.Types (DataField(..), Database(..), IMT_org(..), Org(..), SearchQuery(..), allIMTorgs, allOrgs, dataFields, defaultSearchQuery, doc, performSearch, readOrg, datafield2database)
import Gargantext.Prelude (Unit, bind, const, discard, map, pure, show, ($), (&&), (<), (<$>), (<<<), (<>), (==))
import Gargantext.Data.Array (catMaybes)
import Gargantext.Components.Lang (Lang)
import Gargantext.Components.Lang (Lang)
import Gargantext.
Components.Forest.Tree.Node.Action.Search.Types (DataOriginApi(..), DataField(..), Database(..), IMT_org(..), Org(..), SearchQuery(..), allIMTorgs, allOrgs, dataFields, defaultSearchQuery, doc, performSearch, readDatabase, readOrg, datafield2database
)
import Gargantext.
Prelude (Unit, bind, discard, map, pure, show, ($), (&&), (<), (<$>), (<>), (==), read
)
import Gargantext.Sessions (Session)
import Gargantext.Sessions (Session)
import Gargantext.Types as GT
import Gargantext.Types as GT
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
select :: forall props.
select :: forall props.
R.IsComponent String props (Array R.Element)
R.IsComponent String props (Array R.Element)
...
@@ -326,7 +321,7 @@ databaseInput (search /\ setSearch) dbs =
...
@@ -326,7 +321,7 @@ databaseInput (search /\ setSearch) dbs =
liItem db' = H.option {className : "text-primary center"} [ H.text (show db') ]
liItem db' = H.option {className : "text-primary center"} [ H.text (show db') ]
onChange e = do
onChange e = do
let value = read
Database
$ R2.unsafeEventValue e
let value = read $ R2.unsafeEventValue e
setSearch $ _ { datafield = Just $ External value
setSearch $ _ { datafield = Just $ External value
, databases = fromMaybe Empty value
, databases = fromMaybe Empty value
}
}
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Search/Types.purs
View file @
5b770057
module Gargantext.Components.Forest.Tree.Node.Action.Search.Types where
module Gargantext.Components.Forest.Tree.Node.Action.Search.Types where
import Data.Array (concat)
import Data.Argonaut (class EncodeJson, encodeJson, jsonEmptyObject, (:=), (~>))
import Data.Argonaut (class EncodeJson, encodeJson, jsonEmptyObject, (:=), (~>))
import Data.Array (concat)
import Data.Maybe (Maybe(..), fromMaybe, maybe)
import Data.Maybe (Maybe(..), fromMaybe, maybe)
import Data.Newtype (class Newtype)
import Data.Newtype (class Newtype)
import Data.Set (Set)
import Data.Set (Set)
...
@@ -9,16 +9,14 @@ import Data.Set as Set
...
@@ -9,16 +9,14 @@ import Data.Set as Set
import Data.Tuple (Tuple)
import Data.Tuple (Tuple)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff)
import Effect.Aff (Aff)
import URI.Extra.QueryPairs as QP
import URI.Query as Q
import Gargantext.Prelude (id, class Eq, class Ord, class Show, bind, map, pure, show, ($), (<>))
import Gargantext.Components.Lang
import Gargantext.Components.Lang
import Gargantext.Ends (class ToUrl, backendUrl)
import Gargantext.Ends (class ToUrl, backendUrl)
import Gargantext.Prelude (id, class Eq, class Ord, class Show, bind, map, pure, show, ($), (<>), class Read)
import Gargantext.Routes as GR
import Gargantext.Routes as GR
import Gargantext.Sessions (Session(..), post)
import Gargantext.Sessions (Session(..), post)
import Gargantext.Types as GT
import Gargantext.Types as GT
import URI.Extra.QueryPairs as QP
import URI.Query as Q
------------------------------------------------------------------------
------------------------------------------------------------------------
class Doc a where
class Doc a where
...
@@ -129,17 +127,18 @@ instance docDatabase :: Doc Database where
...
@@ -129,17 +127,18 @@ instance docDatabase :: Doc Database where
-- doc News = "Web filtered by News"
-- doc News = "Web filtered by News"
-- doc SocialNetworks = "Web filtered by MicroBlogs"
-- doc SocialNetworks = "Web filtered by MicroBlogs"
readDatabase :: String -> Maybe Database
instance readDatabase :: Read Database where
readDatabase "All Databases" = Just All_Databases
read :: String -> Maybe Database
readDatabase "PubMed" = Just PubMed
read "All Databases" = Just All_Databases
readDatabase "HAL" = Just $ HAL Nothing
read "PubMed" = Just PubMed
readDatabase "Isidore"= Just Isidore
read "HAL" = Just $ HAL Nothing
readDatabase "IsTex" = Just IsTex
read "Isidore"= Just Isidore
readDatabase "IsTex_Advanced" = Just IsTex_Advanced
read "IsTex" = Just IsTex
-- readDatabase "Web" = Just Web
read "IsTex_Advanced" = Just IsTex_Advanced
-- readDatabase "News" = Just News
-- read "Web" = Just Web
-- readDatabase "Social Networks" = Just SocialNetworks
-- read "News" = Just News
readDatabase _ = Nothing
-- read "Social Networks" = Just SocialNetworks
read _ = Nothing
derive instance eqDatabase :: Eq Database
derive instance eqDatabase :: Eq Database
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Upload.purs
View file @
5b770057
...
@@ -9,8 +9,8 @@ import Effect.Aff (Aff, launchAff)
...
@@ -9,8 +9,8 @@ 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, FileType(..), UploadFileContents(..))
import Gargantext.Components.Forest.Tree.Node.Tools (fragmentPT)
import Gargantext.Components.Forest.Tree.Node.Tools (fragmentPT)
import Gargantext.Components.Lang (
readLang,
Lang(..))
import Gargantext.Components.Lang (Lang(..))
import Gargantext.Prelude (class Show, Unit, discard, bind, const, id, map, pure, show, unit, void, ($))
import Gargantext.Prelude (class Show, Unit, discard, bind, const, id, map, pure, show, unit, void, ($)
, read
)
import Gargantext.Routes as GR
import Gargantext.Routes as GR
import Gargantext.Sessions (Session, postWwwUrlencoded)
import Gargantext.Sessions (Session, postWwwUrlencoded)
import Gargantext.Types (NodeType(..), ID)
import Gargantext.Types (NodeType(..), ID)
...
@@ -132,7 +132,7 @@ uploadFileViewCpt = R.hooksComponent "G.C.F.T.N.A.U.UploadFileView" cpt
...
@@ -132,7 +132,7 @@ uploadFileViewCpt = R.hooksComponent "G.C.F.T.N.A.U.UploadFileView" cpt
setFileType $ const
setFileType $ const
$ unsafePartial
$ unsafePartial
$ fromJust
$ fromJust
$ read
FileType
$ read
$ R2.unsafeEventValue e
$ R2.unsafeEventValue e
onChangeLang :: forall e
onChangeLang :: forall e
...
@@ -142,7 +142,7 @@ uploadFileViewCpt = R.hooksComponent "G.C.F.T.N.A.U.UploadFileView" cpt
...
@@ -142,7 +142,7 @@ uploadFileViewCpt = R.hooksComponent "G.C.F.T.N.A.U.UploadFileView" cpt
onChangeLang (lang /\ setLang) e = do
onChangeLang (lang /\ setLang) e = do
setLang $ const
setLang $ const
$ unsafePartial
$ unsafePartial
$ read
Lang
$ read
$ R2.unsafeEventValue e
$ R2.unsafeEventValue e
...
@@ -247,8 +247,8 @@ fileTypeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.fileTypeView" cpt
...
@@ -247,8 +247,8 @@ fileTypeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.fileTypeView" cpt
where
where
onChange e l =
onChange e l =
setDroppedFile $ const $ Just $ DroppedFile $ { contents
setDroppedFile $ const $ Just $ DroppedFile $ { contents
, fileType: read
FileType
$ R2.unsafeEventValue e
, fileType: read $ R2.unsafeEventValue e
, lang : read
Lang
$ R2.unsafeEventValue l
, lang : read $ R2.unsafeEventValue l
}
}
renderOption opt = H.option {} [ H.text $ show opt ]
renderOption opt = H.option {} [ H.text $ show opt ]
panelFooter =
panelFooter =
...
@@ -272,14 +272,6 @@ fileTypeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.fileTypeView" cpt
...
@@ -272,14 +272,6 @@ fileTypeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.fileTypeView" cpt
cpt {droppedFile: (Nothing /\ _)} _ = do
cpt {droppedFile: (Nothing /\ _)} _ = do
pure $ H.div {} []
pure $ H.div {} []
-- | 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
newtype FileUploadQuery = FileUploadQuery {
newtype FileUploadQuery = FileUploadQuery {
fileType :: FileType
fileType :: FileType
...
...
src/Gargantext/Components/Lang.purs
View file @
5b770057
...
@@ -2,8 +2,7 @@ module Gargantext.Components.Lang where
...
@@ -2,8 +2,7 @@ module Gargantext.Components.Lang where
import Data.Argonaut (class EncodeJson, encodeJson)
import Data.Argonaut (class EncodeJson, encodeJson)
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..))
import Gargantext.Prelude (class Eq, class Show, show, class Read)
import Gargantext.Prelude (class Eq, class Show, show)
-- Language used for search
-- Language used for search
allLangs :: Array Lang
allLangs :: Array Lang
...
@@ -23,14 +22,13 @@ instance showLang :: Show Lang where
...
@@ -23,14 +22,13 @@ instance showLang :: Show Lang where
derive instance eqLang :: Eq Lang
derive instance eqLang :: Eq Lang
-- instance readLang :: Read Lang where
instance readLang :: Read Lang where
read "FR" = Just FR
read "EN" = Just EN
read "All" = Just Universal
read "Nothing" = Just No_extraction
read _ = Nothing
readLang :: String -> Maybe Lang
readLang "FR" = Just FR
readLang "EN" = Just EN
readLang "All" = Just Universal
readLang "Nothing" = Just No_extraction
readLang _ = Nothing
instance encodeJsonLang :: EncodeJson Lang where
instance encodeJsonLang :: EncodeJson Lang where
encodeJson a = encodeJson (show a)
encodeJson a = encodeJson (show a)
...
...
src/Gargantext/Prelude.purs
View file @
5b770057
module Gargantext.Prelude (module Prelude, logs, id)
module Gargantext.Prelude (module Prelude, logs, id
, class Read, read
)
where
where
import Data.Maybe (Maybe(..))
import Prelude (class Applicative, class Apply, class Bind, class BooleanAlgebra, class Bounded, class Category, class CommutativeRing, class Discard, class DivisionRing, class Eq, class EuclideanRing, class Field, class Functor, class HeytingAlgebra, class Monad, class Monoid, class Ord, class Ring, class Semigroup, class Semigroupoid, class Semiring, class Show, type (~>), Ordering(..), Unit, Void, absurd, add, ap, append, apply, between, bind, bottom, clamp, compare, comparing, compose, conj, const, degree, discard, disj, eq, flap, flip, gcd, identity, ifM, join, lcm, liftA1, liftM1, map, max, mempty, min, mod, mul, negate, not, notEq, one, otherwise, pure, recip, show, sub, top, unit, unless, unlessM, void, when, whenM, zero, (#), ($), ($>), (&&), (*), (*>), (+), (-), (/), (/=), (<), (<#>), (<$), (<$>), (<*), (<*>), (<<<), (<=), (<=<), (<>), (<@>), (=<<), (==), (>), (>=), (>=>), (>>=), (>>>), (||))
import Prelude (class Applicative, class Apply, class Bind, class BooleanAlgebra, class Bounded, class Category, class CommutativeRing, class Discard, class DivisionRing, class Eq, class EuclideanRing, class Field, class Functor, class HeytingAlgebra, class Monad, class Monoid, class Ord, class Ring, class Semigroup, class Semigroupoid, class Semiring, class Show, type (~>), Ordering(..), Unit, Void, absurd, add, ap, append, apply, between, bind, bottom, clamp, compare, comparing, compose, conj, const, degree, discard, disj, eq, flap, flip, gcd, identity, ifM, join, lcm, liftA1, liftM1, map, max, mempty, min, mod, mul, negate, not, notEq, one, otherwise, pure, recip, show, sub, top, unit, unless, unlessM, void, when, whenM, zero, (#), ($), ($>), (&&), (*), (*>), (+), (-), (/), (/=), (<), (<#>), (<$), (<$>), (<*), (<*>), (<<<), (<=), (<=<), (<>), (<@>), (=<<), (==), (>), (>=), (>=>), (>>=), (>>>), (||))
import Effect.Console (log)
import Effect.Console (log)
import Effect.Class (class MonadEffect, liftEffect)
import Effect.Class (class MonadEffect, liftEffect)
...
@@ -14,6 +15,8 @@ import Effect.Class (class MonadEffect, liftEffect)
...
@@ -14,6 +15,8 @@ import Effect.Class (class MonadEffect, liftEffect)
id :: forall a. a -> a
id :: forall a. a -> a
id a = a
id a = a
class Read a where
read :: String -> Maybe a
logs:: forall message effect.
logs:: forall message effect.
(MonadEffect effect)
(MonadEffect effect)
...
...
src/Gargantext/Types.purs
View file @
5b770057
module Gargantext.Types where
module Gargantext.Types where
import Prelude
import Prelude
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, jsonEmptyObject, (.:), (:=), (~>))
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, jsonEmptyObject, (.:), (:=), (~>))
import Data.Array as A
import Data.Array as A
import Data.Either (Either(..))
import Data.Either (Either(..))
...
@@ -40,9 +39,6 @@ derive instance eqTermSize :: Eq TermSize
...
@@ -40,9 +39,6 @@ derive instance eqTermSize :: Eq TermSize
class ToQuery a where
class ToQuery a where
toQuery :: a -> Query
toQuery :: a -> Query
class Read a where
read :: String -> a
instance showTermSize :: Show TermSize where
instance showTermSize :: Show TermSize where
show MonoTerm = "MonoTerm"
show MonoTerm = "MonoTerm"
show MultiTerm = "MultiTerm"
show MultiTerm = "MultiTerm"
...
...
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