Commit 2ff9a282 authored by Marco Sehrer's avatar Marco Sehrer
Browse files

Use api per-page respond parameters for pagination

parent bd29be25
...@@ -26,7 +26,7 @@ module Chemotion ...@@ -26,7 +26,7 @@ module Chemotion
params do params do
optional :collection_id, type: Integer, desc: "Collection id" optional :collection_id, type: Integer, desc: "Collection id"
end end
paginate per_page: 5, max_per_page: 25, offset: 0 paginate per_page: 7, max_per_page: 25, offset: 0
get do get do
scope = if params[:collection_id] scope = if params[:collection_id]
......
...@@ -46,7 +46,7 @@ module Chemotion ...@@ -46,7 +46,7 @@ module Chemotion
params do params do
optional :collection_id, type: Integer, desc: "Collection id" optional :collection_id, type: Integer, desc: "Collection id"
end end
paginate per_page: 5, max_per_page: 25, offset: 0 paginate per_page: 7, max_per_page: 25, offset: 0
get do get do
scope = if params[:collection_id] scope = if params[:collection_id]
......
...@@ -37,14 +37,19 @@ export default class ElementsTable extends React.Component { ...@@ -37,14 +37,19 @@ export default class ElementsTable extends React.Component {
} }
onChangeUI(state) { onChangeUI(state) {
let type = this.props.type; const type = this.props.type;
let page = state.pagination && state.pagination[type] && state.pagination[type].page; const pagination = state.pagination && state.pagination[type];
if (page) { if(pagination) {
this.setState({ const {page, perPage} = pagination;
activePage: parseInt(page) if (page) {
}); this.setState({
activePage: parseInt(page),
pageSize: parseInt(perPage)
});
}
} }
//console.log('ElementsType: ' + type + '#activePage ' + page); //console.log('ElementsType: ' + type + '#activePage ' + page);
let {checkedIds, uncheckedIds, checkedAll} = state[this.props.type]; let {checkedIds, uncheckedIds, checkedAll} = state[this.props.type];
......
...@@ -30,7 +30,8 @@ export default class ReactionsFetcher { ...@@ -30,7 +30,8 @@ export default class ReactionsFetcher {
elements: json.reactions.map((r) => new Reaction(r)), elements: json.reactions.map((r) => new Reaction(r)),
totalElements: response.headers.get('X-Total'), totalElements: response.headers.get('X-Total'),
page: response.headers.get('X-Page'), page: response.headers.get('X-Page'),
pages: response.headers.get('X-Total-Pages') pages: response.headers.get('X-Total-Pages'),
perPage: response.headers.get('X-Per-Page')
} }
}) })
}).catch((errorMessage) => { }).catch((errorMessage) => {
......
...@@ -30,7 +30,8 @@ export default class SamplesFetcher { ...@@ -30,7 +30,8 @@ export default class SamplesFetcher {
elements: json.samples.map((s) => new Sample(s)), elements: json.samples.map((s) => new Sample(s)),
totalElements: response.headers.get('X-Total'), totalElements: response.headers.get('X-Total'),
page: response.headers.get('X-Page'), page: response.headers.get('X-Page'),
pages: response.headers.get('X-Total-Pages') pages: response.headers.get('X-Total-Pages'),
perPage: response.headers.get('X-Per-Page')
} }
}) })
}).catch((errorMessage) => { }).catch((errorMessage) => {
......
...@@ -28,7 +28,8 @@ export default class ScreensFetcher { ...@@ -28,7 +28,8 @@ export default class ScreensFetcher {
elements: json.screens.map (s => new Screen(s)), elements: json.screens.map (s => new Screen(s)),
totalElements: response.headers.get('X-Total'), totalElements: response.headers.get('X-Total'),
page: response.headers.get('X-Page'), page: response.headers.get('X-Page'),
pages: response.headers.get('X-Total-Pages') pages: response.headers.get('X-Total-Pages'),
perPage: response.headers.get('X-Per-Page')
} }
}) })
}).catch((errorMessage) => { }).catch((errorMessage) => {
......
...@@ -28,7 +28,8 @@ export default class WellplatesFetcher { ...@@ -28,7 +28,8 @@ export default class WellplatesFetcher {
elements: json.wellplates.map((w) => new Wellplate(w)), elements: json.wellplates.map((w) => new Wellplate(w)),
totalElements: response.headers.get('X-Total'), totalElements: response.headers.get('X-Total'),
page: response.headers.get('X-Page'), page: response.headers.get('X-Page'),
pages: response.headers.get('X-Total-Pages') pages: response.headers.get('X-Total-Pages'),
perPage: response.headers.get('X-Per-Page')
} }
}) })
}).catch((errorMessage) => { }).catch((errorMessage) => {
......
Supports Markdown
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