2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 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, FIELD, $scope, $uibModal, CreationService,
24 MsoService, AaiService, DeleteResumeService, DataService, $uibModalInstance, action, vfModule, featureFlags) {
29 $scope.action = action;
30 $scope.vfModuleName = vfModule.name;
31 $scope.volumeGroups = vfModule.volumeGroups;
32 $scope.lcpAndTenant = null;
33 $scope.regionSelection = {optionId: null, legacyRegion: null, tenant: null};
34 $scope.lcpRegionList = null;
35 $scope.isHomingData = false;
36 $scope.megaRegion = ['AAIAIC25'];
37 $scope.isSoftDeleteEnabled = vfModule.nodeStatus.toLowerCase() !== 'assigned' && action === COMPONENT.DELETE;
39 $scope.isResumeEnabled = action === COMPONENT.RESUME;
40 if ($scope.isResumeEnabled) {
41 $scope.action = 'Instantiate';
46 function getLcpCloudRegionTenantList() {
47 AaiService.getLcpCloudRegionTenantList(DataService
48 .getGlobalCustomerId(), DataService.getServiceType(), function(
50 DataService.setCloudRegionTenantList(response);
51 $scope.lcpAndTenant = response;
52 $scope.isFeatureFlagCloudOwner = featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST);
53 $scope.lcpRegionList = _.uniqBy(response, 'cloudRegionOptionId');
54 $scope.vendorInCloudOwnerRegex = /^[^-]*-/;
58 function initHomingData() {
59 AaiService.getHomingData(DataService.getVnfInstanceId(), DataService.getVfModuleInstanceId())
60 .then(function (res) {
61 if (res && res.data) {
62 $scope.regionSelection.optionId = (res.data.cloudRegionOptionId);
63 $scope.regionSelection.tenant = (res.data[COMPONENT.TENANT_ID]) ? res.data[COMPONENT.TENANT_ID] : null;
64 $scope.isHomingData = $scope.regionSelection.optionId !== null && $scope.regionSelection.tenant !== null;
65 $scope.isHomingData = $scope.isHomingData && (($scope.megaRegion).indexOf(res.data[COMPONENT.CLOUD_REGION_ID]) === -1);
68 getLcpCloudRegionTenantList();
70 .catch(function (error) {
71 getLcpCloudRegionTenantList();
75 function getLcpRegionId() {
76 if(_.isEmpty($scope.regionSelection.legacyRegion)) {
77 return DataService.getCloudOwnerAndLcpCloudRegionFromOptionId($scope.regionSelection.optionId).cloudRegionId;
79 return $scope.regionSelection.legacyRegion;
82 $scope.deleteOrResume = function() {
84 var msoParameterList = [({id: "lcpRegion", value: $scope.regionSelection.optionId})];
85 msoParameterList.push({id: FIELD.ID.LCP_REGION_TEXT, value: $scope.regionSelection.legacyRegion});
86 msoParameterList.push({id: "tenant", value: $scope.regionSelection.tenant});
88 var requestParams = {};
91 if ($scope.isResumeEnabled) {
92 CreationService.initializeComponent(COMPONENT.VF_MODULE);
93 CreationService.setInventoryInfo();
95 var availableVolumeGroupList = $scope.volumeGroups;
97 if (availableVolumeGroupList && availableVolumeGroupList.length > 0) {
98 var volumeGroupList = FIELD.PARAMETER.AVAILABLE_VOLUME_GROUP;
99 volumeGroupList.value = _.map(availableVolumeGroupList, function (volumeGroup) {
100 return volumeGroup.name;
102 msoParameterList.push(volumeGroupList);
105 requestDetails = CreationService.getMsoRequestDetails(msoParameterList);
106 requestParams.url = CreationService.getMsoUrl();
107 msoType = COMPONENT.MSO_CREATE_REQ;
110 DeleteResumeService.initializeComponent(COMPONENT.VF_MODULE);
112 requestDetails = DeleteResumeService.getMsoRequestDetails(msoParameterList);
113 if(DeleteResumeService.isMacro === true) {
114 requestDetails.requestParameters.aLaCarte = false;
116 requestParams.url = DeleteResumeService.getMsoUrl();
117 msoType = COMPONENT.MSO_DELETE_REQ;
120 requestParams.requestDetails = requestDetails;
121 requestParams.userId = DataService.getLoggedInUserId();
122 $uibModalInstance.close({requestParams: requestParams, msoType: msoType});
125 $scope.softDelete = function() {
127 var requestParams = {
128 tenantId: $scope.regionSelection.tenant,
129 lcpCloudRegionId: getLcpRegionId(),
130 serviceInstanceId: DataService.getServiceInstanceId(),
131 vnfInstanceId: DataService.getVnfInstanceId(),
132 vfModuleInstanceId: DataService.getVfModuleInstanceId()
135 requestParams.userId = DataService.getLoggedInUserId();
136 $uibModalInstance.close({requestParams : requestParams, msoType: COMPONENT.MSO_DEACTIVATE_AND_CLOUD_DELETE});
139 $scope.removeVendorFromCloudOwner = function(cloudOwner) {
140 return AaiService.removeVendorFromCloudOwner(cloudOwner)
143 $scope.selectedLcpRegionIsMegaRegion = function() {
144 if ($scope.regionSelection.optionId) {
145 let cloudRegionId = DataService.getCloudOwnerAndLcpCloudRegionFromOptionId($scope.regionSelection.optionId).cloudRegionId;
146 return ($scope.megaRegion).indexOf(cloudRegionId) > -1
152 $scope.cancel = function() {
153 $uibModalInstance.dismiss('cancel');
158 appDS2.controller("vfModuleActionModalController", [ "COMPONENT", "FIELD", "$scope", "$uibModal", "CreationService",
159 "MsoService", "AaiService", "DeleteResumeService", "DataService", "$uibModalInstance", "action", "vfModule", "featureFlags",
160 vfModuleActionModalController ]);