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
1
Merge Requests
1
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
Przemyslaw Kaminski
purescript-gargantext
Commits
5f364a76
Commit
5f364a76
authored
May 10, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[login] guess the backend upon login click
parent
9c0da593
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
20 deletions
+29
-20
Home.purs
src/Gargantext/Components/Nodes/Home.purs
+13
-7
Config.purs
src/Gargantext/Config.purs
+5
-5
Utils.purs
src/Gargantext/Utils.purs
+11
-8
No files found.
src/Gargantext/Components/Nodes/Home.purs
View file @
5f364a76
...
...
@@ -6,23 +6,23 @@ import Data.Array as Array
import Data.Maybe (Maybe(..))
import Data.Newtype (class Newtype)
import Effect (Effect)
import Reactix as R
import Reactix.DOM.HTML as H
import Routing.Hash (setHash)
import Toestand as T
import Gargantext.Components.Data.Landing (BlockText(..), BlockTexts(..), Button(..), LandingData(..))
import Gargantext.Components.FolderView as FV
import Gargantext.Components.Lang (LandingLang(..))
import Gargantext.Components.Lang.Landing.EnUS as En
import Gargantext.Components.Lang.Landing.FrFR as Fr
import Gargantext.Components.Nodes.Home.Public (renderPublic)
import Gargantext.Config as Config
import Gargantext.Ends (Backend(..))
import Gargantext.License (license)
import Gargantext.Sessions (Sessions)
import Gargantext.Sessions as Sessions
import Gargantext.Sessions.Types (Session(..))
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
import Routing.Hash (setHash)
import Toestand as T
here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Home"
...
...
@@ -87,8 +87,14 @@ homeLayoutCpt = here.component "homeLayout" cpt
] where
click mBackend _ =
case mBackend of
Nothing -> T.write_ true showLogin
Just b -> pure unit
Nothing -> do
mLoc <- Config.matchCurrentLocation
case mLoc of
Nothing -> pure unit
Just b -> do
T.write_ (Just b) backend
T.write_ true showLogin
Just b -> T.write_ true showLogin
joinButtonOrTutorial :: forall e. Sessions -> (e -> Effect Unit) -> R.Element
joinButtonOrTutorial sessions click =
...
...
src/Gargantext/Config.purs
View file @
5f364a76
...
...
@@ -13,7 +13,7 @@ import Gargantext.Prelude (bind, pure, ($))
import Gargantext.Ends
import Gargantext.Types (ApiVersion(..))
import Gargantext.Utils (
location
)
import Gargantext.Utils (
href
)
defaultBackends :: NonEmpty Array Backend
defaultBackends =
...
...
@@ -47,8 +47,8 @@ backend_local = backend V10 "/api/" localUrl "local.cnrs"
matchCurrentLocation :: Effect (Maybe Backend)
matchCurrentLocation = do
url <- location
let starts = AN.filter (\(Backend { baseUrl }) -> S.startsWith baseUrl
url
) $ AN.fromNonEmpty defaultBackends
href <- href
let starts = AN.filter (\(Backend { baseUrl }) -> S.startsWith baseUrl
href
) $ AN.fromNonEmpty defaultBackends
pure $ A.head starts
...
...
@@ -60,9 +60,9 @@ publicBackend = backend_local
publicBackend' :: Effect Backend
publicBackend' = do
url <- location
href <- href
pure $ Backend { name : "Public Backend"
, baseUrl :
url
, baseUrl :
href
, prePath : "api/"
, version : V10
}
...
...
src/Gargantext/Utils.purs
View file @
5f364a76
module Gargantext.Utils where
import DOM.Simple.Window (window)
import Data.Either (Either(..))
import Data.Foldable (class Foldable, foldr)
import Data.Lens (Lens', lens)
...
...
@@ -11,9 +10,10 @@ import Data.Sequence.Ordered as OSeq
import Data.String as S
import Data.Unfoldable (class Unfoldable)
import Effect (Effect)
import FFI.Simple ((..))
import FFI.Simple.Functions (delay)
import Prelude
import Web.HTML (window)
import Web.HTML.Window (location)
import Web.HTML.Location as WHL
-- | TODO (hard coded)
csrfMiddlewareToken :: String
...
...
@@ -82,10 +82,6 @@ mapLeft :: forall l m r. (l -> m) -> Either l r -> Either m r
mapLeft f (Left l) = Left (f l)
mapLeft _ (Right r) = Right r
-- | Get current Window Location
location :: Effect String
location = delay unit $ \_ -> pure $ window .. "location"
data On a b = On a b
instance eqOn :: Eq a => Eq (On a b) where
...
...
@@ -102,3 +98,10 @@ sortWith :: forall a b f. Functor f =>
Ord b =>
(a -> b) -> f a -> f a
sortWith f = map (\(On _ y) -> y) <<< OSeq.toUnfoldable <<< foldr (\x -> OSeq.insert (On (f x) x)) OSeq.empty
href :: Effect String
href = do
w <- window
loc <- location w
WHL.href loc
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