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
9a5d4242
Commit
9a5d4242
authored
Jun 21, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[REST] get function.
parent
309bb453
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
27 deletions
+9
-27
DocView.purs
src/DocView.purs
+4
-18
REST.purs
src/Gargantext/REST.purs
+5
-9
No files found.
src/DocView.purs
View file @
9a5d4242
...
@@ -32,6 +32,9 @@ import ReactDOM as RDOM
...
@@ -32,6 +32,9 @@ import ReactDOM as RDOM
import Thermite (PerformAction, Render, Spec, cotransform, createReactSpec, defaultPerformAction, modifyState, simpleSpec)
import Thermite (PerformAction, Render, Spec, cotransform, createReactSpec, defaultPerformAction, modifyState, simpleSpec)
import Unsafe.Coerce (unsafeCoerce)
import Unsafe.Coerce (unsafeCoerce)
import Gargantext.REST (get)
main :: forall e. Eff (dom:: DOM, console :: CONSOLE, ajax :: AJAX | e) Unit
main :: forall e. Eff (dom:: DOM, console :: CONSOLE, ajax :: AJAX | e) Unit
main = do
main = do
case createReactSpec layoutDocview tdata of
case createReactSpec layoutDocview tdata of
...
@@ -143,7 +146,7 @@ performAction (ChangePageSize ps) _ _ = void (cotransform (\state -> changePage
...
@@ -143,7 +146,7 @@ performAction (ChangePageSize ps) _ _ = void (cotransform (\state -> changePage
performAction (ChangePage p) _ _ = void (cotransform (\(TableData td) -> TableData $ td { currentPage = p} ))
performAction (ChangePage p) _ _ = void (cotransform (\(TableData td) -> TableData $ td { currentPage = p} ))
performAction LoadData _ _ = void do
performAction LoadData _ _ = void do
res <- lift $
loadData
"http://localhost:8008/corpus/452132/facet/documents/table"
res <- lift $
get
"http://localhost:8008/corpus/452132/facet/documents/table"
--res <- lift $ loadData "http://localhost:8009/corpus/1/facet/documents/table"
--res <- lift $ loadData "http://localhost:8009/corpus/1/facet/documents/table"
case res of
case res of
Left err -> cotransform $ \(state) -> state
Left err -> cotransform $ \(state) -> state
...
@@ -380,20 +383,3 @@ showRow {row : (Corpus c), delete} =
...
@@ -380,20 +383,3 @@ showRow {row : (Corpus c), delete} =
true -> "fas "
true -> "fas "
false -> "far "
false -> "far "
loadData :: forall eff. String -> Aff ( console :: CONSOLE, ajax :: AJAX| eff) (Either String (Array Response))
loadData url = do
affResp <- liftAff $ attempt $ affjax defaultRequest
{ method = Left GET
, url = url
, headers = [ ContentType applicationJSON
, Accept applicationJSON
-- , RequestHeader "Authorization" $ "Bearer " <> token
]
-- , content = Just $ encodeJson reqBody
}
case affResp of
Left err -> do
pure $ Left $ show err
Right a -> do
let res = decodeJson a.response
pure res
src/Gargantext/REST.purs
View file @
9a5d4242
...
@@ -15,14 +15,10 @@ import Data.Either (Either(..))
...
@@ -15,14 +15,10 @@ import Data.Either (Either(..))
import Network.HTTP.Affjax (AJAX, affjax, defaultRequest)
import Network.HTTP.Affjax (AJAX, affjax, defaultRequest)
--loadData :: forall eff ajax a b. Bind ajax => MonadAff
get :: forall eff t2 t31. DecodeJson t31 => String ->
-- ( ajax :: AJAX
Aff ( console :: CONSOLE, ajax :: AJAX| eff)
-- , consolle :: CONSOLE
(Either String t31)
-- | eff
get url = do
-- )
-- ajax
-- => Respondable a => (a -> Either String b) -> String -> ajax (Either String b)
loadData f url = do
affResp <- liftAff $ attempt $ affjax defaultRequest
affResp <- liftAff $ attempt $ affjax defaultRequest
{ method = Left GET
{ method = Left GET
, url = url
, url = url
...
@@ -35,5 +31,5 @@ loadData f url = do
...
@@ -35,5 +31,5 @@ loadData f url = do
Left err -> do
Left err -> do
pure $ Left $ show err
pure $ Left $ show err
Right a -> do
Right a -> do
let res =
f
a.response
let res =
decodeJson
a.response
pure res
pure res
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