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
3d865bb1
Commit
3d865bb1
authored
Jul 28, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[cacheApi] add raw fetch, fixes to Home/Public
In Home/Public error was thrown: <div> cannot be nested under <p>.
parent
b5dbd5a3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
6 deletions
+32
-6
Public.purs
src/Gargantext/Components/Nodes/Home/Public.purs
+1
-1
Loader.purs
src/Gargantext/Hooks/Loader.purs
+5
-4
CacheAPI.js
src/Gargantext/Utils/CacheAPI.js
+6
-0
CacheAPI.purs
src/Gargantext/Utils/CacheAPI.purs
+20
-1
No files found.
src/Gargantext/Components/Nodes/Home/Public.purs
View file @
3d865bb1
...
@@ -96,7 +96,7 @@ publicLayoutCpt = R.hooksComponent "[G.C.N.H.Public.publicLayout" cpt
...
@@ -96,7 +96,7 @@ publicLayoutCpt = R.hooksComponent "[G.C.N.H.Public.publicLayout" cpt
[ H.h2 {} [H.text "Public Maps"]
[ H.h2 {} [H.text "Public Maps"]
, H.p { className: "lead text-muted"}
, H.p { className: "lead text-muted"}
[ H.text "Discover maps made with "
[ H.text "Discover maps made with "
, H.
div
{className: "fa fa-heart"} []
, H.
span
{className: "fa fa-heart"} []
]
]
, H.p { className:"flex-space-around" }
, H.p { className:"flex-space-around" }
[ H.a { className: "btn btn-primary my-2"
[ H.a { className: "btn btn-primary my-2"
...
...
src/Gargantext/Hooks/Loader.purs
View file @
3d865bb1
module Gargantext.Hooks.Loader where
module Gargantext.Hooks.Loader where
import DOM.Simple.Console (log2)
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, (.:), (:=), (~>), jsonEmptyObject)
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, (.:), (:=), (~>), jsonEmptyObject)
import Data.Argonaut.Core (stringify)
import Data.Argonaut.Core (stringify)
import Data.Argonaut.Parser (jsonParser)
import Data.Argonaut.Parser (jsonParser)
...
@@ -8,9 +7,14 @@ import Data.Either (Either(..))
...
@@ -8,9 +7,14 @@ import Data.Either (Either(..))
import Data.Maybe (Maybe(..), isJust, maybe)
import Data.Maybe (Maybe(..), isJust, maybe)
import Data.Tuple (fst)
import Data.Tuple (fst)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log2)
import Effect.Aff (Aff, launchAff_, throwError)
import Effect.Aff (Aff, launchAff_, throwError)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Effect.Exception (error)
import Effect.Exception (error)
import Milkis as M
import Reactix as R
import Web.Storage.Storage as WSS
import Gargantext.Components.LoadingSpinner (loadingSpinner)
import Gargantext.Components.LoadingSpinner (loadingSpinner)
import Gargantext.Ends (class ToUrl, toUrl)
import Gargantext.Ends (class ToUrl, toUrl)
import Gargantext.Prelude
import Gargantext.Prelude
...
@@ -18,9 +22,6 @@ import Gargantext.Utils.Crypto (Hash)
...
@@ -18,9 +22,6 @@ import Gargantext.Utils.Crypto (Hash)
import Gargantext.Utils as GU
import Gargantext.Utils as GU
import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Milkis as M
import Reactix as R
import Web.Storage.Storage as WSS
useLoader :: forall path st. Eq path
useLoader :: forall path st. Eq path
...
...
src/Gargantext/Utils/CacheAPI.js
View file @
3d865bb1
...
@@ -36,3 +36,9 @@ exports._match = function(cache) {
...
@@ -36,3 +36,9 @@ exports._match = function(cache) {
}
}
}
}
}
}
exports
.
_fetch
=
function
(
req
)
{
return
function
()
{
return
fetch
(
req
);
}
}
src/Gargantext/Utils/CacheAPI.purs
View file @
3d865bb1
...
@@ -69,6 +69,7 @@ add cache req = toAffE $ _add cache req
...
@@ -69,6 +69,7 @@ add cache req = toAffE $ _add cache req
match :: Cache -> Request -> Aff (Maybe M.Response)
match :: Cache -> Request -> Aff (Maybe M.Response)
match cache req = do
match cache req = do
res <- toAffE $ _match cache req
res <- toAffE $ _match cache req
-- _match returns a null/undefined value when cache entity not found
case runExcept $ F.readNullOrUndefined res of
case runExcept $ F.readNullOrUndefined res of
Left err -> throwError $ error $ show err
Left err -> throwError $ error $ show err
Right v -> pure $ F.unsafeFromForeign <$> v
Right v -> pure $ F.unsafeFromForeign <$> v
...
@@ -96,15 +97,33 @@ cachedJson cache req = do
...
@@ -96,15 +97,33 @@ cachedJson cache req = do
j <- M.json res
j <- M.json res
case decodeJson (F.unsafeFromForeign j) of
case decodeJson (F.unsafeFromForeign j) of
Left err -> throwError $ error $ "decodeJson affResp.body: " <> err
Left err -> throwError $ error $ "
[cachedJson]
decodeJson affResp.body: " <> err
Right b -> pure b
Right b -> pure b
delete :: Cache -> Request -> Aff Unit
delete :: Cache -> Request -> Aff Unit
delete cache req = toAffE $ _delete cache req
delete cache req = toAffE $ _delete cache req
-- No cache: raw API calls
fetch :: Request -> Aff M.Response
fetch req = do
res <- toAffE $ _fetch req
pure $ F.unsafeFromForeign res
pureJson :: forall a. DecodeJson a => Request -> Aff a
pureJson req = do
res <- fetch req
j <- M.json res
case decodeJson (F.unsafeFromForeign j) of
Left err -> throwError $ error $ "[pureJson] decodeJson affResp.body: " <> err
Right b -> pure b
foreign import _makeRequest :: forall options trash. Union options trash M.Options =>
foreign import _makeRequest :: forall options trash. Union options trash M.Options =>
M.URL -> { method :: M.Method, headers :: M.Headers | options } -> Request
M.URL -> { method :: M.Method, headers :: M.Headers | options } -> Request
foreign import _openCache :: String -> Effect (Promise Cache)
foreign import _openCache :: String -> Effect (Promise Cache)
foreign import _delete :: Cache -> Request -> Effect (Promise Unit)
foreign import _delete :: Cache -> Request -> Effect (Promise Unit)
foreign import _add :: Cache -> Request -> Effect (Promise Unit)
foreign import _add :: Cache -> Request -> Effect (Promise Unit)
foreign import _match :: Cache -> Request -> Effect (Promise F.Foreign)
foreign import _match :: Cache -> Request -> Effect (Promise F.Foreign)
foreign import _fetch :: Request -> Effect (Promise F.Foreign)
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