[VID-3] Setting docker image tag
[vid.git] / vid / src / main / webapp / app / vid / test / testViewEdit.js
1 "use strict";
2
3 app.config(function($logProvider) {
4     // Optionally set to "false" to disable debug logging.
5     $logProvider.debugEnabled(true);
6 });
7
8 var testViewEditController = function(COMPONENT, DataService, PropertyService,
9         UtilityService, $scope, $timeout, $cookieStore, $log) {
10
11     $scope.popup = new Object();
12     $scope.isTestMode = false;
13
14     $scope.init = function(properties) {
15
16         /*
17          * These 2 statements should be included in non-test code.
18          */
19         PropertyService
20                 .setMsoMaxPollingIntervalMsec(properties.msoMaxPollingIntervalMsec);
21         PropertyService.setMsoMaxPolls(properties.msoMaxPolls);
22
23         /*
24          * Common parameters that shows an example of how the view edit screen
25          * is expected to pass some common service instance values to the
26          * popups.
27          */
28
29         DataService.setSubscriberName("Mobility");
30         DataService.setGlobalCustomerId("CUSTID12345")
31         DataService.setServiceType("Mobility Type 1");
32         DataService.setServiceInstanceName("Example Service Instance Name");
33         DataService.setServiceName("Mobility Service 1");
34         DataService.setServiceInstanceId("mmsc-test-service-instance");
35         DataService.setServiceUuid("XXXX-YYYY-ZZZZ");
36         DataService.setUserServiceInstanceName("USER_SERVICE_INSTANCE_NAME");
37
38         /*
39          * "setTestMode" is only used for testing.
40          */
41
42         setTestMode();
43
44     }
45
46     $scope.autoStartTest = function() {
47         /*
48          * Optionally comment in / out one of these method calls (or add a
49          * similar entry) to auto-invoke an entry as soon as the page is
50          * refreshed.
51          */
52         $timeout(function() {
53             // $scope.showServiceDetails();
54             // $scope.showVnfDetails();
55             // $scope.createService();
56             // $scope.deleteService();
57             // $scope.createNetwork();
58             // $scope.createVnf();
59             // $scope.createVfModule();
60             // $scope.deleteVnf();
61             // $scope.createVfModule();
62         }, 500);
63     }
64
65     /*
66      * This block of code is only used for testing.
67      */
68
69     /*
70      * The first 3 functions override default values set in the server
71      * properties file.
72      * 
73      * 1) The URL for the MSO controller is set to either the "real" controller
74      * or the test version depending on the "Use test MSO controller" checkbox.
75      * 
76      * 2) SDC and AAI are set to use test controller versions.
77      * 
78      * 3) Maximum polling and timeout values are set to lower values to lessen
79      * the time required to run tests.
80      * 
81      */
82
83     var TEST_MODE_COOKIE = "isTestModeEnabled";
84
85     var defaultMsoBaseUrl = PropertyService.getMsoBaseUrl();
86
87     var setTestMode = function() {
88         setTestMsoMode($cookieStore.get(TEST_MODE_COOKIE));
89         PropertyService.setAaiBaseUrl("testaai");
90         PropertyService.setAsdcBaseUrl("testasdc");
91         PropertyService.setMsoMaxPollingIntervalMsec(1000);
92         PropertyService.setMsoMaxPolls(7);
93         PropertyService.setServerResponseTimeoutMsec(10000);
94     };
95
96     $scope.testMsoModeChanged = function() {
97         setTestMsoMode($scope.isTestMsoMode);
98     };
99
100     var setTestMsoMode = function(isEnabled) {
101         $scope.isTestMsoMode = isEnabled;
102         $cookieStore.put(TEST_MODE_COOKIE, isEnabled);
103         if (isEnabled) {
104             PropertyService.setMsoBaseUrl("testmso");
105         } else {
106             PropertyService.setMsoBaseUrl(defaultMsoBaseUrl);
107         }
108     };
109
110     var callbackFunction = function(response) {
111         $scope.callbackResults = "";
112         var color = "none";
113         $scope.callbackStyle = {
114             "background-color" : color
115         };
116         /*
117          * This 1/2 delay was only added to visually highlight the status
118          * change. Probably not needed in the real application code.
119          */
120         $timeout(function() {
121             $scope.callbackResults = UtilityService.getCurrentTime()
122                     + " isSuccessful: " + response.isSuccessful;
123             if (response.isSuccessful) {
124                 color = "#8F8";
125             } else {
126                 color = "#F88";
127             }
128             $scope.callbackStyle = {
129                 "background-color" : color
130             };
131         }, 500);
132     };
133
134     /*
135      * End of block of test-specific code
136      */
137
138     /*
139      * Create functions
140      */
141     $scope.createService = function() {
142
143         DataService.setModelId("91238134091820938018230918230989");
144
145         $scope.$broadcast("createComponent", {
146             componentId : COMPONENT.SERVICE,
147             callbackFunction : callbackFunction
148         });
149     }
150
151     $scope.createVnf = function() {
152
153         DataService.setModelId("91238134091820938018230918230989");
154         DataService.setModelInstanceName("VNF_MODEL_INSTANCE_NAME");
155
156         DataService.setCloudRegionTenantList(exampleCloudRegionTenantList)
157         DataService.setServiceIdList(exampleServiceIdList);
158
159         // Data used to create MSO "relatedInstanceList" object
160
161         DataService.setModelInfo(COMPONENT.SERVICE, exampleServiceModelInfo);
162
163         $scope.$broadcast("createComponent", {
164             componentId : COMPONENT.VNF,
165             callbackFunction : callbackFunction
166         });
167     }
168
169     $scope.createVfModule = function() {
170         DataService
171                 .setInventoryItem(exampleAaiResult["inventory-response-items"][0]);
172
173         DataService.setModelId("91238134091820938018230918230989");
174         DataService.setModelInstanceName("VF_MODULE_MODEL_INSTANCE_NAME");
175
176         DataService.setLcpRegion("Region2");
177         DataService.setTenant("Tenant2");
178         // Data used to create MSO "relatedInstanceList" object
179
180         DataService.setModelInfo(COMPONENT.SERVICE, exampleServiceModelInfo);
181
182         DataService.setVnfInstanceId("VNF_INSTANCE_ID_12345");
183         DataService.setModelInfo(COMPONENT.VNF, exampleVnfModelInfo);
184
185         DataService.setVolumeGroupInstanceId("VOLUME_GROUP_INSTANCE_ID_12345");
186         DataService
187                 .setAvailableVolumeGroupList(exampleAvailableVolumeGroupList);
188         DataService.setModelInfo(COMPONENT.VOLUME_GROUP,
189                 exampleVolumeGroupModelInfo);
190
191         $scope.$broadcast("createComponent", {
192             componentId : COMPONENT.VF_MODULE,
193             callbackFunction : callbackFunction
194         });
195     }
196
197     $scope.createVolumeGroup = function() {
198
199         DataService.setModelId("91238134091820938018230918230989");
200         DataService.setModelInstanceName("VOLUME_GROUP_MODEL_INSTANCE_NAME");
201         DataService.setLcpRegion("Region1");
202         DataService.setTenant("Tenant1");
203         // Data used to create MSO "relatedInstanceList" object
204
205         DataService.setModelInfo(COMPONENT.SERVICE, exampleServiceModelInfo);
206
207         DataService.setVnfInstanceId("VNF_INSTANCE_ID_12345");
208         DataService.setModelInfo(COMPONENT.VNF, exampleVnfModelInfo);
209
210         $scope.$broadcast("createComponent", {
211             componentId : COMPONENT.VOLUME_GROUP,
212             callbackFunction : callbackFunction
213         });
214     }
215
216     $scope.createNetwork = function() {
217
218         DataService.setModelId("91238134091820938018230918230989");
219         DataService.setModelInstanceName("NETWORK_MODEL_INSTANCE_NAME");
220
221         DataService.setCloudRegionTenantList(exampleCloudRegionTenantList)
222         DataService.setServiceIdList(exampleServiceIdList);
223
224         // Data used to create MSO "relatedInstanceList" object
225
226         DataService.setModelInfo(COMPONENT.SERVICE, exampleServiceModelInfo);
227
228         $scope.$broadcast("createComponent", {
229             componentId : COMPONENT.NETWORK,
230             callbackFunction : callbackFunction
231         });
232     }
233
234     /*
235      * Delete functions
236      */
237     $scope.deleteService = function() {
238
239         DataService.setInventoryItem(exampleServiceItem);
240
241         DataService.setModelInfo(COMPONENT.SERVICE, exampleServiceModelInfo);
242
243         $scope.$broadcast("deleteComponent", {
244             componentId : COMPONENT.SERVICE,
245             callbackFunction : callbackFunction
246         });
247     }
248
249     $scope.deleteVnf = function() {
250
251         DataService
252                 .setInventoryItem(exampleAaiResult["inventory-response-items"]["inventory-response-item"][0]);
253
254         DataService.setVnfInstanceId("VNF_INSTANCE_ID_12345");
255         DataService.setModelInfo(COMPONENT.VNF, exampleVnfModelInfo);
256         DataService.setLcpRegion("Region3");
257         DataService.setTenant("Tenant3");
258
259         $scope.$broadcast("deleteComponent", {
260             componentId : COMPONENT.VNF,
261             callbackFunction : callbackFunction
262         });
263     }
264
265     $scope.deleteVfModule = function() {
266
267         DataService.setInventoryItem(exampleVfModuleItem);
268
269         DataService.setVnfInstanceId("VNF_INSTANCE_ID_12345");
270
271         DataService.setVfModuleInstanceId("VF_MODULE_INSTANCE_ID_12345");
272         DataService.setModelInfo(COMPONENT.VF_MODULE, exampleVfModuleModelInfo);
273         DataService.setLcpRegion("Region4");
274         DataService.setTenant("Tenant4");
275
276         $scope.$broadcast("deleteComponent", {
277             componentId : COMPONENT.VF_MODULE,
278             callbackFunction : callbackFunction
279         });
280     }
281
282     $scope.deleteVolumeGroup = function() {
283
284         DataService.setInventoryItem(exampleVolumeGroupItem);
285
286         DataService.setVolumeGroupInstanceId("VOLUME_GROUP_INSTANCE_ID_12345");
287         DataService.setModelInfo(COMPONENT.VOLUME_GROUP,
288                 exampleVolumeGroupModelInfo);
289         DataService.setLcpRegion("Region3");
290         DataService.setTenant("Tenant3");
291
292
293         $scope.$broadcast("deleteComponent", {
294             componentId : COMPONENT.VOLUME_GROUP,
295             callbackFunction : callbackFunction
296         });
297     }
298
299     $scope.deleteNetwork = function() {
300
301         DataService.setInventoryItem(exampleNetworkItem);
302
303         DataService.setNetworkInstanceId("NETWORK_INSTANCE_ID_12345");
304         DataService.setModelInfo(COMPONENT.NETWORK, exampleNetworkModelInfo);
305         DataService.setLcpRegion("Region5");
306         DataService.setTenant("Tenant5");
307
308         $scope.$broadcast("deleteComponent", {
309             componentId : COMPONENT.NETWORK,
310             callbackFunction : callbackFunction
311         });
312     }
313
314     /*
315      * Show Details functions
316      */
317     $scope.showServiceDetails = function() {
318
319         DataService.setInventoryItem(exampleServiceItem);
320
321         $scope.$broadcast("showComponentDetails", {
322             componentId : COMPONENT.SERVICE,
323             callbackFunction : callbackFunction
324         });
325     }
326
327     $scope.showVnfDetails = function() {
328
329         DataService.setVnfInstanceId("VNF_INSTANCE_ID_12345");
330         DataService
331                 .setInventoryItem(exampleAaiResult["inventory-response-items"]["inventory-response-item"][0]);
332
333         $scope.$broadcast("showComponentDetails", {
334             componentId : COMPONENT.VNF,
335             callbackFunction : callbackFunction
336         });
337     }
338
339     $scope.showVfModuleDetails = function() {
340
341         DataService.setVnfInstanceId("VNF_INSTANCE_ID_12345");
342         DataService.setVfModuleInstanceId("VF_MODULE_INSTANCE_ID_12345");
343         DataService.setInventoryItem(exampleVfModuleItem);
344
345         $scope.$broadcast("showComponentDetails", {
346             componentId : COMPONENT.VF_MODULE,
347             callbackFunction : callbackFunction
348         });
349     }
350
351     $scope.showVolumeGroupDetails = function() {
352
353         DataService.setVolumeGroupInstanceId("VOLUME_GROUP_INSTANCE_ID_12345");
354         DataService.setInventoryItem(exampleVolumeGroupItem);
355
356         $scope.$broadcast("showComponentDetails", {
357             componentId : COMPONENT.VOLUME_GROUP,
358             callbackFunction : callbackFunction
359         });
360     }
361
362     $scope.showNetworkDetails = function() {
363
364         DataService.setNetworkInstanceId("NETWORK_INSTANCE_ID_12345");
365         DataService.setInventoryItem(exampleNetworkItem);
366
367         $scope.$broadcast("showComponentDetails", {
368             componentId : COMPONENT.NETWORK,
369             callbackFunction : callbackFunction
370         });
371     }
372 }
373
374 app.controller("testViewEditController", [ "COMPONENT", "DataService",
375         "PropertyService", "UtilityService", "$scope", "$timeout",
376         "$cookieStore", "$log", testViewEditController ]);