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
8931c366
Commit
8931c366
authored
Nov 21, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] toUrl to remove hard coded links.
parent
d4d6fb3a
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
33 additions
and
29 deletions
+33
-29
Tree.purs
src/Gargantext/Components/Tree.purs
+7
-7
Config.purs
src/Gargantext/Config.purs
+9
-5
Annuaire.purs
src/Gargantext/Pages/Annuaire.purs
+3
-3
API.purs
src/Gargantext/Pages/Annuaire/User/Contacts/API.purs
+2
-2
Corpus.purs
src/Gargantext/Pages/Corpus.purs
+2
-2
Document.purs
src/Gargantext/Pages/Corpus/Document.purs
+2
-2
Documents.purs
src/Gargantext/Pages/Corpus/Tabs/Documents.purs
+6
-6
NgramsTable.purs
src/Gargantext/Pages/Corpus/Tabs/Ngrams/NgramsTable.purs
+2
-2
No files found.
src/Gargantext/Components/Tree.purs
View file @
8931c366
...
@@ -23,7 +23,7 @@ import React (ReactElement)
...
@@ -23,7 +23,7 @@ import React (ReactElement)
import React.DOM (a, button, div, h5, i, input, li, span, text, ul)
import React.DOM (a, button, div, h5, i, input, li, span, text, ul)
import React.DOM.Props (Props, _id, _type, className, href, title, onClick, onInput, placeholder, style, value, _data)
import React.DOM.Props (Props, _id, _type, className, href, title, onClick, onInput, placeholder, style, value, _data)
import Thermite (PerformAction, Render, Spec, cotransform, defaultPerformAction, defaultRender, modifyState, simpleSpec)
import Thermite (PerformAction, Render, Spec, cotransform, defaultPerformAction, defaultRender, modifyState, simpleSpec)
import Gargantext.Config (toUrl, End(
Front), NodeType(..)
)
import Gargantext.Config (toUrl, End(
..), NodeType(..), defaultRoot
)
type Name = String
type Name = String
type Open = Boolean
type Open = Boolean
type URL = String
type URL = String
...
@@ -351,7 +351,7 @@ toHtml d s@(NTree (LNode {id, name, nodeType, open, popOver, renameNodeValue, cr
...
@@ -351,7 +351,7 @@ toHtml d s@(NTree (LNode {id, name, nodeType, open, popOver, renameNodeValue, cr
li []
li []
[
[
a [ href (toUrl Front nodeType
id
)]
a [ href (toUrl Front nodeType
(Just id)
)]
( [ text (name <> " ")
( [ text (name <> " ")
]
]
)
)
...
@@ -407,7 +407,7 @@ instance decodeJsonFTree :: DecodeJson (NTree LNode) where
...
@@ -407,7 +407,7 @@ instance decodeJsonFTree :: DecodeJson (NTree LNode) where
loadDefaultNode :: Aff (Either String (NTree LNode))
loadDefaultNode :: Aff (Either String (NTree LNode))
loadDefaultNode = do
loadDefaultNode = do
res <- request $ defaultRequest
res <- request $ defaultRequest
{ url =
"http://localhost:8008/api/v1.0/tree/1" --- http://localhost:8008/api/v1.0/tree/1
{ url =
toUrl Back Tree (Just defaultRoot)
, responseFormat = ResponseFormat.json
, responseFormat = ResponseFormat.json
, method = Left GET
, method = Left GET
, headers = []
, headers = []
...
@@ -439,7 +439,7 @@ instance encodeJsonRenameValue :: EncodeJson RenameValue where
...
@@ -439,7 +439,7 @@ instance encodeJsonRenameValue :: EncodeJson RenameValue where
renameNode :: Int -> RenameValue -> Aff (Either String Unit) --- need to change return type herre
renameNode :: Int -> RenameValue -> Aff (Either String Unit) --- need to change return type herre
renameNode renameNodeId reqbody = do
renameNode renameNodeId reqbody = do
res <- request $ defaultRequest
res <- request $ defaultRequest
{ url =
"http://localhost:8008/api/v1.0/node/" <> show renameNodeId
<> "/rename"
{ url =
toUrl Back Node (Just renameNodeId)
<> "/rename"
, responseFormat = ResponseFormat.json
, responseFormat = ResponseFormat.json
, method = Left PUT
, method = Left PUT
, headers = []
, headers = []
...
@@ -461,7 +461,7 @@ renameNode renameNodeId reqbody = do
...
@@ -461,7 +461,7 @@ renameNode renameNodeId reqbody = do
deleteNode :: Int -> Aff (Either String (Int))
deleteNode :: Int -> Aff (Either String (Int))
deleteNode renameNodeId = do
deleteNode renameNodeId = do
res <- request $ defaultRequest
res <- request $ defaultRequest
{ url =
"http://localhost:8008/api/v1.0/node/" <> show renameNodeId
{ url =
toUrl Back Node (Just renameNodeId)
, responseFormat = ResponseFormat.json
, responseFormat = ResponseFormat.json
, method = Left DELETE
, method = Left DELETE
, headers = []
, headers = []
...
@@ -483,7 +483,7 @@ deleteNode renameNodeId = do
...
@@ -483,7 +483,7 @@ deleteNode renameNodeId = do
deleteNodes :: String -> Aff (Either String Int)
deleteNodes :: String -> Aff (Either String Int)
deleteNodes reqbody = do
deleteNodes reqbody = do
res <- request $ defaultRequest
res <- request $ defaultRequest
{ url =
"http://localhost:8008/api/v1.0/nodes"
{ url =
toUrl Back Nodes Nothing
, responseFormat = ResponseFormat.json
, responseFormat = ResponseFormat.json
, method = Left DELETE
, method = Left DELETE
, headers = []
, headers = []
...
@@ -504,7 +504,7 @@ deleteNodes reqbody = do
...
@@ -504,7 +504,7 @@ deleteNodes reqbody = do
createNode :: String -> Aff (Either String (Int))
createNode :: String -> Aff (Either String (Int))
createNode reqbody= do
createNode reqbody= do
res <- request $ defaultRequest
res <- request $ defaultRequest
{ url =
"http://localhost:8008/api/v1.0/node/"
{ url =
toUrl Back Node Nothing
, responseFormat = ResponseFormat.json
, responseFormat = ResponseFormat.json
, method = Left POST
, method = Left POST
, headers = []
, headers = []
...
...
src/Gargantext/Config.purs
View file @
8931c366
...
@@ -92,21 +92,21 @@ doUrl b p ps = b <> p <> ps
...
@@ -92,21 +92,21 @@ doUrl b p ps = b <> p <> ps
------------------------------------------------------------
------------------------------------------------------------
endBaseUrl :: End -> EndConfig -> UrlBase
endBaseUrl :: End -> EndConfig -> UrlBase
endBaseUrl Back c = baseUrl c.back
endBaseUrl Back c = baseUrl c.back
endBaseUrl Front c =
baseUrl c.front
endBaseUrl Front c =
""
baseUrl :: Config -> UrlBase
baseUrl :: Config -> UrlBase
baseUrl conf = conf.proto <> conf.domain <> ":" <> show conf.port
baseUrl conf = conf.proto <> conf.domain <> ":" <> show conf.port
------------------------------------------------------------
------------------------------------------------------------
endPathUrl :: End -> EndConfig -> NodeType -> Id -> UrlPath
endPathUrl :: End -> EndConfig -> NodeType ->
Maybe
Id -> UrlPath
endPathUrl Back c nt i = pathUrl c.back nt i
endPathUrl Back c nt i = pathUrl c.back nt i
endPathUrl Front c nt i = pathUrl c.front nt i
endPathUrl Front c nt i = pathUrl c.front nt i
pathUrl :: Config -> NodeType -> Id -> UrlPath
pathUrl :: Config -> NodeType ->
Maybe
Id -> UrlPath
pathUrl c nt@(Tab _ _ _ _) i = pathUrl c Node i <> "/" <> show nt
pathUrl c nt@(Tab _ _ _ _) i = pathUrl c Node i <> "/" <> show nt
pathUrl c nt@(Ngrams _ _) i = pathUrl c Node i <> "/" <> show nt
pathUrl c nt@(Ngrams _ _) i = pathUrl c Node i <> "/" <> show nt
pathUrl c nt i = c.prePath <> urlConfig nt <>
"/" <> show i
pathUrl c nt i = c.prePath <> urlConfig nt <>
(maybe "" (\i' -> "/" <> show i') i)
------------------------------------------------------------
------------------------------------------------------------
toUrl :: End -> NodeType -> Id -> Url
toUrl :: End -> NodeType ->
Maybe
Id -> Url
toUrl e nt i = doUrl base path params
toUrl e nt i = doUrl base path params
where
where
base = endBaseUrl e endConfig
base = endBaseUrl e endConfig
...
@@ -126,6 +126,7 @@ data NodeType = NodeUser
...
@@ -126,6 +126,7 @@ data NodeType = NodeUser
| Graph
| Graph
| Individu
| Individu
| Node
| Node
| Nodes
| Tree
| Tree
data End = Back | Front
data End = Back | Front
type Id = Int
type Id = Int
...
@@ -171,6 +172,7 @@ urlConfig Folder = show Folder
...
@@ -171,6 +172,7 @@ urlConfig Folder = show Folder
urlConfig Graph = show Graph
urlConfig Graph = show Graph
urlConfig Individu = show Individu
urlConfig Individu = show Individu
urlConfig Node = show Node
urlConfig Node = show Node
urlConfig Nodes = show Nodes
urlConfig NodeUser = show NodeUser
urlConfig NodeUser = show NodeUser
urlConfig Tree = show Tree
urlConfig Tree = show Tree
------------------------------------------------------------
------------------------------------------------------------
...
@@ -185,6 +187,7 @@ instance showNodeType :: Show NodeType where
...
@@ -185,6 +187,7 @@ instance showNodeType :: Show NodeType where
show Graph = "graph"
show Graph = "graph"
show Individu = "individu"
show Individu = "individu"
show Node = "node"
show Node = "node"
show Nodes = "nodes"
show NodeUser = "user"
show NodeUser = "user"
show Tree = "tree"
show Tree = "tree"
show (Tab t o l s) = "table?view=" <> show t <> "&offset=" <> show o
show (Tab t o l s) = "table?view=" <> show t <> "&offset=" <> show o
...
@@ -212,6 +215,7 @@ readNodeType "NodeFolder" = Folder
...
@@ -212,6 +215,7 @@ readNodeType "NodeFolder" = Folder
readNodeType "NodeGraph" = Graph
readNodeType "NodeGraph" = Graph
readNodeType "Individu" = Individu
readNodeType "Individu" = Individu
readNodeType "Node" = Node
readNodeType "Node" = Node
readNodeType "Nodes" = Nodes
readNodeType "NodeCorpus" = Corpus
readNodeType "NodeCorpus" = Corpus
readNodeType "NodeCorpusV3" = CorpusV3
readNodeType "NodeCorpusV3" = CorpusV3
readNodeType "NodeUser" = NodeUser
readNodeType "NodeUser" = NodeUser
...
...
src/Gargantext/Pages/Annuaire.purs
View file @
8931c366
...
@@ -145,7 +145,7 @@ pageLoader props = React.createElement pageLoaderClass props []
...
@@ -145,7 +145,7 @@ pageLoader props = React.createElement pageLoaderClass props []
renderContactCells :: Contact -> Array ReactElement
renderContactCells :: Contact -> Array ReactElement
renderContactCells (Contact { id, hyperdata : HyperData contact }) =
renderContactCells (Contact { id, hyperdata : HyperData contact }) =
[ a [ href (toUrl Front NodeUser
id
) ] [ text $ maybe' contact.nom <> " " <> maybe' contact.prenom ]
[ a [ href (toUrl Front NodeUser
(Just id)
) ] [ text $ maybe' contact.nom <> " " <> maybe' contact.prenom ]
, text $ maybe' contact.fonction
, text $ maybe' contact.fonction
, text $ maybe' contact.service
, text $ maybe' contact.service
, text $ maybe' contact.groupe
, text $ maybe' contact.groupe
...
@@ -202,12 +202,12 @@ instance decodeAnnuaireTable :: DecodeJson AnnuaireTable where
...
@@ -202,12 +202,12 @@ instance decodeAnnuaireTable :: DecodeJson AnnuaireTable where
pure $ AnnuaireTable { annuaireTable : rows}
pure $ AnnuaireTable { annuaireTable : rows}
------------------------------------------------------------------------
------------------------------------------------------------------------
loadPage :: PageParams -> Aff AnnuaireTable
loadPage :: PageParams -> Aff AnnuaireTable
loadPage {nodeId, params} = get $ toUrl Back (Tab TabDocs 0 10 Nothing)
nodeId
loadPage {nodeId, params} = get $ toUrl Back (Tab TabDocs 0 10 Nothing)
(Just nodeId)
-- TODO Tab TabDocs is not the right API call
-- TODO Tab TabDocs is not the right API call
-- TODO params, see loadPage in Documents
-- TODO params, see loadPage in Documents
getAnnuaireInfo :: Int -> Aff AnnuaireInfo
getAnnuaireInfo :: Int -> Aff AnnuaireInfo
getAnnuaireInfo id = get $ toUrl Back Node
id
getAnnuaireInfo id = get $ toUrl Back Node
(Just id)
------------------------------------------------------------------------------
------------------------------------------------------------------------------
annuaireLoaderClass :: ReactClass (Loader.Props Int AnnuaireInfo)
annuaireLoaderClass :: ReactClass (Loader.Props Int AnnuaireInfo)
...
...
src/Gargantext/Pages/Annuaire/User/Contacts/API.purs
View file @
8931c366
...
@@ -15,11 +15,11 @@ import Gargantext.Prelude
...
@@ -15,11 +15,11 @@ import Gargantext.Prelude
import Gargantext.Pages.Annuaire.User.Contacts.Types (Action(..), State, Contact, _contact)
import Gargantext.Pages.Annuaire.User.Contacts.Types (Action(..), State, Contact, _contact)
import Thermite (PerformAction, modifyState)
import Thermite (PerformAction, modifyState)
getContact :: Int -> Aff Contact
getContact ::
Maybe
Int -> Aff Contact
getContact id = get $ toUrl Back Node id
getContact id = get $ toUrl Back Node id
fetchContact :: Int -> StateCoTransformer State Unit
fetchContact :: Int -> StateCoTransformer State Unit
fetchContact contactId = do
fetchContact contactId = do
contact <- lift $ getContact
contactId
contact <- lift $ getContact
(Just contactId)
void $ modifyState $ _contact ?~ contact
void $ modifyState $ _contact ?~ contact
logs "Fetching contact..."
logs "Fetching contact..."
src/Gargantext/Pages/Corpus.purs
View file @
8931c366
...
@@ -3,7 +3,7 @@ module Gargantext.Pages.Corpus where
...
@@ -3,7 +3,7 @@ module Gargantext.Pages.Corpus where
import Data.Either (Either(..))
import Data.Either (Either(..))
import Data.Lens (Lens', Prism', lens, prism)
import Data.Lens (Lens', Prism', lens, prism)
import Data.Maybe (maybe)
import Data.Maybe (
Maybe(..),
maybe)
import Effect.Aff (Aff)
import Effect.Aff (Aff)
import React as React
import React as React
import React (ReactClass, ReactElement)
import React (ReactClass, ReactElement)
...
@@ -82,7 +82,7 @@ corpusHeaderSpec = simpleSpec defaultPerformAction render
...
@@ -82,7 +82,7 @@ corpusHeaderSpec = simpleSpec defaultPerformAction render
------------------------------------------------------------------------
------------------------------------------------------------------------
getCorpus :: Int -> Aff (NodePoly CorpusInfo)
getCorpus :: Int -> Aff (NodePoly CorpusInfo)
getCorpus = get <<< toUrl Back Corpus
getCorpus = get <<< toUrl Back Corpus
<<< Just
corpusLoaderClass :: ReactClass (Loader.Props Int (NodePoly CorpusInfo))
corpusLoaderClass :: ReactClass (Loader.Props Int (NodePoly CorpusInfo))
corpusLoaderClass = createLoaderClass "CorpusLoader" getCorpus
corpusLoaderClass = createLoaderClass "CorpusLoader" getCorpus
...
...
src/Gargantext/Pages/Corpus/Document.purs
View file @
8931c366
...
@@ -262,14 +262,14 @@ instance decodeDocument :: DecodeJson Document
...
@@ -262,14 +262,14 @@ instance decodeDocument :: DecodeJson Document
------------------------------------------------------------------------
------------------------------------------------------------------------
performAction :: PerformAction State {} Action
performAction :: PerformAction State {} Action
performAction (Load nId) _ _ = do
performAction (Load nId) _ _ = do
node <- lift $ getNode
nId
node <- lift $ getNode
(Just nId)
void $ modifyState $ _document ?~ node
void $ modifyState $ _document ?~ node
logs $ "Node Document " <> show nId <> " fetched."
logs $ "Node Document " <> show nId <> " fetched."
performAction (ChangeString ps) _ _ = pure unit
performAction (ChangeString ps) _ _ = pure unit
performAction (SetInput ps) _ _ = void <$> modifyState $ _ { inputValue = ps }
performAction (SetInput ps) _ _ = void <$> modifyState $ _ { inputValue = ps }
getNode :: Int -> Aff (NodePoly Document)
getNode ::
Maybe
Int -> Aff (NodePoly Document)
getNode = get <<< toUrl Back Node
getNode = get <<< toUrl Back Node
_document :: Lens' State (Maybe (NodePoly Document))
_document :: Lens' State (Maybe (NodePoly Document))
...
...
src/Gargantext/Pages/Corpus/Tabs/Documents.purs
View file @
8931c366
...
@@ -193,7 +193,7 @@ loadPage :: PageParams -> Aff (Array DocumentsView)
...
@@ -193,7 +193,7 @@ loadPage :: PageParams -> Aff (Array DocumentsView)
loadPage {nodeId, params: {limit, offset, orderBy}} = do
loadPage {nodeId, params: {limit, offset, orderBy}} = do
logs "loading documents page: loadPage with Offset and limit"
logs "loading documents page: loadPage with Offset and limit"
--res <- get $ toUrl Back (Children Url_Document offset limit) nodeId
--res <- get $ toUrl Back (Children Url_Document offset limit) nodeId
res <- get $ toUrl Back (Tab TabDocs offset limit (convOrderBy <$> orderBy))
nodeId
res <- get $ toUrl Back (Tab TabDocs offset limit (convOrderBy <$> orderBy))
(Just nodeId)
let docs = res2corpus <$> res
let docs = res2corpus <$> res
_ <- logs "Ok: loading page documents"
_ <- logs "Ok: loading page documents"
_ <- logs $ map show docs
_ <- logs $ map show docs
...
@@ -270,9 +270,9 @@ renderPage loaderDispatch {corpusInfo, dispatch} {currentPath: {nodeId}, loaded:
...
@@ -270,9 +270,9 @@ renderPage loaderDispatch {corpusInfo, dispatch} {currentPath: {nodeId}, loaded:
else
else
div [ ][text r.date]
div [ ][text r.date]
, if (r.delete) then
, if (r.delete) then
a [ href (toUrl Front Url_Document
r._id
), style {textDecoration : "line-through"} ] [ text r.title ]
a [ href (toUrl Front Url_Document
(Just r._id)
), style {textDecoration : "line-through"} ] [ text r.title ]
else
else
a [ href (toUrl Front Url_Document
r._id
) ] [ text r.title ]
a [ href (toUrl Front Url_Document
(Just r._id)
) ] [ text r.title ]
, if (r.delete) then
, if (r.delete) then
div [style {textDecoration : "line-through"}] [ text r.source]
div [style {textDecoration : "line-through"}] [ text r.source]
else
else
...
@@ -341,13 +341,13 @@ instance encodeJsonDDQuery :: EncodeJson DeleteDocumentQuery where
...
@@ -341,13 +341,13 @@ instance encodeJsonDDQuery :: EncodeJson DeleteDocumentQuery where
~> jsonEmptyObject
~> jsonEmptyObject
putFavorites :: Int -> FavoriteQuery -> Aff (Array Int)
putFavorites :: Int -> FavoriteQuery -> Aff (Array Int)
putFavorites nodeId = put (toUrl Back Node
nodeId
<> "/favorites")
putFavorites nodeId = put (toUrl Back Node
(Just nodeId)
<> "/favorites")
deleteFavorites :: Int -> FavoriteQuery -> Aff (Array Int)
deleteFavorites :: Int -> FavoriteQuery -> Aff (Array Int)
deleteFavorites nodeId = deleteWithBody (toUrl Back Node
nodeId
<> "/favorites")
deleteFavorites nodeId = deleteWithBody (toUrl Back Node
(Just nodeId)
<> "/favorites")
deleteDocuments :: Int -> DeleteDocumentQuery -> Aff (Array Int)
deleteDocuments :: Int -> DeleteDocumentQuery -> Aff (Array Int)
deleteDocuments nodeId = deleteWithBody (toUrl Back Node
nodeId
<> "/documents")
deleteDocuments nodeId = deleteWithBody (toUrl Back Node
(Just nodeId)
<> "/documents")
-- TODO: not optimal but Data.Set lacks some function (Set.alter)
-- TODO: not optimal but Data.Set lacks some function (Set.alter)
toggleSet :: forall a. Ord a => a -> Set a -> Set a
toggleSet :: forall a. Ord a => a -> Set a -> Set a
...
...
src/Gargantext/Pages/Corpus/Tabs/Ngrams/NgramsTable.purs
View file @
8931c366
...
@@ -331,11 +331,11 @@ type PageLoaderProps =
...
@@ -331,11 +331,11 @@ type PageLoaderProps =
--, corpusInfo :: Maybe (NodePoly CorpusInfo)
--, corpusInfo :: Maybe (NodePoly CorpusInfo)
}
}
getNgramsTable :: Int -> Aff NgramsTable
getNgramsTable ::
Maybe
Int -> Aff NgramsTable
getNgramsTable = get <<< toUrl Back (Ngrams TabTerms Nothing)
getNgramsTable = get <<< toUrl Back (Ngrams TabTerms Nothing)
loadPage :: PageParams -> Aff NgramsTable
loadPage :: PageParams -> Aff NgramsTable
loadPage {nodeId} = getNgramsTable
nodeId
-- TODO this ignores params
loadPage {nodeId} = getNgramsTable
(Just nodeId)
-- TODO this ignores params
ngramsLoaderClass :: ReactClass (Loader.Props PageParams NgramsTable)
ngramsLoaderClass :: ReactClass (Loader.Props PageParams NgramsTable)
ngramsLoaderClass = Loader.createLoaderClass "NgramsLoader" loadPage
ngramsLoaderClass = Loader.createLoaderClass "NgramsLoader" loadPage
...
...
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