Requesting Stats for a single slice
diff --git a/views/ngXosViews/ceilometerDashboard/src/js/main.js b/views/ngXosViews/ceilometerDashboard/src/js/main.js
index c35d874..01b9adc 100644
--- a/views/ngXosViews/ceilometerDashboard/src/js/main.js
+++ b/views/ngXosViews/ceilometerDashboard/src/js/main.js
@@ -62,13 +62,13 @@
return deferred.promise;
}
- this.getStats = (sliceName) => {
+ this.getStats = (options) => {
let deferred = $q.defer();
- $http.get('/xoslib/meterstatistics/', {cache: true})
+ $http.get('/xoslib/meterstatistics/', {cache: true, params: options})
// $http.get('../stats_mock.son', {cache: true})
.then((res) => {
- deferred.resolve(lodash.filter(res.data, {slice: sliceName}))
+ deferred.resolve(res.data);
})
.catch((e) => {
deferred.reject(e);
@@ -91,8 +91,6 @@
templateUrl: 'templates/ceilometer-dashboard.tpl.html',
controller: function(Ceilometer){
- console.log(Ceilometer.selectedService, Ceilometer.selectedSlice, Ceilometer.selectedResource);
-
// this open the accordion
this.accordion = {
open: {}
@@ -153,6 +151,7 @@
*/
this.selectedResources = null;
this.selectResources = (resources, slice, service) => {
+
//cleaning
this.selectedResources = null;
this.selectedResource = null;
@@ -166,6 +165,11 @@
// store the status
Ceilometer.selectedSlice = slice;
Ceilometer.selectedService = service;
+
+ // store tenant (slice id for ceilometer)
+ // it is passed to ceilometer-stats directive
+ console.log(resources);
+ this.selectedTenant = resources[Object.keys(resources)[0]][0].project_id;
}
/**
@@ -330,14 +334,17 @@
restrict: 'E',
scope: {
name: '=name',
+ tenant: '=tenant'
},
bindToController: true,
controllerAs: 'vm',
templateUrl: 'templates/ceilometer-stats.tpl.html',
controller: function($scope, Ceilometer) {
- this.getStats = () => {
+
+ this.getStats = (tenant) => {
+ console.log(this.tenant);
this.loader = true;
- Ceilometer.getStats(this.name)
+ Ceilometer.getStats({tenant: tenant})
.then(res => {
this.stats = res;
})
@@ -349,9 +356,11 @@
});
};
- this.getStats();
-
- $scope.$watch(() => this.name, () => {this.getStats();});
+ $scope.$watch(() => this.name, (val) => {
+ if(val){
+ this.getStats(this.tenant);
+ }
+ });
}
}
})
diff --git a/views/ngXosViews/ceilometerDashboard/src/templates/ceilometer-dashboard.tpl.html b/views/ngXosViews/ceilometerDashboard/src/templates/ceilometer-dashboard.tpl.html
index f04a974..6445781 100644
--- a/views/ngXosViews/ceilometerDashboard/src/templates/ceilometer-dashboard.tpl.html
+++ b/views/ngXosViews/ceilometerDashboard/src/templates/ceilometer-dashboard.tpl.html
@@ -51,7 +51,7 @@
<h3>Stats</h3>
</div>
<div class="list-group-item">
- <ceilometer-stats ng-if="vm.selectedSlice" name="vm.selectedSlice"></ceilometer-stats>
+ <ceilometer-stats ng-if="vm.selectedSlice" name="vm.selectedSlice" tenant="vm.selectedTenant"></ceilometer-stats>
</div>
</div>
</div>