Matteo Scandolo | f0577ac | 2016-03-21 17:27:42 -0700 | [diff] [blame] | 1 | /** |
| 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 Vavilapalli | d1a8614 | 2016-08-10 17:22:15 -0400 | [diff] [blame] | 18 | $http.get('/api/tenant/monitoring/dashboard/xos-slice-service-mapping/') |
Matteo Scandolo | f0577ac | 2016-03-21 17:27:42 -0700 | [diff] [blame] | 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 | |
Srikanth Vavilapalli | d1a8614 | 2016-08-10 17:22:15 -0400 | [diff] [blame] | 32 | $http.get('/api/tenant/monitoring/dashboard/meters/', {cache: true, params: params}) |
Matteo Scandolo | f0577ac | 2016-03-21 17:27:42 -0700 | [diff] [blame] | 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 | |
Matteo Scandolo | 02f44d6 | 2016-09-19 17:17:58 -0700 | [diff] [blame] | 44 | this.getSamples = (name, limit = 10) => { |
Matteo Scandolo | f0577ac | 2016-03-21 17:27:42 -0700 | [diff] [blame] | 45 | let deferred = $q.defer(); |
| 46 | |
Matteo Scandolo | 02f44d6 | 2016-09-19 17:17:58 -0700 | [diff] [blame] | 47 | $http.get(`/api/tenant/monitoring/dashboard/metersamples/`, {params: {meter: name, limit: limit}}) |
Matteo Scandolo | f0577ac | 2016-03-21 17:27:42 -0700 | [diff] [blame] | 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 | |
Srikanth Vavilapalli | d1a8614 | 2016-08-10 17:22:15 -0400 | [diff] [blame] | 61 | $http.get('/api/tenant/monitoring/dashboard/meterstatistics/', {cache: true, params: options}) |
Matteo Scandolo | f0577ac | 2016-03-21 17:27:42 -0700 | [diff] [blame] | 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 | |