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