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
36f89667
Commit
36f89667
authored
Jul 13, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] backend public url (thx to James Laver aka dysfun)
parent
a850d993
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
17 deletions
+40
-17
Public.purs
src/Gargantext/Components/Nodes/Home/Public.purs
+6
-15
Config.purs
src/Gargantext/Config.purs
+20
-0
Utils.purs
src/Gargantext/Utils.purs
+14
-2
No files found.
src/Gargantext/Components/Nodes/Home/Public.purs
View file @
36f89667
module Gargantext.Components.Nodes.Home.Public where
module Gargantext.Components.Nodes.Home.Public where
import DOM.Simple.Console (log)
import DOM.Simple.Console (log)
import Effect (Effect)
import Effect.Class (liftEffect)
import DOM.Simple.Window (window)
import FFI.Simple.Functions ((...), delay)
import Data.Tuple (fst)
import Data.Tuple (fst)
import Data.Argonaut as Argonaut
import Data.Argonaut as Argonaut
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep (class Generic)
...
@@ -13,9 +9,10 @@ import Data.Maybe (Maybe(..))
...
@@ -13,9 +9,10 @@ import Data.Maybe (Maybe(..))
import Data.NonEmpty (head)
import Data.NonEmpty (head)
import Data.String (take)
import Data.String (take)
import Effect.Aff (Aff)
import Effect.Aff (Aff)
import Gargantext.Config (defaultBackends)
import Effect.Class (liftEffect)
import Gargantext.Config (publicBackend)
import Gargantext.Config.REST (get)
import Gargantext.Config.REST (get)
import Gargantext.Ends (
backend
Url)
import Gargantext.Ends (
to
Url)
import Gargantext.Prelude
import Gargantext.Prelude
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Utils.Argonaut (genericSumDecodeJson, genericSumEncodeJson)
import Gargantext.Utils.Argonaut (genericSumDecodeJson, genericSumEncodeJson)
...
@@ -56,16 +53,10 @@ type LoadData = ()
...
@@ -56,16 +53,10 @@ type LoadData = ()
type LoadProps = (reload :: Int)
type LoadProps = (reload :: Int)
loadPublicData :: Record LoadProps -> Aff (Array PublicData)
loadPublicData :: Record LoadProps -> Aff (Array PublicData)
--loadPublicData _l = get Nothing (backendUrl backend "public")
loadPublicData _l = do
loadPublicData _l = do
-- let backend = head defaultBackends
backend <- liftEffect publicBackend
let windowLocation = "localhost:8008/"
_ <- liftEffect (log backend)
windowLocation' <- liftEffect (location {})
get Nothing (toUrl backend "public")
_ <- liftEffect $ log windowLocation'
get Nothing (windowLocation <> "public")
location :: forall a. a -> Effect String
location _ = window ... "location" $ []
renderPublic :: R.Element
renderPublic :: R.Element
renderPublic = R.createElement renderPublicCpt {} []
renderPublic = R.createElement renderPublicCpt {} []
...
...
src/Gargantext/Config.purs
View file @
36f89667
module Gargantext.Config where
module Gargantext.Config where
import Data.String as S
import Web.HTML.Location (Location(..))
import Effect (Effect)
import Data.NonEmpty (NonEmpty, (:|), head)
import Data.NonEmpty (NonEmpty, (:|), head)
import Gargantext.Ends
import Gargantext.Ends
import Gargantext.Types (ApiVersion(..))
import Gargantext.Types (ApiVersion(..))
import Gargantext.Utils (location)
import Gargantext.Prelude (bind, pure, ($))
defaultBackends :: NonEmpty Array Backend
defaultBackends :: NonEmpty Array Backend
defaultBackends = local :| [prod, partner, demo, dev]
defaultBackends = local :| [prod, partner, demo, dev]
...
@@ -38,3 +43,18 @@ defaultStatic = head defaultStatics
...
@@ -38,3 +43,18 @@ defaultStatic = head defaultStatics
defaultFrontends :: Frontends
defaultFrontends :: Frontends
defaultFrontends = Frontends { app: defaultApp, static: defaultStatic }
defaultFrontends = Frontends { app: defaultApp, static: defaultStatic }
-- | public Backend
-- When user is not logged, use the location of the window
publicBackend :: Effect Backend
publicBackend = do
url <- location
pure $ Backend { name : "Public Backend"
, baseUrl : url
, prePath : "api/"
, version : V10
}
changePort :: String -> String
changePort = S.replace (S.Pattern "http://localhost:8000/") (S.Replacement "http://localhost:8008/")
src/Gargantext/Utils.purs
View file @
36f89667
module Gargantext.Utils where
module Gargantext.Utils where
import
Prelude
import
DOM.Simple.Window (window)
import Data.Either (Either(..))
import Data.Either (Either(..))
import Data.Lens (Lens', lens)
import Data.Lens (Lens', lens)
import Data.Newtype (class Newtype, unwrap, wrap)
import Data.Newtype (class Newtype, unwrap, wrap)
import Data.Set as Set
import Data.Set (Set)
import Data.Set (Set)
import Data.Set as Set
import Data.String as S
import Data.String as S
import Effect (Effect)
import Effect.Class (liftEffect)
import FFI.Simple ((..))
import FFI.Simple.Functions (delay)
import Prelude
-- | TODO (hard coded)
-- | TODO (hard coded)
csrfMiddlewareToken :: String
csrfMiddlewareToken :: String
...
@@ -74,3 +79,10 @@ queryMatchesLabel q l = S.contains (S.Pattern $ normalize q) (normalize l)
...
@@ -74,3 +79,10 @@ queryMatchesLabel q l = S.contains (S.Pattern $ normalize q) (normalize l)
mapLeft :: forall l m r. (l -> m) -> Either l r -> Either m r
mapLeft :: forall l m r. (l -> m) -> Either l r -> Either m r
mapLeft f (Left l) = Left (f l)
mapLeft f (Left l) = Left (f l)
mapLeft _ (Right r) = Right r
mapLeft _ (Right r) = Right r
-- | Get current Window Location
location :: Effect String
location = delay unit $ \_ -> pure $ window .. "location"
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