Commit 165c83d5 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FEAT] Backends manager.

parent a4e388b1
...@@ -34,7 +34,7 @@ forestCpt = R.staticComponent "G.C.Forest.forest" cpt where ...@@ -34,7 +34,7 @@ forestCpt = R.staticComponent "G.C.Forest.forest" cpt where
plus :: R2.Setter Boolean -> R.Element plus :: R2.Setter Boolean -> R.Element
plus showLogin = plus showLogin =
H.button {on: {click}} H.button {on: {click}}
[ H.i { className: "glyphicon glyphicon-log-in"} [] ] [ H.i { className: "glyphicon glyphicon-plus"} [] ]
where where
click _ = do click _ = do
showLogin (const true) showLogin (const true)
...@@ -9,11 +9,13 @@ import Reactix.DOM.HTML as H ...@@ -9,11 +9,13 @@ import Reactix.DOM.HTML as H
import Effect.Aff (Aff, launchAff, runAff) import Effect.Aff (Aff, launchAff, runAff)
data NodeAction = Rename data NodeAction = Rename
| Documentation NodeType
| Add (Array NodeType) | Add (Array NodeType)
| Search | Search
| Download | Upload | Refresh | Download | Upload | Refresh
| Move | Clone | Delete | Move | Clone | Delete
| Share | Share
| Disconnect
data ButtonType = Edit | Click | Pop data ButtonType = Edit | Click | Pop
...@@ -59,14 +61,15 @@ nodeActions NodeUser = [ Add [ FolderPrivate ...@@ -59,14 +61,15 @@ nodeActions NodeUser = [ Add [ FolderPrivate
, FolderTeam , FolderTeam
, FolderPublic , FolderPublic
] ]
, Disconnect
, Delete , Delete
] ]
nodeActions FolderPrivate = [Add [Folder, Corpus]] nodeActions FolderPrivate = [ Add [Folder, Corpus]]
nodeActions FolderTeam = [Add [Folder, Corpus]] nodeActions FolderTeam = [ Add [Folder, Corpus]]
nodeActions FolderPublic = [Add [Folder, Corpus]] nodeActions FolderPublic = [ Add [Folder, Corpus]]
nodeActions Folder = [Add [Corpus], Rename, Delete] nodeActions Folder = [ Add [Corpus], Rename, Delete]
nodeActions Corpus = [ Rename nodeActions Corpus = [ Rename
, Search, Upload, Download , Search, Upload, Download
...@@ -84,4 +87,3 @@ nodeActions _ = [] ...@@ -84,4 +87,3 @@ nodeActions _ = []
--------------------------------------------------------- ---------------------------------------------------------
...@@ -32,7 +32,7 @@ import Gargantext.Routes as Routes ...@@ -32,7 +32,7 @@ import Gargantext.Routes as Routes
import Gargantext.Routes (AppRoute, SessionRoute(..)) import Gargantext.Routes (AppRoute, SessionRoute(..))
import Gargantext.Sessions (Session, sessionId, get, put, post, postWwwUrlencoded, delete) import Gargantext.Sessions (Session, sessionId, get, put, post, postWwwUrlencoded, delete)
import Gargantext.Types (class ToQuery, toQuery, NodeType(..), NodePath(..), readNodeType) import Gargantext.Types (class ToQuery, toQuery, NodeType(..), NodePath(..), readNodeType)
import Gargantext.Utils (id) import Gargantext.Utils (id, glyphicon)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Components.Forest.NodeActions import Gargantext.Components.Forest.NodeActions
...@@ -44,16 +44,16 @@ type Reload = Int ...@@ -44,16 +44,16 @@ type Reload = Int
data NodePopup = CreatePopup | NodePopup data NodePopup = CreatePopup | NodePopup
type Props = ( root :: ID type Props = ( root :: ID
, mCurrentRoute :: Maybe AppRoute , mCurrentRoute :: Maybe AppRoute
, session :: Session , session :: Session
, frontends :: Frontends , frontends :: Frontends
) )
type TreeViewProps = ( tree :: FTree type TreeViewProps = ( tree :: FTree
, mCurrentRoute :: Maybe AppRoute , mCurrentRoute :: Maybe AppRoute
, frontends :: Frontends , frontends :: Frontends
, session :: Session , session :: Session
) )
data NTree a = NTree a (Array (NTree a)) data NTree a = NTree a (Array (NTree a))
...@@ -313,7 +313,6 @@ type NodePopupProps = ...@@ -313,7 +313,6 @@ type NodePopupProps =
) )
iconAStyle = {color:"black", paddingTop: "6px", paddingBottom: "6px"} iconAStyle = {color:"black", paddingTop: "6px", paddingBottom: "6px"}
glyphicon t = "glyphitem glyphicon glyphicon-" <> t
nodePopupView :: (Action -> Aff Unit) nodePopupView :: (Action -> Aff Unit)
-> Record NodePopupProps -> Record NodePopupProps
...@@ -344,11 +343,13 @@ nodePopupView d p (Just NodePopup /\ setPopupOpen) = R.createElement el p [] ...@@ -344,11 +343,13 @@ nodePopupView d p (Just NodePopup /\ setPopupOpen) = R.createElement el p []
rowClass false = "col-md-8" rowClass false = "col-md-8"
Buttons {edit:edits,click:clicks,pop:pops} = buttons nodeType Buttons {edit:edits,click:clicks,pop:pops} = buttons nodeType
panelHeading renameBoxOpen@(open /\ _) = panelHeading renameBoxOpen@(open /\ _) =
H.div {className: "panel-heading"} H.div {className: "panel-heading"}
[ H.div {className: "row" } [ H.div {className: "row" }
[ H.div {className: rowClass open} [ renameBox d {id, name} renameBoxOpen ] [ H.div {className: "col-md-1"} []
, buttonClick d (Documentation nodeType)
, H.div {className: rowClass open} [ renameBox d {id, name} renameBoxOpen ]
, if not (null edits) then editIcon renameBoxOpen else H.div {} [] , if not (null edits) then editIcon renameBoxOpen else H.div {} []
, H.div {className: "col-md-2"} , H.div {className: "col-md-2"}
[ H.a {className: "btn text-danger glyphitem glyphicon glyphicon-remove-circle" [ H.a {className: "btn text-danger glyphitem glyphicon glyphicon-remove-circle"
...@@ -378,7 +379,7 @@ nodePopupView d p (Just NodePopup /\ setPopupOpen) = R.createElement el p [] ...@@ -378,7 +379,7 @@ nodePopupView d p (Just NodePopup /\ setPopupOpen) = R.createElement el p []
, border: "none"}} , border: "none"}}
((map (\a -> buttonPop a setPopupOpen) pops) ((map (\a -> buttonPop a setPopupOpen) pops)
<> <>
(map (\a -> buttonClick a d) clicks)) (map (buttonClick d) clicks))
nodePopupView _ p _ = R.createElement el p [] nodePopupView _ p _ = R.createElement el p []
...@@ -387,12 +388,30 @@ nodePopupView _ p _ = R.createElement el p [] ...@@ -387,12 +388,30 @@ nodePopupView _ p _ = R.createElement el p []
cpt _ _ = pure $ H.div {} [] cpt _ _ = pure $ H.div {} []
-- buttonAction :: NodeAction -> R.Element -- buttonAction :: NodeAction -> R.Element
buttonClick _ (Documentation x ) = H.div {className: "col-md-1"}
[ H.a { style: iconAStyle
, className: (glyphicon "question-sign")
, id: "doc"
, title: "Documentation"
}
-- , onClick: mkEffectFn1 $ \_ -> launchAff $ d $ DeleteNode}
[]
]
buttonClick d Disconnect = H.div {className: "col-md-4"}
[ H.a { style: iconAStyle
, className: (glyphicon "log-out")
, id: "log-out"
, title: "Log Out"
-- , onClick: mkEffectFn1 $ \_ -> launchAff $ d $ DeleteNode}
}
[]
]
buttonClick Delete d = H.div {className: "col-md-4"}
[ H.a {style: iconAStyle buttonClick d Delete = H.div {className: "col-md-4"}
[ H.a { style: iconAStyle
, className: (glyphicon "trash") , className: (glyphicon "trash")
, id: "rename2" , id: "rename2"
, title: "Delete" , title: "Delete"
...@@ -400,15 +419,15 @@ buttonClick Delete d = H.div {className: "col-md-4"} ...@@ -400,15 +419,15 @@ buttonClick Delete d = H.div {className: "col-md-4"}
[] []
] ]
buttonClick Upload _ = H.div {className: "col-md-4"} buttonClick _ Upload = H.div {className: "col-md-4"}
[ H.a {style: iconAStyle [ H.a { style: iconAStyle
, className: (glyphicon "upload") , className: (glyphicon "upload")
, id: "upload" , id: "upload"
, title: "Upload [WIP]"} , title: "Upload [WIP]"}
[] []
] ]
buttonClick Download _ = H.div {className: "col-md-4"} buttonClick _ Download = H.div {className: "col-md-4"}
[ H.a {style: iconAStyle [ H.a {style: iconAStyle
, className: (glyphicon "download") , className: (glyphicon "download")
, id: "download" , id: "download"
...@@ -421,7 +440,7 @@ buttonClick _ _ = H.div {} [] ...@@ -421,7 +440,7 @@ buttonClick _ _ = H.div {} []
buttonPop (Add _) f = H.div {className: "col-md-4"} buttonPop (Add _) f = H.div {className: "col-md-4"}
[ H.a {style: iconAStyle [ H.a { style: iconAStyle
, className: (glyphicon "plus") , className: (glyphicon "plus")
, id: "create" , id: "create"
, title: "Create" , title: "Create"
......
...@@ -3,11 +3,12 @@ ...@@ -3,11 +3,12 @@
-- Select a backend and log into it -- Select a backend and log into it
module Gargantext.Components.Login where module Gargantext.Components.Login where
import Prelude (Unit, bind, const, discard, pure, flip, show, ($), (<>), (*>), (<$>)) import Prelude (Unit, bind, const, discard, pure, flip, show, ($), (<>), (*>), (<$>), (>))
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Tuple (fst, snd) import Data.Tuple (fst, snd)
import DOM.Simple.Console (log) import DOM.Simple.Console (log)
import Data.Sequence as DS
import Effect (Effect) import Effect (Effect)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Effect.Aff (launchAff_) import Effect.Aff (launchAff_)
...@@ -18,9 +19,9 @@ import Reactix.DOM.HTML as H ...@@ -18,9 +19,9 @@ import Reactix.DOM.HTML as H
import Gargantext.Components.Forms (clearfix, card, cardBlock, cardGroup, center, formGroup) import Gargantext.Components.Forms (clearfix, card, cardBlock, cardGroup, center, formGroup)
import Gargantext.Components.Login.Types (AuthRequest(..)) import Gargantext.Components.Login.Types (AuthRequest(..))
import Gargantext.Ends (Backend(..)) import Gargantext.Ends (Backend(..))
import Gargantext.Sessions (Session, Sessions, postAuthRequest, unSessions) import Gargantext.Sessions (Session, Sessions(..), postAuthRequest, unSessions)
import Gargantext.Sessions as Sessions import Gargantext.Sessions as Sessions
import Gargantext.Utils (csrfMiddlewareToken) import Gargantext.Utils (csrfMiddlewareToken, glyphicon)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
-- TODO: ask for login (modal) or account creation after 15 mn when user -- TODO: ask for login (modal) or account creation after 15 mn when user
...@@ -48,13 +49,20 @@ modalCpt = R.hooksComponent "G.C.Login.modal" cpt where ...@@ -48,13 +49,20 @@ modalCpt = R.hooksComponent "G.C.Login.modal" cpt where
[ H.div { className: "modal-dialog", role: "document"} [ H.div { className: "modal-dialog", role: "document"}
[ H.div { className: "modal-content" } [ H.div { className: "modal-content" }
[ H.div { className: "modal-header" } [ H.div { className: "modal-header" }
[ H.h5 { className: "modal-title" } [] [ logo
, H.h2 { className: "center modal-title" } [H.text "Backends manager"]
, H.button { "type": "button", className: "close" , H.button { "type": "button", className: "close"
, "data": { dismiss: "modal" } } , "data": { dismiss: "modal" } }
[ H.span { on: {click} } [ H.text "X" ] ] ] [ H.span { on: {click} } [ H.text "X" ] ] ]
, H.div { className: "modal-body" } children ] ] ] ] , H.div { className: "modal-body" } children ] ] ] ]
modalClass s = "modal myModal" <> if s then "" else " fade" modalClass s = "modal myModal" <> if s then "" else " fade"
logo =
H.div {className: "col-md-10 col-md-push-1"}
[ H.h2 {className: "text-primary center m-a-2"}
[ H.i {className: "material-icons md-36"} [ H.text "control_point" ]
, H.span {className: "icon-text"} [ H.text "Gargantext" ] ] ]
login :: Record Props -> R.Element login :: Record Props -> R.Element
login props = R.createElement loginCpt props [] login props = R.createElement loginCpt props []
...@@ -79,22 +87,49 @@ chooserCpt :: R.Component ChooserProps ...@@ -79,22 +87,49 @@ chooserCpt :: R.Component ChooserProps
chooserCpt = R.staticComponent "G.C.Login.chooser" cpt where chooserCpt = R.staticComponent "G.C.Login.chooser" cpt where
cpt :: Record ChooserProps -> Array R.Element -> R.Element cpt :: Record ChooserProps -> Array R.Element -> R.Element
cpt {backend, backends, sessions} _ = cpt {backend, backends, sessions} _ =
H.ul {} R.fragment $ new <> active
[ renderSessions sessions, renderBackends backends backend ] where
active = if DS.length ss > 0 then [ H.h3 {} [H.text "Active connection(s)"]
, H.ul {} [ renderSessions sessions]
] else [] where
Sessions {sessions:ss} = fst sessions
new = [ H.h3 {} [H.text "New connection(s)"]
, H.ul {} [renderBackends backends backend ]
]
renderSessions :: R2.Reductor Sessions Sessions.Action -> R.Element renderSessions :: R2.Reductor Sessions Sessions.Action -> R.Element
renderSessions sessions = R.fragment (renderSession <$> unSessions (fst sessions)) renderSessions sessions = R.fragment (renderSession sessions <$> unSessions (fst sessions))
renderSession :: Session -> R.Element renderSession :: R2.Reductor Sessions Sessions.Action -> Session -> R.Element
renderSession session = H.li {} [ H.text $ "Active session: " <> show session ] renderSession sessions session = H.li {} $ [ H.text $ "Active session: " <> show session ]
<> [ H.a { on : {click}
, className: glyphicon "log-out"
, id : "log-out"
, title: "Log out"
} [] ]
where
click _ = (snd sessions) (Sessions.Logout session)
renderBackends :: Array Backend -> R.State (Maybe Backend) -> R.Element renderBackends :: Array Backend -> R.State (Maybe Backend) -> R.Element
renderBackends backends state = R.fragment $ (flip renderBackend $ state) <$> backends renderBackends backends state = R.fragment $ (flip renderBackend $ state) <$> backends
{-
renderBackend :: Backend -> R.State (Maybe Backend) -> R.Element renderBackend :: Backend -> R.State (Maybe Backend) -> R.Element
renderBackend backend@(Backend {name}) state = renderBackend backend@(Backend {name}) state =
H.li {} [ H.a {on: {click}} [ H.text $ "Connect to " <> name ] ] where H.li {} [ H.a {on: {click}, className: glyphicon "log-in"} [ H.text $ "Connect to " <> name ] ] where
click _ = (snd state) (const $ Just backend) click _ = (snd state) (const $ Just backend)
-}
renderBackend :: Backend -> R.State (Maybe Backend) -> R.Element
renderBackend backend@(Backend {name}) state =
H.li {} $ [ H.a { on : {click}
-- , className: glyphicon "log-in"
-- , id : "log-in"
} [ H.text $ " Connect to " <> name ] ] <> [ H.a { on : {click}, className : glyphicon "log-in", title: "Log In"} []]
where
click _ = (snd state) (const $ Just backend)
type FormProps = type FormProps =
( backend :: Backend ( backend :: Backend
...@@ -112,8 +147,7 @@ formCpt = R.hooksComponent "G.C.Login.form" cpt where ...@@ -112,8 +147,7 @@ formCpt = R.hooksComponent "G.C.Login.form" cpt where
username <- R.useState' "" username <- R.useState' ""
password <- R.useState' "" password <- R.useState' ""
pure $ H.div {className: "row"} pure $ H.div {className: "row"}
[ logo [ cardGroup
, cardGroup
[ card [ card
[ cardBlock [ cardBlock
[ center [ center
...@@ -141,11 +175,6 @@ formCpt = R.hooksComponent "G.C.Login.form" cpt where ...@@ -141,11 +175,6 @@ formCpt = R.hooksComponent "G.C.Login.form" cpt where
(snd sessions) (Sessions.Login sess) (snd sessions) (Sessions.Login sess)
(snd error) (const "") (snd error) (const "")
(snd visible) (const false) (snd visible) (const false)
logo =
H.div {className: "col-md-10 col-md-push-1"}
[ H.h2 {className: "text-primary center m-a-2"}
[ H.i {className: "material-icons md-36"} [ H.text "control_point" ]
, H.span {className: "icon-text"} [ H.text "Gargantext" ] ] ]
csrfTokenInput :: {} -> R.Element csrfTokenInput :: {} -> R.Element
csrfTokenInput _ = csrfTokenInput _ =
......
...@@ -38,3 +38,6 @@ csrfMiddlewareToken = "Wy52D2nor8kC1r1Y4GrsrSIxQ2eqW8UwkdiQQshMoRwobzU4uldknRUhP ...@@ -38,3 +38,6 @@ csrfMiddlewareToken = "Wy52D2nor8kC1r1Y4GrsrSIxQ2eqW8UwkdiQQshMoRwobzU4uldknRUhP
_unit :: forall s. Lens' s Unit _unit :: forall s. Lens' s Unit
_unit = lens (\_ -> unit) (\s _ -> s) _unit = lens (\_ -> unit) (\s _ -> s)
glyphicon t = "glyphitem glyphicon glyphicon-" <> t
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment