blob: 7f0b1f8c1d3c6e9ddb7be3f24357517d45aec607 [file] [log] [blame]
Matteo Scandolo78b80452016-03-21 17:27:42 -07001/**
2 * © OpenCORD
3 *
4 * Visit http://guide.xosproject.org/devguide/addview/ for more information
5 *
6 * Created by teone on 3/21/16.
7 */
8
9(function () {
10 'use strict';
11
12 angular.module('xos.ceilometerDashboard')
13 .directive('ceilometerStats', function(){
14 return {
15 restrict: 'E',
16 scope: {
17 name: '=name',
18 tenant: '=tenant'
19 },
20 bindToController: true,
21 controllerAs: 'vm',
22 templateUrl: 'templates/ceilometer-stats.tpl.html',
23 controller: function($scope, Ceilometer) {
24
25 this.getStats = (tenant) => {
26 this.loader = true;
27 Ceilometer.getStats({tenant: tenant})
28 .then(res => {
29 res.map(m => {
30 m.resource_name = m.resource_name.replace('mysite_onos_vbng', 'ONOS_FABRIC');
31 m.resource_name = m.resource_name.replace('mysite_onos_volt', 'ONOS_CORD');
32 m.resource_name = m.resource_name.replace('mysite_vbng', 'mysite_vRouter');
33 return m;
34 });
35 this.stats = res;
36 })
37 .catch(err => {
38 this.error = err.data;
39 })
40 .finally(() => {
41 this.loader = false;
42 });
43 };
44
45 $scope.$watch(() => this.name, (val) => {
46 if(val){
47 this.getStats(this.tenant);
48 }
49 });
50 }
51 }
52 });
53})();
54