diff options
author | Regis <boudinot.regis@yahoo.com> | 2017-01-13 20:59:32 +0300 |
---|---|---|
committer | Regis <boudinot.regis@yahoo.com> | 2017-01-13 20:59:32 +0300 |
commit | c5a373c634a0547a204c35fec8fd2c4fe4acbca8 (patch) | |
tree | e80f52d22faea27633726f883887d49f0001211c | |
parent | 4b43126d08972c201551fbd1fe42e85847d5e03f (diff) |
fix pagination component handling different header styles from different server proxies
-rw-r--r-- | app/assets/javascripts/vue_pipelines_index/store.js.es6 | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/app/assets/javascripts/vue_pipelines_index/store.js.es6 b/app/assets/javascripts/vue_pipelines_index/store.js.es6 index 6b34839b030..1982142853a 100644 --- a/app/assets/javascripts/vue_pipelines_index/store.js.es6 +++ b/app/assets/javascripts/vue_pipelines_index/store.js.es6 @@ -3,14 +3,24 @@ /*= require vue_realtime_listener/index.js */ ((gl) => { - const pageValues = headers => ({ - perPage: +headers['X-Per-Page'], - page: +headers['X-Page'], - total: +headers['X-Total'], - totalPages: +headers['X-Total-Pages'], - nextPage: +headers['X-Next-Page'], - previousPage: +headers['X-Prev-Page'], - }); + const pageValues = (headers) => { + const normalizedHeaders = {}; + + Object.keys(headers).forEach((e) => { + normalizedHeaders[e.toUpperCase()] = headers[e]; + }); + + const paginationInfo = { + perPage: +normalizedHeaders['X-PER-PAGE'], + page: +normalizedHeaders['X-PAGE'], + total: +normalizedHeaders['X-TOTAL'], + totalPages: +normalizedHeaders['X-TOTAL-PAGES'], + nextPage: +normalizedHeaders['X-NEXT-PAGE'], + previousPage: +normalizedHeaders['X-PREV-PAGE'], + }; + + return paginationInfo; + }; gl.PipelineStore = class { fetchDataLoop(Vue, pageNum, url, apiScope) { |