[PORTAL-16 PORTAL-18] Widget ms; staging
[portal.git] / ecomp-portal-FE-common / client / app / services / role / role.service.js
1 /*-
2  * ================================================================================
3  * ECOMP Portal
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('RoleService', function ($http, $q, conf,uuid4) {
21         return {
22                 getRoles: function() {
23                         return $http.get(conf.api.getRoles,{
24                 cache: false,
25                 headers: {
26                     'X-ECOMP-RequestID':uuid4.generate()
27                 }
28             })
29                         .then(function(response) {
30                                 if (typeof response.data === 'object') {
31                                         return response.data;
32                                 } else {
33                                         return $q.reject(response.data);
34                                 }
35
36                         }, function(response) {
37                                 // something went wrong
38                                 return $q.reject(response.data);
39                         });
40                 },
41                 
42                 saveRoleFunction: function() {
43                         return $http.post(conf.api.saveRoleFuncion)
44                         .then(function(response) {
45                                 if (typeof response.data === 'object') {
46                                         return response.data;
47                                 } else {
48                                         return $q.reject(response.data);
49                                 }
50
51                         }, function(response) {
52                                 // something went wrong
53                                 return $q.reject(response.data);
54                         });
55                 },
56                 
57                 getRoleFunctionList: function() {
58                         return $http.get(conf.api.getRoleFunctions,{
59                 cache: false,
60                 headers: {
61                     'X-ECOMP-RequestID':uuid4.generate()
62                 }
63             })
64                         .then(function(response) {
65                                 if (typeof response.data === 'object') {
66                                         return response.data;
67                                 } else {
68                                         return $q.reject(response.data);
69                                 }
70
71                         }, function(response) {
72                                 // something went wrong
73                                 return $q.reject(response.data);
74                         });
75                 },
76                 
77                 getFnMenuItems: function(){
78                         
79                         return $http.get('admin_fn_menu')
80                         .then(function(response) {
81                                 if (typeof response.data === 'object') {
82                                         
83                                         return response.data;
84                                 } else {
85                                         return $q.reject(response.data);
86                                 }
87
88                         }, function(response) {
89                                 // something went wrong
90                                 return $q.reject(response.data);
91                         });                     
92                 },
93
94                 getCacheRegions: function() {
95                         return $http.get('get_regions')
96                         .then(function(response) {
97                                 if (typeof response.data === 'object') {
98                                         return response.data;
99                                 } else {
100                                         return $q.reject(response.data);
101                                 }
102         
103                         }, function(response) {
104                                 // something went wrong
105                                 return $q.reject(response.data);
106                         });
107                 },
108                 
109                 getUsageList: function() {
110                         return $http.get('get_usage_list')
111                         .then(function(response) {
112                                 if (typeof response.data === 'object') {
113                                         return response.data;
114                                 } else {
115                                         return $q.reject(response.data);
116                                 }
117         
118                         }, function(response) {
119                                 // something went wrong
120                                 return $q.reject(response.data);
121                         });
122                 },
123                 
124                 getBroadcastList: function() {
125                         return $http.get('get_broadcast_list')
126                         .then(function(response) {
127                                 if (typeof response.data === 'object') {
128                                         return response.data;
129                                 } else {
130                                         return $q.reject(response.data);
131                                 }
132         
133                         }, function(response) {
134                                 // something went wrong
135                                 return $q.reject(response.data);
136                         });
137                 },
138                 
139                 getBroadcast: function(messageLocationId, messageLocation, messageId) {
140                         return $http.get('get_broadcast?message_location_id='+messageLocationId + '&message_location=' + messageLocation + ((messageId != null) ? '&message_id=' + messageId : ''))
141                         .then(function(response) {
142                                 if (typeof response.data === 'object') {
143                                         return response.data;
144                                 } else {
145                                         return $q.reject(response.data);
146                                 }
147         
148                         }, function(response) {
149                                 // something went wrong
150                                 return $q.reject(response.data);
151                         });
152                 },
153                 
154                 getCollaborateList: function() {
155                         return $http.get('get_collaborate_list')
156                         .then(function(response) {
157                                 if (typeof response.data === 'object') {
158                                         return response.data;
159                                 } else {
160                                         return $q.reject(response.data);
161                                 }
162         
163                         }, function(response) {
164                                 // something went wrong
165                                 return $q.reject(response.data);
166                         });
167                 },
168                 
169                 getRole: function(roleId) {
170                         
171                         return $http.get(conf.api.getRole + '?role_id=' + roleId,{
172                 cache: false,
173                 headers: {
174                     'X-ECOMP-RequestID':uuid4.generate()
175                 }
176             })
177                         .then(function(response) {
178                                 if (typeof response.data === 'object') {
179                                         return response.data;
180                                 } else {
181                                         return $q.reject(response.data);
182                                 }
183         
184                         }, function(response) {
185                                 // something went wrong
186                                 return $q.reject(response.data);
187                         });
188                 }
189         };
190 });