diff --git a/ui-v2/app/serializers/application.js b/ui-v2/app/serializers/application.js index e75c96559..815017925 100644 --- a/ui-v2/app/serializers/application.js +++ b/ui-v2/app/serializers/application.js @@ -4,7 +4,6 @@ import { get } from '@ember/object'; import { HEADERS_SYMBOL as HTTP_HEADERS_SYMBOL, HEADERS_INDEX as HTTP_HEADERS_INDEX, - HEADERS_DIGEST as HTTP_HEADERS_DIGEST, } from 'consul-ui/utils/http/consul'; export default Serializer.extend({ // this could get confusing if you tried to override @@ -44,8 +43,7 @@ export default Serializer.extend({ }, normalizeMeta: function(store, primaryModelClass, headers, payload, id, requestType) { const meta = { - index: headers[HTTP_HEADERS_INDEX], - digest: headers[HTTP_HEADERS_DIGEST], + cursor: headers[HTTP_HEADERS_INDEX], date: headers['date'], }; if (requestType === 'query') { diff --git a/ui-v2/app/services/repository.js b/ui-v2/app/services/repository.js index f7fe5ac0e..13eaf7f78 100644 --- a/ui-v2/app/services/repository.js +++ b/ui-v2/app/services/repository.js @@ -14,16 +14,24 @@ export default Service.extend({ }, // store: service('store'), - findAllByDatacenter: function(dc) { - return get(this, 'store').query(this.getModelName(), { + findAllByDatacenter: function(dc, configuration = {}) { + const query = { dc: dc, - }); + }; + if (typeof configuration.cursor !== 'undefined') { + query.index = configuration.cursor; + } + return get(this, 'store').query(this.getModelName(), query); }, - findBySlug: function(slug, dc) { - return get(this, 'store').queryRecord(this.getModelName(), { - id: slug, + findBySlug: function(slug, dc, configuration = {}) { + const query = { dc: dc, - }); + id: slug, + }; + if (typeof configuration.cursor !== 'undefined') { + query.index = configuration.cursor; + } + return get(this, 'store').queryRecord(this.getModelName(), query); }, create: function(obj) { // TODO: This should probably return a Promise diff --git a/ui-v2/app/services/repository/kv.js b/ui-v2/app/services/repository/kv.js index 6185c9022..c3c4b1900 100644 --- a/ui-v2/app/services/repository/kv.js +++ b/ui-v2/app/services/repository/kv.js @@ -13,7 +13,7 @@ export default RepositoryService.extend({ return PRIMARY_KEY; }, // this one gives you the full object so key,values and meta - findBySlug: function(key, dc) { + findBySlug: function(key, dc, configuration = {}) { if (isFolder(key)) { const id = JSON.stringify([dc, key]); let item = get(this, 'store').peekRecord(this.getModelName(), id); @@ -24,23 +24,31 @@ export default RepositoryService.extend({ } return Promise.resolve(item); } - return get(this, 'store').queryRecord(this.getModelName(), { + const query = { id: key, dc: dc, - }); + }; + if (typeof configuration.cursor !== 'undefined') { + query.index = configuration.cursor; + } + return get(this, 'store').queryRecord(this.getModelName(), query); }, // this one only gives you keys // https://www.consul.io/api/kv.html - findAllBySlug: function(key, dc) { + findAllBySlug: function(key, dc, configuration = {}) { if (key === '/') { key = ''; } + const query = { + id: key, + dc: dc, + separator: '/', + }; + if (typeof configuration.cursor !== 'undefined') { + query.index = configuration.cursor; + } return this.get('store') - .query(this.getModelName(), { - id: key, - dc: dc, - separator: '/', - }) + .query(this.getModelName(), query) .then(function(items) { return items.filter(function(item) { return key !== get(item, 'Key'); diff --git a/ui-v2/app/services/repository/session.js b/ui-v2/app/services/repository/session.js index 9dace862d..aba309469 100644 --- a/ui-v2/app/services/repository/session.js +++ b/ui-v2/app/services/repository/session.js @@ -8,11 +8,15 @@ export default RepositoryService.extend({ getModelName: function() { return modelName; }, - findByNode: function(node, dc) { - return get(this, 'store').query(this.getModelName(), { + findByNode: function(node, dc, configuration = {}) { + const query = { id: node, dc: dc, - }); + }; + if (typeof configuration.cursor !== 'undefined') { + query.index = configuration.cursor; + } + return get(this, 'store').query(this.getModelName(), query); }, // TODO: Why Key? Probably should be findBySlug like the others findByKey: function(slug, dc) {