blob: 42af90bfa5d02fb9acb59f218ac446a8d2dc4013 [file] [log] [blame]
Matteo Scandoloa5d03d52016-07-21 11:35:46 -07001(function() {
2 'use strict';
3
4 angular.module('xos.helpers')
5 /**
6 * @ngdoc service
7 * @name xos.helpers.Dashboards
8 * @description Angular resource to fetch /api/core/dashboardviews/:id/
9 **/
10 .service('Dashboards', function($resource, $q, $http){
11 const r = $resource('/api/core/dashboardviews/:id/', { id: '@id' }, {
12 update: { method: 'PUT' }
13 });
14
15 r.prototype.$save = function(){
16 const d = $q.defer();
17
18 $http.put(`/api/core/dashboardviews/${this.id}/`, this)
19 .then((res) => {
20 d.resolve(res.data);
21 })
22 .catch(e => {
23 d.reject(e.data);
24 });
25
26 return d.promise;
27 }
28
29 return r;
30 })
31})();