blob: 593dbf3b80df1b44d32a7da2cd43898a5fd18ff9 [file] [log] [blame]
Matteo Scandolod2044a42017-08-07 16:08:28 -07001
2/*
3 * Copyright 2017-present Open Networking Foundation
4
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8
9 * http://www.apache.org/licenses/LICENSE-2.0
10
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18
Matteo Scandolof0577ac2016-03-21 17:27:42 -070019/**
20 * © OpenCORD
21 *
22 * Visit http://guide.xosproject.org/devguide/addview/ for more information
23 *
24 * Created by teone on 3/21/16.
25 */
26
27(function () {
28 'use strict';
29
30 angular.module('xos.ceilometerDashboard')
31 .directive('ceilometerStats', function(){
32 return {
33 restrict: 'E',
34 scope: {
35 name: '=name',
36 tenant: '=tenant'
37 },
38 bindToController: true,
39 controllerAs: 'vm',
40 templateUrl: 'templates/ceilometer-stats.tpl.html',
41 controller: function($scope, Ceilometer) {
42
43 this.getStats = (tenant) => {
44 this.loader = true;
45 Ceilometer.getStats({tenant: tenant})
46 .then(res => {
47 res.map(m => {
48 m.resource_name = m.resource_name.replace('mysite_onos_vbng', 'ONOS_FABRIC');
49 m.resource_name = m.resource_name.replace('mysite_onos_volt', 'ONOS_CORD');
50 m.resource_name = m.resource_name.replace('mysite_vbng', 'mysite_vRouter');
51 return m;
52 });
53 this.stats = res;
54 })
55 .catch(err => {
56 this.error = err.data;
57 })
58 .finally(() => {
59 this.loader = false;
60 });
61 };
62
63 $scope.$watch(() => this.name, (val) => {
64 if(val){
65 this.getStats(this.tenant);
66 }
67 });
68 }
69 }
70 });
71})();
72