Commit ea9ca36a authored by Alexandre Delanoë's avatar Alexandre Delanoë

[REST] toUrl Children.

parent 15ee6d9c
......@@ -94,6 +94,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 i = pathUrl c Node i <> "/" <> show Children
pathUrl c nt i = c.prePath <> urlConfig nt <> "/" <> show i
------------------------------------------------------------
toUrl :: End -> NodeType -> Id -> Url
......@@ -105,14 +106,16 @@ toUrl e nt i = doUrl base path params
------------------------------------------------------------
data NodeType = NodeUser
| Annuaire
| Children
| Corpus
| Dashboard
| Document
| Error
| Folder
| Graph
| Individu
| Node
| Tree
| Error
data End = Back | Front
type Id = Int
------------------------------------------------------------
......@@ -123,41 +126,47 @@ instance showApiVersion :: Show ApiVersion where
------------------------------------------------------------
------------------------------------------------------------
urlConfig :: NodeType -> Url
urlConfig NodeUser = show NodeUser
urlConfig Annuaire = show Annuaire
urlConfig Children = show Children
urlConfig Corpus = show Corpus
urlConfig Dashboard = show Dashboard
urlConfig Document = show Document
urlConfig Error = show Error
urlConfig Folder = show Folder
urlConfig Graph = show Graph
urlConfig Individu = show Individu
urlConfig Node = show Node
urlConfig NodeUser = show NodeUser
urlConfig Tree = show Tree
urlConfig Error = show Error
------------------------------------------------------------
instance showNodeType :: Show NodeType where
show NodeUser = "user"
show Annuaire = "annuaire"
show Children = "children"
show Corpus = "corpus"
show Dashboard = "dashboard"
show Document = "document"
show Error = "ErrorNodeType"
show Folder = "folder"
show Graph = "graph"
show Individu = "individu"
show Node = "node"
show NodeUser = "user"
show Tree = "tree"
show Error = "ErrorNodeType"
-- | TODO : where is the Read Class ?
-- instance readNodeType :: Read NodeType where
readNodeType :: String -> NodeType
readNodeType "NodeUser" = NodeUser
readNodeType "NodeCorpus" = Corpus
readNodeType "Annuaire" = Annuaire
readNodeType "Children" = Children
readNodeType "Dashboard" = Dashboard
readNodeType "Document" = Document
readNodeType "Folder" = Folder
readNodeType "Graph" = Graph
readNodeType "Individu" = Individu
readNodeType "Node" = Node
readNodeType "NodeCorpus" = Corpus
readNodeType "NodeUser" = NodeUser
readNodeType "Tree" = Tree
readNodeType "Folder" = Folder
readNodeType _ = Error
------------------------------------------------------------
instance ordNodeType :: Ord NodeType where
......
......@@ -11,3 +11,12 @@ render dispatch _ state _ = [h1 [] [text "Annuaire"]]
layoutAnnuaire :: Spec {} {} Void
layoutAnnuaire = simpleSpec defaultPerformAction render
------------------------------------------------------------------------------
--data Action
-- = LoadData
-- | ChangePageSize PageSizes
-- | ChangePage Int
--
......@@ -16,17 +16,17 @@ import Effect (Effect)
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Effect.Console (log)
import Gargantext.Config (NodeType(..), toUrl, End(Back))
import Gargantext.Config.REST (get)
import Gargantext.Utils.DecodeMaybe ((.|))
import React (ReactElement)
import React.DOM (a, b, b', br', div, input, option, select, span, table, tbody, td, text, th, thead, tr, p)
import React.DOM.Props (_type, className, href, onChange, onClick, scope, selected, value)
import Thermite (PerformAction, Render, Spec, modifyState, defaultPerformAction, simpleSpec)
import Unsafe.Coerce (unsafeCoerce)
p'' :: ReactElement
p'' = p [] []
--main :: forall e. Eff (dom:: DOM, console :: CONSOLE, ajax :: AJAX | e) Unit
--main = do
-- case createReactSpec layoutDocview tdata of
......@@ -38,11 +38,11 @@ p'' = p [] []
-- TODO: Pagination Details are not available from the BackEnd
-- TODO: PageSize Change manually sets the totalPages, need to get from backend and reload the data
-- TODO: Search is pending
-- TODO: Delete is pending
-- TODO: Fav is pending
-- TODO: Sort is Pending
-- TODO: Filter is Pending
-- TODO: When a pagination link is clicked, reload data. Right now it doesn't make sense to reload mock data.
-- TODO: When a pagination link is clicked, reload data.
-- Right now it doesn't make sense to reload mock data.
data Action
= LoadData
......@@ -51,7 +51,7 @@ data Action
type State = CorpusTableData
type CorpusTableData = TableData Corpus
type CorpusTableData = TableData CorpusView
newtype TableData a
= TableData
......@@ -66,8 +66,8 @@ newtype TableData a
-- , tree :: FTree
}
newtype Corpus
= Corpus
newtype CorpusView
= CorpusView
{ _id :: Int
, url :: String
, date :: String
......@@ -78,10 +78,9 @@ newtype Corpus
}
derive instance genericCorpus :: Generic CorpusView _
derive instance genericCorpus :: Generic Corpus _
instance showCorpus :: Show Corpus where
instance showCorpus :: Show CorpusView where
show = genericShow
......@@ -116,7 +115,6 @@ newtype Hyperdata = Hyperdata
-- pure $ Response { cid, created, favorite, ngramCount, hyperdata }
instance decodeHyperdata :: DecodeJson Hyperdata where
decodeJson json = do
obj <- decodeJson json
......@@ -154,7 +152,7 @@ layoutDocview = simpleSpec performAction render
[ div [className "row"]
[
div [className "col-md-12"]
[ p''
[ p [] []
, div [] [ text " Filter ", input []]
, br'
, div [className "row"]
......@@ -196,7 +194,7 @@ performAction LoadData _ _ = do
loadPage :: Aff (Either String CorpusTableData)
loadPage = do
res <- get "http://localhost:8008/node/452132/children"
res <- get $ toUrl Back Children 452132
-- res <- get "http://localhost:8008/corpus/472764/facet/documents/table?offset=0&limit=10"
case res of
Left err -> do
......@@ -208,9 +206,9 @@ loadPage = do
_ <- liftEffect $ log $ show "loading"
pure $ Right docs
where
res2corpus :: Array Response -> Array Corpus
res2corpus :: Array Response -> Array CorpusView
res2corpus rs = map (\(Response r) ->
Corpus { _id : r.cid
CorpusView { _id : r.cid
, url : ""
, date : r.created
, title : (\(Hyperdata hr) -> hr.title) r.hyperdata
......@@ -220,7 +218,7 @@ loadPage = do
}) rs
toTableData :: Array Corpus -> CorpusTableData
toTableData :: Array CorpusView -> CorpusTableData
toTableData ds = TableData
{ rows : map (\d -> { row : d , delete : false}) ds
, totalPages : 474
......@@ -233,12 +231,12 @@ loadPage = do
---------------------------------------------------------
sampleData' :: Corpus
sampleData' = Corpus {_id : 1, url : "", date : "date3", title : "title", source : "source", fav : false, ngramCount : 1}
sampleData' :: CorpusView
sampleData' = CorpusView {_id : 1, url : "", date : "date3", title : "title", source : "source", fav : false, ngramCount : 1}
--
sampleData :: Array Corpus
sampleData :: Array CorpusView
--sampleData = replicate 10 sampleData'
sampleData = map (\(Tuple t s) -> Corpus {_id : 1, url : "", date : "2017", title: t, source: s, fav : false, ngramCount : 10}) sampleDocuments
sampleData = map (\(Tuple t s) -> CorpusView {_id : 1, url : "", date : "2017", title: t, source: s, fav : false, ngramCount : 10}) sampleDocuments
sampleDocuments :: Array (Tuple String String)
sampleDocuments = [Tuple "Macroscopic dynamics of the fusion process" "Journal de Physique Lettres",Tuple "Effects of static and cyclic fatigue at high temperature upon reaction bonded silicon nitride" "Journal de Physique Colloques",Tuple "Reliability of metal/glass-ceramic junctions made by solid state bonding" "Journal de Physique Colloques",Tuple "High temperature mechanical properties and intergranular structure of sialons" "Journal de Physique Colloques",Tuple "SOLUTIONS OF THE LANDAU-VLASOV EQUATION IN NUCLEAR PHYSICS" "Journal de Physique Colloques",Tuple "A STUDY ON THE FUSION REACTION 139La + 12C AT 50 MeV/u WITH THE VUU EQUATION" "Journal de Physique Colloques",Tuple "Atomic structure of \"vitreous\" interfacial films in sialon" "Journal de Physique Colloques",Tuple "MICROSTRUCTURAL AND ANALYTICAL CHARACTERIZATION OF Al2O3/Al-Mg COMPOSITE INTERFACES" "Journal de Physique Colloques",Tuple "Development of oxidation resistant high temperature NbTiAl alloys and intermetallics" "Journal de Physique IV Colloque",Tuple "Determination of brazed joint constitutive law by inverse method" "Journal de Physique IV Colloque",Tuple "Two dimensional estimates from ocean SAR images" "Nonlinear Processes in Geophysics",Tuple "Comparison Between New Carbon Nanostructures Produced by Plasma with Industrial Carbon Black Grades" "Journal de Physique III",Tuple "<i>Letter to the Editor:</i> SCIPION, a new flexible ionospheric sounder in Senegal" "Annales Geophysicae",Tuple "Is reducibility in nuclear multifragmentation related to thermal scaling?" "Physics Letters B",Tuple "Independence of fragment charge distributions of the size of heavy multifragmenting sources" "Physics Letters B",Tuple "Hard photons and neutral pions as probes of hot and dense nuclear matter" "Nuclear Physics A",Tuple "Surveying the nuclear caloric curve" "Physics Letters B",Tuple "A hot expanding source in 50 A MeV Xe+Sn central reactions" "Physics Letters B"]
......@@ -246,14 +244,14 @@ sampleDocuments = [Tuple "Macroscopic dynamics of the fusion process" "Journal d
data' :: Array Corpus -> Array {row :: Corpus, delete :: Boolean}
data' :: Array CorpusView -> Array {row :: CorpusView, delete :: Boolean}
data' = map {row : _, delete : false}
sdata :: Array { row :: Corpus, delete :: Boolean }
sdata :: Array { row :: CorpusView, delete :: Boolean }
sdata = data' sampleData
tdata :: TableData Corpus
tdata :: TableData CorpusView
tdata = TableData
{ rows : sdata
, totalPages : 10
......@@ -265,8 +263,8 @@ tdata = TableData
}
showRow :: {row :: Corpus, delete :: Boolean} -> ReactElement
showRow {row : (Corpus c), delete} =
showRow :: {row :: CorpusView, delete :: Boolean} -> ReactElement
showRow {row : (CorpusView c), delete} =
tr []
[ td [] [div [className $ fa <> "fa-star"][]]
-- TODO show date: Year-Month-Day only
......
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