Initial OpenECOMP policy/engine commit
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / app / fusion / scripts / services / adminService.js
1 /*-
2  * ================================================================================
3  * eCOMP Portal SDK
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ================================================================================
19  */
20 app.factory('AdminService', function ($http, $q) {
21         return {
22                 getRoles: function() {
23                         return $http.get('get_roles')
24                         .then(function(response) {
25                                 if (typeof response.data === 'object') {
26                                         return response.data;
27                                 } else {
28                                         return $q.reject(response.data);
29                                 }
30
31                         }, function(response) {
32                                 // something went wrong
33                                 return $q.reject(response.data);
34                         });
35                 },
36                 
37                 getRoleFunctionList: function() {
38                         return $http.get('get_role_functions')
39                         .then(function(response) {
40                                 if (typeof response.data === 'object') {
41                                         return response.data;
42                                 } else {
43                                         return $q.reject(response.data);
44                                 }
45
46                         }, function(response) {
47                                 // something went wrong
48                                 return $q.reject(response.data);
49                         });
50                 },
51                 
52                 getFnMenuItems: function(){
53                         
54                         return $http.get('admin_fn_menu')
55                         .then(function(response) {
56                                 if (typeof response.data === 'object') {
57                                         
58                                         return response.data;
59                                 } else {
60                                         return $q.reject(response.data);
61                                 }
62
63                         }, function(response) {
64                                 // something went wrong
65                                 return $q.reject(response.data);
66                         });                     
67                 },
68
69                 getCacheRegions: function() {
70                         return $http.get('get_regions')
71                         .then(function(response) {
72                                 if (typeof response.data === 'object') {
73                                         return response.data;
74                                 } else {
75                                         return $q.reject(response.data);
76                                 }
77         
78                         }, function(response) {
79                                 // something went wrong
80                                 return $q.reject(response.data);
81                         });
82                 },
83                 
84                 getUsageList: function() {
85                         return $http.get('get_usage_list')
86                         .then(function(response) {
87                                 if (typeof response.data === 'object') {
88                                         return response.data;
89                                 } else {
90                                         return $q.reject(response.data);
91                                 }
92         
93                         }, function(response) {
94                                 // something went wrong
95                                 return $q.reject(response.data);
96                         });
97                 },
98                 
99                 getBroadcastList: function() {
100                         return $http.get('get_broadcast_list')
101                         .then(function(response) {
102                                 if (typeof response.data === 'object') {
103                                         return response.data;
104                                 } else {
105                                         return $q.reject(response.data);
106                                 }
107         
108                         }, function(response) {
109                                 // something went wrong
110                                 return $q.reject(response.data);
111                         });
112                 },
113                 
114                 getBroadcast: function(messageLocationId, messageLocation, messageId) {
115                         return $http.get('get_broadcast?message_location_id='+messageLocationId + '&message_location=' + messageLocation + ((messageId != null) ? '&message_id=' + messageId : ''))
116                         .then(function(response) {
117                                 if (typeof response.data === 'object') {
118                                         return response.data;
119                                 } else {
120                                         return $q.reject(response.data);
121                                 }
122         
123                         }, function(response) {
124                                 // something went wrong
125                                 return $q.reject(response.data);
126                         });
127                 },
128                 
129                 getCollaborateList: function() {
130                         return $http.get('get_collaborate_list')
131                         .then(function(response) {
132                                 if (typeof response.data === 'object') {
133                                         return response.data;
134                                 } else {
135                                         return $q.reject(response.data);
136                                 }
137         
138                         }, function(response) {
139                                 // something went wrong
140                                 return $q.reject(response.data);
141                         });
142                 },
143                 
144                 getRole: function(roleId) {
145                         
146                         return $http.get('get_role?role_id=' + roleId)
147                         .then(function(response) {
148                                 if (typeof response.data === 'object') {
149                                         return response.data;
150                                 } else {
151                                         return $q.reject(response.data);
152                                 }
153         
154                         }, function(response) {
155                                 // something went wrong
156                                 return $q.reject(response.data);
157                         });
158                 }
159         };
160 });