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
Hide 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)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe)
import Effect.Aff (Aff)
import Gargantext.Prelude
import Gargantext.Prelude
(class Eq, class Show, class Read, Unit)
import Gargantext.Sessions (Session)
import Gargantext.Types as GT
import Gargantext.Components.Forest.Tree.Node (NodeAction(..), glyphiconNodeAction)
import Data.Maybe (Maybe(..))
type Props =
( dispatch :: Action -> Aff Unit
, id :: Int
...
...
@@ -66,9 +68,18 @@ data FileType = CSV | CSV_HAL | WOS | PresseRIS
derive instance genericFileType :: Generic FileType _
instance eqFileType :: Eq FileType where
eq = genericEq
eq = genericEq
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
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
) where
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 Gargantext.Components.Lang (Lang)
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.Sessions (Session)
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
( 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.String (length)
import Data.Set as Set
import Data.String (length)
import Data.Tuple (fst)
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 Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Prelude (Unit, bind, const, discard, map, pure, show, ($), (&&), (<), (<$>), (<<<), (<>), (==))
import Gargantext.Data.Array (catMaybes)
import Effect.Aff (launchAff_)
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.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.Types as GT
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
select :: forall props.
R.IsComponent String props (Array R.Element)
...
...
@@ -326,7 +321,7 @@ databaseInput (search /\ setSearch) dbs =
liItem db' = H.option {className : "text-primary center"} [ H.text (show db') ]
onChange e = do
let value = read
Database
$ R2.unsafeEventValue e
let value = read $ R2.unsafeEventValue e
setSearch $ _ { datafield = Just $ External 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
import Data.Array (concat)
import Data.Argonaut (class EncodeJson, encodeJson, jsonEmptyObject, (:=), (~>))
import Data.Array (concat)
import Data.Maybe (Maybe(..), fromMaybe, maybe)
import Data.Newtype (class Newtype)
import Data.Set (Set)
...
...
@@ -9,16 +9,14 @@ import Data.Set as Set
import Data.Tuple (Tuple)
import Data.Tuple.Nested ((/\))
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.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.Sessions (Session(..), post)
import Gargantext.Types as GT
import URI.Extra.QueryPairs as QP
import URI.Query as Q
------------------------------------------------------------------------
class Doc a where
...
...
@@ -129,17 +127,18 @@ instance docDatabase :: Doc Database where
-- doc News = "Web filtered by News"
-- doc SocialNetworks = "Web filtered by MicroBlogs"
readDatabase :: String -> Maybe Database
readDatabase "All Databases" = Just All_Databases
readDatabase "PubMed" = Just PubMed
readDatabase "HAL" = Just $ HAL Nothing
readDatabase "Isidore"= Just Isidore
readDatabase "IsTex" = Just IsTex
readDatabase "IsTex_Advanced" = Just IsTex_Advanced
-- readDatabase "Web" = Just Web
-- readDatabase "News" = Just News
-- readDatabase "Social Networks" = Just SocialNetworks
readDatabase _ = Nothing
instance readDatabase :: Read Database where
read :: String -> Maybe Database
read "All Databases" = Just All_Databases
read "PubMed" = Just PubMed
read "HAL" = Just $ HAL Nothing
read "Isidore"= Just Isidore
read "IsTex" = Just IsTex
read "IsTex_Advanced" = Just IsTex_Advanced
-- read "Web" = Just Web
-- read "News" = Just News
-- read "Social Networks" = Just SocialNetworks
read _ = Nothing
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)
import Effect.Class (liftEffect)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..), Props, FileType(..), UploadFileContents(..))
import Gargantext.Components.Forest.Tree.Node.Tools (fragmentPT)
import Gargantext.Components.Lang (
readLang,
Lang(..))
import Gargantext.Prelude (class Show, Unit, discard, bind, const, id, map, pure, show, unit, void, ($))
import Gargantext.Components.Lang (Lang(..))
import Gargantext.Prelude (class Show, Unit, discard, bind, const, id, map, pure, show, unit, void, ($)
, read
)
import Gargantext.Routes as GR
import Gargantext.Sessions (Session, postWwwUrlencoded)
import Gargantext.Types (NodeType(..), ID)
...
...
@@ -132,7 +132,7 @@ uploadFileViewCpt = R.hooksComponent "G.C.F.T.N.A.U.UploadFileView" cpt
setFileType $ const
$ unsafePartial
$ fromJust
$ read
FileType
$ read
$ R2.unsafeEventValue e
onChangeLang :: forall e
...
...
@@ -142,7 +142,7 @@ uploadFileViewCpt = R.hooksComponent "G.C.F.T.N.A.U.UploadFileView" cpt
onChangeLang (lang /\ setLang) e = do
setLang $ const
$ unsafePartial
$ read
Lang
$ read
$ R2.unsafeEventValue e
...
...
@@ -247,8 +247,8 @@ fileTypeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.fileTypeView" cpt
where
onChange e l =
setDroppedFile $ const $ Just $ DroppedFile $ { contents
, fileType: read
FileType
$ R2.unsafeEventValue e
, lang : read
Lang
$ R2.unsafeEventValue l
, fileType: read $ R2.unsafeEventValue e
, lang : read $ R2.unsafeEventValue l
}
renderOption opt = H.option {} [ H.text $ show opt ]
panelFooter =
...
...
@@ -272,14 +272,6 @@ fileTypeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.fileTypeView" cpt
cpt {droppedFile: (Nothing /\ _)} _ = do
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 {
fileType :: FileType
...
...
src/Gargantext/Components/Lang.purs
View file @
5b770057
...
...
@@ -2,8 +2,7 @@ module Gargantext.Components.Lang where
import Data.Argonaut (class EncodeJson, encodeJson)
import Data.Maybe (Maybe(..))
import Gargantext.Prelude (class Eq, class Show, show)
import Gargantext.Prelude (class Eq, class Show, show, class Read)
-- Language used for search
allLangs :: Array Lang
...
...
@@ -23,14 +22,13 @@ instance showLang :: Show Lang where
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
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
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 Effect.Console (log)
import Effect.Class (class MonadEffect, liftEffect)
...
...
@@ -14,6 +15,8 @@ import Effect.Class (class MonadEffect, liftEffect)
id :: forall a. a -> a
id a = a
class Read a where
read :: String -> Maybe a
logs:: forall message effect.
(MonadEffect effect)
...
...
src/Gargantext/Types.purs
View file @
5b770057
module Gargantext.Types where
import Prelude
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, jsonEmptyObject, (.:), (:=), (~>))
import Data.Array as A
import Data.Either (Either(..))
...
...
@@ -40,9 +39,6 @@ derive instance eqTermSize :: Eq TermSize
class ToQuery a where
toQuery :: a -> Query
class Read a where
read :: String -> a
instance showTermSize :: Show TermSize where
show MonoTerm = "MonoTerm"
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