Commit 6d590bf1 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] routes for table.

parent 97fcab0f
...@@ -94,11 +94,11 @@ baseUrl :: Config -> UrlBase ...@@ -94,11 +94,11 @@ 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 -> 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 -> Id -> UrlPath
pathUrl c nt@(Children _ _ _) i = pathUrl c Node i <> "/" <> show nt pathUrl c nt@(Tab _ _ _) 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 <> "/" <> show i
------------------------------------------------------------ ------------------------------------------------------------
toUrl :: End -> NodeType -> Id -> Url toUrl :: End -> NodeType -> Id -> Url
...@@ -110,7 +110,7 @@ toUrl e nt i = doUrl base path params ...@@ -110,7 +110,7 @@ toUrl e nt i = doUrl base path params
------------------------------------------------------------ ------------------------------------------------------------
data NodeType = NodeUser data NodeType = NodeUser
| Annuaire | Annuaire
| Children NodeType Offset Limit | Tab TabType Offset Limit
| Corpus | Corpus
| CorpusV3 | CorpusV3
| Dashboard | Dashboard
...@@ -133,10 +133,20 @@ instance showApiVersion :: Show ApiVersion where ...@@ -133,10 +133,20 @@ instance showApiVersion :: Show ApiVersion where
show V10 = "v1.0" show V10 = "v1.0"
show V11 = "v1.1" show V11 = "v1.1"
------------------------------------------------------------ ------------------------------------------------------------
data TabType = TabDocs | TabTerms | TabSources | TabAuthors | TabTrash
instance showTabType :: Show TabType where
show TabDocs = "Docs"
show TabTerms = "Terms"
show TabSources = "Sources"
show TabAuthors = "Authors"
show TabTrash = "Trash"
------------------------------------------------------------ ------------------------------------------------------------
urlConfig :: NodeType -> Url urlConfig :: NodeType -> Url
urlConfig Annuaire = show Annuaire urlConfig Annuaire = show Annuaire
urlConfig nt@(Children _ _ _) = show nt urlConfig nt@(Tab _ _ _) = show nt
urlConfig Corpus = show Corpus urlConfig Corpus = show Corpus
urlConfig CorpusV3 = show CorpusV3 urlConfig CorpusV3 = show CorpusV3
urlConfig Dashboard = show Dashboard urlConfig Dashboard = show Dashboard
...@@ -162,17 +172,17 @@ instance showNodeType :: Show NodeType where ...@@ -162,17 +172,17 @@ instance showNodeType :: Show NodeType where
show Node = "node" show Node = "node"
show NodeUser = "user" show NodeUser = "user"
show Tree = "tree" show Tree = "tree"
show (Children t o l) = "children?type=" <> show t <> "&offset=" <> show o <> "&limit=" <> show l show (Tab t o l) = "table?view=" <> show t <> "&offset=" <> show o <> "&limit=" <> show l <> "&order=DateAsc"
-- | TODO : where is the Read Class ? -- | TODO : where is the Read Class ?
-- instance readNodeType :: Read NodeType where -- instance readNodeType :: Read NodeType where
readNodeType :: String -> NodeType readNodeType :: String -> NodeType
readNodeType "Annuaire" = Annuaire readNodeType "NodeAnnuaire" = Annuaire
readNodeType "Children" = (Children Node 0 0) readNodeType "Tab" = (Tab TabDocs 0 0)
readNodeType "Dashboard" = Dashboard readNodeType "NodeDashboard" = Dashboard
readNodeType "Document" = Url_Document readNodeType "Document" = Url_Document
readNodeType "Folder" = Folder readNodeType "NodeFolder" = Folder
readNodeType "Graph" = Graph readNodeType "NodeGraph" = Graph
readNodeType "Individu" = Individu readNodeType "Individu" = Individu
readNodeType "Node" = Node readNodeType "Node" = Node
readNodeType "NodeCorpus" = Corpus readNodeType "NodeCorpus" = Corpus
......
...@@ -13,7 +13,7 @@ import Thermite (Render, Spec ...@@ -13,7 +13,7 @@ import Thermite (Render, Spec
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Config (toUrl, NodeType(..), End(..)) import Gargantext.Config (toUrl, NodeType(..), TabType(..), End(..))
import Gargantext.Config.REST (get) import Gargantext.Config.REST (get)
import Gargantext.Pages.Annuaire.User.Users.Types.Types (User(..), HyperData(..)) import Gargantext.Pages.Annuaire.User.Users.Types.Types (User(..), HyperData(..))
import Data.Argonaut (class DecodeJson, decodeJson, (.?)) import Data.Argonaut (class DecodeJson, decodeJson, (.?))
...@@ -180,7 +180,7 @@ instance decodeAnnuaireTable :: DecodeJson AnnuaireTable where ...@@ -180,7 +180,7 @@ instance decodeAnnuaireTable :: DecodeJson AnnuaireTable where
pure $ AnnuaireTable { annuaireTable : rows} pure $ AnnuaireTable { annuaireTable : rows}
------------------------------------------------------------------------ ------------------------------------------------------------------------
getTable :: Int -> Aff AnnuaireTable getTable :: Int -> Aff AnnuaireTable
getTable id = get $ toUrl Back (Children Annuaire 0 10) id getTable id = get $ toUrl Back (Tab TabDocs 0 10) id
getInfo :: Int -> Aff AnnuaireInfo getInfo :: Int -> Aff AnnuaireInfo
getInfo id = get $ toUrl Back Node id getInfo id = get $ toUrl Back Node id
......
...@@ -13,7 +13,7 @@ import React.DOM.Props (_type, className, href) ...@@ -13,7 +13,7 @@ import React.DOM.Props (_type, className, href)
import Thermite (Render, Spec, defaultPerformAction, simpleSpec) import Thermite (Render, Spec, defaultPerformAction, simpleSpec)
------------------------------------------------------------------------ ------------------------------------------------------------------------
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Config (NodeType(..), toUrl, End(..)) import Gargantext.Config (NodeType(..), TabType(..), toUrl, End(..))
import Gargantext.Config.REST (get, post) import Gargantext.Config.REST (get, post)
import Gargantext.Utils.DecodeMaybe ((.|)) import Gargantext.Utils.DecodeMaybe ((.|))
import Gargantext.Components.Charts.Options.ECharts (chart) import Gargantext.Components.Charts.Options.ECharts (chart)
...@@ -170,7 +170,8 @@ mock = false ...@@ -170,7 +170,8 @@ mock = false
loadPage :: {nodeId :: Int, limit :: Int, offset :: Int} -> Aff (Array DocumentsView) loadPage :: {nodeId :: Int, limit :: Int, offset :: Int} -> Aff (Array DocumentsView)
loadPage {nodeId, limit, offset} = do loadPage {nodeId, limit, offset} = 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 ) 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
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment