blob: 510fa18f2e49cb1c674fe3732b5273e66f763a26 [file] [log] [blame]
Matteo Scandolod2044a42017-08-07 16:08:28 -07001
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 Scandolobba1d782016-07-12 15:56:23 -070019'use strict';
20
21angular.module('xos.dashboardManager', [
22 'ngResource',
23 'ngCookies',
24 'ui.router',
25 'xos.helpers',
26 'dndLists'
27])
28.config(($stateProvider) => {
29 $stateProvider
30 .state('manage-user-dashboards', {
31 url: '/',
32 template: '<user-dashboards></user-dashboards>'
33 })
34 .state('add-dashboards', {
35 url: '/add',
36 template: '<dashboard-form></dashboard-form>'
37 })
38 .state('edit-dashboards', {
39 url: '/dashboards/:id',
40 template: '<dashboard-form></dashboard-form>'
41 });
42})
43.config(function($httpProvider){
44 $httpProvider.interceptors.push('NoHyperlinks');
45})
46.service('UserDashboards', function($http, $q){
47 this.query = () => {
48 const d = $q.defer();
49
50 $http.get('/api/utility/dashboards')
51 .then(res => {
52 d.resolve(res.data);
53 })
54 .catch(err => {
55 d.reject(err);
56 });
57
58 return {$promise: d.promise};
59 }
60
61 this.update = (dashboard) => {
62 const d = $q.defer();
63 $http.post('/api/utility/dashboards/', dashboard)
64 .then(res => {
65 d.resolve(res.data);
66 })
67 .catch(err => {
68 d.reject(err);
69 });
70
71 return {$promise: d.promise};
72 }
73});