org.onap migration
[vid.git] / vid-app-common / src / main / webapp / app / vid / scripts / controller / AddNetworkNodeController.js
1 /*-
2 * ============LICENSE_START=======================================================
3 * VID
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 *      http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
19 */
20
21 /**
22  * The Instantiation (or View/Edit) Controller controls the instantiation/removal of
23  * deployable objects (Services, VNFs, VF-Modules, Networks, and Volume-Groups)
24  */
25
26 "use strict";
27
28 appDS2.controller("AddNetworkNodeController", ["COMPONENT", "FIELD", "PARAMETER", "DataService", "CreationService", "$scope", "$window", "$location",
29     function (COMPONENT, FIELD, PARAMETER, DataService, CreationService, $scope, $window, $location) {
30
31         $scope.serviceMetadataFields = [];
32         $scope.tenantList = [];
33         $scope.nodeTemplateFields = {};
34         
35         $scope.regexInstanceName = /^([a-z])+([0-9a-z\-_\.]*)$/i;
36         $scope.errorMsg = FIELD.ERROR.INSTANCE_NAME_VALIDATE;
37
38         var handleGetParametersResponse = function(parameters) {
39             $scope.serviceMetadataFields = parameters.summaryList;
40             $scope.tenantList = DataService.getCloudRegionTenantList();
41
42         if(DataService.getPortMirroningConfigFields()){
43             $scope.nodeTemplateFields =DataService.getPortMirroningConfigFields();
44         }else {
45             $scope.nodeTemplateFields = angular.copy(_.keyBy(parameters.userProvidedList, 'id'));
46         }
47
48            $scope.modelName = DataService.getModelInfo(COMPONENT.VNF).modelCustomizationName;
49         };
50
51         CreationService.initializeComponent(COMPONENT.VNF);
52
53         CreationService.getParameters(handleGetParametersResponse);
54
55         $scope.setTenant = function(field)  {
56             $scope.nodeTemplateFields.tenant.optionList = _.filter($scope.tenantList, {'cloudRegionId': field.value, 'isPermitted': true});
57         };
58
59         $scope.cancel = function()  {
60             $window.history.back();
61         };
62
63         $scope.next = function()  {
64             // DataService.setLcpRegion($scope.nodeTemplateFields.lcpRegion.value);
65             // DataService.setModelInstanceName($scope.nodeTemplateFields.instanceName.value);
66             // DataService.setTenant($scope.nodeTemplateFields.tenant.value);
67             // var suppressRollback = ($scope.nodeTemplateFields.suppressRollback.value) ? true : false;
68             // DataService.setSuppressRollback(suppressRollback);
69             DataService.setPortMirroningConfigFields($scope.nodeTemplateFields);
70             $location.path("/serviceProxyConfig");
71         };
72
73         $scope.$on('$routeChangeStart', function (event, next, current) {
74             if(next.$$route.originalPath !=="/serviceProxyConfig"){
75                 DataService.setPortMirroningConfigFields(null);
76             }
77         });
78     }]);