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

[FIX] NodeId fixed, still offset and limit not changed.

parent b54293bf
module Gargantext.Pages.Corpus.Tabs.Documents where module Gargantext.Pages.Corpus.Tabs.Documents where
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..), maybe)
import Affjax (defaultRequest, printResponseFormatError, request) import Affjax (defaultRequest, printResponseFormatError, request)
import Affjax.ResponseFormat as ResponseFormat import Affjax.ResponseFormat as ResponseFormat
import Control.Monad.Cont.Trans (lift) import Control.Monad.Cont.Trans (lift)
...@@ -182,10 +182,7 @@ performAction (UpdateNodeId nId) _ _ = do ...@@ -182,10 +182,7 @@ performAction (UpdateNodeId nId) _ _ = do
performAction (LoadData n) props state@(TableData table) = do performAction (LoadData n) props state@(TableData table) = do
logs "loading documents page" logs "loading documents page"
logs table.nodeId res <- lift $ loadPage state
let limit = pageSizes2Int table.pageSize
let offset = limit * (table.currentPage +1)
res <- lift $ loadPage n offset limit
case res of case res of
Left err -> do Left err -> do
...@@ -198,27 +195,24 @@ performAction (LoadData n) props state@(TableData table) = do ...@@ -198,27 +195,24 @@ performAction (LoadData n) props state@(TableData table) = do
performAction (ChangePageSize ps) props state@(TableData table) = do performAction (ChangePageSize ps) props state@(TableData table) = do
void $ modifyState $ changePageSize ps void $ modifyState $ changePageSize ps
logs table.nodeId
performAction (LoadData nId) props state performAction (LoadData nId) props state
where where
nId = case table.nodeId of nId = maybe 0 identity table.nodeId
Nothing -> 0
(Just n) -> n
performAction (ChangePage p) props state@(TableData table) = do performAction (ChangePage p) props state@(TableData table) = do
void $ modifyState \(TableData td) -> TableData $ td { currentPage = p } void $ modifyState \(TableData td) -> TableData $ td { currentPage = p }
logs table.nodeId
performAction (LoadData nId) props state performAction (LoadData nId) props state
where where
nId = case table.nodeId of nId = maybe 0 identity table.nodeId
Nothing -> 0
(Just n)-> n
loadPage :: CorpusTableData -> Aff (Either String CorpusTableData)
loadPage t@(TableData table) = do
logs "loading documents page: loadPage with Offset and limit"
let limit = pageSizes2Int table.pageSize
let offset = limit * (table.currentPage +1)
loadPage :: Int -> Offset -> Limit -> Aff (Either String CorpusTableData) res <- get $ toUrl Back (Children offset limit) $ maybe 0 identity table.nodeId
loadPage n o l = do
logs "loading documents page: loadPage"
res <- get $ toUrl Back (Children o l) n
case res of case res of
Left err -> do Left err -> do
_ <- logs "Err: loading page documents" _ <- logs "Err: loading page documents"
...@@ -246,16 +240,15 @@ loadPage n o l = do ...@@ -246,16 +240,15 @@ loadPage n o l = do
toTableData :: Array DocumentsView -> CorpusTableData toTableData :: Array DocumentsView -> CorpusTableData
toTableData ds = TableData toTableData ds = TableData
{ rows : map (\d -> { row : d , delete : false}) ds { rows : map (\d -> { row : d , delete : false}) ds
, totalPages : 474 , totalPages : table.totalPages
, currentPage : 1 , currentPage : table.currentPage
, pageSize : PS10 , pageSize : table.pageSize
, totalRecords : 47361 , totalRecords : table.totalRecords
, title : "Documents" , title : table.title
, nodeId : Nothing , nodeId : table.nodeId
} }
--------------------------------------------------------- ---------------------------------------------------------
sampleData' :: DocumentsView sampleData' :: DocumentsView
sampleData' = DocumentsView {_id : 1, url : "", date : "date3", title : "title", source : "source", fav : false, ngramCount : 1} sampleData' = DocumentsView {_id : 1, url : "", date : "date3", title : "title", source : "source", fav : false, ngramCount : 1}
......
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