blob: b9ccd2edecc69b7114dad4d59a5ac3b3e6f178a7 [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 .service('Ceilometer', function($http, $q){
32
33 this.getMappings = () => {
34 let deferred = $q.defer();
35
Srikanth Vavilapallid1a86142016-08-10 17:22:15 -040036 $http.get('/api/tenant/monitoring/dashboard/xos-slice-service-mapping/')
Matteo Scandolof0577ac2016-03-21 17:27:42 -070037 .then((res) => {
38 deferred.resolve(res.data)
39 })
40 .catch((e) => {
41 deferred.reject(e);
42 });
43
44 return deferred.promise;
45 };
46
47 this.getMeters = (params) => {
48 let deferred = $q.defer();
49
Srikanth Vavilapallid1a86142016-08-10 17:22:15 -040050 $http.get('/api/tenant/monitoring/dashboard/meters/', {cache: true, params: params})
Matteo Scandolof0577ac2016-03-21 17:27:42 -070051 // $http.get('../meters_mock.json', {cache: true})
52 .then((res) => {
53 deferred.resolve(res.data)
54 })
55 .catch((e) => {
56 deferred.reject(e);
57 });
58
59 return deferred.promise;
60 };
61
Matteo Scandolo02f44d62016-09-19 17:17:58 -070062 this.getSamples = (name, limit = 10) => {
Matteo Scandolof0577ac2016-03-21 17:27:42 -070063 let deferred = $q.defer();
64
Matteo Scandolo02f44d62016-09-19 17:17:58 -070065 $http.get(`/api/tenant/monitoring/dashboard/metersamples/`, {params: {meter: name, limit: limit}})
Matteo Scandolof0577ac2016-03-21 17:27:42 -070066 .then((res) => {
67 deferred.resolve(res.data)
68 })
69 .catch((e) => {
70 deferred.reject(e);
71 });
72
73 return deferred.promise;
74 };
75
76 this.getStats = (options) => {
77 let deferred = $q.defer();
78
Srikanth Vavilapallid1a86142016-08-10 17:22:15 -040079 $http.get('/api/tenant/monitoring/dashboard/meterstatistics/', {cache: true, params: options})
Matteo Scandolof0577ac2016-03-21 17:27:42 -070080 // $http.get('../stats_mock.son', {cache: true})
81 .then((res) => {
82 deferred.resolve(res.data);
83 })
84 .catch((e) => {
85 deferred.reject(e);
86 });
87
88 return deferred.promise;
89 };
90
91 // hold dashboard status (opened service, slice, resource)
92 this.selectedService = null;
93 this.selectedSlice = null;
94 this.selectedResource = null;
95 });
96})();
97