blob: 025e95d5fc0de0b06c4563472a801db786b44921 [file] [log] [blame]
Matteo Scandolobba1d782016-07-12 15:56:23 -07001'use strict';
2
3angular.module('xos.dashboardManager', [
4 'ngResource',
5 'ngCookies',
6 'ui.router',
7 'xos.helpers',
8 'dndLists'
9])
10.config(($stateProvider) => {
11 $stateProvider
12 .state('manage-user-dashboards', {
13 url: '/',
14 template: '<user-dashboards></user-dashboards>'
15 })
16 .state('add-dashboards', {
17 url: '/add',
18 template: '<dashboard-form></dashboard-form>'
19 })
20 .state('edit-dashboards', {
21 url: '/dashboards/:id',
22 template: '<dashboard-form></dashboard-form>'
23 });
24})
25.config(function($httpProvider){
26 $httpProvider.interceptors.push('NoHyperlinks');
27})
28.service('UserDashboards', function($http, $q){
29 this.query = () => {
30 const d = $q.defer();
31
32 $http.get('/api/utility/dashboards')
33 .then(res => {
34 d.resolve(res.data);
35 })
36 .catch(err => {
37 d.reject(err);
38 });
39
40 return {$promise: d.promise};
41 }
42
43 this.update = (dashboard) => {
44 const d = $q.defer();
45 $http.post('/api/utility/dashboards/', dashboard)
46 .then(res => {
47 d.resolve(res.data);
48 })
49 .catch(err => {
50 d.reject(err);
51 });
52
53 return {$promise: d.promise};
54 }
55});