diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-02-04 00:10:50 +0300 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-02-09 14:11:15 +0300 |
commit | 71899e10878455277b7e2ed120d9424489a9d72b (patch) | |
tree | 4763fa0da8466eed03bd474b5e2390bc8371b650 /app/assets/javascripts/environments | |
parent | 2aeb45bdb55a634a490bf535242a6f8c10aaa938 (diff) |
Adjustments for the new response with counters
a
Diffstat (limited to 'app/assets/javascripts/environments')
-rw-r--r-- | app/assets/javascripts/environments/components/environment.js.es6 | 8 | ||||
-rw-r--r-- | app/assets/javascripts/environments/stores/environments_store.js.es6 | 22 |
2 files changed, 26 insertions, 4 deletions
diff --git a/app/assets/javascripts/environments/components/environment.js.es6 b/app/assets/javascripts/environments/components/environment.js.es6 index 93f65ba0ea8..3e899e5895b 100644 --- a/app/assets/javascripts/environments/components/environment.js.es6 +++ b/app/assets/javascripts/environments/components/environment.js.es6 @@ -7,6 +7,7 @@ window.Vue = require('vue'); window.Vue.use(require('vue-resource')); require('../services/environments_service'); require('./environment_item'); +require('../../vue_pagination/index'); (() => { window.gl = window.gl || {}; @@ -79,7 +80,9 @@ require('./environment_item'); return gl.environmentsService.all() .then(resp => resp.json()) .then((json) => { - this.store.storeEnvironments(json); + this.store.storeAvailableCount(json.available_count); + this.store.storeStoppedCount(json.stopped_count); + this.store.storeEnvironments(json.environments); }) .then(() => { this.isLoading = false; @@ -131,7 +134,8 @@ require('./environment_item'); {{state.availableCounter}} </span> </a> - </li><li v-bind:class="{ 'active' : scope === 'stopped' }"> + </li> + <li v-bind:class="{ 'active' : scope === 'stopped' }"> <a :href="projectStoppedEnvironmentsPath"> Stopped <span class="badge js-stopped-environments-count"> diff --git a/app/assets/javascripts/environments/stores/environments_store.js.es6 b/app/assets/javascripts/environments/stores/environments_store.js.es6 index a533b8b61d6..c05f353647c 100644 --- a/app/assets/javascripts/environments/stores/environments_store.js.es6 +++ b/app/assets/javascripts/environments/stores/environments_store.js.es6 @@ -42,8 +42,26 @@ return filteredEnvironments; }, - storeCounts() { - //TODO + /** + * Stores the number of available environments. + * + * @param {Number} count = 0 + * @return {Number} + */ + storeAvailableCount(count = 0) { + this.state.availableCounter = count; + return count; + }, + + /** + * Stores the number of closed environments. + * + * @param {Number} count = 0 + * @return {Number} + */ + storeStoppedCount(count = 0) { + this.state.stoppedCounter = count; + return count; }, }; |