Security/ Package Name changes
[portal.git] / ecomp-portal-FE-common / client / app / services / role / role.service.js
1 /*-
2  * ============LICENSE_START==========================================
3  * ONAP Portal
4  * ===================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ===================================================================
7  *
8  * Unless otherwise specified, all software contained herein is licensed
9  * under the Apache License, Version 2.0 (the "License");
10  * you may not use this software except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *             http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  * Unless otherwise specified, all documentation contained herein is licensed
22  * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23  * you may not use this documentation except in compliance with the License.
24  * You may obtain a copy of the License at
25  *
26  *             https://creativecommons.org/licenses/by/4.0/
27  *
28  * Unless required by applicable law or agreed to in writing, documentation
29  * distributed under the License is distributed on an "AS IS" BASIS,
30  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31  * See the License for the specific language governing permissions and
32  * limitations under the License.
33  *
34  * ============LICENSE_END============================================
35  *
36  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
37  */
38 app.factory('RoleService', function ($http, $q, conf,uuid4) {
39         var manageRoleDetails = {};
40         return {
41                 getRoles(appId) {
42                         return $http.get(conf.api.getRoles.replace(':appId', appId),{
43                 cache: false,
44                 headers: {
45                     'X-ECOMP-RequestID':uuid4.generate()
46                 }
47             })
48                         .then(function(response) {
49                                 if (typeof response.data === 'object') {
50                                         return response.data;
51                                 } else {
52                                         return $q.reject(response.data);
53                                 }
54
55                         }, function(response) {
56                                 // something went wrong
57                                 return $q.reject(response.data);
58                         });
59                 },
60                 
61                 saveRoleFunction(appId) {
62                         return $http.post(conf.api.saveRoleFuncion.replace(':appId', appId))
63                         .then(function(response) {
64                                 if (typeof response.data === 'object') {
65                                         return response.data;
66                                 } else {
67                                         return $q.reject(response.data);
68                                 }
69
70                         }, function(response) {
71                                 // something went wrong
72                                 return $q.reject(response.data);
73                         });
74                 },
75                 
76                 getRoleFunctionList(appId) {
77                         return $http.get(conf.api.getRoleFunctions.replace(':appId', appId),{
78                 cache: false,
79                 headers: {
80                     'X-ECOMP-RequestID':uuid4.generate()
81                 }
82             })
83                         .then(function(response) {
84                                 if (typeof response.data === 'object') {
85                                         return response.data;
86                                 } else {
87                                         return $q.reject(response.data);
88                                 }
89
90                         }, function(response) {
91                                 // something went wrong
92                                 return $q.reject(response.data);
93                         });
94                 },
95                 
96                 getFnMenuItems: function(){
97                         
98                         return $http.get('admin_fn_menu')
99                         .then(function(response) {
100                                 if (typeof response.data === 'object') {
101                                         
102                                         return response.data;
103                                 } else {
104                                         return $q.reject(response.data);
105                                 }
106
107                         }, function(response) {
108                                 // something went wrong
109                                 return $q.reject(response.data);
110                         });                     
111                 },
112
113                 getCacheRegions: function() {
114                         return $http.get('get_regions')
115                         .then(function(response) {
116                                 if (typeof response.data === 'object') {
117                                         return response.data;
118                                 } else {
119                                         return $q.reject(response.data);
120                                 }
121         
122                         }, function(response) {
123                                 // something went wrong
124                                 return $q.reject(response.data);
125                         });
126                 },
127                 
128                 getUsageList: function() {
129                         return $http.get('get_usage_list')
130                         .then(function(response) {
131                                 if (typeof response.data === 'object') {
132                                         return response.data;
133                                 } else {
134                                         return $q.reject(response.data);
135                                 }
136         
137                         }, function(response) {
138                                 // something went wrong
139                                 return $q.reject(response.data);
140                         });
141                 },
142                 
143                 getBroadcastList: function() {
144                         return $http.get('get_broadcast_list')
145                         .then(function(response) {
146                                 if (typeof response.data === 'object') {
147                                         return response.data;
148                                 } else {
149                                         return $q.reject(response.data);
150                                 }
151         
152                         }, function(response) {
153                                 // something went wrong
154                                 return $q.reject(response.data);
155                         });
156                 },
157                 
158                 getBroadcast: function(messageLocationId, messageLocation, messageId) {
159                         return $http.get('get_broadcast?message_location_id='+messageLocationId + '&message_location=' + messageLocation + ((messageId != null) ? '&message_id=' + messageId : ''))
160                         .then(function(response) {
161                                 if (typeof response.data === 'object') {
162                                         return response.data;
163                                 } else {
164                                         return $q.reject(response.data);
165                                 }
166         
167                         }, function(response) {
168                                 // something went wrong
169                                 return $q.reject(response.data);
170                         });
171                 },
172                 
173                 getCollaborateList: function() {
174                         return $http.get('get_collaborate_list')
175                         .then(function(response) {
176                                 if (typeof response.data === 'object') {
177                                         return response.data;
178                                 } else {
179                                         return $q.reject(response.data);
180                                 }
181         
182                         }, function(response) {
183                                 // something went wrong
184                                 return $q.reject(response.data);
185                         });
186                 },
187                 
188                 getRole: function(appId, roleId) {
189                         
190                         return $http.get(conf.api.getRole + '/' + appId + '/' + roleId,{    
191                 cache: false,
192                 headers: {
193                     'X-ECOMP-RequestID':uuid4.generate()
194                 }
195             })
196                         .then(function(response) {
197                                 if (typeof response.data === 'object') {
198                                         return response.data;
199                                 } else {
200                                         return $q.reject(response.data);
201                                 }
202         
203                         }, function(response) {
204                                 // something went wrong
205                                 return $q.reject(response.data);
206                         });
207                 },
208                 
209                 saveRole(appId) {
210                         return $http.post(conf.api.saveRole.replace(':appId', appId))
211                         .then(function(response) {
212                                 if (typeof response.data === 'object') {
213                                         return response.data;
214                                 } else {
215                                         return $q.reject(response.data);
216                                 }
217
218                         }, function(response) {
219                                 // something went wrong
220                                 return $q.reject(response.data);
221                         });
222                 },
223                 
224                 getCentralizedApps: function(userId) {
225                         
226                         return $http.get(conf.api.centralizedApps + '?userId=' + userId,{
227                 cache: false,
228                 headers: {
229                     'X-ECOMP-RequestID':uuid4.generate()
230                 }
231             })
232                         .then(function(response) {
233                                 if (typeof response.data === 'object') {
234                                         return response.data;
235                                 } else {
236                                         return $q.reject(response.data);
237                                 }
238         
239                         }, function(response) {
240                                 // something went wrong
241                                 return $q.reject(response.data);
242                         });
243                 },
244                 
245                 setManageRoleDetails:function(apps, id){
246                         manageRoleDetails = {
247                                         apps: apps,
248                                         id: id
249                         }
250                 },
251                 
252                 getManageRoleDetails: function(){
253                         return manageRoleDetails;
254                 }
255         };
256 });