[VID-6] Initial rebase push
[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(10000);\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                 $scope.getSubscriberDet = function(selectedCustomer){\r
243                         window.location.href = COMPONENT.SUBDETAILS_SELECTEDSUBSCRIBER + selectedCustomer;\r
244                 };\r
245         }\r
246 ]);\r