2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
23 var vfModuleActionModalController = function(COMPONENT, $scope, $uibModal, CreationService,
24 MsoService, AaiService, DeleteResumeService, DataService, $uibModalInstance, action, vfModule, featureFlags) {
29 $scope.action = action;
30 $scope.vfModuleName = vfModule.name;
31 $scope.lcpAndTenant = null;
32 $scope.regionSelection = {lcpRegion: null, legacyRegion: null, tenant: null};
33 $scope.lcpRegionList = null;
34 $scope.isHomingData = false;
35 $scope.megaRegion = ['AAIAIC25', 'rdm3', 'rdm5a'];
36 $scope.isSoftDeleteEnabled = vfModule.nodeStatus.toLowerCase() !== 'assigned' && action === COMPONENT.DELETE;
38 $scope.isResumeEnabled = action === COMPONENT.RESUME;
39 if ($scope.isResumeEnabled) {
40 $scope.action = 'Instantiate';
45 function getLcpCloudRegionTenantList() {
46 AaiService.getLcpCloudRegionTenantList(DataService
47 .getGlobalCustomerId(), DataService.getServiceType(), function(
49 $scope.lcpAndTenant = response;
50 $scope.isFeatureFlagCloudOwner = featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST);
51 $scope.lcpRegionList = _.uniqBy(response, 'cloudRegionId');
55 function initHomingData() {
56 AaiService.getHomingData(DataService.getVnfInstanceId(), DataService.getVfModuleInstanceId())
57 .then(function (res) {
58 if (res && res.data) {
59 $scope.regionSelection = {
60 lcpRegion: (res.data[COMPONENT.CLOUD_REGION_ID]) ? res.data[COMPONENT.CLOUD_REGION_ID] : null,
62 tenant: (res.data[COMPONENT.TENANT_ID]) ? res.data[COMPONENT.TENANT_ID] : null
64 $scope.isHomingData = $scope.regionSelection.lcpRegion !== null && res.data.tenant !== null;
65 $scope.isHomingData = $scope.isHomingData && (($scope.megaRegion).indexOf($scope.regionSelection.lcpRegion) === -1);
68 if (!$scope.isHomingData) {
69 getLcpCloudRegionTenantList();
72 .catch(function (error) {
73 getLcpCloudRegionTenantList();
77 function getLcpRegionId() {
78 if(_.isEmpty($scope.regionSelection.legacyRegion)) {
79 return $scope.regionSelection.lcpRegion
81 return $scope.regionSelection.legacyRegion;
84 $scope.deleteOrResume = function() {
86 var regionSelectionList = [({id: "lcpRegion", value: getLcpRegionId()})];
87 regionSelectionList.push({id: "tenant", value: $scope.regionSelection.tenant});
89 var requestParams = {};
92 if ($scope.isResumeEnabled) {
93 CreationService.initializeComponent(COMPONENT.VF_MODULE);
94 CreationService.setInventoryInfo();
96 requestDetails = CreationService.getMsoRequestDetails(regionSelectionList);
97 requestParams.url = CreationService.getMsoUrl();
98 msoType = COMPONENT.MSO_CREATE_REQ;
101 DeleteResumeService.initializeComponent(COMPONENT.VF_MODULE);
103 requestDetails = DeleteResumeService.getMsoRequestDetails(regionSelectionList);
104 if(DeleteResumeService.isMacro === true) {
105 requestDetails.requestParameters.aLaCarte = false;
107 requestParams.url = DeleteResumeService.getMsoUrl();
108 msoType = COMPONENT.MSO_DELETE_REQ;
111 requestParams.requestDetails = requestDetails;
112 requestParams.userId = DataService.getLoggedInUserId();
113 $uibModalInstance.close({requestParams: requestParams, msoType: msoType});
116 $scope.softDelete = function() {
118 var requestParams = {
119 tenantId: $scope.regionSelection.tenant,
120 lcpCloudRegionId: getLcpRegionId(),
121 serviceInstanceId: DataService.getServiceInstanceId(),
122 vnfInstanceId: DataService.getVnfInstanceId(),
123 vfModuleInstanceId: DataService.getVfModuleInstanceId()
126 requestParams.userId = DataService.getLoggedInUserId();
127 $uibModalInstance.close({requestParams : requestParams, msoType: COMPONENT.MSO_DEACTIVATE_AND_CLOUD_DELETE});
130 $scope.cancel = function() {
131 $uibModalInstance.dismiss('cancel');
136 appDS2.controller("vfModuleActionModalController", [ "COMPONENT", "$scope", "$uibModal", "CreationService",
137 "MsoService", "AaiService", "DeleteResumeService", "DataService", "$uibModalInstance", "action", "vfModule", "featureFlags",
138 vfModuleActionModalController ]);