Fix corpusLoader, add node type to Children, .?? chart, warning free build

parent 04c93526
......@@ -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 (Children o l) i = pathUrl c Node i <> "/" <> show (Children o l)
pathUrl c nt@(Children _ _ _) 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 Offset Limit
| Children NodeType Offset Limit
| Corpus
| CorpusV3
| Dashboard
......@@ -136,7 +136,7 @@ instance showApiVersion :: Show ApiVersion where
------------------------------------------------------------
urlConfig :: NodeType -> Url
urlConfig Annuaire = show Annuaire
urlConfig (Children o l) = show (Children o l)
urlConfig nt@(Children _ _ _) = show nt
urlConfig Corpus = show Corpus
urlConfig CorpusV3 = show CorpusV3
urlConfig Dashboard = show Dashboard
......@@ -162,13 +162,13 @@ instance showNodeType :: Show NodeType where
show Node = "node"
show NodeUser = "user"
show Tree = "tree"
show (Children o l) = "children?offset=" <> show o <> "&limit=" <> show l
show (Children t o l) = "children?type=" <> show t <> "&offset=" <> show o <> "&limit=" <> show l
-- | TODO : where is the Read Class ?
-- instance readNodeType :: Read NodeType where
readNodeType :: String -> NodeType
readNodeType "Annuaire" = Annuaire
readNodeType "Children" = (Children 0 0)
readNodeType "Children" = (Children Node 0 0)
readNodeType "Dashboard" = Dashboard
readNodeType "Document" = Url_Document
readNodeType "Folder" = Folder
......
module Gargantext.Pages.Annuaire where
import Data.Array (concat)
import Data.Traversable (foldl)
import Control.Monad.Trans.Class (lift)
import Data.Either (Either(..))
import Data.Lens (Lens', Prism', lens, prism, (?~))
import Data.Lens (Lens', lens, (?~))
import Data.Maybe (Maybe(..), maybe)
import React (ReactElement)
import React.DOM (div, h1, h3, hr, i, p, text, thead, tbody, input, br', b, b', tr, th, table, td, a)
import React.DOM.Props (_type, className, href, onChange, onClick, scope, selected, value, style)
import Effect.Console (log)
import React.DOM (a, b, b', br', div, h3, hr, i, input, p, table, tbody, td, text, th, thead, tr)
import React.DOM.Props (className, href, scope, style)
import Effect.Aff (Aff)
import Thermite (Render, Spec
, simpleSpec
......@@ -20,7 +16,6 @@ import Gargantext.Prelude
import Gargantext.Config (toUrl, NodeType(..), End(..))
import Gargantext.Config.REST (get)
import Gargantext.Pages.Annuaire.User.Users.Types.Types (User(..), HyperData(..))
import Gargantext.Utils.DecodeMaybe ((.?|))
import Data.Argonaut (class DecodeJson, decodeJson, (.?))
------------------------------------------------------------------------------
type State = { info :: Maybe AnnuaireInfo
......@@ -185,7 +180,7 @@ instance decodeAnnuaireTable :: DecodeJson AnnuaireTable where
pure $ AnnuaireTable { annuaireTable : rows}
------------------------------------------------------------------------
getTable :: Int -> Aff AnnuaireTable
getTable id = get $ toUrl Back (Children 0 10) id
getTable id = get $ toUrl Back (Children Annuaire 0 10) id
getInfo :: Int -> Aff AnnuaireInfo
getInfo id = get $ toUrl Back Node id
......
......@@ -53,9 +53,9 @@ layout = simpleSpec defaultPerformAction render
where
render :: Render {} {nodeId :: Int} Void
render _ {nodeId} _ _ =
[ nodeLoader { path: nodeId
, component: createClass "Layout" layout' initialState
} ]
[ corpusLoader { path: nodeId
, component: createClass "Layout" layout' initialState
} ]
layout' :: Spec State Props Action
layout' = noState corpusHeaderSpec
......@@ -99,12 +99,11 @@ corpusHeaderSpec = simpleSpec defaultPerformAction render
------------------------------------------------------------------------
getNode :: Int -> Aff (NodePoly CorpusInfo)
getNode = get <<< toUrl Back Node
-- MOCK getNode = const $ pure corpusInfoDefault
getCorpus :: Int -> Aff (NodePoly CorpusInfo)
getCorpus = get <<< toUrl Back Corpus
nodeLoaderClass :: ReactClass (Loader.Props Int (NodePoly CorpusInfo))
nodeLoaderClass = createLoaderClass "NodeLoader" getNode
corpusLoaderClass :: ReactClass (Loader.Props Int (NodePoly CorpusInfo))
corpusLoaderClass = createLoaderClass "CorpusLoader" getCorpus
nodeLoader :: Loader.Props Int (NodePoly CorpusInfo) -> ReactElement
nodeLoader = React.createLeafElement nodeLoaderClass
corpusLoader :: Loader.Props Int (NodePoly CorpusInfo) -> ReactElement
corpusLoader = React.createLeafElement corpusLoaderClass
......@@ -170,7 +170,7 @@ 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 offset limit) nodeId
res <- get $ toUrl Back (Children Url_Document offset limit) nodeId
let docs = res2corpus <$> res
_ <- logs "Ok: loading page documents"
_ <- logs $ map show docs
......
module Gargantext.Pages.Corpus.Tabs.Types where
import Data.Argonaut (class DecodeJson, decodeJson, (.?))
import Data.Argonaut (class DecodeJson, decodeJson, (.?), (.??))
import Data.Maybe (Maybe(..))
--------------------------------------------------------
import Gargantext.Prelude
......@@ -38,7 +38,7 @@ instance decodeCorpusInfo :: DecodeJson CorpusInfo where
desc <- obj .? "desc"
query <- obj .? "query"
authors <- obj .? "authors"
chart <- obj .? "chart"
chart <- obj .?? "chart"
let totalRecords = 47361 -- TODO
pure $ CorpusInfo {title, desc, query, authors, chart, totalRecords}
......
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