From 1cfb08779ea0e00be69e072a940b3063e049fe6b Mon Sep 17 00:00:00 2001 From: Ofir Sonsino Date: Wed, 31 Jan 2018 17:19:00 +0200 Subject: org.onap migration Change-Id: I52f0b2851f2c765752b6d21f49b32136d7d72a3d Issue-ID: VID-86 Signed-off-by: Ofir Sonsino --- .../scripts/controller/AddNetworkNodeController.js | 78 ++ .../scripts/controller/InstantiationController.js | 438 ++++++---- .../scripts/controller/ServiceModelController.js | 83 +- .../controller/ServiceProxyConfigController.js | 342 ++++++++ .../webapp/app/vid/scripts/controller/VidApp.js | 29 +- .../scripts/controller/aaiSubscriberController.js | 892 +++++++++++++-------- .../controller/change-management.controller.js | 75 +- .../controller/deleteResumeDialogController.js | 148 ++++ .../scripts/controller/deletionDialogController.js | 123 --- .../vid/scripts/controller/msoCommitController.js | 46 +- .../scripts/controller/msoCommitModalController.js | 237 ++++++ .../controller/pnfSearchAssociationController.js | 138 ++++ .../controller/testEnvironmentsController.js | 102 +++ 13 files changed, 2047 insertions(+), 684 deletions(-) create mode 100644 vid-app-common/src/main/webapp/app/vid/scripts/controller/AddNetworkNodeController.js create mode 100644 vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceProxyConfigController.js create mode 100644 vid-app-common/src/main/webapp/app/vid/scripts/controller/deleteResumeDialogController.js delete mode 100755 vid-app-common/src/main/webapp/app/vid/scripts/controller/deletionDialogController.js create mode 100644 vid-app-common/src/main/webapp/app/vid/scripts/controller/msoCommitModalController.js create mode 100644 vid-app-common/src/main/webapp/app/vid/scripts/controller/pnfSearchAssociationController.js create mode 100644 vid-app-common/src/main/webapp/app/vid/scripts/controller/testEnvironmentsController.js (limited to 'vid-app-common/src/main/webapp/app/vid/scripts/controller') diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/AddNetworkNodeController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/AddNetworkNodeController.js new file mode 100644 index 00000000..458da3f7 --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/AddNetworkNodeController.js @@ -0,0 +1,78 @@ +/*- +* ============LICENSE_START======================================================= +* VID +* ================================================================================ +* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +* ================================================================================ +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* ============LICENSE_END========================================================= +*/ + +/** + * The Instantiation (or View/Edit) Controller controls the instantiation/removal of + * deployable objects (Services, VNFs, VF-Modules, Networks, and Volume-Groups) + */ + +"use strict"; + +appDS2.controller("AddNetworkNodeController", ["COMPONENT", "FIELD", "PARAMETER", "DataService", "CreationService", "$scope", "$window", "$location", + function (COMPONENT, FIELD, PARAMETER, DataService, CreationService, $scope, $window, $location) { + + $scope.serviceMetadataFields = []; + $scope.tenantList = []; + $scope.nodeTemplateFields = {}; + + $scope.regexInstanceName = /^([a-z])+([0-9a-z\-_\.]*)$/i; + $scope.errorMsg = FIELD.ERROR.INSTANCE_NAME_VALIDATE; + + var handleGetParametersResponse = function(parameters) { + $scope.serviceMetadataFields = parameters.summaryList; + $scope.tenantList = DataService.getCloudRegionTenantList(); + + if(DataService.getPortMirroningConfigFields()){ + $scope.nodeTemplateFields =DataService.getPortMirroningConfigFields(); + }else { + $scope.nodeTemplateFields = angular.copy(_.keyBy(parameters.userProvidedList, 'id')); + } + + $scope.modelName = DataService.getModelInfo(COMPONENT.VNF).modelCustomizationName; + }; + + CreationService.initializeComponent(COMPONENT.VNF); + + CreationService.getParameters(handleGetParametersResponse); + + $scope.setTenant = function(field) { + $scope.nodeTemplateFields.tenant.optionList = _.filter($scope.tenantList, {'cloudRegionId': field.value, 'isPermitted': true}); + }; + + $scope.cancel = function() { + $window.history.back(); + }; + + $scope.next = function() { + // DataService.setLcpRegion($scope.nodeTemplateFields.lcpRegion.value); + // DataService.setModelInstanceName($scope.nodeTemplateFields.instanceName.value); + // DataService.setTenant($scope.nodeTemplateFields.tenant.value); + // var suppressRollback = ($scope.nodeTemplateFields.suppressRollback.value) ? true : false; + // DataService.setSuppressRollback(suppressRollback); + DataService.setPortMirroningConfigFields($scope.nodeTemplateFields); + $location.path("/serviceProxyConfig"); + }; + + $scope.$on('$routeChangeStart', function (event, next, current) { + if(next.$$route.originalPath !=="/serviceProxyConfig"){ + DataService.setPortMirroningConfigFields(null); + } + }); + }]); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/InstantiationController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/InstantiationController.js index f0653f68..f1dc384c 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/InstantiationController.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/InstantiationController.js @@ -26,14 +26,18 @@ "use strict"; appDS2.requires.push('ui.tree'); - - appDS2.controller("InstantiationController", function ($scope, $route, $location, $timeout, COMPONENT, VIDCONFIGURATION, FIELD, DataService, PropertyService, UtilityService, VnfService, $http, vidService) { - + + appDS2.controller("InstantiationController", function ($scope, $route, $location, $timeout, COMPONENT, VIDCONFIGURATION, FIELD, DataService, PropertyService, UtilityService, VnfService, $http, vidService, AaiService,PnfService, $q) { + $scope.popup = new Object(); $scope.defaultBaseUrl = ""; $scope.responseTimeoutMsec = 60000; $scope.properties = UtilityService.getProperties(); - $scope.isPermitted = $location.search().isPermitted; + $scope.resumeStatus = COMPONENT.RESUME_STATUS; + //isPermitted - returned as string from url and converted into boolean + $scope.isPermitted = $location.search().isPermitted == "true"; + $scope.STATUS_CONSTANTS = FIELD.STATUS; + $scope.pnfs = [];// PNF data init; $scope.init = function() { /* @@ -63,8 +67,9 @@ // DataService.setServiceInstanceId("mmsc-test-service-instance"); // DataService.setServiceUuid("XXXX-YYYY-ZZZZ"); // DataService.setUserServiceInstanceName("USER_SERVICE_INSTANCE_NAME"); + } - + //PropertyService.setMsoBaseUrl("testmso"); $scope.convertModel = function(asdcModel) { @@ -78,7 +83,23 @@ "convertedModel": $scope.convertModel(vidService.getModel()), "instance": vidService.getInstance() }; - + + preparePnfs(); + + + function preparePnfs(){ + var serviceInstance = { + globalCustomerId: $location.search().subscriberId, + serviceType: $location.search().serviceType, + serviceInstanceId: $location.search().serviceInstanceId + }; + + _setPnf(serviceInstance).then(function(data){ + $scope.pnfs = data; + }); + } + + $scope.returnVfModules = function (vnfInstance) { var svcModel = $scope.service.convertedModel; @@ -213,9 +234,10 @@ DataService.setServiceUuid($scope.service.model.service.uuid); DataService.setNetworkInstanceId(network.object[FIELD.ID.NETWORK_ID]); - $scope.$broadcast(COMPONENT.DELETE_COMPONENT, { + $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, { componentId : COMPONENT.NETWORK, - callbackFunction : deleteCallbackFunction + callbackFunction : deleteOrResumeCallback, + dialogMethod: COMPONENT.DELETE }); }; @@ -233,14 +255,8 @@ } DataService.setMacro($scope.isMacro()); DataService.setInventoryItem(serviceInstance); - - DataService.setModelInfo(COMPONENT.SERVICE, { - "modelInvariantId": $scope.service.model.service.invariantUuid, - "modelVersion": $scope.service.model.service.version, - "modelNameVersionId": $scope.service.model.service.uuid, - "modelName": $scope.service.model.service.name, - "inputs": "" - }); + setCurrentServiceModelInfoFromScope(); + DataService.setSubscriberName(serviceObject[FIELD.ID.SUBSCRIBER_NAME]); DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]); @@ -253,105 +269,150 @@ DataService.setServiceUuid($scope.service.model.service.uuid); - $scope.$broadcast(COMPONENT.DELETE_COMPONENT, { + $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, { componentId : COMPONENT.SERVICE, - callbackFunction : deleteServiceInstanceCallbackFunction + callbackFunction : deleteServiceInstanceCallbackFunction, + dialogMethod: COMPONENT.DELETE }); }; - $scope.deleteVfModule = function(serviceObject, vfModule, vnf) { - - console.log("Removing VF-Module " + vfModule.name); - + function populate_popup_vfModule(serviceObject, vfModule, vnf){ var serviceInstance = serviceObject.object; - DataService.setInventoryItem(vfModule.object); - - var svcModel = $scope.service.convertedModel; + DataService.setInventoryItem(vfModule.object); - //var vnfModelInvariantUuid = vnf.object[FIELD.ID.MODEL_INVAR_ID]; - var vnfModelVersionId = vnf.object[FIELD.ID.MODEL_VERSION_ID]; - var vnfModelCustomizationUuid = vnf.object[FIELD.ID.MODEL_CUSTOMIZATION_ID];; - var vfModuleInstanceID = vfModule.object[FIELD.ID.VF_MODULE_ID]; - if (vfModuleInstanceID == null) { - vfModuleInstanceID = ""; - } - - var vnfModel = null; - var vfModuleModel = null; - - DataService.setModelInfo(COMPONENT.VF_MODULE, { - "modelInvariantId": "", - "modelVersion": "", - "modelNameVersionId": "", - "modelCustomizationName": "", - "customizationUuid": "", - "modelName": "", - "inputs": "" - }); - - if ( (!($scope.isObjectEmpty(svcModel))) && ( !($scope.isObjectEmpty(svcModel.vnfs) ) ) ) { - if ( (svcModel.isNewFlow) && (vnfModelCustomizationUuid != null ) ) { - vnfModel = svcModel.vnfs[vnfModelCustomizationUuid]; - - var vfModuleCustomizationUuid = vfModule.object[FIELD.ID.MODEL_CUSTOMIZATION_ID]; - if ( !($scope.isObjectEmpty(vnfModel.vfModules) ) && UtilityService.hasContents(vfModuleCustomizationUuid) ) { - - vfModuleModel = vnfModel.vfModules[vfModuleCustomizationUuid]; - - } - } - else { - // old flow - if (vnfModelVersionId != null ) { - vnfModel = svcModel.vnfs[vnfModelVersionId]; - } - //var vfModuleInvariantUuid = vfModule.object[FIELD.ID.MODEL_INVAR_ID]; - var vfModuleModelVersionId = vfModule.object[FIELD.ID.MODEL_VERSION_ID]; - if ( (!($scope.isObjectEmpty(vnfModel))) && (!($scope.isObjectEmpty(vnfModel.vfModules))) && - UtilityService.hasContents(vfModuleModelVersionId) ) { - vfModuleModel = vnfModel.vfModules[vfModuleModelVersionId]; - } - } - if ( !($scope.isObjectEmpty(vfModuleModel)) ) { - DataService.setModelInfo(COMPONENT.VF_MODULE, { - "modelInvariantId": vfModuleModel.invariantUuid, - "modelVersion": vfModuleModel.version, - "modelNameVersionId": vfModuleModel.uuid, - "modelCustomizationName": vfModuleModel.modelCustomizationName, - "customizationUuid": vfModuleModel.customizationUuid, - "modelName": vfModuleModel.name, - "inputs": "" - }); - } - } + var svcModel = $scope.service.convertedModel; - DataService.setVnfInstanceId(vnf.object[FIELD.ID.VNF_ID]); - DataService.setVfModuleInstanceId(vfModuleInstanceID); - - DataService.setSubscriberName(serviceObject[COMPONENT.SUBSCRIBER_NAME]); - DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]); - DataService.setServiceInstanceId(serviceInstance[FIELD.ID.SERVICE_INSTANCE_ID]); - - DataService.setGlobalCustomerId(serviceObject[FIELD.ID.GLOBAL_CUST_ID]); - DataService.setServiceInstanceName($scope.service.instance.name); - - DataService.setServiceName($scope.service.model.service.name); - - DataService.setServiceUuid($scope.service.model.service.uuid); + //var vnfModelInvariantUuid = vnf.object[FIELD.ID.MODEL_INVAR_ID]; + var vnfModelVersionId = vnf.object[FIELD.ID.MODEL_VERSION_ID]; + var vnfModelCustomizationUuid = vnf.object[FIELD.ID.MODEL_CUSTOMIZATION_ID];; + var vfModuleInstanceID = vfModule.object[FIELD.ID.VF_MODULE_ID]; + if (vfModuleInstanceID == null) { + vfModuleInstanceID = ""; + } + + var vnfModel = null; + var vfModuleModel = null; + + DataService.setModelInfo(COMPONENT.VF_MODULE, { + "modelInvariantId": "", + "modelVersion": "", + "modelNameVersionId": "", + "modelCustomizationName": "", + "customizationUuid": "", + "modelName": "", + "inputs": "" + }); + + if ( (!($scope.isObjectEmpty(svcModel))) && ( !($scope.isObjectEmpty(svcModel.vnfs) ) ) ) { + if ( (svcModel.isNewFlow) && (vnfModelCustomizationUuid != null ) ) { + vnfModel = svcModel.vnfs[vnfModelCustomizationUuid]; + + var vfModuleCustomizationUuid = vfModule.object[FIELD.ID.MODEL_CUSTOMIZATION_ID]; + if ( !($scope.isObjectEmpty(vnfModel.vfModules) ) && UtilityService.hasContents(vfModuleCustomizationUuid) ) { + + vfModuleModel = vnfModel.vfModules[vfModuleCustomizationUuid]; + + } + } + else { + // old flow + if (vnfModelVersionId != null ) { + vnfModel = svcModel.vnfs[vnfModelVersionId]; + } + //var vfModuleInvariantUuid = vfModule.object[FIELD.ID.MODEL_INVAR_ID]; + var vfModuleModelVersionId = vfModule.object[FIELD.ID.MODEL_VERSION_ID]; + if ( (!($scope.isObjectEmpty(vnfModel))) && (!($scope.isObjectEmpty(vnfModel.vfModules))) && + UtilityService.hasContents(vfModuleModelVersionId) ) { + vfModuleModel = vnfModel.vfModules[vfModuleModelVersionId]; + } + } + if ( !($scope.isObjectEmpty(vfModuleModel)) ) { + DataService.setModelInfo(COMPONENT.VF_MODULE, { + "modelInvariantId": vfModuleModel.invariantUuid, + "modelVersion": vfModuleModel.version, + "modelNameVersionId": vfModuleModel.uuid, + "modelCustomizationName": vfModuleModel.modelCustomizationName, + "customizationUuid": vfModuleModel.customizationUuid, + "modelName": vfModuleModel.name, + "inputs": "" + }); + } + } + + DataService.setVnfInstanceId(vnf.object[FIELD.ID.VNF_ID]); + DataService.setVfModuleInstanceId(vfModuleInstanceID); + + DataService.setSubscriberName(serviceObject[COMPONENT.SUBSCRIBER_NAME]); + DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]); + DataService.setServiceInstanceId(serviceInstance[FIELD.ID.SERVICE_INSTANCE_ID]); + + DataService.setGlobalCustomerId(serviceObject[FIELD.ID.GLOBAL_CUST_ID]); + DataService.setServiceInstanceName($scope.service.instance.name); + + DataService.setServiceName($scope.service.model.service.name); + + DataService.setServiceUuid($scope.service.model.service.uuid); + } + + $scope.deleteVfModule = function(serviceObject, vfModule, vnf) { + + console.log("Removing VF-Module " + vfModule.name); + + populate_popup_vfModule(serviceObject, vfModule, vnf); - $scope.$broadcast(COMPONENT.DELETE_COMPONENT, { + $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, { componentId : COMPONENT.VF_MODULE, - callbackFunction : deleteCallbackFunction + callbackFunction : deleteOrResumeCallback, + dialogMethod: COMPONENT.DELETE }); return; }; - $scope.deleteVnf = function(serviceObject, vnf) { + function setCurrentServiceModelInfoFromScope(){ + DataService.setModelInfo(COMPONENT.SERVICE, { + "modelInvariantId": $scope.service.model.service.invariantUuid, + "modelVersion": $scope.service.model.service.version, + "modelNameVersionId": $scope.service.model.service.uuid, + "modelName": $scope.service.model.service.name, + "inputs": "" + }); + }; + + function setCurrentVNFModelInfo(vnf){ + var svcModel = $scope.service.convertedModel; + var vnfModel; + var vnfModelCustomizationUuid = vnf.object[FIELD.ID.MODEL_CUSTOMIZATION_ID]; + var vnfModelVersionId = vnf.object[FIELD.ID.MODEL_VERSION_ID]; + if ( (!($scope.isObjectEmpty(svcModel))) && ( !($scope.isObjectEmpty(svcModel.vnfs) ) ) ) { + if ( (svcModel.isNewFlow) && (vnfModelCustomizationUuid != null ) ) { + vnfModel = svcModel.vnfs[vnfModelCustomizationUuid]; + } + else { + vnfModel = svcModel.vnfs[vnfModelVersionId]; + } + if ( !($scope.isObjectEmpty(vnfModel) ) ) { + + DataService.setModelInfo(COMPONENT.VNF, { + "modelInvariantId": vnfModel.invariantUuid, + "modelVersion": vnfModel.version, + "modelNameVersionId": vnfModel.uuid, + "modelCustomizationName": vnfModel.modelCustomizationName, + "customizationUuid": vnfModel.customizationUuid, + "modelName": vnfModel.name, + "inputs": "" + }); + } + } + + + + } + $scope.deleteVnf = function(serviceObject, vnf) { console.log("Removing VNF " + vnf.name); var serviceInstance = serviceObject.object; @@ -424,9 +485,10 @@ DataService.setServiceUuid($scope.service.model.service.uuid); - $scope.$broadcast(COMPONENT.DELETE_COMPONENT, { + $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, { componentId : COMPONENT.VNF, - callbackFunction : deleteCallbackFunction + callbackFunction : deleteOrResumeCallback, + dialogMethod: COMPONENT.DELETE }); }; @@ -517,8 +579,9 @@ DataService.setVnfInstanceId(vnf.nodeId); DataService.setVolumeGroupInstanceId(volumeGroup.nodeId); - $scope.$broadcast(COMPONENT.DELETE_COMPONENT, { + $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, { componentId : COMPONENT.VOLUME_GROUP, + dialogMethod: COMPONENT.DELETE }); }; @@ -585,10 +648,11 @@ DataService.setVnfInstanceId(vnf.nodeId); DataService.setVolumeGroupInstanceId(volumeGroup.nodeId); - $scope.$broadcast(COMPONENT.DELETE_COMPONENT, { - componentId : COMPONENT.VOLUME_GROUP, - callbackFunction : deleteCallbackFunction - }); + $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, { + componentId : COMPONENT.VOLUME_GROUP, + callbackFunction : deleteOrResumeCallback, + dialogMethod: COMPONENT.DELETE + }); }; $scope.describeNetwork = function(serviceObject, networkObject) { @@ -783,14 +847,8 @@ "inputs": "", "displayInputs": netModel.displayInputs }); - - DataService.setModelInfo(COMPONENT.SERVICE, { - "modelInvariantId": $scope.service.model.service.invariantUuid, - "modelVersion": $scope.service.model.service.version, - "modelNameVersionId": $scope.service.model.service.uuid, - "modelName": $scope.service.model.service.name, - "inputs": "" - }); + setCurrentServiceModelInfoFromScope(); + $scope.$broadcast(COMPONENT.CREATE_COMPONENT, { componentId : COMPONENT.NETWORK, @@ -814,6 +872,8 @@ DataService.setServiceInstanceId($scope.service.instance.id); DataService.setServiceName($scope.service.model.service.name); + console.log ( "existingVnfs: " ); + console.log (JSON.stringify ( existingVnfs, null, 4)); console.log ( "existingVnfs: " ); console.log (JSON.stringify ( existingVnfs, null, 4)); var vnf_type = ""; var vnf_role = ""; @@ -833,7 +893,7 @@ vnf_code = vnf.nfCode; } DataService.setModelInfo(COMPONENT.VNF, { - "modelType": "vnf", + "modelType": vnf.isPnf ? "pnf" : "vnf", "modelInvariantId": vnf.invariantUuid, "modelVersion": vnf.version, "modelNameVersionId": vnf.uuid, @@ -845,23 +905,27 @@ "vnfType": vnf_type, "vnfRole": vnf_role, "vnfFunction": vnf_function, - "vnfCode": vnf_code + "vnfCode": vnf_code, + "properties": vnf.properties }); DataService.setModelInstanceName($scope.service.model.service.name); - - DataService.setModelInfo(COMPONENT.SERVICE, { - "modelInvariantId": $scope.service.model.service.invariantUuid, - "modelVersion": $scope.service.model.service.version, - "modelNameVersionId": $scope.service.model.service.uuid, - "modelName": $scope.service.model.service.name, - "inputs": "" - }); - - $scope.$broadcast(COMPONENT.CREATE_COMPONENT, { - componentId : COMPONENT.VNF, - callbackFunction : createVnfCallbackFunction - }); + setCurrentServiceModelInfoFromScope(); + + if (vnf.isConfig) { + DataService.setServiceProxies($scope.service.model.serviceProxies); + DataService.setSourceServiceProxies(vnf.sourceNodes); + DataService.setCollectorServiceProxies(vnf.collectorNodes); + DataService.setConfigurationByPolicy(vnf.isConfigurationByPolicy); + $location.path("/addNetworkNode"); + } else if(vnf.isPnf){ + $location.path("/pnfSearchAssociation"); + } else { + $scope.$broadcast(COMPONENT.CREATE_COMPONENT, { + componentId: COMPONENT.VNF, + callbackFunction: createVnfCallbackFunction + }); + } }; $scope.addVfModuleInstance = function(vnfInstance, vfModuleModel) { @@ -898,20 +962,11 @@ availableVolumeGroupList.push({"instance": volumeGroupInstance}); }); - if (vfModuleModel.volumeGroupAllowed) { - DataService.setAvailableVolumeGroupList(availableVolumeGroupList); - } - - DataService.setModelInfo(COMPONENT.SERVICE, { - "modelInvariantId": $scope.service.model.service.invariantUuid, - "modelVersion": $scope.service.model.service.version, - "modelNameVersionId": $scope.service.model.service.uuid, - "modelName": $scope.service.model.service.name, - "inputs": "" - }); + DataService.setAvailableVolumeGroupList(availableVolumeGroupList); + setCurrentServiceModelInfoFromScope(); DataService.setVnfInstanceId(vnfInstance.object[FIELD.ID.VNF_ID]); - + DataService.setModelInfo(COMPONENT.VNF, { "modelInvariantId": vnfModel.invariantUuid, "modelVersion": vnfModel.version, @@ -954,6 +1009,7 @@ DataService.setServiceInstanceName($scope.service.instance.name); DataService.setServiceInstanceId($scope.service.instance.id); DataService.setServiceName($scope.service.model.service.name); + setCurrentServiceModelInfoFromScope(); DataService.setModelInfo(COMPONENT.SERVICE, { "modelInvariantId": $scope.service.model.service.invariantUuid, @@ -976,7 +1032,7 @@ else { vnfModel = svcModel.vnfs[vnfModelVersionId]; } - + DataService.setModelInfo(COMPONENT.VNF, { "modelInvariantId": vnfModel.invariantUuid, "modelVersion": vnfModel.version, @@ -1003,6 +1059,76 @@ }); }; + $scope.resume = function(serviceObject, vfModule, vnfModel) { + populate_popup_vfModule(serviceObject, vfModule, vnfModel); + setCurrentVNFModelInfo(vnfModel); + DataService.setVfModuleInstanceName(vfModule.object[FIELD.ID.VF_MODULE_NAME]); + setCurrentServiceModelInfoFromScope(); + $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, { + componentId : COMPONENT.VF_MODULE, + callbackFunction : deleteOrResumeCallback, + dialogMethod: COMPONENT.RESUME + }); + }; + + $scope.deleteConfiguration = function (serviceObject, configuration) { + console.log("Deleting Configuration " + configuration.name); + + var serviceInstance = serviceObject.object; + var svcModel = $scope.service.convertedModel; + var configModel; + DataService.setInventoryItem(configuration.object); + // set model default and override later if found + DataService.setModelInfo(COMPONENT.CONFIGURATION, {}); + + if ( configuration.object != null ) { + + //var netModelInvariantUuid = network.object[FIELD.ID.MODEL_INVAR_ID]; + var configModelVersionId = configuration.object[FIELD.ID.MODEL_VERSION_ID]; // model uuid + var configModelCustomizationUuid = configuration.object[FIELD.ID.MODEL_CUSTOMIZATION_ID]; + + //configurations added to vnfs list, in order to be part of the "Add VNF" drop-down list + if ( (!($scope.isObjectEmpty(svcModel))) && ( !($scope.isObjectEmpty(svcModel.vnfs) ) ) ) { + if ( (svcModel.isNewFlow) && (UtilityService.hasContents(configModelCustomizationUuid) ) ) { + configModel = svcModel.vnfs[configModelCustomizationUuid]; + } + else { + + if ( UtilityService.hasContents(configModelVersionId) ) { + configModel = svcModel.vnfs[configModelVersionId]; + } + + } + } + } + if (!($scope.isObjectEmpty(configModel) ) ) { + DataService.setModelInfo(COMPONENT.CONFIGURATION, { + "modelInvariantId": configModel.invariantUuid, + "modelVersion": configModel.version, + "modelNameVersionId": configModel.uuid, + "modelCustomizationName": configModel.modelCustomizationName, + "customizationUuid": configModel.customizationUuid, + "modelName": configModel.name, + "inputs": "" + }); + } + + DataService.setSubscriberName(serviceObject[COMPONENT.SUBSCRIBER_NAME]); + DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]); + DataService.setServiceInstanceId(serviceInstance[FIELD.ID.SERVICE_INSTANCE_ID]); + + DataService.setGlobalCustomerId(serviceObject[FIELD.ID.GLOBAL_CUST_ID]); + DataService.setServiceInstanceName($scope.service.instance.name); + DataService.setServiceName($scope.service.model.service.name); + DataService.setServiceUuid($scope.service.model.service.uuid); + DataService.setConfigurationInstanceId(configuration.object[FIELD.ID.CONFIGURATION_ID]); + + $scope.$broadcast(COMPONENT.DELETE_COMPONENT, { + componentId : COMPONENT.CONFIGURATION, + callbackFunction : deleteCallbackFunction + }); + }; + $scope.resetProgress = function() { $scope.percentProgress = 0; $scope.progressClass = FIELD.STYLE.PROGRESS_BAR_INFO; @@ -1055,7 +1181,35 @@ $scope.reloadRoute = function() { $route.reload(); } - + + + + /* + Private metthods + */ + + /* + setPnf + * set the controller pnf param using api call + * return: void + */ + function _setPnf(data){ // data is the $scope.service.instance object + return PnfService.getPnfs(data) + .then( + function success(response){ + return response.data; + // * can add here changes on the data that are needed to the view ( filter, ect..) + }, + function error(error){ + console.error(error); + } + ); + } + + /* + Callbaks functions + + */ var updateProvStatusVnfCallbackFunction = function(response) { $scope.callbackResults = ""; var color = FIELD.ID.COLOR_NONE; @@ -1112,7 +1266,7 @@ }; - var deleteCallbackFunction = function(response) { + var deleteOrResumeCallback = function(response) { $scope.callbackResults = ""; var color = FIELD.ID.COLOR_NONE; $scope.callbackStyle = { diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js index 8844d40a..967a3900 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js @@ -41,14 +41,13 @@ $scope.services = []; if (response.data && angular.isArray(response.data.services)) { wholeData = response.data.services; - $scope.services = $scope.filterDataWithHigerVersion(wholeData); + $scope.services = $scope.filterDataWithHigherVersion(wholeData); $scope.viewPerPage=10; $scope.totalPage=$scope.services.length/$scope.viewPerPage; $scope.sortBy=COMPONENT.NAME; $scope.scrollViewPerPage=2; $scope.currentPage=1; $scope.searchCategory; - $scope.searchString=""; $scope.currentPageNum=1; $scope.isSpinnerVisible = false; $scope.isProgressVisible = false; @@ -61,67 +60,35 @@ }, function errorCallback(response) { console.log("Error: " + response); }); - } - $scope.isFiltered=function(arr,obj){ - var filtered = false; - if(arr.length>0){ - for(var i=0;i=parseFloat(serviceData[i].version.trim()))){ - var data = $scope.isThisHigher(fiterDataServices,serviceData[j]); - if(data.isHigher){ - fiterDataServices[data.index] = serviceData[j]; - } - } - } - } - } - return fiterDataServices; - } - $scope.isThisHigher = function(arr,obj){ - var returnObj = { - isHigher:false, - index:0 - }; - if(arr.length>0){ - var isNotMatched = true; - for(var i=0;iparseFloat(fiterDataServices[index].service.version.trim())) { + fiterDataServices[index].service = serviceData[i]; } } - if(isNotMatched && !$scope.isFiltered(arr,obj)){ - returnObj = { - isHigher:true, - index:arr.length - }; - } - }else{ - returnObj = { - isHigher:true, - index:0 - } } - return returnObj; - } + return Object.keys(fiterDataServices).map(function(key) { + var service = fiterDataServices[key].service; + service.hasPreviousVersion = fiterDataServices[key].hasPreviousVersion; + return service; + }); + }; $scope.init = function() { var msecs = PropertyService.retrieveMsoMaxPollingIntervalMsec(); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceProxyConfigController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceProxyConfigController.js new file mode 100644 index 00000000..6e7ad50c --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceProxyConfigController.js @@ -0,0 +1,342 @@ +/*- +* ============LICENSE_START======================================================= +* VID +* ================================================================================ +* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +* ================================================================================ +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* ============LICENSE_END========================================================= +*/ + +/** + * The Instantiation (or View/Edit) Controller controls the instantiation/removal of + * deployable objects (Services, VNFs, VF-Modules, Networks, and Volume-Groups) + */ + +"use strict"; + +appDS2.controller("ServiceProxyConfigController", ["COMPONENT", "$log", "FIELD", "PARAMETER", "DataService", "CreationService", "$scope", "$window", "$location", "AaiService", "$uibModal", "UtilityService", "$timeout", + function (COMPONENT, $log, FIELD, PARAMETER, DataService, CreationService, $scope, $window, $location, AaiService, $uibModal, UtilityService, $timeout) { + + $scope.selectedMetadata = {}; + + $scope.serviceMetadataFields = []; + $scope.nodeTemplateFields = {}; + + $scope.configurationByPolicy = DataService.getConfigurationByPolicy(); + + $scope.collectorType = $scope.configurationByPolicy ? 'pnf' : 'vnf'; //default + $scope.collectorInstance; + $scope.collectorInstanceName = ""; + $scope.collectorInstanceList = null; + $scope.collectorMetadata = []; + $scope.collectorNoResults = false; + + $scope.sourceInstance; + $scope.sourceInstanceName = ""; + $scope.sourceInstanceList = null; + $scope.sourceMetadata = []; + $scope.sourceNoResults = false; + + $scope.errorMsg = FIELD.ERROR.INSTANCE_NAME_VALIDATE; + + $scope.modelName = DataService.getModelInfo(COMPONENT.VNF).modelCustomizationName; + + $scope.serviceTypes = []; + + function init() { + loadServiceTypes(); + + generateMetadata(sourceServiceProxy); + generateMetadata(collectorServiceProxy); + + } + + function setDefaultCollectorServiceType() { + const configServiceType = DataService.getServiceType(); + $scope.collectorServiceType = mustFind($scope.serviceTypes, {"service-type": configServiceType}); + loadCollectorProxies(); + } + + function handleGetServiceTypesResponse(response) { + $scope.serviceTypes = response.data; + setDefaultCollectorServiceType(); + } + + var handleGetParametersResponse = function(parameters) { + $scope.serviceMetadataFields = parameters.summaryList; + $scope.nodeTemplateFields = DataService.getPortMirroningConfigFields(); + }; + + var mustFind = function (collection, predicate) { + const result = _.find(collection, predicate); + const description = "result for find " + JSON.stringify(predicate); + UtilityService.checkUndefined(description, result); + $log.debug(description, result); + return result; + }; + + + $scope.back = function() { + $window.history.back(); + }; + + + function loadServiceTypes() { + const subscriberId = DataService.getGlobalCustomerId(); + AaiService.getSubscriberServiceTypes(subscriberId) + .then(handleGetServiceTypesResponse) + .catch(function (error) { + $log.error(error); + }); + } + + var modalInstance; + + $scope.create = function() { + $scope.disableCreate= true; + var portMirroringConfigFields = DataService.getPortMirroningConfigFields(); + portMirroringConfigFields.sourceInstance = mustFind($scope.sourceInstanceList, {'id': $scope.sourceInstance}); + portMirroringConfigFields.destinationInstance = mustFind($scope.collectorInstanceList, {'id': $scope.collectorInstance}); + + var selectedVnfsList; + + if ($scope.configurationByPolicy) { + selectedVnfsList = [ + portMirroringConfigFields.sourceInstance.properties + ]; + } else { + selectedVnfsList = [ + portMirroringConfigFields.sourceInstance.properties, + portMirroringConfigFields.destinationInstance.properties + ]; + } + + AaiService.getVnfVersionsByInvariantId( + selectedVnfsList.map(function(x) { + return UtilityService.checkUndefined("model-invariant-id", x['model-invariant-id']); + }) + ) + .then(function (response) { + $log.debug("getVnfVersionsByInvariantId: response", response); + + selectedVnfsList + .map(function (inOutProperties) { + const model = mustFind(response.data.model, {'model-invariant-id': inOutProperties['model-invariant-id']}); + + const modelVer = mustFind(model["model-vers"]["model-ver"], {'model-version-id': inOutProperties['model-version-id']}); + + inOutProperties['model-version'] = modelVer['model-version']; + inOutProperties['model-name'] = modelVer['model-name']; + UtilityService.checkUndefined("model-version", modelVer); + }); + }) + + .then(function () { + var requestParams = { + configurationModelInfo: DataService.getModelInfo(COMPONENT.VNF), + relatedTopModelsInfo: DataService.getModelInfo(COMPONENT.SERVICE), + portMirroringConfigFields:portMirroringConfigFields, + attuuid: DataService.getLoggedInUserId(), + topServiceInstanceId: DataService.getServiceInstanceId(), + configurationByPolicy: $scope.configurationByPolicy, + callbackFunction: updateViewCallbackFunction + }; + + modalInstance = $uibModal.open({ + templateUrl: 'app/vid/scripts/modals/mso-commit/mso-commit.html', + controller : "msoCommitModalController", + backdrop: true, + resolve: { + msoType: function () { + return COMPONENT.MSO_CREATE_REQ; + }, + requestParams: function () { + return requestParams; + } + } + }); + }) + .catch(function (error) { + $log.error("error while configuration create", error); + $scope.disableCreate= false; + }); + }; + + $scope.openMetadataModal = function(name) { + $scope.selectedMetadata = $scope[name]; + modalInstance = $uibModal.open({ + templateUrl: 'app/vid/scripts/modals/service-metadata/service-metadata.html', + backdrop: false, + scope : $scope, + resolve: { + } + }); + }; + + $scope.cancel = function() { + modalInstance.dismiss('cancel'); + }; + + var updateViewCallbackFunction = function(response) { + $scope.callbackResults = ""; + var color = FIELD.ID.COLOR_NONE; + $scope.callbackStyle = { + "background-color" : color + }; + + /* + * This 1/2 delay was only added to visually highlight the status + * change. Probably not needed in the real application code. + */ + $timeout(function() { + $scope.callbackResults = UtilityService.getCurrentTime() + + FIELD.STATUS.IS_SUCCESSFUL + response.isSuccessful; + if (response.isSuccessful) { + color = FIELD.ID.COLOR_8F8; + $window.history.go(-2); + } else { + $scope.disableCreate=false; + color = FIELD.ID.COLOR_F88; + } + $scope.callbackStyle = { + "background-color" : color + }; + }, 500); + }; + + CreationService.initializeComponent(COMPONENT.VNF); + CreationService.initializeComponent(COMPONENT.SERVICE); + CreationService.getParameters(handleGetParametersResponse); + + var sourceServiceProxies = DataService.getSourceServiceProxies(); + var collectorServiceProxies = DataService.getCollectorServiceProxies(); + var serviceProxiesList = DataService.getServiceProxies(); + + var sourceServiceProxy = { + serviceList: sourceServiceProxies, + instanceListScopePropertyName: "sourceInstanceList", + name: "sourceInstanceName", + metadata: "sourceMetadata", + noResults: "sourceNoResults" + }; + + var collectorServiceProxy = { + serviceList: collectorServiceProxies, + instanceListScopePropertyName: "collectorInstanceList", + name: "collectorInstanceName", + metadata: "collectorMetadata", + noResults: "collectorNoResults" + }; + + $scope.onSourceServiceTypeSelected = function() { + clearSourceProxySelection(); + loadSourceProxies(); + }; + + $scope.onCollectorServiceTypeSelected = function() { + clearCollectorProxySelection(); + loadCollectorProxies(); + }; + + function clearSourceProxySelection() { + $scope.sourceInstance = undefined; + } + + function clearCollectorProxySelection() { + $scope.collectorInstance = undefined; + } + + function loadSourceProxies() { + var serviceProxy = serviceProxiesList[(sourceServiceProxy.serviceList)[0]]; + var selectedServiceType = $scope.sourceServiceType['service-type']; + loadProxyInstances(sourceServiceProxy, selectedServiceType, serviceProxy); + } + + function loadCollectorProxies() { + var serviceProxy = serviceProxiesList[(collectorServiceProxy.serviceList)[0]]; + var selectedServiceType = $scope.collectorServiceType['service-type']; + loadProxyInstances(collectorServiceProxy, selectedServiceType, serviceProxy); + } + + function loadProxyInstances(service, serviceType, serviceProxy) { + $scope[service.instanceListScopePropertyName] = null; + // $scope.collectorType = $scope.configurationByPolicy ? 'pnf' : 'vnf'; + var configNodeTemplateFields = DataService.getPortMirroningConfigFields(); + if (service.name == "collectorInstanceName" && $scope.configurationByPolicy) { + var configurationModel = DataService.getModelInfo(COMPONENT.VNF); + AaiService.getPnfInstancesList( + DataService.getGlobalCustomerId(), + serviceType, + serviceProxy.sourceModelUuid, + serviceProxy.sourceModelInvariant, + configNodeTemplateFields.lcpRegion.value, + configurationModel.properties.equip_vendor, + configurationModel.properties.equip_model + ) + .then(function (response) { + var results = response.results || []; + $scope[service.instanceListScopePropertyName] = results; + $scope[service.noResults] = (results.length === 0); + }) + .catch(function (error) { + $scope[service.noResults] = true; + $log.error("No pnf instance found for " + service.name, error); + }); + } else { + AaiService.getVnfInstancesList( + DataService.getGlobalCustomerId(), + serviceType, + serviceProxy.sourceModelUuid, + serviceProxy.sourceModelInvariant, + configNodeTemplateFields.lcpRegion.value + ) + .then(function (response) { + var results = response.results || []; + $scope[service.instanceListScopePropertyName] = results; + $scope[service.noResults] = (results.length === 0); + }) + .catch(function (error) { + $scope[service.noResults] = true; + $log.error("No vnf instance found for " + service.name, error); + }); + } + } + + function generateMetadata(service) { + const serviceProxy = serviceProxiesList[(service.serviceList)[0]]; + $scope[service.name] = serviceProxy.name; + + $scope[service.metadata] = [ + {"name" :"Name" ,"value" : serviceProxy.name}, + {"name" :"Version",value : serviceProxy.version}, + {"name" :"Description", value : serviceProxy.description}, + {"name" :"Type", value : serviceProxy.type}, + {"name" :"Invariant UUID", value : serviceProxy.invariantUuid}, + {"name" :"UUID", value : serviceProxy.uuid}, + {"name" :"Customization UUID", value : serviceProxy.customizationUuid}, + {"name" :"Source Model Uuid", value : serviceProxy.sourceModelUuid}, + {"name" :"Source Model Invariant", value : serviceProxy.sourceModelInvariant}, + {"name" :"Source Model Name", value : serviceProxy.sourceModelName} + ]; + } + + init(); + $scope.$on('$routeChangeStart', function (event, next, current) { + if(next.$$route.originalPath!=="/addNetworkNode"){ + DataService.setPortMirroningConfigFields(null); + } + }); + }]); + + diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/VidApp.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/VidApp.js index b611def4..6129fd96 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/VidApp.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/VidApp.js @@ -20,7 +20,7 @@ (function () { 'use strict'; - + appDS2.config(['$routeProvider', '$locationProvider', function ($routeProvider) { $routeProvider .when('/models/services', { @@ -32,30 +32,47 @@ templateUrl: 'app/vid/scripts/view-models/createInstanceServiceModels.htm' }) .when('/instances/services', { - templateUrl : "app/vid/scripts/view-models/aaiGetSubs.htm", + templateUrl : "app/vid/scripts/view-models/aaiGetSubs.htm", controller : "aaiSubscriberController" }) .when('/instances/subscribers', { - templateUrl : "app/vid/scripts/view-models/aaiGetSubscriberList.htm", + templateUrl : "app/vid/scripts/view-models/aaiGetSubscriberList.htm", controller : "aaiSubscriberController" }) .when('/instances/serviceTypes', { - templateUrl : "app/vid/scripts/view-models/aaiServiceTypes.htm", + templateUrl : "app/vid/scripts/view-models/aaiServiceTypes.htm", controller : "aaiSubscriberController" }) .when('/instances/subdetails', { - templateUrl : "app/vid/scripts/view-models/aaiSubDetails.htm", + templateUrl : "app/vid/scripts/view-models/aaiSubDetails.htm", controller : "aaiSubscriberController" }) .when('/change-management', { templateUrl : "app/vid/scripts/view-models/change-management.html", controller : "changeManagementController", controllerAs: 'vm' - }) + }) + .when('/testEnvironments', { + templateUrl : "app/vid/scripts/view-models/testEnvironments.htm", + controller : "testEnvironmentsController", + controllerAs: 'vm' + }) .when('/instantiate', { controller: 'InstantiationController', templateUrl: 'app/vid/scripts/view-models/instantiate.htm' }) + .when('/addNetworkNode', { + controller: 'AddNetworkNodeController', + templateUrl: 'app/vid/scripts/view-models/addNetworkNode.htm' + }) + .when('/pnfSearchAssociation', { + controller: 'pnfSearchAssociationController', + templateUrl: 'app/vid/scripts/view-models/pnfSearchAssociation.htm' + }) + .when('/serviceProxyConfig', { + controller: 'ServiceProxyConfigController', + templateUrl: 'app/vid/scripts/view-models/serviceProxyConfig.htm' + }) .otherwise({ redirectTo: '/models/services' }); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js index a86c1b1b..d58b83f6 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js @@ -20,8 +20,8 @@ "use strict"; -appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", "DataService", "PropertyService", "$scope", "$http", "$timeout", "$location", "$log", "$route", "VIDCONFIGURATION", "UtilityService", "vidService", "AaiService", "MsoService", - function (COMPONENT, FIELD, PARAMETER, DataService, PropertyService, $scope, $http, $timeout, $location, $log, $route, VIDCONFIGURATION, UtilityService, vidService, AaiService, MsoService) { +appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", "DataService", "PropertyService", "$scope", "$http", "$timeout", "$location", "$log", "$route", "$uibModal", "VIDCONFIGURATION", "UtilityService", "vidService", "AaiService", "MsoService", "OwningEntityService", "$q", + function (COMPONENT, FIELD, PARAMETER, DataService, PropertyService, $scope, $http, $timeout, $location, $log, $route, $uibModal, VIDCONFIGURATION, UtilityService, vidService, AaiService, MsoService, OwningEntityService, $q) { $scope.showVnfDetails = function (vnf) { console.log("showVnfDetails"); @@ -121,253 +121,215 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", DataService.setSubscribers($scope.custSubList); - if (selectedServicetype !== "" && selectedServicetype !== 'undefined') { - $location.path(COMPONENT.CREATE_INSTANCE_PATH); - } - }; - - $scope.serviceTypeName=""; - $scope.getAaiServiceModelsList = function(){ - var globalCustomerId=""; - var serviceTypeId = DataService.getGlobalCustomerId(); - $scope.serviceTypeList = DataService.getServiceIdList(); - $scope.createSubscriberName = DataService.getSubscriberName(); - $scope.status = FIELD.STATUS.FETCHING_SERVICE_CATALOG; - $scope.custSubList = DataService.getSubscribers(); - for(var i=0; i<$scope.serviceTypeList.length;i++){ - if(parseInt(serviceTypeId) === i ){ - $scope.serviceTypeName = $scope.serviceTypeList[i].name; + if (selectedServicetype !== "" && selectedServicetype !== 'undefined'&& selectedServicetype !== undefined) { + $location.path(COMPONENT.CREATE_INSTANCE_PATH); + } + }; + + $scope.serviceTypeName = ""; + $scope.getAaiServiceModelsList = function () { + var globalCustomerId = ""; + var serviceTypeId = DataService.getGlobalCustomerId(); + $scope.serviceTypeList = DataService.getServiceIdList(); + $scope.createSubscriberName = DataService.getSubscriberName(); + $scope.status = FIELD.STATUS.FETCHING_SERVICE_CATALOG; + $scope.custSubList = DataService.getSubscribers(); + for (var i = 0; i < $scope.serviceTypeList.length; i++) { + if (parseInt(serviceTypeId) === i) { + $scope.serviceTypeName = $scope.serviceTypeList[i].name; + } + } + ; + for (var i = 0; i < $scope.custSubList.length; i++) { + if ($scope.createSubscriberName === $scope.custSubList[i].subscriberName) { + globalCustomerId = $scope.custSubList[i].globalCustomerId; + globalCustId = globalCustomerId; + } + } + ; + var pathQuery = ""; + + if (null !== globalCustomerId && "" !== globalCustomerId && undefined !== globalCustomerId + && null !== serviceTypeId && "" !== serviceTypeId && undefined !== serviceTypeId) { + pathQuery = COMPONENT.SERVICES_PATH + globalCustomerId + "/" + $scope.serviceTypeName; + } + + var namedQueryId = '6e806bc2-8f9b-4534-bb68-be91267ff6c8'; + AaiService.getServiceModelsByServiceType(namedQueryId, globalCustomerId, $scope.serviceTypeName, function (response) { // success + $scope.services = []; + if (angular.isArray(response.data['inventory-response-item']) && response.data['inventory-response-item'].length > 0 && response.data['inventory-response-item'][0]['inventory-response-items']) { + wholeData = response.data['inventory-response-item'][0]['inventory-response-items']['inventory-response-item']; + $scope.services = $scope.filterDataWithHigerVersion(response.data['inventory-response-item'][0]['inventory-response-items']['inventory-response-item']); + $scope.serviceType = response.data['inventory-response-item'][0]['service-subscription']['service-type']; + $scope.viewPerPage = 10; + $scope.totalPage = $scope.services.length / $scope.viewPerPage; + $scope.sortBy = "name"; + $scope.scrollViewPerPage = 2; + $scope.currentPage = 1; + $scope.searchCategory; + $scope.searchString = ""; + $scope.currentPageNum = 1; + $scope.isSpinnerVisible = false; + $scope.isProgressVisible = false; + } else { + $scope.status = "Failed to get service models from ASDC."; + $scope.error = true; + $scope.isSpinnerVisible = false; } - } - ; - for(var i=0; i<$scope.custSubList.length;i++){ - if($scope.createSubscriberName === $scope.custSubList[i].subscriberName){ - globalCustomerId = $scope.custSubList[i].globalCustomerId; - globalCustId = globalCustomerId; - } - } - ; - var pathQuery =""; - - if(null !== globalCustomerId && "" !== globalCustomerId && undefined !== globalCustomerId - && null !== serviceTypeId && "" !== serviceTypeId && undefined !== serviceTypeId){ - pathQuery = COMPONENT.SERVICES_PATH +globalCustomerId+"/"+$scope.serviceTypeName; - } - - var namedQueryId='6e806bc2-8f9b-4534-bb68-be91267ff6c8'; - AaiService.getServiceModelsByServiceType(namedQueryId,globalCustomerId,$scope.serviceTypeName,function(response) { // success - $scope.services = []; - if (angular.isArray(response.data['inventory-response-item']) && response.data['inventory-response-item'].length > 0 && response.data['inventory-response-item'][0]['inventory-response-items']) { - wholeData = response.data['inventory-response-item'][0]['inventory-response-items']['inventory-response-item']; - $scope.services = $scope.filterDataWithHigerVersion(response.data['inventory-response-item'][0]['inventory-response-items']['inventory-response-item']); - $scope.serviceType = response.data['inventory-response-item'][0]['service-subscription']['service-type']; - $scope.viewPerPage=10; - $scope.totalPage=$scope.services.length/$scope.viewPerPage; - $scope.sortBy="name"; - $scope.scrollViewPerPage=2; - $scope.currentPage=1; - $scope.searchCategory; - $scope.searchString=""; - $scope.currentPageNum=1; - $scope.isSpinnerVisible = false; - $scope.isProgressVisible = false; - } else { - $scope.status = "Failed to get service models from A&AI."; - $scope.error = true; - $scope.isSpinnerVisible = false; - } - DataService.setServiceIdList(response); - }, function(response) { // failure - $scope.showError(FIELD.ERROR.AAI); - $scope.errorMsg = FIELD.ERROR.FETCHING_SERVICES+ response.status; - $scope.errorDetails = response.data; - }); - - }; - - var globalCustId;// This value will be assigned only on create new service instance screen-macro - $scope.createType = "a la carte"; - $scope.deployService = function(service,hideServiceFields) { - hideServiceFields = hideServiceFields|| false; - var temp = service; - service.uuid = service['service-instance']['model-version-id']; - - console.log("Instantiating ASDC service " + service.uuid); - - $http.get('rest/models/services/' + service.uuid) - .then(function successCallback(getServiceResponse) { - getServiceResponse.data['service'].serviceTypeName =$scope.serviceTypeName ; - getServiceResponse.data['service'].createSubscriberName =$scope.createSubscriberName ; - var serviceModel = getServiceResponse.data; - DataService.setServiceName(serviceModel.service.name); - - DataService.setModelInfo(COMPONENT.SERVICE, { - "modelInvariantId": serviceModel.service.invariantUuid, - "modelVersion": serviceModel.service.version, - "modelNameVersionId": serviceModel.service.uuid, - "modelName": serviceModel.service.name, - "description": serviceModel.service.description,"serviceType": serviceModel.service.serviceType, + DataService.setServiceIdList(response); + }, function (response) { // failure + $scope.showError(FIELD.ERROR.AAI); + $scope.errorMsg = FIELD.ERROR.FETCHING_SERVICES + response.status; + $scope.errorDetails = response.data; + }); + + }; + + var globalCustId;// This value will be assigned only on create new service instance screen-macro + $scope.createType = "a la carte"; + $scope.deployService = function (service, hideServiceFields) { + hideServiceFields = hideServiceFields || false; + var temp = service; + service.uuid = service['service-instance']['model-version-id']; + + console.log("Instantiating ASDC service " + service.uuid); + + $http.get('rest/models/services/' + service.uuid) + .then(function successCallback(getServiceResponse) { + getServiceResponse.data['service'].serviceTypeName = $scope.serviceTypeName; + getServiceResponse.data['service'].createSubscriberName = $scope.createSubscriberName; + var serviceModel = getServiceResponse.data; + DataService.setServiceName(serviceModel.service.name); + + DataService.setModelInfo(COMPONENT.SERVICE, { + "modelInvariantId": serviceModel.service.invariantUuid, + "modelVersion": serviceModel.service.version, + "modelNameVersionId": serviceModel.service.uuid, + "modelName": serviceModel.service.name, + "description": serviceModel.service.description, + "serviceType": serviceModel.service.serviceType, "serviceRole": serviceModel.service.serviceRole, - "category":serviceModel.service.category, - "serviceTypeName":serviceModel.service.serviceTypeName, - "createSubscriberName":serviceModel.service.createSubscriberName - }); - DataService.setHideServiceFields(hideServiceFields); - if(hideServiceFields){ - DataService.setServiceType($scope.serviceTypeName); - DataService.setGlobalCustomerId(globalCustId); - } - - DataService.setALaCarte (true); - $scope.createType = "a la carte"; - var broadcastType = "createComponent"; - - if (UtilityService.arrayContains (VIDCONFIGURATION.MACRO_SERVICES, serviceModel.service.invariantUuid )) { - DataService.setALaCarte (false); - $scope.createType = "Macro"; - var convertedAsdcModel = UtilityService.convertModel(serviceModel); - - //console.log ("display inputs "); - //console.log (JSON.stringify ( convertedAsdcModel.completeDisplayInputs)); - - DataService.setModelInfo(COMPONENT.SERVICE, { - "modelInvariantId": serviceModel.service.invariantUuid, - "modelVersion": serviceModel.service.version, - "modelNameVersionId": serviceModel.service.uuid, - "modelName": serviceModel.service.name, - "description": serviceModel.service.description, - "category":serviceModel.service.category, - "serviceEcompNaming": serviceModel.service.serviceEcompNaming, - "inputs": serviceModel.service.inputs, - "displayInputs": convertedAsdcModel.completeDisplayInputs, - "serviceTypeName":serviceModel.service.serviceTypeName, - "createSubscriberName":serviceModel.service.createSubscriberName, - "serviceType": serviceModel.service.serviceType, + "category": serviceModel.service.category, + "serviceTypeName": serviceModel.service.serviceTypeName, + "createSubscriberName": serviceModel.service.createSubscriberName + }); + DataService.setHideServiceFields(hideServiceFields); + if (hideServiceFields) { + DataService.setServiceType($scope.serviceTypeName); + DataService.setGlobalCustomerId(globalCustId); + } + + DataService.setALaCarte(true); + $scope.createType = "a la carte"; + var broadcastType = "createComponent"; + + if (UtilityService.arrayContains(VIDCONFIGURATION.MACRO_SERVICES, serviceModel.service.invariantUuid)) { + DataService.setALaCarte(false); + $scope.createType = "Macro"; + var convertedAsdcModel = UtilityService.convertModel(serviceModel); + + //console.log ("display inputs "); + //console.log (JSON.stringify ( convertedAsdcModel.completeDisplayInputs)); + + DataService.setModelInfo(COMPONENT.SERVICE, { + "modelInvariantId": serviceModel.service.invariantUuid, + "modelVersion": serviceModel.service.version, + "modelNameVersionId": serviceModel.service.uuid, + "modelName": serviceModel.service.name, + "description": serviceModel.service.description, + "category": serviceModel.service.category, + "serviceEcompNaming": serviceModel.service.serviceEcompNaming, + "inputs": serviceModel.service.inputs, + "displayInputs": convertedAsdcModel.completeDisplayInputs, + "serviceTypeName": serviceModel.service.serviceTypeName, + "createSubscriberName": serviceModel.service.createSubscriberName, + "serviceType": serviceModel.service.serviceType, "serviceRole": serviceModel.service.serviceRole - });} - ; - - $scope.$broadcast(broadcastType, { - componentId : COMPONENT.SERVICE, - callbackFunction : function(response) { - if (response.isSuccessful) { - vidService.setModel(serviceModel); - - var subscriberId = "Not Found"; - var serviceType = "Not Found"; - - var serviceInstanceId = response.instanceId; - - for (var i = 0; i < response.control.length; i++) { - if (response.control[i].id == "subscriberName") { - subscriberId = response.control[i].value; - } else if (response.control[i].id == "serviceType") { - serviceType = response.control[i].value; - } - } - - - $scope.refreshSubs(subscriberId,serviceType,serviceInstanceId); - - } - } - }); - - }, function errorCallback(response) { - console.log("Error: " + response); - }); - }; - $scope.isFiltered=function(arr,obj){ - var filtered = false; - if(arr.length>0){ - for(var i=0;i=parseFloat(serviceData[i]['extra-properties']['extra-property'][6]['property-value']))){ - var data = $scope.isThisHigher(fiterDataServices,serviceData[j]); - if(data.isHigher){ - fiterDataServices[data.index] = serviceData[j]; - } - } - } - } - } - return fiterDataServices; - } - - $scope.isThisHigher = function(arr,obj){ - var returnObj = { - isHigher:false, - index:0 - }; - if(arr.length>0){ - var isNotMatched = true; - for(var i=0;i PropertyService.getMsoMaxPolls()) { + _this.isMsoError = true; + showError(FIELD.ERROR.MAX_POLLS_EXCEEDED); + } else { + _this.timer = $timeout(getRequestStatus, PropertyService + .getMsoMaxPollingIntervalMsec()); + } + } catch (error) { + _this.isMsoError = true; + MsoService.showResponseContentError(error, showError); + } + }; + + var showError = function(summary, details) { + var message = summary; + if (UtilityService.hasContents(details)) { + message += " (" + details + ")"; + } + $scope.isSpinnerVisible = false; + $scope.isProgressVisible = false; + $scope.error = message; + $scope.status = FIELD.STATUS.ERROR; + }; + + var getRequestStatus = function() { + MsoService.getOrchestrationRequest(_this.requestId, handleGetResponse); + }; + + var updateLog = function(response) { + $scope.log = MsoService.getFormattedCommonResponse(response) + + $scope.log; + UtilityService.checkUndefined("entity", response.data.entity); + UtilityService.checkUndefined("status", response.data.status); + MsoService.checkValidStatus(response); + }; + + var updateLogFinalResponse = function(response) { + $scope.log = MsoService.getFormattedSingleGetOrchestrationRequestResponse(response) + + $scope.log; + UtilityService.checkUndefined("entity", response.data.entity); + UtilityService.checkUndefined("status", response.data.status); + MsoService.checkValidStatus(response); + }; + + var updateViewAfterInitialResponse = function(response) { + $scope.isCloseEnabled = true; + updateLog(response); + + _this.requestId = UtilityService.checkUndefined(FIELD.ID.REQUEST_ID, + UtilityService.checkUndefined(FIELD.ID.REQUEST_REFERENCES, + response.data.entity.requestReferences).requestId); + + $scope.percentProgress = 4; // Show "a little more" progress + $scope.status = FIELD.STATUS.IN_PROGRESS; + }; + + var init = function(msoType) { + switch(msoType) { + case COMPONENT.MSO_CREATE_REQ: + return MsoService.createConfigurationInstance(requestParams); + case COMPONENT.MSO_CHANGE_CONFIG_STATUS_REQ: + return MsoService.toggleConfigurationStatus(requestParams); + case COMPONENT.MSO_CHANGE_PORT_STATUS_REQ: + return MsoService.togglePortStatus(requestParams); + case COMPONENT.MSO_CREATE_REALATIONSHIP: + return MsoService.associatePnf(requestParams); + case COMPONENT.MSO_REMOVE_RELATIONSHIP: + return MsoService.dissociatePnf(requestParams); + case COMPONENT.MSO_ACTIVATE_SERVICE_REQ: + return MsoService.activateInstance(requestParams); + case COMPONENT.MSO_DEACTIVATE_SERVICE_REQ: + return MsoService.deactivateInstance(requestParams); + } + }; + + var successCallbackFunction = function(response) { + try { + updateViewAfterInitialResponse(response); + _this.timer = $timeout(getRequestStatus, PropertyService + .getMsoMaxPollingIntervalMsec()); + + $scope.instanceId = response.data.entity.instanceId; + if ($scope.instanceId == null) { + $scope.instanceId = response.data.entity.requestReferences.instanceId; + } + } catch (error) { + if ( response.data != null && response.data.status != null ) { + if (response.data.status > 299 || response.data.status < 200 ) { + // MSO returned an error + _this.isMsoError = true; + } + } + MsoService.showResponseContentError(error, showError); + } + }; + + var errorCallbackFunction = function (error) { + UtilityService.setHttpErrorHandler(function(error) { + $scope.isCloseEnabled = true; + _this.isMsoError = true; + showError(FIELD.ERROR.SYSTEM_FAILURE, UtilityService + .getHttpErrorMessage(error)); + }); + }; + + $scope.close = function() { + $uibModalInstance.dismiss('cancel'); + + if (_this.timer !== undefined) { + $timeout.cancel(_this.timer); + } + + if (angular.isFunction(_this.callbackFunction)) { + if ($scope.error === "") { + _this.callbackFunction({ + isSuccessful : true, + instanceId : $scope.instanceId + }); + } else { + _this.callbackFunction({ + isSuccessful : false + }); + } + } + }; + + _this.msoRequestType = msoType; + + init(_this.msoRequestType) + .then(function (response) { + successCallbackFunction(response); + }) + .catch(function (error) { + errorCallbackFunction(error); + }); +}; + +appDS2.controller("msoCommitModalController", [ "COMPONENT", "FIELD", "$scope", "$http", "$timeout", + "$window", "$log", "MsoService", "PropertyService", "UtilityService", "DataService", "$uibModalInstance", "msoType", "requestParams", "vidService", + msoCommitModalController ]); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/pnfSearchAssociationController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/pnfSearchAssociationController.js new file mode 100644 index 00000000..22a20abf --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/pnfSearchAssociationController.js @@ -0,0 +1,138 @@ +/*- +* ============LICENSE_START======================================================= +* VID +* ================================================================================ +* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +* ================================================================================ +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* ============LICENSE_END========================================================= +*/ + +/** + * The Instantiation (or View/Edit) Controller controls the instantiation/removal of + * deployable objects (Services, VNFs, VF-Modules, Networks, and Volume-Groups) + */ + +"use strict"; + +appDS2.controller("pnfSearchAssociationController", ["COMPONENT", "$log", "FIELD", "PARAMETER", "DataService", "CreationService", "$scope", "$window", "$location", "AaiService", "$uibModal", "UtilityService", "vidService", "$timeout", + function (COMPONENT, $log, FIELD, PARAMETER, DataService, CreationService, $scope, $window, $location, AaiService, $uibModal, UtilityService, vidService, $timeout) { + + var requestParams = {}; + + $scope.selectedMetadata = {}; + + $scope.serviceMetadataFields = []; + $scope.nodeTemplateFields = {}; + + $scope.pnfInstance= false; + $scope.notFound= false; + + $scope.pnfMetadata = []; + + $scope.errorMsg = FIELD.ERROR.INSTANCE_NAME_VALIDATE; + + $scope.modelName = DataService.getModelInfo(COMPONENT.VNF).modelCustomizationName; + + var handleGetParametersResponse = function(parameters) { + $scope.serviceMetadataFields = parameters.summaryList; + $scope.serviceMetadataFields.forEach(function (t, number) { + $scope.serviceMetadataFields[number].key = $scope.serviceMetadataFields[number].name.split(' ').join('') + }) + $scope.nodeTemplateFields = _.keyBy(parameters.userProvidedList, 'id'); + }; + + CreationService.initializeComponent(COMPONENT.VNF); + + CreationService.getParameters(handleGetParametersResponse); + + $scope.back = function() { + $window.history.back(); + }; + + $scope.searchPnf = function(pnfName) { + $scope.pnfInstance= false; + $scope.notFound=false; + + AaiService.getPnfByName(pnfName) + .then(function (response) { + $scope.pnfInstance = response.data; + requestParams.pnf = response.data.pnfName; + }) + .catch(function (error) { + $scope.pnfNameNotFound= pnfName; + $scope.notFound= true; + }); + + } + var modalInstance; + + $scope.associate = function() { + + requestParams.serviceModelInfo = vidService.getModel().service; + requestParams.attuuid = DataService.getLoggedInUserId(); + requestParams.instanceId = DataService.getServiceInstanceId(); + + modalInstance = $uibModal.open({ + templateUrl: 'app/vid/scripts/modals/mso-commit/mso-commit.html', + controller: "msoCommitModalController", + backdrop: false, + resolve: { + msoType: function () { + return COMPONENT.MSO_CREATE_REALATIONSHIP; + }, + requestParams: function () { + requestParams.callbackFunction = updateViewCallbackFunction; + return requestParams; + } + } + }) + + + }; + + var updateViewCallbackFunction = function(response) { + $scope.callbackResults = ""; + var color = FIELD.ID.COLOR_NONE; + $scope.callbackStyle = { + "background-color" : color + }; + + /* + * This 1/2 delay was only added to visually highlight the status + * change. Probably not needed in the real application code. + */ + $timeout(function() { + $scope.callbackResults = UtilityService.getCurrentTime() + + FIELD.STATUS.IS_SUCCESSFUL + response.isSuccessful; + if (response.isSuccessful) { + color = FIELD.ID.COLOR_8F8; + $scope.back(); + } else { + color = FIELD.ID.COLOR_F88; + } + $scope.callbackStyle = { + "background-color" : color + }; + }, 500); + }; + + + $scope.cancel = function() { + modalInstance.dismiss('cancel'); + }; + + + }]); + + diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/testEnvironmentsController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/testEnvironmentsController.js new file mode 100644 index 00000000..f5c3a0e0 --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/testEnvironmentsController.js @@ -0,0 +1,102 @@ +(function () { + 'use strict'; + + appDS2.controller("testEnvironmentsController", ["$uibModal", "TestEnvironmentsService", "$log", "$rootScope", "$scope", "COMPONENT", testEnvironmentsController]); + + function testEnvironmentsController($uibModal, TestEnvironmentsService, $log, $rootScope, $scope, COMPONENT) { + var vm = this; + + var toggleValue; + + var init = function() { + vm.loadAAIestEnvironments(); + }; + + vm.loadAAIestEnvironments = function() { + TestEnvironmentsService.loadAAIestEnvironments("VNF") + .then(function(response) { + vm.environments = response.operationalEnvironment; + vm.connectError = false; + if(!vm.environments.length) { + vm.emptyData = true; + } + }) + .catch(function (error) { + vm.connectError = error.message || "Unknown error"; + $log.error(error); + }); + }; + + function handleEnvActionComplete(result) { + if (result.isSuccessful) { + vm.loadAAIestEnvironments(); + } + $scope.popup.isVisible = false; + } + + vm.onTestEnvActivateClick = function(testEnv) { + var modalInstance = $uibModal.open({ + templateUrl: 'app/vid/scripts/modals/attach-test-env-manifest/attach-test-env-manifest.html', + controller: 'attachTestEnvManifestController', + controllerAs: 'vm', + resolve: {} + }); + + modalInstance.result.then(function (result) { + if (result) { + + var relatedEcompEnv = _.find(testEnv.relationshipList.relationship, { relatedTo: "operational-environment" }); + + var manifest = result; + var envId = testEnv.operationalEnvironmentId; + var relatedInstanceId = + _.find(relatedEcompEnv.relationshipData, {"relationshipKey": "operational-environment.operational-environment-id"}) + .relationshipValue; + var relatedInstanceName = + _.find(relatedEcompEnv.relatedToProperty, {"propertyKey": "operational-environment.operational-name"}) + .propertyValue; + var workloadContext = testEnv.workloadContext; + + $rootScope.$broadcast(COMPONENT.MSO_ACTIVATE_ENVIRONMENT, { + url: COMPONENT.MSO_ACTIVATE_ENVIRONMENT, + envId: envId, + relatedInstanceId: relatedInstanceId, + relatedInstanceName: relatedInstanceName, + workloadContext: workloadContext, + manifest: manifest, + callbackFunction: handleEnvActionComplete + }); + + } + }); + }; + + vm.onTestEnvDeactivateClick = function(testEnv) { + var envId = testEnv.operationalEnvironmentId; + $rootScope.$broadcast(COMPONENT.MSO_DEACTIVATE_ENVIRONMENT, { + url : COMPONENT.MSO_DEACTIVATE_ENVIRONMENT, + envId : envId, + callbackFunction: handleEnvActionComplete + }); + }; + + vm.isEnvActive = function(testEnv) { + return testEnv.operationalEnvironmentStatus==='Activate'; + }; + + vm.getEnvStatus = function (testEnv) { + return this.isEnvActive(testEnv) ? "Active" : "Inactive"; + }; + + vm.createNewTestEnvironment = function() { + var modalInstance = $uibModal.open({ + templateUrl: 'app/vid/scripts/modals/new-test-environment/new-test-environment.html', + controller: 'newTestEnvironmentModalController', + controllerAs: 'vm', + resolve: {} + }); + }; + + init(); + } +})(); \ No newline at end of file -- cgit 1.2.3-korg