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

[FIX] routes for table.

parent 97fcab0f
......@@ -98,7 +98,7 @@ endPathUrl Back c nt i = pathUrl c.back nt i
endPathUrl Front c nt i = pathUrl c.front nt i
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
------------------------------------------------------------
toUrl :: End -> NodeType -> Id -> Url
......@@ -110,7 +110,7 @@ toUrl e nt i = doUrl base path params
------------------------------------------------------------
data NodeType = NodeUser
| Annuaire
| Children NodeType Offset Limit
| Tab TabType Offset Limit
| Corpus
| CorpusV3
| Dashboard
......@@ -133,10 +133,20 @@ instance showApiVersion :: Show ApiVersion where
show V10 = "v1.0"
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 Annuaire = show Annuaire
urlConfig nt@(Children _ _ _) = show nt
urlConfig nt@(Tab _ _ _) = show nt
urlConfig Corpus = show Corpus
urlConfig CorpusV3 = show CorpusV3
urlConfig Dashboard = show Dashboard
......@@ -162,17 +172,17 @@ instance showNodeType :: Show NodeType where
show Node = "node"
show NodeUser = "user"
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 ?
-- instance readNodeType :: Read NodeType where
readNodeType :: String -> NodeType
readNodeType "Annuaire" = Annuaire
readNodeType "Children" = (Children Node 0 0)
readNodeType "Dashboard" = Dashboard
readNodeType "NodeAnnuaire" = Annuaire
readNodeType "Tab" = (Tab TabDocs 0 0)
readNodeType "NodeDashboard" = Dashboard
readNodeType "Document" = Url_Document
readNodeType "Folder" = Folder
readNodeType "Graph" = Graph
readNodeType "NodeFolder" = Folder
readNodeType "NodeGraph" = Graph
readNodeType "Individu" = Individu
readNodeType "Node" = Node
readNodeType "NodeCorpus" = Corpus
......
......@@ -13,7 +13,7 @@ import Thermite (Render, Spec
------------------------------------------------------------------------------
import Gargantext.Prelude
import Gargantext.Config (toUrl, NodeType(..), End(..))
import Gargantext.Config (toUrl, NodeType(..), TabType(..), End(..))
import Gargantext.Config.REST (get)
import Gargantext.Pages.Annuaire.User.Users.Types.Types (User(..), HyperData(..))
import Data.Argonaut (class DecodeJson, decodeJson, (.?))
......@@ -180,7 +180,7 @@ instance decodeAnnuaireTable :: DecodeJson AnnuaireTable where
pure $ AnnuaireTable { annuaireTable : rows}
------------------------------------------------------------------------
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 id = get $ toUrl Back Node id
......
......@@ -13,7 +13,7 @@ import React.DOM.Props (_type, className, href)
import Thermite (Render, Spec, defaultPerformAction, simpleSpec)
------------------------------------------------------------------------
import Gargantext.Prelude
import Gargantext.Config (NodeType(..), toUrl, End(..))
import Gargantext.Config (NodeType(..), TabType(..), toUrl, End(..))
import Gargantext.Config.REST (get, post)
import Gargantext.Utils.DecodeMaybe ((.|))
import Gargantext.Components.Charts.Options.ECharts (chart)
......@@ -170,7 +170,8 @@ mock = false
loadPage :: {nodeId :: Int, limit :: Int, offset :: Int} -> Aff (Array DocumentsView)
loadPage {nodeId, limit, offset} = do
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
_ <- logs "Ok: loading page documents"
_ <- 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