Commit 8dd19489 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] EcoSystem Explorer (WIP) and migrations

parent 8a629d69
......@@ -57,24 +57,23 @@ chooserCpt = here.component "chooser" cpt where
sessions' <- T.useLive T.unequal sessions
pure $
R.fragment $
[ H.h2 { className: "center modal-title" }
[ H.text "Instances manager" ]]
<> activeConnections sessions sessions' <>
[ H.h3 {} [ H.text "Existing connections" ]
{- [ H.h2 { className: "mx-auto" } [ H.text "Workspace manager" ]]
<> -} activeConnections sessions sessions' <>
[ H.h3 {} [ H.text "Existing places" ]
, H.table { className : "table" }
[ H.thead { className: "thead-light" }
[ H.tr {} (map header headers) ]
, H.tbody {} (map (renderBackend backend) backends) ]
, H.input { className: "form-control", type:"text", placeholder } ]
placeholder = "Search for your institute"
headers = [ "", "Label of instance", "Gargurl" ]
headers = [ "", "GarganText places", "Garg protocol url" ]
header label = H.th {} [ H.text label ]
-- Shown in the chooser
activeConnections :: forall s. T.ReadWrite s Sessions => s -> Sessions -> Array R.Element
activeConnections _ sessions' | Sessions.null sessions' = []
activeConnections sessions sessions' =
[ H.h3 {} [ H.text "Active connection(s)" ]
[ H.h3 {} [ H.text "Active place(s)" ]
, H.ul {} [ renderSessions sessions sessions' ] ]
renderSessions :: forall s. T.ReadWrite s Sessions => s -> Sessions -> R.Element
......@@ -103,11 +102,11 @@ clearCacheButton =
*> liftEffect (here.log "cache cleared")
renderBackend :: forall b. T.Write b (Maybe Backend) => b -> Backend -> R.Element
renderBackend cursor backend@(Backend {name}) =
renderBackend cursor backend@(Backend {name, baseUrl}) =
H.tr {}
[ H.td {} [ H.a { on: { click }, title: "Log In", className } [] ]
, H.td {} [ H.a { on: { click }} [ H.text (backendLabel name) ]]
, H.td {} [ H.text $ "garg://" <> name ]] where
, H.td {} [ H.text $ DST.replace (DST.Pattern "http") (DST.Replacement "garg") $ baseUrl ]] where
className = "fa fa-hand-o-right" -- "glyphitem fa fa-log-in"
click _ = T.write_ (Just backend) cursor
......
......@@ -31,7 +31,7 @@ modalCpt = here.component "modal" cpt where
[ 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" ]]]
[ H.span {className: "center icon-text"} [ H.text "Exploring the eco-system with the workspace manager" ]]]
, H.button -- TODO , font-size : "50px"
{ type: "button", className: "close"
, data: { dismiss: "modal" }}
......
......@@ -12,34 +12,24 @@ import Gargantext.Prelude (bind, pure, ($))
import Gargantext.Types (ApiVersion(..))
import Gargantext.Utils (href)
defaultBackends :: NonEmpty Array Backend
defaultBackends =
backend_local :| [ backend_prod, backend_partner, backend_demo, backend_dev ]
prodUrl :: String
prodUrl = "https://v4.gargantext.org"
backend_prod :: Backend
backend_prod = backend V10 "/api/" prodUrl "iscpif.cnrs"
partnerUrl :: String
partnerUrl = "https://imtv4.gargantext.org"
backend_partner :: Backend
backend_partner = backend V10 "/api/" partnerUrl "institut-mines-telecom.imt"
demoUrl :: String
demoUrl = "https://demo.gargantext.org"
backend_demo :: Backend
backend_demo = backend V10 "/api/" demoUrl "demo.inshs.cnrs"
devUrl :: String
devUrl = "https://dev.gargantext.org"
backend_dev :: Backend
backend_dev = backend V10 "/api/" devUrl "devel.inshs.cnrs"
localUrl :: String
localUrl = "http://localhost:8008"
backend_local :: Backend
backend_local = backend V10 "/api/" localUrl "local.cnrs"
defaultBackends = backend' "Show Room (Demo)" "https://demo.gargantext.org"
:| [ backend' "Laboratory Room (CNRS/ISCPIF)" "https://cnrs.gargantext.org"
, backend' "Class Room" "https://learn.gargantext.org"
, backend' "Funding Partner (IMT)" "https://imtv5.gargantext.org"
, backend' "Scientific Community (Complex Systems)" "https://community.gargantext.org"
, backend' "European Project (VIGIE)" "https://europa.gargantext.org"
, backend' "Dev SandBox" "https://dev.gargantext.org"
, backend' "Private Bunker (Local Only)" "http://localhost:8008"
, backend' "Business Room (Hello Word)" "https://garg.helloword.io"
]
where
backend' n u = backend n V10 "/api/" u
matchCurrentLocation :: Effect (Maybe Backend)
matchCurrentLocation = do
......@@ -51,7 +41,7 @@ matchCurrentLocation = do
-- | public Backend
-- When user is not logged, use the location of the window
publicBackend :: Backend
publicBackend = backend_local
publicBackend = backend "local" V10 "/api/" "http://localhost:8008"
publicBackend' :: Effect Backend
publicBackend' = do
......
......@@ -36,8 +36,11 @@ instance Eq Backend where eq = genericEq
instance Show Backend where show (Backend {name}) = name
instance ToUrl Backend String where toUrl = backendUrl
backend :: ApiVersion -> String -> String -> String -> Backend
backend version prePath baseUrl name = Backend { name, version, prePath, baseUrl }
type BaseUrl = String
type PrePath = String
type Name = String
backend :: Name -> ApiVersion -> PrePath -> BaseUrl -> Backend
backend name version prePath baseUrl = Backend { name, version, prePath, baseUrl }
-- | Creates a backend url from a backend and the path as a string
backendUrl :: Backend -> String -> String
......
......@@ -7,8 +7,8 @@ module Gargantext.Sessions.Types
import Data.Array as A
import Data.Either (Either(..))
import Data.Generic.Rep (class Generic)
import Data.Eq.Generic (genericEq)
import Data.Generic.Rep (class Generic)
import Data.Int as Int
import Data.Map (Map)
import Data.Map as Map
......@@ -19,21 +19,20 @@ import Data.Sequence as Seq
import Data.Set (Set)
import Data.Set as Set
import Data.Show.Generic (genericShow)
import Data.String as DST
import Data.Tuple (Tuple)
import Foreign.Object as Object
import Reactix as R
import Simple.JSON as JSON
import Toestand as T
import Gargantext.Prelude
import Gargantext.Components.Login.Types (TreeId)
import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Ends (class ToUrl, Backend(..), backendUrl, sessionPath)
import Gargantext.Prelude
import Gargantext.Routes (SessionRoute)
import Gargantext.Types (NodePath, SessionId(..), nodePath)
import Gargantext.Utils.JSON as GJSON
import Gargantext.Utils.Tuple as GUT
import Reactix as R
import Simple.JSON as JSON
import Toestand as T
-- | A Session represents an authenticated session for a user at a
-- | backend. It contains a token and root tree id.
......@@ -61,9 +60,18 @@ instance JSON.WriteForeign Session where
JSON.writeImpl { backend, caches: caches', token, treeId, username }
where
caches' = JSON.writeImpl $ Object.fromFoldable (GUT.mapFst show <$> Map.toUnfoldable caches :: Array (Tuple String NT.CacheState))
instance Eq Session where eq = genericEq
instance Show Session where show (Session {backend, username}) = username <> "@" <> show backend
instance Show Session where
show (Session {backend, username}) = username <> "@" <> url
where
Backend {baseUrl} = backend
url = DST.replace (DST.Pattern "http://") (DST.Replacement "")
$ DST.replace (DST.Pattern "https://") (DST.Replacement "") baseUrl
instance ToUrl Session SessionRoute where toUrl (Session {backend}) r = backendUrl backend (sessionPath r)
instance ToUrl Session NodePath where toUrl (Session {backend}) np = backendUrl backend (nodePath np)
instance ToUrl Session String where toUrl = sessionUrl
......
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