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
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
gargantext
purescript-gargantext
Commits
30998d6f
Commit
30998d6f
authored
Jun 22, 2018
by
Mael NICOLAS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor, getting the info, need to do lenses
parent
350f3412
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
84 additions
and
88 deletions
+84
-88
API.purs
src/Gargantext/Users/API.purs
+28
-6
Specs.purs
src/Gargantext/Users/Specs.purs
+2
-1
Renders.purs
src/Gargantext/Users/Specs/Renders.purs
+10
-3
Types.purs
src/Gargantext/Users/Types.purs
+2
-0
Lens.purs
src/Gargantext/Users/Types/Lens.purs
+5
-1
States.purs
src/Gargantext/Users/Types/States.purs
+35
-0
Types.purs
src/Gargantext/Users/Types/Types.purs
+2
-77
No files found.
src/Gargantext/Users/API.purs
View file @
30998d6f
module Gargantext.Users.API
module Gargantext.Users.API
where
where
import Gargantext.Users.Types
import Control.Monad.Aff (Aff)
import Control.Monad.Aff (Aff)
import Control.Monad.Aff.Console (CONSOLE)
import Control.Monad.Aff.Console (CONSOLE, log)
import Data.Either (Either)
import Control.Monad.Trans.Class (lift)
import DOM (DOM)
import Data.Either (Either(..))
import Data.Lens (set)
import Data.Maybe (Maybe(..))
import Gargantext.REST (get)
import Gargantext.REST (get)
import Gargantext.Users (User)
import Network.HTTP.Affjax (AJAX)
import Network.HTTP.Affjax (AJAX)
import Prelude (show, ($), (<>))
import Prelude (id, show, void, ($), (<>), bind)
import Thermite (PerformAction, modifyState)
u
ser :: forall eff. Int -> Aff
getU
ser :: forall eff. Int -> Aff
(console :: CONSOLE, ajax :: AJAX | eff) (Either String User)
(console :: CONSOLE, ajax :: AJAX | eff) (Either String User)
user id = get $ "localhost:8008/node/" <> show id
getUser id = get $ "localhost:8008/node/" <> show id
performAction :: forall eff props. PerformAction ( console :: CONSOLE
, ajax :: AJAX
, dom :: DOM
| eff ) State props Action
performAction NoOp _ _ = void do
modifyState id
performAction FetchUser _ _ = void do
value <- lift $ getUser 452145
let user = case value of
(Right user) -> Just user
_ -> Nothing
modifyState \state -> set _user user state
performAction _ _ _ = void do
modifyState id
src/Gargantext/Users/Specs.purs
View file @
30998d6f
...
@@ -9,7 +9,8 @@ import Control.Monad.Aff.Console (CONSOLE)
...
@@ -9,7 +9,8 @@ import Control.Monad.Aff.Console (CONSOLE)
import DOM (DOM)
import DOM (DOM)
import Network.HTTP.Affjax (AJAX)
import Network.HTTP.Affjax (AJAX)
import Thermite (Spec, simpleSpec)
import Thermite (Spec, simpleSpec)
import Gargantext.Users.Types.Types (Action, State, performAction)
import Gargantext.Users.Types (Action, State)
import Gargantext.Users.API (performAction)
layoutUser :: forall props eff . Spec ( console :: CONSOLE
layoutUser :: forall props eff . Spec ( console :: CONSOLE
, ajax :: AJAX
, ajax :: AJAX
...
...
src/Gargantext/Users/Specs/Renders.purs
View file @
30998d6f
module Gargantext.Users.Specs.Renders
module Gargantext.Users.Specs.Renders
where
where
import Control.Monad.Aff (attempt)
import Control.Monad.Aff.Class (liftAff)
import Control.Monad.Aff.Class (liftAff)
import Data.Either (Either(..))
import Data.Generic (gShow)
import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..))
import Data.Tuple (Tuple(..))
import Prelude (($), (<<<))
import Gargantext.Users.API (getUser)
import Gargantext.Users.Types
import Prelude (show, ($), (<<<))
import React (ReactElement)
import React (ReactElement)
import React.DOM (div, h4, li, span, text, ul)
import React.DOM (div, h4, li, span, text, ul)
import React.DOM.Props (_id, className)
import React.DOM.Props (_id, className)
import Thermite (Render)
import Thermite (Render)
import Gargantext.Users.Types.Types (Action, State)
infoRender :: forall props. Tuple String String -> Array ReactElement
infoRender :: forall props. Tuple String String -> Array ReactElement
...
@@ -67,7 +72,9 @@ render dispatch _ state _ =
...
@@ -67,7 +72,9 @@ render dispatch _ state _ =
div [className "row"]
div [className "row"]
[
[
div [className "col-md-8"]
div [className "col-md-8"]
$ card "Jean HEUDE" [userInfos]
$ card (case state.user of (Just _) -> "Ok"
Nothing -> "Pas Ok")
[userInfos]
]
]
]
]
]
]
...
...
src/Gargantext/Users/Types.purs
View file @
30998d6f
module Gargantext.Users.Types
module Gargantext.Users.Types
(module Gargantext.Users.Types.Types,
(module Gargantext.Users.Types.Types,
module Gargantext.Users.Types.Lens,
module Gargantext.Users.Types.Lens,
module Gargantext.Users.Types.States,
brevetSpec,
brevetSpec,
projectSpec,
projectSpec,
facets
facets
...
@@ -9,6 +10,7 @@ module Gargantext.Users.Types
...
@@ -9,6 +10,7 @@ module Gargantext.Users.Types
import Gargantext.Users.Types.Lens
import Gargantext.Users.Types.Lens
import Gargantext.Users.Types.Types
import Gargantext.Users.Types.Types
import Gargantext.Users.Types.States
import Brevets as B
import Brevets as B
import Control.Monad.Aff.Console (CONSOLE)
import Control.Monad.Aff.Console (CONSOLE)
...
...
src/Gargantext/Users/Types/Lens.purs
View file @
30998d6f
...
@@ -5,13 +5,17 @@ import Control.Monad.Aff.Console (CONSOLE)
...
@@ -5,13 +5,17 @@ import Control.Monad.Aff.Console (CONSOLE)
import DOM (DOM)
import DOM (DOM)
import Data.Either (Either(..))
import Data.Either (Either(..))
import Data.Lens (Lens', Prism', lens, prism)
import Data.Lens (Lens', Prism', lens, prism)
import Data.Maybe (Maybe)
import Gargantext.Users.Types.States (Action(..), State)
import Gargantext.Users.Types.Types (User)
import Network.HTTP.Affjax (AJAX)
import Network.HTTP.Affjax (AJAX)
import Projects as PS
import Projects as PS
import Publications as P
import Publications as P
import Tab as Tab
import Tab as Tab
import Thermite (Spec, focus)
import Thermite (Spec, focus)
import Gargantext.Users.Types.Types (State(..), Action(..))
_user :: Lens' State (Maybe User)
_user = lens (\s -> s.user) (\s ss -> s{user = ss})
_tablens :: Lens' State Tab.State
_tablens :: Lens' State Tab.State
_tablens = lens (\s -> s.activeTab) (\s ss -> s {activeTab = ss})
_tablens = lens (\s -> s.activeTab) (\s ss -> s {activeTab = ss})
...
...
src/Gargantext/Users/Types/States.purs
0 → 100644
View file @
30998d6f
module Gargantext.Users.Types.States
where
import Brevets as B
import Data.Maybe (Maybe(..))
import Gargantext.Users.Types.Types (User)
import Projects as PS
import Publications as P
import Tab as Tab
data Action
= NoOp
| PublicationA P.Action
| BrevetsA B.Action
| ProjectsA PS.Action
| TabA Tab.Action
| FetchUser
type State =
{ activeTab :: Int
, publications :: P.State
, brevets :: B.State
, projects :: PS.State
, user :: Maybe User
}
initialState :: State
initialState =
{ activeTab : 0
, publications : P.initialState
, brevets : B.initialState
, projects : PS.initialState
, user: Nothing
}
src/Gargantext/Users/Types/Types.purs
View file @
30998d6f
module Gargantext.Users.Types.Types where
module Gargantext.Users.Types.Types where
import Brevets as B
import Control.Monad.Aff.Console (CONSOLE)
import DOM (DOM)
import Data.Argonaut (class DecodeJson, decodeJson, (.?))
import Data.Argonaut (class DecodeJson, decodeJson, (.?))
import Network.HTTP.Affjax (AJAX)
import Data.Generic (class Generic)
import Prelude (bind, id, pure, void, ($))
import Prelude (bind, pure, ($))
import Projects as PS
import Publications as P
import Tab as Tab
import Thermite (PerformAction, modifyState)
type State =
{ activeTab :: Int
, publications :: P.State
, brevets :: B.State
, projects :: PS.State
}
initialState :: State
initialState =
{ activeTab : 0
, publications : P.initialState
, brevets : B.initialState
, projects : PS.initialState
}
data Action
= NoOp
| PublicationA P.Action
| BrevetsA B.Action
| ProjectsA PS.Action
| TabA Tab.Action
performAction :: forall eff props. PerformAction ( console :: CONSOLE
, ajax :: AJAX
, dom :: DOM
| eff ) State props Action
performAction NoOp _ _ = void do
modifyState id
performAction _ _ _ = void do
modifyState id
-- id 452146
-- typename 41
-- userId 1
-- parentId 452132
-- name "Pierre DEMUGNIER"
-- date "2018-06-18T14:27:50.670952Z"
-- hyperdata
-- bureau "V.305"
-- atel ""
-- fax ""
-- aprecision ""
-- service2 null
-- groupe ""
-- service "ARMINES"
-- lieu "Paris"
-- pservice ""
-- date_modification "07/06/2018"
-- pfonction ""
-- fonction "Service Développement Partenarial - Chargé de Projet France & International"
-- url ""
-- statut null
-- prenom "Pierre"
-- idutilentite "1055"
-- afonction ""
-- grprech ""
-- nom "DEMUGNIER"
-- entite "Armines"
-- entite2 null
-- id "11002"
-- tel "01.40.51.93.66"
-- idutilsiecoles null
-- groupe2 null
-- sexe "1"
-- mail "pierre.demugnier@mines-paristech.fr"
-- actif "1"
newtype User =
newtype User =
User {
User {
...
...
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