029860f8357ea3a4534585703d1a05151f436bc7
[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                 PropertyService.setServerResponseTimeoutMsec(30000);\r
68 \r
69                         // These two properties only added for testing  \r
70                         properties.msoDefaultBaseUrl = $scope.baseUrl;\r
71                         properties.responseTimeoutMsec = $scope.responseTimeoutMsec;\r
72 \r
73                         UtilityService.setProperties(properties);\r
74                 }\r
75                 \r
76                 $scope.autoGetSubs = function() {\r
77                         /*\r
78                          * Optionally comment in / out one of these method calls (or add a similar\r
79                          * entry) to auto-invoke an entry when the test screen is redrawn.\r
80                          */\r
81                         $timeout(function() {\r
82                                 $scope.getSubscribers();\r
83                                 // $scope.deleteServiceInstance();\r
84                                 // $scope.generateInvalidUrl405();                      \r
85                         }, 100);\r
86                 }\r
87                 \r
88                 $scope.autoGetSubDetails = function() {\r
89                         /*\r
90                          * Optionally comment in / out one of these method calls (or add a similar\r
91                          * entry) to auto-invoke an entry when the test screen is redrawn.\r
92                          */\r
93                         $timeout(function() {\r
94                                 $scope.getSubDetails();\r
95                                 // $scope.deleteServiceInstance();\r
96                                 // $scope.generateInvalidUrl405();                      \r
97                         }, 100);\r
98                 }\r
99                 \r
100                 $scope.autoPopulateViewEdit = function() {\r
101                         /*\r
102                          * Optionally comment in / out one of these method calls (or add a similar\r
103                          * entry) to auto-invoke an entry when the test screen is redrawn.\r
104                          */\r
105                         $timeout(function() {\r
106                         $scope.getComponentList();\r
107                                 // $scope.deleteServiceInstance();\r
108                                 // $scope.generateInvalidUrl405();                      \r
109                         }, 100);\r
110                 }\r
111                 \r
112                 $scope.refreshSubs = function() {\r
113                         /*\r
114                          * Optionally comment in / out one of these method calls (or add a similar\r
115                          * entry) to auto-invoke an entry when the test screen is redrawn.\r
116                          */\r
117                         $timeout(function() {\r
118                                 $scope.refreshSubscribers();\r
119                                 // $scope.deleteServiceInstance();\r
120                                 // $scope.generateInvalidUrl405();                      \r
121                         }, 100);\r
122                 }\r
123                 \r
124                 $scope.autoStartQueryTest = function() {\r
125                         /*\r
126                          * Optionally comment in / out one of these method calls (or add a similar\r
127                          * entry) to auto-invoke an entry when the test screen is redrawn.\r
128                          */\r
129                         $timeout(function() {\r
130                                 // $scope.queryServiceInstance();\r
131                         }, 100);\r
132                 }\r
133                 \r
134                 $scope.queryServiceInstance = function() {\r
135                         /*\r
136                          * Example of method call needed to query a service instance.\r
137                          */\r
138                         $scope.$broadcast(COMPONENT.QUERY_SERVICE_INSTANCE, {\r
139                                 serviceInstanceId: COMPONENT.SERVICE_INSTANCE_ID_1\r
140                         });\r
141                 }\r
142         \r
143                 $scope.getSubscribers = function() {\r
144                         /*\r
145                          * Example of method call needed to commit an instance creation request.\r
146                          */\r
147                         $scope.$broadcast(COMPONENT.GET_SUBS, {\r
148                                 url : FIELD.ID.AAI_GET_SUBSCRIBERS,\r
149                                 requestDetails : createServiceRequestDetails\r
150                         });\r
151                 }\r
152                 \r
153                 $scope.getSubDetails = function() {\r
154                         /*\r
155                          * Example of method call needed to commit an instance creation request.\r
156                          */\r
157                         $scope.$broadcast(COMPONENT.GET_SUB_DETAILS, {\r
158                                 url : FIELD.ID.AAI_SUB_DETAILS,\r
159                                 requestDetails : createServiceRequestDetails\r
160                         });\r
161                 }\r
162                 \r
163                 $scope.getComponentList = function() {\r
164                         /*\r
165                          * Example of method call needed to commit an instance creation request.\r
166                          */\r
167                         $scope.$broadcast(COMPONENT.GET_COMPONENT_LIST, {\r
168                                 url : FIELD.ID.AAI_SUB_VIEWEDIT,\r
169                                 requestDetails : createServiceRequestDetails\r
170                         });\r
171                 }\r
172                 \r
173                 \r
174                 $scope.refreshSubscribers = function() {\r
175                         /*\r
176                          * Example of method call needed to commit an instance creation request.\r
177                          */\r
178                         $scope.$broadcast(COMPONENT.GET_SUBS, {\r
179                                 url : FIELD.ID.AAI_REFRESH_SUBSCRIBERS,\r
180                                 requestDetails : createServiceRequestDetails\r
181                         });\r
182                 }\r
183         \r
184                 $scope.deleteServiceInstance = function() {\r
185                         /*\r
186                          * Example of method call needed to commit an instance deletion request.\r
187                          */\r
188                         $scope.$broadcast(COMPONENT.MSO_DELETE_REQ,     {\r
189                                 url : COMPONENT.MSO_DELETE_SVC_INSTANCE_PATH + COMPONENT.SERVICE_INSTANCE_ID_1,\r
190                                 requestDetails : deleteServiceRequestDetails\r
191                         });\r
192                 }\r
193         \r
194                 $scope.createNetworkInstance = function() {\r
195                         $scope.$broadcast(COMPONENT.MSO_CREATE_REQ, {\r
196                                 url : COMPONENT.MSO_CREATE_NW_INSTANCE,\r
197                                 requestDetails : createNetworkRequestDetails\r
198                         });\r
199                 }\r
200         \r
201                 $scope.deleteNetworkInstance = function() {\r
202                         $scope.$broadcast(COMPONENT.MSO_DELETE_REQ,     {\r
203                                 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
204                                 requestDetails : deleteNetworkRequestDetails\r
205                         });\r
206                 }\r
207         \r
208                 $scope.generateError = function(testName) {\r
209                         // Clone example request object\r
210                         var request = JSON.parse(JSON.stringify(createServiceRequestDetails));\r
211                         request.modelInfo.modelName = testName;\r
212                         $scope.$broadcast(COMPONENT.MSO_CREATE_REQ, {\r
213                                 url : COMPONENT.MSO_CREATE_SVC_INSTANCE,\r
214                                 requestDetails : request\r
215                         });\r
216                 }\r
217         \r
218                 $scope.generateInvalidUrl404 = function() {\r
219                         var properties = UtilityService.getProperties(properties);\r
220                         properties.msoDefaultBaseUrl = COMPONENT.INVALID_STRING;\r
221                         UtilityService.setProperties(properties);\r
222                         $scope.$broadcast(COMPONENT.REFRESH_PROPERTIES);\r
223                 \r
224                         $scope.$broadcast(COMPONENT.MSO_CREATE_REQ, {\r
225                                 url : COMPONENT.MSO_CREATE_SVC_INSTANCE,\r
226                                 requestDetails : createServiceRequestDetails\r
227                         });\r
228 \r
229                         properties.msoDefaultBaseUrl = $scope.baseUrl;\r
230                         UtilityService.setProperties(properties);\r
231                         $scope.$broadcast(COMPONENT.REFRESH_PROPERTIES);                                \r
232                 }\r
233         \r
234                 $scope.generateInvalidUrl405 = function() {\r
235                         $scope.$broadcast(COMPONENT.MSO_CREATE_REQ, {\r
236                                 url : COMPONENT.INVALID_STRING_MSO_CREATE_SVC_INSTANCE,\r
237                                 requestDetails : createServiceRequestDetails\r
238                         });\r
239                 }\r
240         \r
241                 /*\r
242                  * Test data objects:\r
243                  */\r
244         \r
245                 var subscriberInfo = {\r
246                         globalSubscriberId : COMPONENT.GLOBAL_SUBSCRIBER_ID_1,\r
247                         subscriberName : COMPONENT.SUBSCRIBER_NAME_GED12\r
248                 };\r
249         \r
250                 var createServiceRequestDetails = {\r
251                         modelInfo : {\r
252                                 modelType : COMPONENT.SERVICE,\r
253                                 modelId : COMPONENT.MODEL_ID_1,\r
254                                 modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_1,\r
255                                 modelName : COMPONENT.MODEL_NAME_WANBONDING,\r
256                                 modelVersion : COMPONENT.MODEL_VERSION_1\r
257                         },\r
258                         subscriberInfo : subscriberInfo,\r
259                         requestParameters : {\r
260                                 vpnId : COMPONENT.VPN_ID_1,\r
261                                 productName : COMPONENT.PRODUCT_NAME_TRINITY,\r
262                                 customerId : COMPONENT.CUSTOMER_ID_1\r
263                         }\r
264                 };\r
265         \r
266                 var deleteServiceRequestDetails = {\r
267                         modelInfo : {\r
268                                 modelType : COMPONENT.SERVICE,\r
269                                 modelId : COMPONENT.MODEL_ID_1,\r
270                                 modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_1,\r
271                                 modelName : COMPONENT.MODEL_NAME_WANBONDING,\r
272                                 modelVersion : COMPONENT.MODEL_VERSION_1\r
273                         }\r
274                 };\r
275         \r
276                 var createNetworkRequestDetails = {\r
277                         modelInfo : {\r
278                                 modelType : COMPONENT.NETWORK,\r
279                                 modelId : COMPONENT.MODEL_ID_2,\r
280                                 modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_2,\r
281                                 modelName : COMPONENT.MODEL_NAME_VISBCOAMNETWORK,\r
282                                 modelVersion : COMPONENT.MODEL_VERSION_1\r
283                         },\r
284                         relatedModelList : [\r
285                                         {\r
286                                                 relatedModel : {\r
287                                                         instanceId : COMPONENT.INSTANCE_ID_1,\r
288                                                         modelInfo : {\r
289                                                                 modelType : COMPONENT.SERVICE,\r
290                                                                 modelId : COMPONENT.MODEL_ID_3,\r
291                                                                 modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_3,\r
292                                                                 modelName : COMPONENT.MODEL_NAME_IISBC,\r
293                                                                 modelVersion : COMPONENT.MODEL_VERSION_1\r
294                                                         }\r
295                                                 }\r
296                                         },\r
297                                         {\r
298                                                 relatedModel : {\r
299                                                         instanceId : COMPONENT.INSTANCE_ID_2,\r
300                                                         modelInfo : {\r
301                                                                 modelType : COMPONENT.VNF,\r
302                                                                 modelId : COMPONENT.MODEL_ID_4,\r
303                                                                 modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_4,\r
304                                                                 modelName : COMPONENT.MODEL_NAME_VISBC,\r
305                                                                 modelVersion : COMPONENT.MODEL_VERSION_1\r
306                                                         }\r
307                                                 }\r
308                                         },\r
309                                         {\r
310                                                 relatedModel : {\r
311                                                         instanceId : COMPONENT.INSTANCE_ID_3,\r
312                                                         modelInfo : {\r
313                                                                 modelType : COMPONENT.VF_MODULE,\r
314                                                                 modelId : COMPONENT.MODEL_ID_5,\r
315                                                                 modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_5,\r
316                                                                 modelName : COMPONENT.MODEL_NAME_VISBCRTPEXPANSIONMODULE,\r
317                                                                 modelVersion : COMPONENT.MODEL_VERSION_1\r
318                                                         }\r
319                                                 }\r
320                                         } ],\r
321                         subscriberInfo : subscriberInfo,\r
322                         requestParameters : {\r
323                                 /*\r
324                                  * FYI: quotes around field names are needed due to embedded "-"\r
325                                  * characters\r
326                                  */\r
327                                 "cidr-mask" : COMPONENT.CIDR_MASK_1,\r
328                                 "gateway-address" : COMPONENT.GATEWAY_ADDRESS_1,\r
329                                 "dhcp-enabled" : COMPONENT.TRUE\r
330                         }\r
331                 };\r
332         \r
333                 var deleteNetworkRequestDetails = {\r
334                         modelInfo : {\r
335                                 modelType : COMPONENT.NETWORK,\r
336                                 modelId : COMPONENT.MODEL_ID_2,\r
337                                 modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_2,\r
338                                 modelName : COMPONENT.MODEL_NAME_VISBCOAMNETWORK,\r
339                                 modelVersion : COMPONENT.MODEL_VERSION_1\r
340                         },\r
341                         relatedModelList : [\r
342                                         {\r
343                                                 relatedModel : {\r
344                                                         instanceId : COMPONENT.INSTANCE_ID_1,\r
345                                                         modelInfo : {\r
346                                                                 modelType : COMPONENT.SERVICE,\r
347                                                                 modelId : COMPONENT.MODEL_ID_3,\r
348                                                                 modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_3,\r
349                                                                 modelName : COMPONENT.MODEL_NAME_IISBC,\r
350                                                                 modelVersion : COMPONENT.MODEL_VERSION_1\r
351                                                         }\r
352                                                 }\r
353                                         },\r
354                                         {\r
355                                                 relatedModel : {\r
356                                                         instanceId : COMPONENT.INSTANCE_ID_2,\r
357                                                         modelInfo : {\r
358                                                                 modelType : COMPONENT.VNF,\r
359                                                                 modelId : COMPONENT.MODEL_ID_4,\r
360                                                                 modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_4,\r
361                                                                 modelName : COMPONENT.MODEL_NAME_VISBC,\r
362                                                                 modelVersion : COMPONENT.MODEL_VERSION_1\r
363                                                         }\r
364                                                 }\r
365                                         },\r
366                                         {\r
367                                                 relatedModel : {\r
368                                                         instanceId : COMPONENT.INSTANCE_ID_3,\r
369                                                         modelInfo : {\r
370                                                                 modelType : COMPONENT.VF_MODULE,\r
371                                                                 modelId : COMPONENT.MODEL_ID_5,\r
372                                                                 modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_5,\r
373                                                                 modelName : COMPONENT.MODEL_NAME_VISBCRTPEXPANSIONMODULE,\r
374                                                                 modelVersion : COMPONENT.MODEL_VERSION_1\r
375                                                         }\r
376                                                 }\r
377                                         } ]\r
378                 };\r
379                 $scope.getSubscriberDet = function(selectedCustomer){\r
380                         window.location.href = COMPONENT.SUBDETAILS_SELECTEDSUBSCRIBER + selectedCustomer;\r
381                 };\r
382         }\r
383 ]);\r