blob: 24737c3768ff07f4b25f26bd025f6c197e4a10fb [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
18 $http.get('/xoslib/xos-slice-service-mapping/')
19 .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
32 $http.get('/xoslib/meters/', {cache: true, params: params})
33 // $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
44 this.getSamples = (name, tenant) => {
45 let deferred = $q.defer();
46
47 $http.get(`/xoslib/metersamples/`, {params: {meter: name, tenant: tenant}})
48 .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
61 $http.get('/xoslib/meterstatistics/', {cache: true, params: options})
62 // $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