Merge from ECOMP's repository
[vid.git] / vid-app-common / src / main / webapp / app / vid / scripts / controller / subscriberSearch.js
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * VID\r
4  * ================================================================================\r
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  * \r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * \r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  * ============LICENSE_END=========================================================\r
19  */\r
20 \r
21 "use strict";\r
22 \r
23 appDS2.requires.push('ngRoute');\r
24 appDS2.requires.push('ui.tree');\r
25 \r
26 appDS2.config(function($routeProvider) {\r
27         $routeProvider\r
28         .when("/subviewedit", {\r
29                 templateUrl : "app/vid/scripts/view-models/aaiSubViewEdit.htm",\r
30                 controller : "aaiSubscriberSearchController"\r
31 \r
32         })\r
33         .when("/subdetails", {\r
34                 templateUrl : "app/vid/scripts/view-models/aaiSubDetails.htm",\r
35                 controller : "aaiSubscriberController"\r
36 \r
37         })\r
38         .otherwise({\r
39                 templateUrl : "app/vid/scripts/view-models/aaiGetSubs.htm", \r
40                 controller : "aaiSubscriberSearchController"\r
41         });\r
42 });\r
43 \r
44 appDS2.config(function(treeConfig) {\r
45           treeConfig.defaultCollapsed = true; // collapse nodes by default\r
46         });\r
47 \r
48 appDS2.factory("user",function(){\r
49     return {};\r
50 });\r
51 \r
52 appDS2.controller("aaiSubscriberSearchController", [ "$scope", "$timeout", "$log", "UtilityService", "user", "PropertyService", "COMPONENT", "FIELD",\r
53     function($scope, $timeout, $log, UtilityService, user, PropertyService, COMPONENT, FIELD) {\r
54 \r
55                 $scope.baseUrl = "";\r
56                 $scope.responseTimeoutMsec = 10000;\r
57                 $scope.msoMaxPollingIntervalMsec = 1000;\r
58                 $scope.msoMaxPolls = 7;\r
59                 \r
60                 $scope.init = function(properties) {\r
61                 var msecs = PropertyService.retrieveMsoMaxPollingIntervalMsec();\r
62                 PropertyService.setMsoMaxPollingIntervalMsec(msecs);\r
63                 \r
64                 var polls = PropertyService.retrieveMsoMaxPolls();\r
65                 PropertyService.setMsoMaxPolls(polls);\r
66                 \r
67                 // These two properties only added for testing\r
68                         properties.msoDefaultBaseUrl = $scope.baseUrl;\r
69                         properties.responseTimeoutMsec = $scope.responseTimeoutMsec;\r
70 \r
71                         UtilityService.setProperties(properties);\r
72                 };\r
73                 \r
74                 $scope.autoGetSubs = function() {\r
75                         /*\r
76                          * Optionally comment in / out one of these method calls (or add a similar\r
77                          * entry) to auto-invoke an entry when the test screen is redrawn.\r
78                          */\r
79                         $timeout(function() {\r
80                                 $scope.getSubscribers();\r
81                                 // $scope.deleteServiceInstance();\r
82                                 // $scope.generateInvalidUrl405();                      \r
83                         }, 100);\r
84                 }\r
85                 \r
86                 $scope.autoGetSubDetails = function() {\r
87                         /*\r
88                          * Optionally comment in / out one of these method calls (or add a similar\r
89                          * entry) to auto-invoke an entry when the test screen is redrawn.\r
90                          */\r
91                         $timeout(function() {\r
92                                 $scope.getSubDetails();\r
93                                 // $scope.deleteServiceInstance();\r
94                                 // $scope.generateInvalidUrl405();                      \r
95                         }, 100);\r
96                 }\r
97                 \r
98                 $scope.autoPopulateViewEdit = function() {\r
99                         /*\r
100                          * Optionally comment in / out one of these method calls (or add a similar\r
101                          * entry) to auto-invoke an entry when the test screen is redrawn.\r
102                          */\r
103                         $timeout(function() {\r
104                         $scope.getComponentList();\r
105                                 // $scope.deleteServiceInstance();\r
106                                 // $scope.generateInvalidUrl405();                      \r
107                         }, 100);\r
108                 }\r
109                 \r
110                 $scope.refreshSubs = function() {\r
111                         /*\r
112                          * Optionally comment in / out one of these method calls (or add a similar\r
113                          * entry) to auto-invoke an entry when the test screen is redrawn.\r
114                          */\r
115                         $timeout(function() {\r
116                                 $scope.refreshSubscribers();\r
117                                 // $scope.deleteServiceInstance();\r
118                                 // $scope.generateInvalidUrl405();                      \r
119                         }, 100);\r
120                 }\r
121                 \r
122                 $scope.autoStartQueryTest = function() {\r
123                         /*\r
124                          * Optionally comment in / out one of these method calls (or add a similar\r
125                          * entry) to auto-invoke an entry when the test screen is redrawn.\r
126                          */\r
127                         $timeout(function() {\r
128                                 // $scope.queryServiceInstance();\r
129                         }, 100);\r
130                 }\r
131                 \r
132                 $scope.queryServiceInstance = function() {\r
133                         /*\r
134                          * Example of method call needed to query a service instance.\r
135                          */\r
136                         $scope.$broadcast(COMPONENT.QUERY_SERVICE_INSTANCE, {\r
137                                 serviceInstanceId: COMPONENT.SERVICE_INSTANCE_ID_1\r
138                         });\r
139                 }\r
140         \r
141                 $scope.getSubscribers = function() {\r
142                         /*\r
143                          * Example of method call needed to commit an instance creation request.\r
144                          */\r
145                         $scope.$broadcast(COMPONENT.GET_SUBS, {\r
146                                 url : FIELD.ID.AAI_GET_SUBSCRIBERS,\r
147                                 requestDetails : createServiceRequestDetails\r
148                         });\r
149                 }\r
150                 \r
151                 $scope.getSubDetails = function() {\r
152                         /*\r
153                          * Example of method call needed to commit an instance creation request.\r
154                          */\r
155                         $scope.$broadcast(COMPONENT.GET_SUB_DETAILS, {\r
156                                 url : FIELD.ID.AAI_SUB_DETAILS,\r
157                                 requestDetails : createServiceRequestDetails\r
158                         });\r
159                 }\r
160                 \r
161                 $scope.getComponentList = function() {\r
162                         /*\r
163                          * Example of method call needed to commit an instance creation request.\r
164                          */\r
165                         $scope.$broadcast(COMPONENT.GET_COMPONENT_LIST, {\r
166                                 url : FIELD.ID.AAI_SUB_VIEWEDIT,\r
167                                 requestDetails : createServiceRequestDetails\r
168                         });\r
169                 }\r
170                 \r
171                 \r
172                 $scope.refreshSubscribers = function() {\r
173                         /*\r
174                          * Example of method call needed to commit an instance creation request.\r
175                          */\r
176                         $scope.$broadcast(COMPONENT.GET_SUBS, {\r
177                                 url : FIELD.ID.AAI_REFRESH_SUBSCRIBERS,\r
178                                 requestDetails : createServiceRequestDetails\r
179                         });\r
180                 }\r
181         \r
182                 $scope.deleteServiceInstance = function() {\r
183                         /*\r
184                          * Example of method call needed to commit an instance deletion request.\r
185                          */\r
186                         $scope.$broadcast(COMPONENT.MSO_DELETE_REQ,     {\r
187                                 url : COMPONENT.MSO_DELETE_SVC_INSTANCE_PATH + COMPONENT.SERVICE_INSTANCE_ID_1,\r
188                                 requestDetails : deleteServiceRequestDetails\r
189                         });\r
190                 }\r
191         \r
192                 $scope.createNetworkInstance = function() {\r
193                         $scope.$broadcast(COMPONENT.MSO_CREATE_REQ, {\r
194                                 url : COMPONENT.MSO_CREATE_NW_INSTANCE,\r
195                                 requestDetails : createNetworkRequestDetails\r
196                         });\r
197                 }\r
198         \r
199                 $scope.deleteNetworkInstance = function() {\r
200                         $scope.$broadcast(COMPONENT.MSO_DELETE_REQ,     {\r
201                                 url : COMPONENT.MSO_CREATE_NW_INSTANCE_PATH + COMPONENT.SERVICE_INSTANCE_ID_1 + COMPONENT.FORWARD_SLASH + COMPONENT.NETWORKS + COMPONENT.FORWARD_SLASH + COMPONENT.DELETE_INSTANCE_ID_1,\r
202                                 requestDetails : deleteNetworkRequestDetails\r
203                         });\r
204                 }\r
205         \r
206                 $scope.generateError = function(testName) {\r
207                         // Clone example request object\r
208                         var request = JSON.parse(JSON.stringify(createServiceRequestDetails));\r
209                         request.modelInfo.modelName = testName;\r
210                         $scope.$broadcast(COMPONENT.MSO_CREATE_REQ, {\r
211                                 url : COMPONENT.MSO_CREATE_SVC_INSTANCE,\r
212                                 requestDetails : request\r
213                         });\r
214                 }\r
215         \r
216                 $scope.generateInvalidUrl404 = function() {\r
217                         var properties = UtilityService.getProperties(properties);\r
218                         properties.msoDefaultBaseUrl = COMPONENT.INVALID_STRING;\r
219                         UtilityService.setProperties(properties);\r
220                         $scope.$broadcast(COMPONENT.REFRESH_PROPERTIES);\r
221                 \r
222                         $scope.$broadcast(COMPONENT.MSO_CREATE_REQ, {\r
223                                 url : COMPONENT.MSO_CREATE_SVC_INSTANCE,\r
224                                 requestDetails : createServiceRequestDetails\r
225                         });\r
226 \r
227                         properties.msoDefaultBaseUrl = $scope.baseUrl;\r
228                         UtilityService.setProperties(properties);\r
229                         $scope.$broadcast(COMPONENT.REFRESH_PROPERTIES);                                \r
230                 }\r
231         \r
232                 $scope.generateInvalidUrl405 = function() {\r
233                         $scope.$broadcast(COMPONENT.MSO_CREATE_REQ, {\r
234                                 url : COMPONENT.INVALID_STRING_MSO_CREATE_SVC_INSTANCE,\r
235                                 requestDetails : createServiceRequestDetails\r
236                         });\r
237                 }\r
238         \r
239                 /*\r
240                  * Test data objects:\r
241                  */\r
242         \r
243                 var subscriberInfo = {\r
244                         globalSubscriberId : COMPONENT.GLOBAL_SUBSCRIBER_ID_1,\r
245                         subscriberName : COMPONENT.SUBSCRIBER_NAME_GED12\r
246                 };\r
247         \r
248                 var createServiceRequestDetails = {\r
249                         modelInfo : {\r
250                                 modelType : COMPONENT.SERVICE,\r
251                                 modelId : COMPONENT.MODEL_ID_1,\r
252                                 modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_1,\r
253                                 modelName : COMPONENT.MODEL_NAME_WANBONDING,\r
254                                 modelVersion : COMPONENT.MODEL_VERSION_1\r
255                         },\r
256                         subscriberInfo : subscriberInfo,\r
257                         requestParameters : {\r
258                                 vpnId : COMPONENT.VPN_ID_1,\r
259                                 productName : COMPONENT.PRODUCT_NAME_TRINITY,\r
260                                 customerId : COMPONENT.CUSTOMER_ID_1\r
261                         }\r
262                 };\r
263         \r
264                 var deleteServiceRequestDetails = {\r
265                         modelInfo : {\r
266                                 modelType : COMPONENT.SERVICE,\r
267                                 modelId : COMPONENT.MODEL_ID_1,\r
268                                 modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_1,\r
269                                 modelName : COMPONENT.MODEL_NAME_WANBONDING,\r
270                                 modelVersion : COMPONENT.MODEL_VERSION_1\r
271                         }\r
272                 };\r
273         \r
274                 var createNetworkRequestDetails = {\r
275                         modelInfo : {\r
276                                 modelType : COMPONENT.NETWORK,\r
277                                 modelId : COMPONENT.MODEL_ID_2,\r
278                                 modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_2,\r
279                                 modelName : COMPONENT.MODEL_NAME_VISBCOAMNETWORK,\r
280                                 modelVersion : COMPONENT.MODEL_VERSION_1\r
281                         },\r
282                         relatedModelList : [\r
283                                         {\r
284                                                 relatedModel : {\r
285                                                         instanceId : COMPONENT.INSTANCE_ID_1,\r
286                                                         modelInfo : {\r
287                                                                 modelType : COMPONENT.SERVICE,\r
288                                                                 modelId : COMPONENT.MODEL_ID_3,\r
289                                                                 modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_3,\r
290                                                                 modelName : COMPONENT.MODEL_NAME_IISBC,\r
291                                                                 modelVersion : COMPONENT.MODEL_VERSION_1\r
292                                                         }\r
293                                                 }\r
294                                         },\r
295                                         {\r
296                                                 relatedModel : {\r
297                                                         instanceId : COMPONENT.INSTANCE_ID_2,\r
298                                                         modelInfo : {\r
299                                                                 modelType : COMPONENT.VNF,\r
300                                                                 modelId : COMPONENT.MODEL_ID_4,\r
301                                                                 modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_4,\r
302                                                                 modelName : COMPONENT.MODEL_NAME_VISBC,\r
303                                                                 modelVersion : COMPONENT.MODEL_VERSION_1\r
304                                                         }\r
305                                                 }\r
306                                         },\r
307                                         {\r
308                                                 relatedModel : {\r
309                                                         instanceId : COMPONENT.INSTANCE_ID_3,\r
310                                                         modelInfo : {\r
311                                                                 modelType : COMPONENT.VF_MODULE,\r
312                                                                 modelId : COMPONENT.MODEL_ID_5,\r
313                                                                 modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_5,\r
314                                                                 modelName : COMPONENT.MODEL_NAME_VISBCRTPEXPANSIONMODULE,\r
315                                                                 modelVersion : COMPONENT.MODEL_VERSION_1\r
316                                                         }\r
317                                                 }\r
318                                         } ],\r
319                         subscriberInfo : subscriberInfo,\r
320                         requestParameters : {\r
321                                 /*\r
322                                  * FYI: quotes around field names are needed due to embedded "-"\r
323                                  * characters\r
324                                  */\r
325                                 "cidr-mask" : COMPONENT.CIDR_MASK_1,\r
326                                 "gateway-address" : COMPONENT.GATEWAY_ADDRESS_1,\r
327                                 "dhcp-enabled" : COMPONENT.TRUE\r
328                         }\r
329                 };\r
330         \r
331                 var deleteNetworkRequestDetails = {\r
332                         modelInfo : {\r
333                                 modelType : COMPONENT.NETWORK,\r
334                                 modelId : COMPONENT.MODEL_ID_2,\r
335                                 modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_2,\r
336                                 modelName : COMPONENT.MODEL_NAME_VISBCOAMNETWORK,\r
337                                 modelVersion : COMPONENT.MODEL_VERSION_1\r
338                         },\r
339                         relatedModelList : [\r
340                                         {\r
341                                                 relatedModel : {\r
342                                                         instanceId : COMPONENT.INSTANCE_ID_1,\r
343                                                         modelInfo : {\r
344                                                                 modelType : COMPONENT.SERVICE,\r
345                                                                 modelId : COMPONENT.MODEL_ID_3,\r
346                                                                 modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_3,\r
347                                                                 modelName : COMPONENT.MODEL_NAME_IISBC,\r
348                                                                 modelVersion : COMPONENT.MODEL_VERSION_1\r
349                                                         }\r
350                                                 }\r
351                                         },\r
352                                         {\r
353                                                 relatedModel : {\r
354                                                         instanceId : COMPONENT.INSTANCE_ID_2,\r
355                                                         modelInfo : {\r
356                                                                 modelType : COMPONENT.VNF,\r
357                                                                 modelId : COMPONENT.MODEL_ID_4,\r
358                                                                 modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_4,\r
359                                                                 modelName : COMPONENT.MODEL_NAME_VISBC,\r
360                                                                 modelVersion : COMPONENT.MODEL_VERSION_1\r
361                                                         }\r
362                                                 }\r
363                                         },\r
364                                         {\r
365                                                 relatedModel : {\r
366                                                         instanceId : COMPONENT.INSTANCE_ID_3,\r
367                                                         modelInfo : {\r
368                                                                 modelType : COMPONENT.VF_MODULE,\r
369                                                                 modelId : COMPONENT.MODEL_ID_5,\r
370                                                                 modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_5,\r
371                                                                 modelName : COMPONENT.MODEL_NAME_VISBCRTPEXPANSIONMODULE,\r
372                                                                 modelVersion : COMPONENT.MODEL_VERSION_1\r
373                                                         }\r
374                                                 }\r
375                                         } ]\r
376                 };\r
377                 $scope.getSubscriberDet = function(selectedCustomer){\r
378                         window.location.href = COMPONENT.SUBDETAILS_SELECTEDSUBSCRIBER + selectedCustomer;\r
379                 };\r
380         }\r
381 ]);\r