blob: bcd582b2bf2fd1e6ffee3dea336abc1825303f58 [file] [log] [blame]
Matteo Scandolof0577ac2016-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 .service('Ceilometer', function($http, $q){
14
15 this.getMappings = () => {
16 let deferred = $q.defer();
17
Srikanth Vavilapallid1a86142016-08-10 17:22:15 -040018 $http.get('/api/tenant/monitoring/dashboard/xos-slice-service-mapping/')
Matteo Scandolof0577ac2016-03-21 17:27:42 -070019 .then((res) => {
20 deferred.resolve(res.data)
21 })
22 .catch((e) => {
23 deferred.reject(e);
24 });
25
26 return deferred.promise;
27 };
28
29 this.getMeters = (params) => {
30 let deferred = $q.defer();
31
Srikanth Vavilapallid1a86142016-08-10 17:22:15 -040032 $http.get('/api/tenant/monitoring/dashboard/meters/', {cache: true, params: params})
Matteo Scandolof0577ac2016-03-21 17:27:42 -070033 // $http.get('../meters_mock.json', {cache: true})
34 .then((res) => {
35 deferred.resolve(res.data)
36 })
37 .catch((e) => {
38 deferred.reject(e);
39 });
40
41 return deferred.promise;
42 };
43
Matteo Scandolo02f44d62016-09-19 17:17:58 -070044 this.getSamples = (name, limit = 10) => {
Matteo Scandolof0577ac2016-03-21 17:27:42 -070045 let deferred = $q.defer();
46
Matteo Scandolo02f44d62016-09-19 17:17:58 -070047 $http.get(`/api/tenant/monitoring/dashboard/metersamples/`, {params: {meter: name, limit: limit}})
Matteo Scandolof0577ac2016-03-21 17:27:42 -070048 .then((res) => {
49 deferred.resolve(res.data)
50 })
51 .catch((e) => {
52 deferred.reject(e);
53 });
54
55 return deferred.promise;
56 };
57
58 this.getStats = (options) => {
59 let deferred = $q.defer();
60
Srikanth Vavilapallid1a86142016-08-10 17:22:15 -040061 $http.get('/api/tenant/monitoring/dashboard/meterstatistics/', {cache: true, params: options})
Matteo Scandolof0577ac2016-03-21 17:27:42 -070062 // $http.get('../stats_mock.son', {cache: true})
63 .then((res) => {
64 deferred.resolve(res.data);
65 })
66 .catch((e) => {
67 deferred.reject(e);
68 });
69
70 return deferred.promise;
71 };
72
73 // hold dashboard status (opened service, slice, resource)
74 this.selectedService = null;
75 this.selectedSlice = null;
76 this.selectedResource = null;
77 });
78})();
79