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
ba53e379
Commit
ba53e379
authored
Sep 24, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Config] version of api Back|Front End datatype.
parent
771c3b98
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
36 deletions
+61
-36
Tree.purs
src/Gargantext/Components/Tree.purs
+10
-9
Config.purs
src/Gargantext/Config.purs
+46
-22
Router.purs
src/Gargantext/Router.purs
+5
-5
No files found.
src/Gargantext/Components/Tree.purs
View file @
ba53e379
...
...
@@ -21,6 +21,8 @@ import React.DOM (a, div, i, li, text, ul)
import React.DOM.Props (Props, className, href, onClick)
import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec)
import Gargantext.Config (NodeType(..), toUrl, readNodeType, End(..), ApiVersion)
type Name = String
type Open = Boolean
type URL = String
...
...
@@ -53,8 +55,6 @@ toggleNode sid (NTree (LNode {id, name, nodeType, open}) ary) =
where
nopen = if sid == id then not open else open
------------------------------------------------------------------------
-- Realistic Tree for the UI
...
...
@@ -115,7 +115,7 @@ toHtml d (NTree (LNode {id, name, nodeType, open}) []) =
[
li []
[
a [ href
"#"
]
a [ href
(toUrl Front (readNodeType nodeType) id)
]
( [ text (name <> " ")
] <> nodeOptionsView false
)
...
...
@@ -125,7 +125,8 @@ toHtml d (NTree (LNode {id, name, nodeType, open}) ary) =
ul [ ]
[ li [] $
( [ a [onClick $ (\e-> d $ ToggleFolder id)] [i [fldr open] []]
, text $ " " <> name <> " "
, a [ href (toUrl Front (readNodeType nodeType) id )]
[ text $ " " <> name <> " " ]
] <> nodeOptionsCorp false <>
if open then
map (toHtml d) ary
...
...
@@ -161,7 +162,7 @@ instance decodeJsonFTree :: DecodeJson (NTree LNode) where
loadDefaultNode :: Aff (Either String (NTree LNode))
loadDefaultNode = do
res <- request $ defaultRequest
{ url =
"http://localhost:8008/tree/1"
{ url =
toUrl Back Tree 1
, responseFormat = ResponseFormat.json
, method = Left GET
, headers = []
...
...
@@ -182,7 +183,7 @@ loadDefaultNode = do
renameNode :: Aff (Either String (Int)) --- need to change return type herre
renameNode = do
res <- request $ defaultRequest
{ url =
"http://localhost:8008/tree/1"
{ url =
toUrl Back Tree 1
, responseFormat = ResponseFormat.json
, method = Left PUT
, headers = []
...
...
@@ -203,7 +204,7 @@ renameNode = do
deleteNode :: Aff (Either String (Int))
deleteNode = do
res <- request $ defaultRequest
{ url =
"http://localhost:8008/tree/1"
{ url =
toUrl Back Tree 1
, responseFormat = ResponseFormat.json
, method = Left DELETE
, headers = []
...
...
@@ -225,7 +226,7 @@ deleteNode = do
deleteNodes :: String -> Aff (Either String Int)
deleteNodes reqbody = do
res <- request $ defaultRequest
{ url =
"http://localhost:8008/tree"
{ url =
toUrl Back Tree 1
, responseFormat = ResponseFormat.json
, method = Left DELETE
, headers = []
...
...
@@ -246,7 +247,7 @@ deleteNodes reqbody = do
createNode :: String -> Aff (Either String (Int))
createNode reqbody= do
res <- request $ defaultRequest
{ url =
"http://localhost:8008/tree"
{ url =
toUrl Back Tree 1
, responseFormat = ResponseFormat.json
, method = Left POST
, headers = []
...
...
src/Gargantext/Config.purs
View file @
ba53e379
...
...
@@ -5,15 +5,15 @@ developpement is : toUrl.
* Example usage:
- for Mock config:
- toUrl Corpus 3 == "http://localhost:2015/corpus/3"
- toUrl
Front
Corpus 3 == "http://localhost:2015/corpus/3"
- (this mode supposes you have the mock haskell backend running)
- for Dev config:
- toUrl Corpus 3 == "http://localhost:8008/corpus/3"
- toUrl
Front
Corpus 3 == "http://localhost:8008/corpus/3"
- (this mode supposes you have the dev haskell backend running)
- for Prod config:
- toUrl Corpus 3 == "https://gargantext.org:8080/corpus/3"
- toUrl
Front
Corpus 3 == "https://gargantext.org:8080/corpus/3"
- (this mode supposes you have a prod haskell backend running on the specified url)
-}
module Gargantext.Config where
...
...
@@ -27,14 +27,20 @@ import Data.Maybe (maybe)
import Data.Tuple (Tuple(..))
------------------------------------------------------------
-- | Versions wille used later after the release
-- data ApiVersion = V1
-- | Versions will used later after the release
data ApiVersion = V10 | V11
instance showApiVersion :: Show ApiVersion where
show V10 = "v1.0"
show V11 = "v1.1"
data End = Back | Front
-- | Main options of the configuration
data Mode = Mock | Dev | Prod
config :: FrontEndConfig
config = mkConfig
Mock
config = mkConfig
Dev V10
mkAdress :: Mode -> String
mkAdress Mock = "localhost"
...
...
@@ -55,9 +61,11 @@ mkProto Prod = "https://"
urlConfig :: Map NodeType Url
urlConfig = DM.fromFoldable [ Tuple UserPage "user"
, easy Corpus
, easy Project
, easy Document
, easy Annuaire
, easy Individu
, easy Tree
]
where
easy :: NodeType -> Tuple NodeType Url
...
...
@@ -66,37 +74,54 @@ urlConfig = DM.fromFoldable [ Tuple UserPage "user"
type FrontEndConfig = { proto :: String
, port :: Int
, address :: String
, apiVersion :: ApiVersion
, urls :: Map NodeType Url
}
mkConfig :: Mode -> FrontEndConfig
mkConfig mode
= { proto
: mkProto mode
mkConfig :: Mode ->
ApiVersion ->
FrontEndConfig
mkConfig mode
v = { proto
: mkProto mode
, address : mkAdress mode
, port : mkPort mode
, apiVersion : v
, urls : urlConfig
}
------------------------------------------------------------
------------------------------------------------------------
-- | Main function to use in the Front-End developpement
-- for more complex urls, use urlConfig and smart constructors
toUrl :: NodeType -> Id -> Url
toUrl
nt i = config.proto <> config.address <> ":" <> show config.port <> "/"
<> path
toUrl ::
End ->
NodeType -> Id -> Url
toUrl
end nt i = config.proto <> config.address <> ":" <> show config.port <> end'
<> path
where
end' = case end of
Back -> "/api/" <> show config.apiVersion <> "/"
Front -> "/"
path = subPath <> "/" <> show i
subPath = maybe "error" identity (DM.lookup nt config.urls)
subPath = maybe "error
SubPath
" identity (DM.lookup nt config.urls)
------------------------------------------------------------
type Url = String
type Id = Int
------------------------------------------------------------
data NodeType = UserPage | Corpus | Document | Annuaire | Individu | Project
data NodeType = UserPage | Corpus | Document | Annuaire | Individu | Project
| Tree | Error
------------------------------------------------------------
instance showNodeType :: Show NodeType where
show UserPage = "user
Page
"
show UserPage = "user"
show Corpus = "corpus"
show Document = "document"
show Annuaire = "annuaire"
show Individu = "individu"
show Project = "project"
show Tree = "tree"
show Error = "errNodeType"
readNodeType :: String -> NodeType
readNodeType "NodeUser" = UserPage
readNodeType "NodeCorpus" = Corpus
readNodeType "Document" = Document
readNodeType "Annuaire" = Annuaire
readNodeType "Individu" = Individu
readNodeType "Project" = Project
readNodeType "Tree" = Tree
readNodeType _ = Error
instance ordNodeType :: Ord NodeType where
compare n1 n2 = compare (show n1) (show n2)
...
...
@@ -104,4 +129,3 @@ instance ordNodeType :: Ord NodeType where
instance eqNodeType :: Eq NodeType where
eq n1 n2 = eq (show n1) (show n2)
------------------------------------------------------------
------------------------------------------------------------
src/Gargantext/Router.purs
View file @
ba53e379
...
...
@@ -32,11 +32,11 @@ instance showRoutes :: Show Routes where
show Login = "Login"
show AddCorpus = "AddCorpus"
show DocView = "DocView"
show SearchView = "Search
View
"
show (UserPage i) = "User
Page
"
show (DocAnnotation i)= "Document
View
"
show SearchView = "Search"
show (UserPage i) = "User"
show (DocAnnotation i)= "Document"
show Tabview = "Tabview"
show CorpusAnalysis = "
c
orpus"
show CorpusAnalysis = "
C
orpus"
show PGraphExplorer = "graphExplorer"
show NGramsTable = "NGramsTable"
show Dashboard = "Dashboard"
...
...
@@ -49,7 +49,7 @@ routing :: Match Routes
routing =
Login <$ route "login"
<|> Tabview <$ route "tabview"
<|> DocAnnotation <$> (route "document
View
" *> int)
<|> DocAnnotation <$> (route "document" *> int)
<|> UserPage <$> (route "user" *> int)
<|> SearchView <$ route "search"
<|> DocView <$ route "docView"
...
...
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