Matteo Scandolo | b4fdd0a | 2016-05-09 15:27:47 -0700 | [diff] [blame] | 1 | (function() { |
| 2 | 'use strict'; |
| 3 | |
| 4 | angular.module('xos.helpers') |
| 5 | /** |
| 6 | * @ngdoc service |
| 7 | * @name xos.helpers.SlicesPlus |
| 8 | * @description Angular resource to fetch /api/utility/slicesplus/ |
| 9 | * This is a read-only API and only the `query` method is currently supported. |
| 10 | **/ |
| 11 | .service('SlicesPlus', function($http, $q){ |
| 12 | this.query = (params) => { |
| 13 | let deferred = $q.defer(); |
| 14 | |
| 15 | $http.get('/api/utility/slicesplus/', {params: params}) |
| 16 | .then(res => { |
| 17 | deferred.resolve(res.data); |
| 18 | }) |
| 19 | .catch(res => { |
| 20 | deferred.reject(res.data); |
| 21 | }); |
| 22 | |
| 23 | return {$promise: deferred.promise}; |
| 24 | } |
Matteo Scandolo | 62e0c61 | 2016-05-31 15:15:00 -0700 | [diff] [blame] | 25 | |
| 26 | this.get = (id, params) => { |
| 27 | let deferred = $q.defer(); |
| 28 | |
| 29 | $http.get(`/api/utility/slicesplus/${id}`, {params: params}) |
| 30 | .then(res => { |
| 31 | deferred.resolve(res.data); |
| 32 | }) |
| 33 | .catch(res => { |
| 34 | deferred.reject(res.data); |
| 35 | }); |
| 36 | return {$promise: deferred.promise}; |
| 37 | |
| 38 | } |
Matteo Scandolo | b4fdd0a | 2016-05-09 15:27:47 -0700 | [diff] [blame] | 39 | }) |
| 40 | })(); |