blob: 7f0b1f8c1d3c6e9ddb7be3f24357517d45aec607 [file] [log] [blame]
/**
* © OpenCORD
*
* Visit http://guide.xosproject.org/devguide/addview/ for more information
*
* Created by teone on 3/21/16.
*/
(function () {
'use strict';
angular.module('xos.ceilometerDashboard')
.directive('ceilometerStats', function(){
return {
restrict: 'E',
scope: {
name: '=name',
tenant: '=tenant'
},
bindToController: true,
controllerAs: 'vm',
templateUrl: 'templates/ceilometer-stats.tpl.html',
controller: function($scope, Ceilometer) {
this.getStats = (tenant) => {
this.loader = true;
Ceilometer.getStats({tenant: tenant})
.then(res => {
res.map(m => {
m.resource_name = m.resource_name.replace('mysite_onos_vbng', 'ONOS_FABRIC');
m.resource_name = m.resource_name.replace('mysite_onos_volt', 'ONOS_CORD');
m.resource_name = m.resource_name.replace('mysite_vbng', 'mysite_vRouter');
return m;
});
this.stats = res;
})
.catch(err => {
this.error = err.data;
})
.finally(() => {
this.loader = false;
});
};
$scope.$watch(() => this.name, (val) => {
if(val){
this.getStats(this.tenant);
}
});
}
}
});
})();