Matteo Scandolo | d2044a4 | 2017-08-07 16:08:28 -0700 | [diff] [blame] | 1 | |
| 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 Scandolo | f0577ac | 2016-03-21 17:27:42 -0700 | [diff] [blame] | 19 | /** |
| 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 Vavilapalli | d1a8614 | 2016-08-10 17:22:15 -0400 | [diff] [blame] | 36 | $http.get('/api/tenant/monitoring/dashboard/xos-slice-service-mapping/') |
Matteo Scandolo | f0577ac | 2016-03-21 17:27:42 -0700 | [diff] [blame] | 37 | .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 Vavilapalli | d1a8614 | 2016-08-10 17:22:15 -0400 | [diff] [blame] | 50 | $http.get('/api/tenant/monitoring/dashboard/meters/', {cache: true, params: params}) |
Matteo Scandolo | f0577ac | 2016-03-21 17:27:42 -0700 | [diff] [blame] | 51 | // $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 Scandolo | 02f44d6 | 2016-09-19 17:17:58 -0700 | [diff] [blame] | 62 | this.getSamples = (name, limit = 10) => { |
Matteo Scandolo | f0577ac | 2016-03-21 17:27:42 -0700 | [diff] [blame] | 63 | let deferred = $q.defer(); |
| 64 | |
Matteo Scandolo | 02f44d6 | 2016-09-19 17:17:58 -0700 | [diff] [blame] | 65 | $http.get(`/api/tenant/monitoring/dashboard/metersamples/`, {params: {meter: name, limit: limit}}) |
Matteo Scandolo | f0577ac | 2016-03-21 17:27:42 -0700 | [diff] [blame] | 66 | .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 Vavilapalli | d1a8614 | 2016-08-10 17:22:15 -0400 | [diff] [blame] | 79 | $http.get('/api/tenant/monitoring/dashboard/meterstatistics/', {cache: true, params: options}) |
Matteo Scandolo | f0577ac | 2016-03-21 17:27:42 -0700 | [diff] [blame] | 80 | // $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 | |