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