From d350d5ac25c8df2846e4f0d9082cb4d364a17a83 Mon Sep 17 00:00:00 2001 From: "Sonsino, Ofir (os0695)" Date: Mon, 6 Aug 2018 16:14:59 +0300 Subject: UI Feature flagging support Change-Id: Ic2151dab6306c42364483e9064c01bab3dd7378b Issue-ID: VID-208 Signed-off-by: Sonsino, Ofir (os0695) --- .../webapp/WEB-INF/conf/dev.features.properties | 14 + .../main/webapp/WEB-INF/conf/features.properties | 11 + .../vid/scripts/constants/componentConstants.js | 30 +- .../app/vid/scripts/constants/fieldConstants.js | 10 +- .../app/vid/scripts/constants/vidConfiguration.js | 7 +- .../scripts/controller/InstantiationController.js | 2566 ++++++++++---------- .../scripts/controller/ServiceModelController.js | 136 +- .../controller/ServiceProxyConfigController.js | 3 + .../webapp/app/vid/scripts/controller/VidApp.js | 8 + .../scripts/controller/aaiSubscriberController.js | 452 +++- .../controller/change-management.controller.js | 103 +- .../scripts/controller/creationDialogController.js | 682 +++--- .../controller/deleteResumeDialogController.js | 109 +- .../scripts/controller/msoCommitModalController.js | 11 +- .../controller/pnfSearchAssociationController.js | 3 + .../controller/testEnvironmentsController.js | 2 +- .../change-managements-by-statuses.filter.js | 16 +- .../alert-change-management.html | 1 + .../cancel-pending-workflow.html | 4 +- .../change-management-manual-tasks.controller.js | 2 + .../vid/scripts/modals/css/manual-task-popup.css | 10 + .../failed-change-management.html | 3 +- .../in-progress-change-management.html | 1 + .../vid/scripts/modals/mso-commit/mso-commit.html | 2 +- .../new-change-management.controller.js | 58 +- .../new-change-management.html | 6 +- .../new-test-environment/new-test-environment.html | 2 +- .../webapp/app/vid/scripts/services/aaiService.js | 109 +- .../webapp/app/vid/scripts/services/asdcService.js | 63 +- .../app/vid/scripts/services/creationService.js | 11 +- .../webapp/app/vid/scripts/services/dataService.js | 12 + .../vid/scripts/services/deleteResumeService.js | 23 +- .../app/vid/scripts/services/detailsService.js | 142 +- .../webapp/app/vid/scripts/services/msoService.js | 72 +- .../app/vid/scripts/services/utilityService.js | 53 +- .../vid/scripts/view-models/change-management.html | 36 +- .../app/vid/scripts/view-models/creationDialog.htm | 68 +- .../app/vid/scripts/view-models/detailsDialog.htm | 4 +- .../webapp/app/vid/scripts/view-models/iframe.htm | 1 + .../app/vid/scripts/view-models/iframeDialog.htm | 6 + .../app/vid/scripts/view-models/instantiate.htm | 708 ++++-- .../scripts/view-models/previousVersionDialog.htm | 8 +- .../app/vid/scripts/view-models/serviceModels.htm | 36 +- 43 files changed, 3274 insertions(+), 2330 deletions(-) create mode 100644 vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties create mode 100644 vid-app-common/src/main/webapp/WEB-INF/conf/features.properties create mode 100644 vid-app-common/src/main/webapp/app/vid/scripts/modals/css/manual-task-popup.css create mode 100644 vid-app-common/src/main/webapp/app/vid/scripts/view-models/iframe.htm create mode 100644 vid-app-common/src/main/webapp/app/vid/scripts/view-models/iframeDialog.htm (limited to 'vid-app-common/src/main/webapp') diff --git a/vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties b/vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties new file mode 100644 index 00000000..8ff0db2a --- /dev/null +++ b/vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties @@ -0,0 +1,14 @@ +FLAG_ASYNC_INSTANTIATION = true +FLAG_ASYNC_JOBS = true +FLAG_REGION_ID_FROM_REMOTE = true +CREATE_INSTANCE_TEST = false +EMPTY_DRAWING_BOARD_TEST = false +FLAG_ADVANCED_PORTS_FILTER = true +FLAG_ADD_MSO_TESTAPI_FIELD = true +FLAG_UNASSIGN_SERVICE = true +FLAG_COLLECTION_RESOURCE_SUPPORT = true +FLAG_NETWORK_TO_ASYNC_INSTANTIATION = true +FLAG_SERVICE_MODEL_CACHE = true +FLAG_SHOW_ASSIGNMENTS = true +FLAG_SHOW_VERIFY_SERVICE=false +FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD = false diff --git a/vid-app-common/src/main/webapp/WEB-INF/conf/features.properties b/vid-app-common/src/main/webapp/WEB-INF/conf/features.properties new file mode 100644 index 00000000..de466bea --- /dev/null +++ b/vid-app-common/src/main/webapp/WEB-INF/conf/features.properties @@ -0,0 +1,11 @@ +# features.properties +# ------------------- + +# This file is, generally, empty. + +# Configure `featureFlags.filename` in system.properties to use +# one of the ready-made sets: + +# - featureFlags.filename = ci.features.properties +# - featureFlags.filename = ist.features.properties +# - featureFlags.filename = e2e.features.properties diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js b/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js index b08b2b16..e3edf830 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js @@ -29,6 +29,7 @@ appDS2 CLOUD_REGION_ID : "cloudRegionID", COMPONENT_STATUS : "ComponentStatus", CREATE_COMPONENT : "createComponent", + IFRAME_DIALOG : "iframeDialog", DELETE_RESUME_COMPONENT : "deleteResumeComponent", DELETE:"Delete", RESUME:"Resume", @@ -46,6 +47,7 @@ appDS2 MODEL_VERSION_1 : "1", MSO_CREATE_REQ : "createInstance", MSO_DELETE_REQ : "deleteInstance", + MSO_DELETE_CONFIGURATION_REQ : 'deleteConfiguration', MSO_CHANGE_CONFIG_STATUS_REQ: "changeConfigurationStatus", MSO_CHANGE_PORT_STATUS_REQ: "changePortStatus", MSO_CREATE_ENVIRONMENT: "createEnvironmentInstance", @@ -81,7 +83,6 @@ appDS2 VNF_TYPE : "vnfType", VOLUME_GROUP : "volumeGroup", IS_PERMITTED: "is-permitted", - RESUME_STATUS: "PendingActivation", PNF : "pnf", // IDs CIDR_MASK_1 : "255.255.255.000", @@ -123,6 +124,8 @@ appDS2 AAI_GET_TENANTS : "aai_get_tenants/", AAI_SUB_DETAILS_PATH : "aai_sub_details/", AAI_GET_VERSION_BY_INVARIANT_ID:"aai_get_version_by_invariant_id/", + AAI_GET_PORT_MIRRORING_CONFIGS_DATA : "aai_getPortMirroringConfigsData", + AAI_GET_PORT_MIRRORING_SOURCE_PORTS : "aai_getPortMirroringSourcePorts", SEARCH_SERVICE_INSTANCES:"search_service_instances", AAI_GET_VNF_DATA_PATH: "aai_get_vnf_data/", AAI_GET_VNF_BY_CUSTOMERID_AND_SERVICETYPE: "get_vnf_data_by_globalid_and_service_type/", @@ -130,6 +133,7 @@ appDS2 AAI_SUB_VIEWEDIT_PATH : "aai_sub_viewedit", AAI_GET_VNF_INFO : "aai_get_vnf_information", AAI_GET_PNF_INSTANCE: "aai_get_service_instance_pnfs", + AAI_GET_CR_INSTANCE: "aai_get_network_collection_details", AAI_GET_VNF_INSTANCES_LIST: "aai_get_vnf_instances", AAI_GET_PNF_INSTANCES_LIST: "aai_get_pnf_instances", AAI_GET_BY_URI: "aai_get_by_uri/", @@ -146,6 +150,7 @@ appDS2 WORKFLOW: "workflow", GET_TIME_SLOTS:"get_time_slots", SUBMIT_VNF_CHANGE_TIMESLOTS:"submit_vnf_change_timeslots", + AAI_GET_INSTANCE_GROUPS_BY_VNF_INSTANCE_ID_PATH: 'aai_get_instance_groups_by_vnf_instance_id', FORWARD_SLASH : "/", GET_SYSTEM_PROP_VNF_PROV_STATUS_PATH : "get_system_prop_vnf_prov_status", @@ -174,14 +179,18 @@ appDS2 SERVICES_PATH : "rest/models/services/", SERVICETYPE_SUB_PATH : "&serviceType=", SERVICEINSTANCEID_SUB_PATH : "&serviceInstanceId=", + MODELVERSIONID_SUB_PATH : "&aaiModelVersionId=", SERVICEMODELS_INSTANCES_SERVICES_PATH : "serviceModels.htm#/instances/services", SERVICEMODELS_MODELS_SERVICES_PATH : "serviceModels.htm#/models/services", SUBDETAILS_SELECTEDSUBSCRIBER : "#subdetails?selectedSubscriber=", SUBSCRIBERNAME_SUB_PATH : "&subscriberName=", WELCOME_PATH : "welcome.htm", IS_PERMITTED_SUB_PATH: "&isPermitted=", + SERVICE_POPUP_IFRAME_URL: "app/ui/#/servicePopup?serviceModelId=", + SUB_INTERFACE_POPUP_IFRAME_URL: "app/ui/#/vlan?", + VERIFY_SERVICE_URL: "rest/models/services/verifyService", - //Test Environment Urls: + //Test Environment Urls: OPERATIONAL_ENVIRONMENT_CREATE : "operationalEnvironment/create", OPERATIONAL_ENVIRONMENT_DEACTIVATE : "operationalEnvironment/deactivate?operationalEnvironment=", OPERATIONAL_ENVIRONMENT_ACTIVATE : "operationalEnvironment/activate?operationalEnvironment=", @@ -196,7 +205,7 @@ appDS2 INSTANTIATE_URL : "app/vid/scripts/view-models/instantiate.htm", SERVICE_MODELS : "app/vid/scripts/view-models/serviceModels.htm", - + ACTIVATE_SERVICE_STATUSES: ['created', 'pendingdelete', 'pending-delete', 'assigned'], FULL_NAME_MAP : { "model-invariant-id" : "Model ID", @@ -223,7 +232,18 @@ appDS2 update: "update", replace: "replace", vnfScaleOut: "VNF Scale Out" - } + }, + + FEATURE_FLAGS:{ + FLAG_ASYNC_INSTANTIATION : "FLAG_ASYNC_INSTANTIATION", + FLAG_VLAN_TAGGING_VIEW_EDIT: "FLAG_VLAN_TAGGING_VIEW_EDIT", + FLAG_NETWORK_TO_ASYNC_INSTANTIATION : "FLAG_NETWORK_TO_ASYNC_INSTANTIATION", + FLAG_REGION_ID_FROM_REMOTE : "FLAG_REGION_ID_FROM_REMOTE", + FLAG_ADD_MSO_TESTAPI_FIELD : "FLAG_ADD_MSO_TESTAPI_FIELD", + FLAG_COLLECTION_RESOURCE_SUPPORT : "FLAG_COLLECTION_RESOURCE_SUPPORT", + FLAG_SHOW_ASSIGNMENTS: "FLAG_SHOW_ASSIGNMENTS", + FLAG_SHOW_VERIFY_SERVICE: "FLAG_SHOW_VERIFY_SERVICE" + } }; -})()) +})()); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/constants/fieldConstants.js b/vid-app-common/src/main/webapp/app/vid/scripts/constants/fieldConstants.js index fc051d02..544a8114 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/constants/fieldConstants.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/constants/fieldConstants.js @@ -119,6 +119,8 @@ appDS2.factory("FIELD", ["PARAMETER", function (PARAMETER) { VF_MODULES: "vfModules", VF_MODULE_ID: "vf-module-id", VF_MODULE_NAME: "vf-module-name", + VF_MODULE_MODEL_CUSTOMIZATION_ID: "vf-module-model-customization-id", + VF_MODULE_MODEL_VERSION_ID: "vf-module-model-version-id", VID: "VID", VNF_ID: "vnf-id", VNF_NAME: "vnf-name", @@ -140,10 +142,9 @@ appDS2.factory("FIELD", ["PARAMETER", function (PARAMETER) { CONFIGURATION_NAME: "configuration-name", CONFIGURATION_TYPE: "configuration-type", CONFIGURATION_ID: "configuration-id", - PORT: "l-interface", - PORT_ID: "interface-id", - PORT_NAME: "interface-name", - PORT_MIRRORED: "is-port-mirrored" + PORT_ID: "interfaceId", + PORT_NAME: "interfaceName", + PORT_MIRRORED: "isPortMirrored" }; var KEY = { @@ -270,6 +271,7 @@ appDS2.factory("FIELD", ["PARAMETER", function (PARAMETER) { AAI_ACTIVE: "Active", AAI_INACTIVE: "Inactive", AAI_CREATED: "Created", + AAI_DELETE: "Deleted", AAI_ENABLED: "Enabled", AAI_DISABLED: "Disabled" }; diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/constants/vidConfiguration.js b/vid-app-common/src/main/webapp/app/vid/scripts/constants/vidConfiguration.js index 84cb5ad7..f71213bf 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/constants/vidConfiguration.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/constants/vidConfiguration.js @@ -85,11 +85,11 @@ appDS2.constant("VIDCONFIGURATION", (function() { /* * Max number of times that VID will poll MSO for a given request status */ - var MSO_MAX_POLLS = 10; + var MSO_MAX_POLLS = 1440; /* * Number of msecs that VID will wait between MSO polls. */ - var MSO_POLLING_INTERVAL_MSECS = 10000; + var MSO_POLLING_INTERVAL_MSECS = 200; var SCHEDULER_POLLING_INTERVAL_MSECS = 10000; @@ -109,6 +109,8 @@ appDS2.constant("VIDCONFIGURATION", (function() { var SCALE_OUT_CONTROLLERS = ["", "SDNC", "APPC"]; + var SDNC_SHOW_ASSIGNMENTS_URL = "https://sdnc.api.simpledemo.onap.org:8448/configAdapter/index#/resource_manager/"; + return { ASDC_MODEL_STATUS : ASDC_MODEL_STATUS, MSO_MAX_POLLS : MSO_MAX_POLLS, @@ -122,6 +124,7 @@ appDS2.constant("VIDCONFIGURATION", (function() { COMPONENT_LIST_NAMED_QUERY_ID : COMPONENT_LIST_NAMED_QUERY_ID, SCHEDULER_CALLBACK_URL: SCHEDULER_CALLBACK_URL, SCHEDULER_PORTAL_URL: SCHEDULER_PORTAL_URL, + SDNC_SHOW_ASSIGNMENTS_URL: SDNC_SHOW_ASSIGNMENTS_URL, SCALE_OUT_CONTROLLERS: SCALE_OUT_CONTROLLERS }; })()) 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 f1dc384c..1b3ab09c 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 @@ -23,35 +23,38 @@ * deployable objects (Services, VNFs, VF-Modules, Networks, and Volume-Groups) */ (function () { - "use strict"; + "use strict"; - appDS2.requires.push('ui.tree'); + appDS2.requires.push('ui.tree'); - 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(); + appDS2.controller("InstantiationController", function ($scope, $route, $location, $timeout, COMPONENT, VIDCONFIGURATION, FIELD, DataService, PropertyService, UtilityService, VnfService, $http, vidService, AaiService, PnfService, CrService, AsdcService, $q, featureFlags, _, CreationService, $window) { + $scope.popup = new Object(); + $scope.defaultBaseUrl = ""; + $scope.responseTimeoutMsec = 60000; + $scope.properties = UtilityService.getProperties(); $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.isPermitted = $location.search().isPermitted == "true"; + $scope.STATUS_CONSTANTS = FIELD.STATUS; $scope.pnfs = [];// PNF data init; - - $scope.init = function() { + $scope.collectionResource = {}; + $scope.collections = []; + $scope.networks = []; + $scope.isCR = false; + $scope.isVFC = false; + $scope.init = function () { /* * These 2 statements should be included in non-test code. */ - // takes a default value, retrieves the prop value from the file system and sets it - var msecs = PropertyService.retrieveMsoMaxPollingIntervalMsec(); - PropertyService.setMsoMaxPollingIntervalMsec(msecs); - - // takes a default value, retrieves the prop value from the file system and sets it - var polls = PropertyService.retrieveMsoMaxPolls(); - PropertyService.setMsoMaxPolls(polls); - - PropertyService.setServerResponseTimeoutMsec(30000); + // takes a default value, retrieves the prop value from the file system and sets it + var msecs = PropertyService.retrieveMsoMaxPollingIntervalMsec(); + PropertyService.setMsoMaxPollingIntervalMsec(msecs); + + // takes a default value, retrieves the prop value from the file system and sets it + var polls = PropertyService.retrieveMsoMaxPolls(); + PropertyService.setMsoMaxPolls(polls); + + PropertyService.setServerResponseTimeoutMsec(30000); /* * Common parameters that shows an example of how the view edit screen @@ -72,273 +75,219 @@ //PropertyService.setMsoBaseUrl("testmso"); - $scope.convertModel = function(asdcModel) { - if (!asdcModel) return undefined; - var convertedAsdcModel = UtilityService.convertModel(asdcModel); - return convertedAsdcModel; - }; - - $scope.service = { - "model": vidService.getModel(), - "convertedModel": $scope.convertModel(vidService.getModel()), - "instance": vidService.getInstance() - }; + $scope.convertModel = function (asdcModel) { + if (!asdcModel) return undefined; + var convertedAsdcModel = UtilityService.convertModel(asdcModel); + return convertedAsdcModel; + }; + + $scope.prepareScopeWithModel = function () { + // skip if no model + if (!vidService.getModel()) return; - preparePnfs(); + $scope.service = { + "model": vidService.getModel(), + "convertedModel": $scope.convertModel(vidService.getModel()), + "instance": vidService.getInstance() + }; - function preparePnfs(){ - var serviceInstance = { + $scope.isCR = !_.isEmpty($scope.service.model.collectionResource) && featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_COLLECTION_RESOURCE_SUPPORT); + if ($scope.isCR) + prepareCr(); + else + preparePnfs(); + }; + + function preparePnfs() { + var serviceInstance = { globalCustomerId: $location.search().subscriberId, serviceType: $location.search().serviceType, serviceInstanceId: $location.search().serviceInstanceId - }; + }; - _setPnf(serviceInstance).then(function(data){ + _setPnf(serviceInstance).then(function (data) { $scope.pnfs = data; }); - } - - - $scope.returnVfModules = function (vnfInstance) { - - var svcModel = $scope.service.convertedModel; - //var vnfModelInvariantUuid = vnfInstance[FIELD.ID.MODEL_INVAR_ID]; - var vnfModelVersionId = vnfInstance[FIELD.ID.MODEL_VERSION_ID]; // model uuid - var vnfModelCustomizationUuid = vnfInstance[FIELD.ID.MODEL_CUSTOMIZATION_ID]; - - var vnfModel = null; - - if ( (!($scope.isObjectEmpty(svcModel))) && ( !($scope.isObjectEmpty(svcModel.vnfs) ) ) ) { - if ( (svcModel.isNewFlow) && (vnfModelCustomizationUuid != null ) ) { - vnfModel = svcModel.vnfs[vnfModelCustomizationUuid]; - if ( !($scope.isObjectEmpty(vnfModel.vfModules) ) ) { - //console.log ("vnfModel.vfModules: "); console.log (JSON.stringify(vnfModel.vfModules, null, 4)); - return (vnfModel.vfModules); - } - } - else { - // old flow - if ( vnfModelVersionId != null ) { - vnfModel = svcModel.vnfs[vnfModelVersionId]; - if ( !($scope.isObjectEmpty(vnfModel.vfModules) ) ) { - //console.log ("vnfModel.vfModules: "); console.log (JSON.stringify(vnfModel.vfModules, null, 4)); - return (vnfModel.vfModules); - } - } - } - - } - return null; - } - $scope.hasVfModules = function (vnfInstance) { - if ($scope.returnVfModules(vnfInstance) != null ){ - return true; - } - return false; - } - $scope.returnVolumeGroups = function (vnfInstance) { - - var svcModel = $scope.service.convertedModel; - - //var vnfModelInvariantUuid = vnfInstance[FIELD.ID.MODEL_INVAR_ID]; - var vnfModelVersionId = vnfInstance[FIELD.ID.MODEL_VERSION_ID]; - var vnfModelCustomizationUuid = vnfInstance[FIELD.ID.MODEL_CUSTOMIZATION_ID]; - - var vnfModel = null; - - if ( (!($scope.isObjectEmpty(svcModel))) && ( !($scope.isObjectEmpty(svcModel.vnfs) ) ) ) { - if ( (svcModel.isNewFlow) && (vnfModelCustomizationUuid != null ) ) { - vnfModel = svcModel.vnfs[vnfModelCustomizationUuid]; - if ( !($scope.isObjectEmpty(vnfModel.volumeGroups) ) ) { - //console.log ("vnfModel.volumeGroups: "); console.log (JSON.stringify(vnfModel.volumeGroups, null, 4)); - return (vnfModel.volumeGroups); - } - } - else { - // old flow - if ( vnfModelVersionId != null ) { - vnfModel = svcModel.vnfs[vnfModelVersionId]; - if ( !($scope.isObjectEmpty(vnfModel.volumeGroups) ) ) { - //console.log ("vnfModel.vfModules: "); console.log (JSON.stringify(vnfModel.volumeGroups, null, 4)); - return (vnfModel.volumeGroups); - } - } - } - - } - return null; - } - $scope.hasVolumeGroups = function (vnfInstance) { - if ($scope.returnVolumeGroups(vnfInstance) != null ){ - return true; - } - return false; - } - $scope.deleteNetwork = function(serviceObject, network) { - - console.log("Removing Network " + network.name); - - //Send delete network request to MSO - - //var networks = this.service.instance.networks; - - //networks.splice(networks.indexOf(network), 1); - - //Retrieve updated data from A&AI - var serviceInstance = serviceObject.object; - var svcModel = $scope.service.convertedModel; - var netModel; - DataService.setInventoryItem(network.object); - // set model default and override later if found - DataService.setModelInfo(COMPONENT.NETWORK, {}); - - if ( network.object != null ) { - - //var netModelInvariantUuid = network.object[FIELD.ID.MODEL_INVAR_ID]; - var netModelVersionId = network.object[FIELD.ID.MODEL_VERSION_ID]; // model uuid - var netModelCustomizationUuid = network.object[FIELD.ID.MODEL_CUSTOMIZATION_ID]; - - if ( (!($scope.isObjectEmpty(svcModel))) && ( !($scope.isObjectEmpty(svcModel.networks) ) ) ) { - if ( (svcModel.isNewFlow) && (UtilityService.hasContents(netModelCustomizationUuid) ) ) { - netModel = svcModel.networks[netModelCustomizationUuid]; - } - else { - - if ( UtilityService.hasContents(netModelVersionId) ) { - netModel = svcModel.networks[netModelVersionId]; - } - - } - } - } - if (!($scope.isObjectEmpty(netModel) ) ) { - DataService.setModelInfo(COMPONENT.NETWORK, { - "modelInvariantId": netModel.invariantUuid, - "modelVersion": netModel.version, - "modelNameVersionId": netModel.uuid, - "modelCustomizationName": netModel.modelCustomizationName, - "customizationUuid": netModel.customizationUuid, - "modelName": netModel.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.setNetworkInstanceId(network.object[FIELD.ID.NETWORK_ID]); - - $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, { - componentId : COMPONENT.NETWORK, - callbackFunction : deleteOrResumeCallback, - dialogMethod: COMPONENT.DELETE - }); - }; - - $scope.deleteService = function(serviceObject) { - - var serviceInstance = serviceObject.object; - - console.log("Removing Service " + $scope.service.instance.name); - - if ( $scope.isMacro() ) { - DataService.setALaCarte (false); - } - else { - DataService.setALaCarte (true); - } - DataService.setMacro($scope.isMacro()); - DataService.setInventoryItem(serviceInstance); - setCurrentServiceModelInfoFromScope(); - - - DataService.setSubscriberName(serviceObject[FIELD.ID.SUBSCRIBER_NAME]); - DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]); - DataService.setServiceInstanceId(serviceInstance[FIELD.ID.SERVICE_INSTANCE_ID]); - - DataService.setGlobalCustomerId(serviceObject[COMPONENT.GLOBAL_CUSTOMER_ID]); - DataService.setServiceInstanceName($scope.service.instance.name); - - DataService.setServiceName($scope.service.model.service.name); - - DataService.setServiceUuid($scope.service.model.service.uuid); - - $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, { - componentId : COMPONENT.SERVICE, - callbackFunction : deleteServiceInstanceCallbackFunction, - dialogMethod: COMPONENT.DELETE - }); - - }; + } - function populate_popup_vfModule(serviceObject, vfModule, vnf){ - var serviceInstance = serviceObject.object; - DataService.setInventoryItem(vfModule.object); + function prepareCr() { + var serviceInstance = { + globalCustomerId: $location.search().subscriberId, + serviceType: $location.search().serviceType, + serviceInstanceId: $location.search().serviceInstanceId + }; - var svcModel = $scope.service.convertedModel; + _setCr(serviceInstance).then(function (data) { + $scope.collectionResource = data; + $scope.collections.push($scope.collectionResource.collection); + $scope.networks.push($scope.collectionResource.networks[0]); + }); + } - //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 = ""; - } + $scope.returnVfModules = function (vnfInstance) { - var vnfModel = null; - var vfModuleModel = null; + var svcModel = $scope.service.convertedModel; + //var vnfModelInvariantUuid = vnfInstance[FIELD.ID.MODEL_INVAR_ID]; + var vnfModelVersionId = vnfInstance[FIELD.ID.MODEL_VERSION_ID]; // model uuid + var vnfModelCustomizationUuid = vnfInstance[FIELD.ID.MODEL_CUSTOMIZATION_ID]; - DataService.setModelInfo(COMPONENT.VF_MODULE, { - "modelInvariantId": "", - "modelVersion": "", - "modelNameVersionId": "", - "modelCustomizationName": "", - "customizationUuid": "", - "modelName": "", - "inputs": "" - }); + var vnfModel = null; - if ( (!($scope.isObjectEmpty(svcModel))) && ( !($scope.isObjectEmpty(svcModel.vnfs) ) ) ) { - if ( (svcModel.isNewFlow) && (vnfModelCustomizationUuid != null ) ) { + if ((!($scope.isObjectEmpty(svcModel))) && (!($scope.isObjectEmpty(svcModel.vnfs)))) { + if ((svcModel.isNewFlow) && (vnfModelCustomizationUuid != null)) { vnfModel = svcModel.vnfs[vnfModelCustomizationUuid]; + if (vnfModel !== undefined) { + if (!($scope.isObjectEmpty(vnfModel.vfModules))) { + //console.log ("vnfModel.vfModules: "); console.log (JSON.stringify(vnfModel.vfModules, null, 4)); + return (vnfModel.vfModules); + } + } + } + else { + // old flow + if (vnfModelVersionId != null) { + vnfModel = svcModel.vnfs[vnfModelVersionId]; + if (vnfModel !== undefined) { + if (!($scope.isObjectEmpty(vnfModel.vfModules))) { + //console.log ("vnfModel.vfModules: "); console.log (JSON.stringify(vnfModel.vfModules, null, 4)); + return (vnfModel.vfModules); + } + } + } + } - var vfModuleCustomizationUuid = vfModule.object[FIELD.ID.MODEL_CUSTOMIZATION_ID]; - if ( !($scope.isObjectEmpty(vnfModel.vfModules) ) && UtilityService.hasContents(vfModuleCustomizationUuid) ) { + } + return null; + } + $scope.hasVfModules = function (vnfInstance) { + if ($scope.returnVfModules(vnfInstance) != null) { + return true; + } + return false; + } + $scope.returnVolumeGroups = function (vnfInstance) { - vfModuleModel = vnfModel.vfModules[vfModuleCustomizationUuid]; + var svcModel = $scope.service.convertedModel; + + //var vnfModelInvariantUuid = vnfInstance[FIELD.ID.MODEL_INVAR_ID]; + var vnfModelVersionId = vnfInstance[FIELD.ID.MODEL_VERSION_ID]; + var vnfModelCustomizationUuid = vnfInstance[FIELD.ID.MODEL_CUSTOMIZATION_ID]; + var vnfModel = null; + + if ((!($scope.isObjectEmpty(svcModel))) && (!($scope.isObjectEmpty(svcModel.vnfs)))) { + if ((svcModel.isNewFlow) && (vnfModelCustomizationUuid != null)) { + vnfModel = svcModel.vnfs[vnfModelCustomizationUuid]; + if (vnfModel !== undefined) { + + if (!($scope.isObjectEmpty(vnfModel.volumeGroups))) { + //console.log ("vnfModel.volumeGroups: "); console.log (JSON.stringify(vnfModel.volumeGroups, null, 4)); + return (vnfModel.volumeGroups); + } } } else { // old flow - if (vnfModelVersionId != null ) { + if (vnfModelVersionId != null) { vnfModel = svcModel.vnfs[vnfModelVersionId]; + if (!($scope.isObjectEmpty(vnfModel.volumeGroups))) { + //console.log ("vnfModel.vfModules: "); console.log (JSON.stringify(vnfModel.volumeGroups, null, 4)); + return (vnfModel.volumeGroups); + } } - //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": "" - }); } + + } + return null; + } + $scope.hasVolumeGroups = function (vnfInstance) { + if ($scope.returnVolumeGroups(vnfInstance) != null) { + return true; + } + return false; + } + $scope.deleteNetwork = function (serviceObject, network) { + + console.log("Removing Network " + network.name); + + //Send delete network request to MSO + + //var networks = this.service.instance.networks; + + //networks.splice(networks.indexOf(network), 1); + + //Retrieve updated data from A&AI + var serviceInstance = serviceObject.object; + + setCurrentNetworkModelInfoFromScope(network); + + DataService.setInventoryItem(network.object); + + 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.setNetworkInstanceId(network.object[FIELD.ID.NETWORK_ID]); + + $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, { + componentId: COMPONENT.NETWORK, + callbackFunction: deleteOrResumeCallback, + dialogMethod: COMPONENT.DELETE + }); + }; + + $scope.deleteService = function (serviceObject, serviceOrchestrationStatus) { + + var serviceInstance = serviceObject.object; + + console.log("Removing Service " + $scope.service.instance.name); + + if ($scope.isMacro()) { + DataService.setALaCarte(false); + } + else { + DataService.setALaCarte(true); + } + DataService.setMacro($scope.isMacro()); + DataService.setInventoryItem(serviceInstance); + setCurrentServiceModelInfoFromScope(); + + + DataService.setSubscriberName(serviceObject[FIELD.ID.SUBSCRIBER_NAME]); + DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]); + DataService.setServiceInstanceId(serviceInstance[FIELD.ID.SERVICE_INSTANCE_ID]); + + DataService.setGlobalCustomerId(serviceObject[COMPONENT.GLOBAL_CUSTOMER_ID]); + DataService.setServiceInstanceName($scope.service.instance.name); + + DataService.setServiceName($scope.service.model.service.name); + + DataService.setServiceUuid($scope.service.model.service.uuid); + + $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, { + componentId: COMPONENT.SERVICE, + callbackFunction: deleteServiceInstanceCallbackFunction, + dialogMethod: COMPONENT.DELETE, + serviceStatus: serviceOrchestrationStatus + }); + + }; + + function populate_popup_vfModule(serviceObject, vfModule, vnf) { + var serviceInstance = serviceObject.object; + + DataService.setInventoryItem(vfModule.object); + + setCurrentVfModuleModelInfoFromScope(vnf, vfModule); + var vfModuleInstanceID = vfModule.object[FIELD.ID.VF_MODULE_ID]; + if (vfModuleInstanceID == null) { + vfModuleInstanceID = ""; } DataService.setVnfInstanceId(vnf.object[FIELD.ID.VNF_ID]); @@ -354,25 +303,25 @@ DataService.setServiceName($scope.service.model.service.name); DataService.setServiceUuid($scope.service.model.service.uuid); - } + } - $scope.deleteVfModule = function(serviceObject, vfModule, vnf) { + $scope.deleteVfModule = function (serviceObject, vfModule, vnf) { - console.log("Removing VF-Module " + vfModule.name); + console.log("Removing VF-Module " + vfModule.name); populate_popup_vfModule(serviceObject, vfModule, vnf); - - $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, { - componentId : COMPONENT.VF_MODULE, - callbackFunction : deleteOrResumeCallback, + + $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, { + componentId: COMPONENT.VF_MODULE, + callbackFunction: deleteOrResumeCallback, dialogMethod: COMPONENT.DELETE - }); - - return; + }); + + return; - }; + }; - function setCurrentServiceModelInfoFromScope(){ + function setCurrentServiceModelInfoFromScope() { DataService.setModelInfo(COMPONENT.SERVICE, { "modelInvariantId": $scope.service.model.service.invariantUuid, "modelVersion": $scope.service.model.service.version, @@ -380,21 +329,21 @@ "modelName": $scope.service.model.service.name, "inputs": "" }); - }; + }; - function setCurrentVNFModelInfo(vnf){ + 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]; + if ((!($scope.isObjectEmpty(svcModel))) && (!($scope.isObjectEmpty(svcModel.vnfs)))) { + if ((svcModel.isNewFlow) && (vnfModelCustomizationUuid != null)) { + vnfModel = svcModel.vnfs[vnfModelCustomizationUuid]; } else { - vnfModel = svcModel.vnfs[vnfModelVersionId]; + vnfModel = svcModel.vnfs[vnfModelVersionId]; } - if ( !($scope.isObjectEmpty(vnfModel) ) ) { + if (!($scope.isObjectEmpty(vnfModel))) { DataService.setModelInfo(COMPONENT.VNF, { "modelInvariantId": vnfModel.invariantUuid, @@ -409,972 +358,1145 @@ } + } - } - - $scope.deleteVnf = function(serviceObject, vnf) { - console.log("Removing VNF " + vnf.name); - - var serviceInstance = serviceObject.object; - var svcModel = $scope.service.convertedModel; - DataService.setInventoryItem(vnf.object); - - /*var vnftype = vnf.object['vnf-type']; - if (vnftype == null) - vnftype = ""; - else - { - var n = vnftype.search("/"); - if (n >= 0) - vnftype = vnftype.substring(n+1); - }*/ - - var svcModel = $scope.service.convertedModel; - var vnfModelInvariantUuid = null; - var vnfModelVersion = null; - var vnfModelCustomizationUuid = null; - var vnfModel = null; - var vnfModelVersionId = null; - - vnfModelInvariantUuid = vnf.object[FIELD.ID.MODEL_INVAR_ID]; - vnfModelVersionId = vnf.object[FIELD.ID.MODEL_VERSION_ID]; - vnfModelCustomizationUuid = vnf.object[FIELD.ID.MODEL_CUSTOMIZATION_ID]; - - DataService.setModelInfo(COMPONENT.VNF, { - "modelInvariantId": vnfModelInvariantUuid, - "modelVersion": "", - "modelNameVersionId": vnfModelVersionId, - "modelCustomizationName": "", - "customizationUuid": vnfModelCustomizationUuid, - "modelName": "", - "inputs": "" - }); - - if ( (!($scope.isObjectEmpty(svcModel))) && ( !($scope.isObjectEmpty(svcModel.vnfs) ) ) ) { - if ( (svcModel.isNewFlow) && (vnfModelCustomizationUuid != null ) ) { - vnfModel = svcModel.vnfs[vnfModelCustomizationUuid]; - } - else { - vnfModel = svcModel.vnfs[vnfModelVersionId]; - } - //console.log ( "vnf models: "); console.log ( JSON.stringify ($scope.service.convertedModel.vnfs, null, 4) ); - 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": "" - }); - } - } - - DataService.setVnfInstanceId(vnf.object[FIELD.ID.VNF_ID]); - - 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.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, { - componentId : COMPONENT.VNF, - callbackFunction : deleteOrResumeCallback, - dialogMethod: COMPONENT.DELETE - }); - - }; - - - - $scope.deleteVolumeGroup = function(serviceObject, vnf, vfModule, volumeGroup) { - - console.log("Removing Volume Group " + volumeGroup.name); - var haveModel = false; - var svcModel = $scope.service.convertedModel; - - var vnfModelInvariantUuid = null; - var vnfModelVersion = null; - var vnfModelCustomizationUuid = null; - var vnfModel = null; - var vnfModelVersionId = null; - - vnfModelInvariantUuid = vnf.object[FIELD.ID.MODEL_INVAR_ID]; - vnfModelVersionId = vnf.object[FIELD.ID.MODEL_VERSION_ID]; - vnfModelCustomizationUuid = vnf.object[FIELD.ID.MODEL_CUSTOMIZATION_ID]; - - DataService.setModelInfo(COMPONENT.VOLUME_GROUP, { - "modelInvariantId": "", - "modelVersion": "", - "modelNameVersionId": "", - "modelCustomizationName": "", - "customizationUuid": "", - "modelName": "", - "inputs": "" - }); - - if ( (!($scope.isObjectEmpty(svcModel))) && ( !($scope.isObjectEmpty(svcModel.vnfs) ) ) ) { - if ( (svcModel.isNewFlow) && (vnfModelCustomizationUuid != null ) ) { - vnfModel = svcModel.vnfs[vnfModelCustomizationUuid]; - } - else { - vnfModel = svcModel.vnfs[vnfModelVersionId]; - } - } - - - // volume groups don't have model-invariant-id/version in a&ai. - // Their model-invariant-id/version is the one for the associated vfModule - - var vfModuleInvariantUuid = vfModule.object[FIELD.ID.MODEL_INVAR_ID]; - var vfModuleModelVersionId = vfModule.object[FIELD.ID.MODEL_VERSION_ID]; - var vfModuleCustomizationUuid = vfModule.object[FIELD.ID.MODEL_CUSTOMIZATION_ID]; - var volGroupModel = null; - - if ( !($scope.isObjectEmpty(vnfModel.volumeGroups) ) ) { - if ( ( !($scope.isObjectEmpty(vnfModel) ) ) && ( !($scope.isObjectEmpty(vnfModel.volumeGroups) ) ) ) { - if ( (svcModel.isNewFlow) && (UtilityService.hasContents(vfModuleCustomizationUuid) ) ){ - volGroupModel = vnfModel.volumeGroups[vfModuleCustomizationUuid]; - } - else { - volGroupModel = vnfModel.volumeGroups[vfModuleModelVersionId]; - } - if ( !($scope.isObjectEmpty(volGroupModel) ) ) { - DataService.setModelInfo(COMPONENT.VOLUME_GROUP, { - "modelInvariantId": volGroupModel.invariantUuid, - "modelVersion": volGroupModel.version, - "modelNameVersionId": volGroupModel.uuid, - "modelCustomizationName": volGroupModel.modelCustomizationName, - "customizationUuid": volGroupModel.customizationUuid, - "modelName": volGroupModel.name, - "inputs": "" - }); - - } - } - } - - var serviceInstance = serviceObject.object; - - DataService.setInventoryItem(volumeGroup.object); - - 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.setVnfInstanceId(vnf.nodeId); - DataService.setVolumeGroupInstanceId(volumeGroup.nodeId); - - $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, { - componentId : COMPONENT.VOLUME_GROUP, - dialogMethod: COMPONENT.DELETE - }); - }; - - $scope.deleteVnfVolumeGroup = function(serviceObject, vnf, volumeGroup) { - - console.log("Removing Volume Group " + volumeGroup.name); - var serviceInstance = serviceObject.object; - - DataService.setInventoryItem(volumeGroup.object); - - var svcModel = $scope.service.convertedModel; - - 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 volGroupModelInvariantUuid = volumeGroup.object[FIELD.ID.MODEL_INVAR_ID]; - var volGroupModelVersionId = volumeGroup.object[FIELD.ID.MODEL_VERSION_ID]; - var volGroupModelCustomizationUuid = volumeGroup.object[FIELD.ID.MODEL_CUSTOMIZATION_ID]; - - var vnfModel = null; - var volGroupModel = null; - - // send an empty model by default since model is not required for deletes - DataService.setModelInfo(COMPONENT.VOLUME_GROUP, {}); - - if ( svcModel.isNewFlow ) { - vnfModel = svcModel.vnfs[vnfModelCustomizationUuid]; - if ( UtilityService.hasContents (volGroupModelCustomizationUuid) ) { - volGroupModel = vnfModel.volumeGroups[volGroupModelCustomizationUuid]; - } - } - else { - - vnfModel = svcModel.vnfs[vnfModelVersionId]; - if ( UtilityService.hasContents (volGroupModelVersionId) ) { - volGroupModel = vnfModel.volumeGroups[volGroupModelVersionId]; - } - } - if ( !($scope.isObjectEmpty(volGroupModel) ) ) { - DataService.setModelInfo(COMPONENT.VOLUME_GROUP, { - "modelInvariantId": volGroupModel.invariantUuid, - "modelVersion": volGroupModel.version, - "modelNameVersionId": volGroupModel.uuid, - "modelName": volGroupModel.name, - "modelCustomizationName": volGroupModel.modelCustomizationName, - "customizationUuid": volGroupModel.customizationUuid, - "inputs": "" - }); - } - - DataService.setVnfInstanceId(vnf.object[FIELD.ID.VNF_ID]); - - 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.setVnfInstanceId(vnf.nodeId); - DataService.setVolumeGroupInstanceId(volumeGroup.nodeId); - - $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, { - componentId : COMPONENT.VOLUME_GROUP, - callbackFunction : deleteOrResumeCallback, - dialogMethod: COMPONENT.DELETE - }); - }; - - $scope.describeNetwork = function(serviceObject, networkObject) { - var serviceInstance = serviceObject.object; - var network = networkObject.object; - //console.log ("networkObject="); console.log (JSON.stringify(networkObject, null, 4)); - - DataService.setResCustomizationUuid(" "); - - var svcModel = $scope.service.convertedModel; - var netModel = null; - - if ( !($scope.isObjectEmpty(network) ) ) { - - var netModelInvariantUuid = network[FIELD.ID.MODEL_INVAR_ID]; - var netModelVersionId = network[FIELD.ID.MODEL_VERSION_ID]; - var netModelCustomizationUuid = network[FIELD.ID.MODEL_CUSTOMIZATION_ID]; - - if ( UtilityService.hasContents (netModelCustomizationUuid) ) { - // set it to what came from a&ai - DataService.setResCustomizationUuid(netModelCustomizationUuid); - } - - if ( (!($scope.isObjectEmpty(svcModel))) && (!($scope.isObjectEmpty(svcModel.networks))) ) { - if ( svcModel.isNewFlow ) { - netModel = svcModel.networks[netModelCustomizationUuid]; - } - else { - netModel = svcModel.networks[netModelVersionId]; - } - /* - * The details pop-up should use a&ai info - * if ( !($scope.isObjectEmpty(netModel) ) ) { - if (UtilityService.hasContents(netModel.customizationUuid)) { - DataService.setResCustomizationUuid(netModel.customizationUuid); - } - }*/ - } - } - - DataService.setNetworkInstanceId(network[FIELD.ID.NETWORK_ID]); - DataService.setInventoryItem(networkObject); - DataService.setSubscriberName(serviceObject.subscriberName); - DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]); - DataService.setServiceInstanceId(serviceInstance[FIELD.ID.SERVICE_INSTANCE_ID]); - - $scope.$broadcast(COMPONENT.SHOW_COMPONENT_DETAILS, { - componentId : COMPONENT.NETWORK - }); - }; - - // for service instance id - no need for this! - $scope.describeService = function(serviceObject) { - var serviceInstance = serviceObject.object; - - DataService.setInventoryItem(serviceInstance); - //DataService.setModelInfo(serviceInstance['service-instance-id'], serviceInstance); - - DataService.setSubscriberName(serviceObject[COMPONENT.SUBSCRIBER_NAME]); - DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]); - DataService.setServiceInstanceId(serviceInstance[FIELD.ID.SERVICE_INSTANCE_ID]); - - //Display popup with additional service information - $scope.$broadcast(COMPONENT.SHOW_COMPONENT_DETAILS, { - componentId : COMPONENT.SERVICE - }); - - }; - - $scope.describeVfModule = function(serviceObject, vfModuleObject, vnf) { - var serviceInstance = serviceObject.object; - var vfModule = vfModuleObject.object; - - /*var vfModuleInvariantUuid = vfModule[FIELD.ID.MODEL_INVAR_ID]; - var vfModuleModelVersionId = vfModule[FIELD.ID.MODEL_VERSION_ID];*/ - var vfModuleCustomizationUuid = vfModule[FIELD.ID.MODEL_CUSTOMIZATION_ID]; - - DataService.setCustomizationUuid(" "); - if ( UtilityService.hasContents (vfModuleCustomizationUuid) ) { - DataService.setCustomizationUuid(vfModuleCustomizationUuid); - } - - //Display popup with additional VF-Module information - DataService.setVfModuleInstanceId(vfModule[FIELD.ID.VF_MODULE_ID]); - DataService.setInventoryItem(vfModule) - - DataService.setSubscriberName(serviceObject[COMPONENT.SUBSCRIBER_NAME]); - DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]); - DataService.setServiceInstanceId(serviceInstance[FIELD.ID.SERVICE_INSTANCE_ID]); - - $scope.$broadcast(COMPONENT.SHOW_COMPONENT_DETAILS, { - componentId : COMPONENT.VF_MODULE - }); - }; - - $scope.getStatusOfVnf = function(serviceObject, vnfObject) { - var serviceInstance = serviceObject.object; - var vnf = vnfObject.object; - - DataService.setVnfInstanceId(vnf[FIELD.ID.VNF_ID]); - DataService.setInventoryItem(vnf); - - DataService.setSubscriberName(serviceObject[COMPONENT.SUBSCRIBER_NAME]); - DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]); - DataService.setServiceInstanceId(serviceInstance[FIELD.ID.SERVICE_INSTANCE_ID]); - DataService.setServiceInstanceName(serviceInstance[FIELD.ID.SERVICE_INSTANCE_NAME]); - - $scope.$broadcast(COMPONENT.COMPONENT_STATUS, { - componentId : COMPONENT.VNF, - callbackFunction : updateProvStatusVnfCallbackFunction - }); - }; - - $scope.describeVnf = function(serviceObject, vnfObject) { - var serviceInstance = serviceObject.object; - var vnf = vnfObject.object; - DataService.setResCustomizationUuid(" "); - - //var vnfInvariantUuid = vnf[FIELD.ID.MODEL_INVAR_ID]; - //var vnfVersionId = vnf[FIELD.ID.MODEL_VERSION_ID]; - var vnfCustomizationUuid = vnf[FIELD.ID.MODEL_CUSTOMIZATION_ID]; - - if ( UtilityService.hasContents (vnfCustomizationUuid) ) { - DataService.setResCustomizationUuid(vnfCustomizationUuid); - } - //Display popup with additional VNF information - DataService.setVnfInstanceId(vnf[FIELD.ID.VNF_ID]); - DataService.setInventoryItem(vnf); - - DataService.setSubscriberName(serviceObject[COMPONENT.SUBSCRIBER_NAME]); - DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]); - DataService.setServiceInstanceId(serviceInstance[FIELD.ID.SERVICE_INSTANCE_ID]); - - $scope.$broadcast(COMPONENT.SHOW_COMPONENT_DETAILS, { - componentId : COMPONENT.VNF - }); - }; - - $scope.describeVolumeGroup = function(serviceObject, vnf, volumeGroupObject) { - - var serviceInstance = serviceObject.object; - var volumeGroup = volumeGroupObject.object; - - //var volGroupInvariantUuid = volumeGroup[FIELD.ID.MODEL_INVAR_ID]; - //var volGroupVersionId = volumeGroup[FIELD.ID.MODEL_VERSION_ID]; - var volGroupCustomizationUuid = volumeGroup[FIELD.ID.MODEL_CUSTOMIZATION_ID]; - - DataService.setCustomizationUuid(" "); - if ( UtilityService.hasContents(volGroupCustomizationUuid) ) { - DataService.setCustomizationUuid(volGroupCustomizationUuid); - } - DataService.setVolumeGroupInstanceId(volumeGroup[FIELD.ID.VOLUME_GROUP_ID]); - DataService.setInventoryItem(volumeGroup); - - DataService.setSubscriberName(serviceObject[COMPONENT.SUBSCRIBER_NAME]); - DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]); - DataService.setServiceInstanceId(serviceInstance[FIELD.ID.SERVICE_INSTANCE_ID]); - - - $scope.$broadcast(COMPONENT.SHOW_COMPONENT_DETAILS, { - componentId : COMPONENT.VOLUME_GROUP - }); - }; - - $scope.addNetworkInstance = function(netModel, existingVnfs) { - - // For networks we assume that we always follow the new flow - console.log("Adding network to service instance" + this.service.instance.name); - if ( VIDCONFIGURATION.VNF_STATUS_CHECK_ENABLED && (UtilityService.hasContents(existingVnfs)) && (existingVnfs.length > 0) ) { - var msg = VnfService.isVnfListStatusValid (existingVnfs); - if ( msg != "" ) { - alert ( msg ); - return; - } - } - - DataService.setSubscriberName($scope.service.instance.subscriberName); - DataService.setGlobalCustomerId($scope.service.instance.globalCustomerId); - DataService.setServiceType($scope.service.instance.serviceType); - DataService.setServiceInstanceName($scope.service.instance.name); - DataService.setServiceInstanceId($scope.service.instance.id); - DataService.setServiceName($scope.service.model.service.name); - - DataService.setModelInfo(COMPONENT.NETWORK, { - "modelType": "network", - "modelInvariantId": netModel.invariantUuid, - "modelVersion": netModel.version, - "modelNameVersionId": netModel.uuid, - "modelName": netModel.name, - "modelCustomizationName": netModel.modelCustomizationName, - "customizationUuid": netModel.customizationUuid, - "inputs": "", - "displayInputs": netModel.displayInputs - }); - setCurrentServiceModelInfoFromScope(); - - - $scope.$broadcast(COMPONENT.CREATE_COMPONENT, { - componentId : COMPONENT.NETWORK, - callbackFunction : createVnfCallbackFunction - }); - }; - - $scope.addVnfInstance = function(vnf, existingVnfs) { - - if ( VIDCONFIGURATION.VNF_STATUS_CHECK_ENABLED && (UtilityService.hasContents(existingVnfs)) && (existingVnfs.length > 0) ) { - var msg = VnfService.isVnfListStatusValid (existingVnfs); - if ( msg != "" ) { - alert ( msg ); - return; - } - } - DataService.setSubscriberName($scope.service.instance.subscriberName); - DataService.setGlobalCustomerId($scope.service.instance.globalCustomerId); - DataService.setServiceType($scope.service.instance.serviceType); - DataService.setServiceInstanceName($scope.service.instance.name); - 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 = ""; - var vnf_function = ""; - var vnf_code = ""; - - if (UtilityService.hasContents (vnf.nfType) ) { - vnf_type = vnf.nfType; - } - if (UtilityService.hasContents (vnf.nfRole) ) { - vnf_role = vnf.nfRole; - } - if (UtilityService.hasContents (vnf.nfFunction) ) { - vnf_function = vnf.nfFunction; - } - if (UtilityService.hasContents (vnf.nfCode) ) { - vnf_code = vnf.nfCode; - } - DataService.setModelInfo(COMPONENT.VNF, { - "modelType": vnf.isPnf ? "pnf" : "vnf", - "modelInvariantId": vnf.invariantUuid, - "modelVersion": vnf.version, - "modelNameVersionId": vnf.uuid, - "modelName": vnf.name, - "modelCustomizationName": vnf.modelCustomizationName, - "customizationUuid": vnf.customizationUuid, - "inputs": "", - "displayInputs": vnf.displayInputs, - "vnfType": vnf_type, - "vnfRole": vnf_role, - "vnfFunction": vnf_function, - "vnfCode": vnf_code, - "properties": vnf.properties - }); - - DataService.setModelInstanceName($scope.service.model.service.name); - 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) { - - if ( VIDCONFIGURATION.VNF_STATUS_CHECK_ENABLED ) { - var msg = VnfService.isVnfStatusValid (vnfInstance); - if ( msg != "" ) { - alert ( msg ); - return; - } - - } - var svcModel = $scope.service.convertedModel; - DataService.setSubscriberName($scope.service.instance.subscriberName); - DataService.setGlobalCustomerId($scope.service.instance.globalCustomerId); - DataService.setServiceType($scope.service.instance.serviceType); - DataService.setServiceInstanceName($scope.service.instance.name); - DataService.setServiceInstanceId($scope.service.instance.id); - DataService.setServiceName($scope.service.model.service.name); - - var vnfModelInvariantUuid = vnfInstance.object[FIELD.ID.MODEL_INVAR_ID]; - var vnfModelVersionId = vnfInstance.object[FIELD.ID.MODEL_VERSION_ID]; - var vnfModelCustomizationUuid = vnfInstance.object[FIELD.ID.MODEL_CUSTOMIZATION_ID]; - var vnfModel = null; - if ( svcModel.isNewFlow ) { - vnfModel = svcModel.vnfs[vnfModelCustomizationUuid]; - } - else { - vnfModel = svcModel.vnfs[vnfModelVersionId]; - } - - var availableVolumeGroupList = []; - angular.forEach(vnfInstance[FIELD.ID.AVAILABLEVOLUMEGROUPS], function(volumeGroupInstance, key) { - availableVolumeGroupList.push({"instance": volumeGroupInstance}); - }); - - DataService.setAvailableVolumeGroupList(availableVolumeGroupList); - setCurrentServiceModelInfoFromScope(); - - DataService.setVnfInstanceId(vnfInstance.object[FIELD.ID.VNF_ID]); - - DataService.setModelInfo(COMPONENT.VNF, { - "modelInvariantId": vnfModel.invariantUuid, - "modelVersion": vnfModel.version, - "modelNameVersionId": vnfModel.uuid, - "modelName": vnfModel.name, - "modelCustomizationName": vnfModel.modelCustomizationName, - "customizationUuid": vnfModel.customizationUuid, - "inputs": "" - }); - - DataService.setModelInfo(COMPONENT.VF_MODULE, { - "modelInvariantId": vfModuleModel.invariantUuid, - "modelVersion": vfModuleModel.version, - "modelNameVersionId": vfModuleModel.uuid, - "customizationUuid": vfModuleModel.customizationUuid, - "modelCustomizationName": vfModuleModel.modelCustomizationName, - "modelName": vfModuleModel.name, - "inputs": "" - }); - - $scope.$broadcast(COMPONENT.CREATE_COMPONENT, { - componentId : COMPONENT.VF_MODULE, - callbackFunction : createVfModuleCallbackFunction - }); - - }; - - $scope.addVolumeGroupInstance = function(vnfInstance, volumeGroupModel) { - if ( VIDCONFIGURATION.VNF_STATUS_CHECK_ENABLED ) { - var msg = VnfService.isVnfStatusValid (vnfInstance); - if ( msg != "" ) { - alert ( msg ); - return; - } - } - var svcModel = $scope.service.convertedModel; - DataService.setSubscriberName($scope.service.instance.subscriberName); - DataService.setGlobalCustomerId($scope.service.instance.globalCustomerId); - DataService.setServiceType($scope.service.instance.serviceType); - 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, - "modelVersion": $scope.service.model.service.version, - "modelNameVersionId": $scope.service.model.service.uuid, - "modelName": $scope.service.model.service.name, - "inputs": "" - }); - - DataService.setVnfInstanceId(vnfInstance.object[FIELD.ID.VNF_ID]); - - var vnfModelInvariantUuid = vnfInstance.object[FIELD.ID.MODEL_INVAR_ID]; - var vnfModelVersionId = vnfInstance.object[FIELD.ID.MODEL_VERSION_ID]; - var vnfCustomizationUuid = vnfInstance.object[FIELD.ID.MODEL_CUSTOMIZATION_ID]; - var vnfModel = null; - - if ( svcModel.isNewFlow ) { - vnfModel = svcModel.vnfs[vnfCustomizationUuid]; - } - else { - vnfModel = svcModel.vnfs[vnfModelVersionId]; - } - - DataService.setModelInfo(COMPONENT.VNF, { - "modelInvariantId": vnfModel.invariantUuid, - "modelVersion": vnfModel.version, - "modelNameVersionId": vnfModel.uuid, - "modelName": vnfModel.name, - "modelCustomizationName": vnfModel.modelCustomizationName, - "customizationUuid": vnfModel.customizationUuid, - "inputs": "" - }); - - DataService.setModelInfo(COMPONENT.VOLUME_GROUP, { - "modelInvariantId": volumeGroupModel.invariantUuid, - "modelVersion": volumeGroupModel.version, - "modelNameVersionId": volumeGroupModel.uuid, - "modelName": volumeGroupModel.name, - "modelCustomizationName": volumeGroupModel.modelCustomizationName, - "customizationUuid": volumeGroupModel.customizationUuid, - "inputs": "" - }); - - $scope.$broadcast(COMPONENT.CREATE_COMPONENT, { - componentId : COMPONENT.VOLUME_GROUP, - callbackFunction : createVolumeGroupCallbackFunction - }); - }; - - $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; + function setCurrentNetworkModelInfoFromScope(network) { var svcModel = $scope.service.convertedModel; - var configModel; - DataService.setInventoryItem(configuration.object); + var netModel; // set model default and override later if found - DataService.setModelInfo(COMPONENT.CONFIGURATION, {}); + DataService.setModelInfo(COMPONENT.NETWORK, {}); - if ( configuration.object != null ) { + if (network.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]; + var netModelVersionId = network.object[FIELD.ID.MODEL_VERSION_ID]; // model uuid + var netModelCustomizationUuid = network.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]; + if (UtilityService.hasContents(netModelCustomizationUuid)) { + // set it to what came from a&ai + DataService.setResCustomizationUuid(netModelCustomizationUuid); + } + + if ((!($scope.isObjectEmpty(svcModel))) && (!($scope.isObjectEmpty(svcModel.networks)))) { + if ((svcModel.isNewFlow) && (UtilityService.hasContents(netModelCustomizationUuid))) { + netModel = svcModel.networks[netModelCustomizationUuid]; } else { - if ( UtilityService.hasContents(configModelVersionId) ) { - configModel = svcModel.vnfs[configModelVersionId]; + if (UtilityService.hasContents(netModelVersionId)) { + netModel = svcModel.networks[netModelVersionId]; } } } } - 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, + if (!($scope.isObjectEmpty(netModel))) { + DataService.setModelInfo(COMPONENT.NETWORK, { + "modelInvariantId": netModel.invariantUuid, + "modelVersion": netModel.version, + "modelNameVersionId": netModel.uuid, + "modelCustomizationName": netModel.modelCustomizationName, + "customizationUuid": netModel.customizationUuid, + "modelName": netModel.name, "inputs": "" }); } + } - DataService.setSubscriberName(serviceObject[COMPONENT.SUBSCRIBER_NAME]); - DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]); - DataService.setServiceInstanceId(serviceInstance[FIELD.ID.SERVICE_INSTANCE_ID]); + function setCurrentVfModuleModelInfoFromScope(vnf, vfModule) { - 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]); + var svcModel = $scope.service.convertedModel; + + //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 vnfModel = null; + var vfModuleModel = null; - $scope.$broadcast(COMPONENT.DELETE_COMPONENT, { - componentId : COMPONENT.CONFIGURATION, - callbackFunction : deleteCallbackFunction + DataService.setModelInfo(COMPONENT.VF_MODULE, { + "modelInvariantId": "", + "modelVersion": "", + "modelNameVersionId": "", + "modelCustomizationName": "", + "customizationUuid": "", + "modelName": "", + "inputs": "" }); - }; - $scope.resetProgress = function() { - $scope.percentProgress = 0; - $scope.progressClass = FIELD.STYLE.PROGRESS_BAR_INFO; - }; - - $scope.setProgress = function(percentProgress) { - percentProgress = parseInt(percentProgress); - if (percentProgress >= 100) { - $scope.progressClass = FIELD.STYLE.PROGRESS_BAR_SUCCESS; - } - - if (percentProgress < $scope.percentProgress) { - return; - } - - $scope.percentProgress = percentProgress; - $scope.progressWidth = {width: percentProgress + "%"}; - if (percentProgress >= 5) { - $scope.progressText = percentProgress + " %"; - } else { - // Hidden since color combination is barely visible when progress portion is narrow. - $scope.progressText = ""; - } - }; - $scope.isObjectEmpty = function(o) { - var len = 0; - if (UtilityService.hasContents(o)){ - var keys = Object.keys(o); - len = keys.length; - if ( len == 0 ) { - return true; - } - else { - return false; - } - } - else { - return true; - } - } - $scope.isMacro = function() { - if (UtilityService.arrayContains (VIDCONFIGURATION.MACRO_SERVICES, $scope.service.model.service.invariantUuid )) { - return(true); - - } - else { - return (false); - } - } - $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); - } - ); + 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)) && !($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": "" + }); + } + } } - /* - Callbaks functions + function setCurrentVolumeGroupModelInfoFromScope(vnf, vfModule) { + var svcModel = $scope.service.convertedModel; - */ - var updateProvStatusVnfCallbackFunction = function(response) { - $scope.callbackResults = ""; - var color = FIELD.ID.COLOR_NONE; - $scope.callbackStyle = { - "background-color" : color - }; - $scope.reloadRoute(); - /* - * 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; - - } else { - color = FIELD.ID.COLOR_F88; - } - $scope.callbackStyle = { - "background-color" : color - }; - }, 500); - - }; - - var createVnfCallbackFunction = 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.reloadRoute(); - } else { - color = FIELD.ID.COLOR_F88; - } - $scope.callbackStyle = { - "background-color" : color - }; - }, 500); - - - - }; - - var deleteOrResumeCallback = 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.reloadRoute(); - } else { - color = FIELD.ID.COLOR_F88; - } - $scope.callbackStyle = { - "background-color" : color - }; - }, 500); - - }; - - var createVfModuleCallbackFunction = 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.reloadRoute(); - } else { - color = FIELD.ID.COLOR_F88; - } - $scope.callbackStyle = { - "background-color" : color - }; - }, 500); - - }; - - var deleteServiceInstanceCallbackFunction = 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; - $location.path(COMPONENT.SERVICEMODELS_MODELS_SERVICES_PATH) - } else { - color = FIELD.ID.COLOR_F88; - } - $scope.callbackStyle = { - "background-color" : color - }; - }, 500); - - }; - - var createVolumeGroupCallbackFunction = 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.reloadRoute(); - } else { - color = FIELD.ID.COLOR_F88; - } - $scope.callbackStyle = { - "background-color" : color - }; - }, 500); - - - - }; - - }); + var vnfModelCustomizationUuid = null; + var vnfModel = null; + var vnfModelVersionId = null; + + vnfModelVersionId = vnf.object[FIELD.ID.MODEL_VERSION_ID]; + vnfModelCustomizationUuid = vnf.object[FIELD.ID.MODEL_CUSTOMIZATION_ID]; + + DataService.setModelInfo(COMPONENT.VOLUME_GROUP, { + "modelInvariantId": "", + "modelVersion": "", + "modelNameVersionId": "", + "modelCustomizationName": "", + "customizationUuid": "", + "modelName": "", + "inputs": "" + }); + + if ((!($scope.isObjectEmpty(svcModel))) && (!($scope.isObjectEmpty(svcModel.vnfs)))) { + if ((svcModel.isNewFlow) && (vnfModelCustomizationUuid != null)) { + vnfModel = svcModel.vnfs[vnfModelCustomizationUuid]; + } + else { + vnfModel = svcModel.vnfs[vnfModelVersionId]; + } + } + + + // volume groups don't have model-invariant-id/version in a&ai. + // Their model-invariant-id/version is the one for the associated vfModule + + var vfModuleModelVersionId = vfModule.object[FIELD.ID.MODEL_VERSION_ID]; + var vfModuleCustomizationUuid = vfModule.object[FIELD.ID.MODEL_CUSTOMIZATION_ID]; + var volGroupModel = null; + + if (!($scope.isObjectEmpty(vnfModel)) && !($scope.isObjectEmpty(vnfModel.volumeGroups))) { + if ((svcModel.isNewFlow) && (UtilityService.hasContents(vfModuleCustomizationUuid))) { + volGroupModel = vnfModel.volumeGroups[vfModuleCustomizationUuid]; + } + else { + volGroupModel = vnfModel.volumeGroups[vfModuleModelVersionId]; + } + if (!($scope.isObjectEmpty(volGroupModel))) { + DataService.setModelInfo(COMPONENT.VOLUME_GROUP, { + "modelInvariantId": volGroupModel.invariantUuid, + "modelVersion": volGroupModel.version, + "modelNameVersionId": volGroupModel.uuid, + "modelCustomizationName": volGroupModel.modelCustomizationName, + "customizationUuid": volGroupModel.customizationUuid, + "modelName": volGroupModel.name, + "inputs": "" + }); + + } + } + } + + function setCurrentVolumeGroupModelInfoByVfModuleFromScope(vnf, volumeGroup) { + var svcModel = $scope.service.convertedModel; + + var vnfModelCustomizationUuid = null; + var vnfModel = null; + var vnfModelVersionId = null; + + vnfModelVersionId = vnf.object[FIELD.ID.MODEL_VERSION_ID]; + vnfModelCustomizationUuid = vnf.object[FIELD.ID.MODEL_CUSTOMIZATION_ID]; + + DataService.setModelInfo(COMPONENT.VOLUME_GROUP, { + "modelInvariantId": "", + "modelVersion": "", + "modelNameVersionId": "", + "modelCustomizationName": "", + "customizationUuid": "", + "modelName": "", + "inputs": "" + }); + + if ((!($scope.isObjectEmpty(svcModel))) && (!($scope.isObjectEmpty(svcModel.vnfs)))) { + if ((svcModel.isNewFlow) && (vnfModelCustomizationUuid != null)) { + vnfModel = svcModel.vnfs[vnfModelCustomizationUuid]; + } + else { + vnfModel = svcModel.vnfs[vnfModelVersionId]; + } + } + + + // volume groups don't have model-invariant-id/version in a&ai. + // Their model-invariant-id/version is the one for the associated vfModule + + var vfModuleModelVersionId = volumeGroup.object[FIELD.ID.VF_MODULE_MODEL_VERSION_ID]; + var vfModuleCustomizationUuid = volumeGroup.object[FIELD.ID.VF_MODULE_MODEL_CUSTOMIZATION_ID]; + var volGroupModel = null; + if ((!($scope.isObjectEmpty(vnfModel))) && (!($scope.isObjectEmpty(vnfModel.volumeGroups)))) { + if ((svcModel.isNewFlow) && (UtilityService.hasContents(vfModuleCustomizationUuid))) { + volGroupModel = vnfModel.volumeGroups[vfModuleCustomizationUuid]; + } + else { + volGroupModel = vnfModel.volumeGroups[vfModuleModelVersionId]; + } + if (!($scope.isObjectEmpty(volGroupModel))) { + DataService.setModelInfo(COMPONENT.VOLUME_GROUP, { + "modelInvariantId": volGroupModel.invariantUuid, + "modelVersion": volGroupModel.version, + "modelNameVersionId": volGroupModel.uuid, + "modelCustomizationName": volGroupModel.modelCustomizationName, + "customizationUuid": volGroupModel.customizationUuid, + "modelName": volGroupModel.name, + "inputs": "" + }); + + } + } + } + + $scope.deleteVnf = function (serviceObject, vnf) { + console.log("Removing VNF " + vnf.name); + + var serviceInstance = serviceObject.object; + var svcModel = $scope.service.convertedModel; + DataService.setInventoryItem(vnf.object); + + /*var vnftype = vnf.object['vnf-type']; + if (vnftype == null) + vnftype = ""; + else + { + var n = vnftype.search("/"); + if (n >= 0) + vnftype = vnftype.substring(n+1); + }*/ + + var svcModel = $scope.service.convertedModel; + var vnfModelInvariantUuid = null; + var vnfModelVersion = null; + var vnfModelCustomizationUuid = null; + var vnfModel = null; + var vnfModelVersionId = null; + + vnfModelInvariantUuid = vnf.object[FIELD.ID.MODEL_INVAR_ID]; + vnfModelVersionId = vnf.object[FIELD.ID.MODEL_VERSION_ID]; + vnfModelCustomizationUuid = vnf.object[FIELD.ID.MODEL_CUSTOMIZATION_ID]; + + DataService.setModelInfo(COMPONENT.VNF, { + "modelInvariantId": vnfModelInvariantUuid, + "modelVersion": "", + "modelNameVersionId": vnfModelVersionId, + "modelCustomizationName": "", + "customizationUuid": vnfModelCustomizationUuid, + "modelName": "", + "inputs": "" + }); + + if ((!($scope.isObjectEmpty(svcModel))) && (!($scope.isObjectEmpty(svcModel.vnfs)))) { + if ((svcModel.isNewFlow) && (vnfModelCustomizationUuid != null)) { + vnfModel = svcModel.vnfs[vnfModelCustomizationUuid]; + } + else { + vnfModel = svcModel.vnfs[vnfModelVersionId]; + } + //console.log ( "vnf models: "); console.log ( JSON.stringify ($scope.service.convertedModel.vnfs, null, 4) ); + 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": "" + }); + } + } + + DataService.setVnfInstanceId(vnf.object[FIELD.ID.VNF_ID]); + + 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.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, { + componentId: COMPONENT.VNF, + callbackFunction: deleteOrResumeCallback, + dialogMethod: COMPONENT.DELETE + }); + + }; + + $scope.deleteVolumeGroup = function (serviceObject, vnf, vfModule, volumeGroup) { + + console.log("Removing Volume Group " + volumeGroup.name); + var haveModel = false; + + var serviceInstance = serviceObject.object; + + setCurrentVolumeGroupModelInfoFromScope(vnf, vfModule); + + DataService.setInventoryItem(volumeGroup.object); + + 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.setVnfInstanceId(vnf.nodeId); + DataService.setVolumeGroupInstanceId(volumeGroup.nodeId); + + $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, { + componentId: COMPONENT.VOLUME_GROUP, + dialogMethod: COMPONENT.DELETE + }); + }; + + $scope.deleteVnfVolumeGroup = function (serviceObject, vnf, volumeGroup) { + + console.log("Removing Volume Group " + volumeGroup.name); + var serviceInstance = serviceObject.object; + + DataService.setInventoryItem(volumeGroup.object); + + var svcModel = $scope.service.convertedModel; + + 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 volGroupModelInvariantUuid = volumeGroup.object[FIELD.ID.MODEL_INVAR_ID]; + var volGroupModelVersionId = volumeGroup.object[FIELD.ID.MODEL_VERSION_ID]; + var volGroupModelCustomizationUuid = volumeGroup.object[FIELD.ID.MODEL_CUSTOMIZATION_ID]; + + var vnfModel = null; + var volGroupModel = null; + + // send an empty model by default since model is not required for deletes + DataService.setModelInfo(COMPONENT.VOLUME_GROUP, {}); + + if (svcModel.isNewFlow) { + vnfModel = svcModel.vnfs[vnfModelCustomizationUuid]; + if (UtilityService.hasContents(volGroupModelCustomizationUuid)) { + volGroupModel = vnfModel.volumeGroups[volGroupModelCustomizationUuid]; + } + } + else { + + vnfModel = svcModel.vnfs[vnfModelVersionId]; + if (UtilityService.hasContents(volGroupModelVersionId)) { + volGroupModel = vnfModel.volumeGroups[volGroupModelVersionId]; + } + } + if (!($scope.isObjectEmpty(volGroupModel))) { + DataService.setModelInfo(COMPONENT.VOLUME_GROUP, { + "modelInvariantId": volGroupModel.invariantUuid, + "modelVersion": volGroupModel.version, + "modelNameVersionId": volGroupModel.uuid, + "modelName": volGroupModel.name, + "modelCustomizationName": volGroupModel.modelCustomizationName, + "customizationUuid": volGroupModel.customizationUuid, + "inputs": "" + }); + } + + DataService.setVnfInstanceId(vnf.object[FIELD.ID.VNF_ID]); + + 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.setVnfInstanceId(vnf.nodeId); + DataService.setVolumeGroupInstanceId(volumeGroup.nodeId); + + $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, { + componentId: COMPONENT.VOLUME_GROUP, + callbackFunction: deleteOrResumeCallback, + dialogMethod: COMPONENT.DELETE + }); + }; + + $scope.describeNetwork = function (serviceObject, networkObject) { + var serviceInstance = serviceObject.object; + var network = networkObject.object; + //console.log ("networkObject="); console.log (JSON.stringify(networkObject, null, 4)); + + DataService.setResCustomizationUuid(" "); + + setCurrentServiceModelInfoFromScope(); + setCurrentNetworkModelInfoFromScope(networkObject); + + DataService.setNetworkInstanceId(network[FIELD.ID.NETWORK_ID]); + DataService.setInventoryItem(networkObject); + DataService.setSubscriberName(serviceObject.subscriberName); + DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]); + DataService.setServiceInstanceId(serviceInstance[FIELD.ID.SERVICE_INSTANCE_ID]); + + $scope.$broadcast(COMPONENT.SHOW_COMPONENT_DETAILS, { + componentId: COMPONENT.NETWORK + }); + }; + + // for service instance id - no need for this! + $scope.describeService = function (serviceObject) { + var serviceInstance = serviceObject.object; + setCurrentServiceModelInfoFromScope(); + + DataService.setInventoryItem(serviceInstance); + //DataService.setModelInfo(serviceInstance['service-instance-id'], serviceInstance); + + DataService.setSubscriberName(serviceObject[COMPONENT.SUBSCRIBER_NAME]); + DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]); + DataService.setServiceInstanceId(serviceInstance[FIELD.ID.SERVICE_INSTANCE_ID]); + + //Display popup with additional service information + $scope.$broadcast(COMPONENT.SHOW_COMPONENT_DETAILS, { + componentId: COMPONENT.SERVICE + }); + + }; + + $scope.describeVfModule = function (serviceObject, vfModuleObject, vnf) { + var serviceInstance = serviceObject.object; + var vfModule = vfModuleObject.object; + + /*var vfModuleInvariantUuid = vfModule[FIELD.ID.MODEL_INVAR_ID]; + var vfModuleModelVersionId = vfModule[FIELD.ID.MODEL_VERSION_ID];*/ + var vfModuleCustomizationUuid = vfModule[FIELD.ID.MODEL_CUSTOMIZATION_ID]; + + setCurrentServiceModelInfoFromScope(); + setCurrentVfModuleModelInfoFromScope(vnf, vfModuleObject); + + DataService.setCustomizationUuid(" "); + if (UtilityService.hasContents(vfModuleCustomizationUuid)) { + DataService.setCustomizationUuid(vfModuleCustomizationUuid); + } + + //Display popup with additional VF-Module information + DataService.setVfModuleInstanceId(vfModule[FIELD.ID.VF_MODULE_ID]); + DataService.setInventoryItem(vfModule) + + DataService.setSubscriberName(serviceObject[COMPONENT.SUBSCRIBER_NAME]); + DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]); + DataService.setServiceInstanceId(serviceInstance[FIELD.ID.SERVICE_INSTANCE_ID]); + + $scope.$broadcast(COMPONENT.SHOW_COMPONENT_DETAILS, { + componentId: COMPONENT.VF_MODULE + }); + }; + + $scope.getStatusOfVnf = function (serviceObject, vnfObject) { + var serviceInstance = serviceObject.object; + var vnf = vnfObject.object; + + DataService.setVnfInstanceId(vnf[FIELD.ID.VNF_ID]); + DataService.setInventoryItem(vnf); + + DataService.setSubscriberName(serviceObject[COMPONENT.SUBSCRIBER_NAME]); + DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]); + DataService.setServiceInstanceId(serviceInstance[FIELD.ID.SERVICE_INSTANCE_ID]); + DataService.setServiceInstanceName(serviceInstance[FIELD.ID.SERVICE_INSTANCE_NAME]); + + $scope.$broadcast(COMPONENT.COMPONENT_STATUS, { + componentId: COMPONENT.VNF, + callbackFunction: updateProvStatusVnfCallbackFunction + }); + }; + + $scope.describeVnf = function (serviceObject, vnfObject) { + var serviceInstance = serviceObject.object; + var vnf = vnfObject.object; + DataService.setResCustomizationUuid(" "); + + //var vnfInvariantUuid = vnf[FIELD.ID.MODEL_INVAR_ID]; + //var vnfVersionId = vnf[FIELD.ID.MODEL_VERSION_ID]; + var vnfCustomizationUuid = vnf[FIELD.ID.MODEL_CUSTOMIZATION_ID]; + + if (UtilityService.hasContents(vnfCustomizationUuid)) { + DataService.setResCustomizationUuid(vnfCustomizationUuid); + } + + setCurrentServiceModelInfoFromScope(); + setCurrentVNFModelInfo(vnfObject); + + //Display popup with additional VNF information + DataService.setVnfInstanceId(vnf[FIELD.ID.VNF_ID]); + DataService.setInventoryItem(vnf); + + DataService.setSubscriberName(serviceObject[COMPONENT.SUBSCRIBER_NAME]); + DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]); + DataService.setServiceInstanceId(serviceInstance[FIELD.ID.SERVICE_INSTANCE_ID]); + + $scope.$broadcast(COMPONENT.SHOW_COMPONENT_DETAILS, { + componentId: COMPONENT.VNF + }); + }; + + $scope.describeVolumeGroup = function (serviceObject, vnf, volumeGroupObject) { + + var serviceInstance = serviceObject.object; + var volumeGroup = volumeGroupObject.object; + + var volGroupCustomizationUuid = volumeGroup[FIELD.ID.MODEL_CUSTOMIZATION_ID]; + + setCurrentServiceModelInfoFromScope(); + setCurrentVolumeGroupModelInfoByVfModuleFromScope(vnf, volumeGroupObject); + + DataService.setCustomizationUuid(" "); + if (UtilityService.hasContents(volGroupCustomizationUuid)) { + DataService.setCustomizationUuid(volGroupCustomizationUuid); + } + DataService.setVolumeGroupInstanceId(volumeGroup[FIELD.ID.VOLUME_GROUP_ID]); + DataService.setInventoryItem(volumeGroup); + + DataService.setSubscriberName(serviceObject[COMPONENT.SUBSCRIBER_NAME]); + DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]); + DataService.setServiceInstanceId(serviceInstance[FIELD.ID.SERVICE_INSTANCE_ID]); + + + $scope.$broadcast(COMPONENT.SHOW_COMPONENT_DETAILS, { + componentId: COMPONENT.VOLUME_GROUP + }); + }; + + $scope.addNetworkInstance = function (netModel, existingVnfs) { + + // For networks we assume that we always follow the new flow + console.log("Adding network to service instance" + this.service.instance.name); + if (VIDCONFIGURATION.VNF_STATUS_CHECK_ENABLED && (UtilityService.hasContents(existingVnfs)) && (existingVnfs.length > 0)) { + var msg = VnfService.isVnfListStatusValid(existingVnfs); + if (msg != "") { + alert(msg); + return; + } + } + + DataService.setSubscriberName($scope.service.instance.subscriberName); + DataService.setGlobalCustomerId($scope.service.instance.globalCustomerId); + DataService.setServiceType($scope.service.instance.serviceType); + DataService.setServiceInstanceName($scope.service.instance.name); + DataService.setServiceInstanceId($scope.service.instance.id); + DataService.setServiceName($scope.service.model.service.name); + + DataService.setModelInfo(COMPONENT.NETWORK, { + "modelType": "network", + "modelInvariantId": netModel.invariantUuid, + "modelVersion": netModel.version, + "modelNameVersionId": netModel.uuid, + "modelName": netModel.name, + "modelCustomizationName": netModel.modelCustomizationName, + "customizationUuid": netModel.customizationUuid, + "inputs": "", + "displayInputs": netModel.displayInputs + }); + setCurrentServiceModelInfoFromScope(); + + + $scope.$broadcast(COMPONENT.CREATE_COMPONENT, { + componentId: COMPONENT.NETWORK, + callbackFunction: createVnfCallbackFunction + }); + }; + + $scope.addVnfInstance = function (vnf, existingVnfs) { + + if (VIDCONFIGURATION.VNF_STATUS_CHECK_ENABLED && (UtilityService.hasContents(existingVnfs)) && (existingVnfs.length > 0)) { + var msg = VnfService.isVnfListStatusValid(existingVnfs); + if (msg != "") { + alert(msg); + return; + } + } + + var isVfc = false; + + _.map($scope.service.model.vnfs, function (value, key) { + if (value.uuid == vnf.uuid) { + if (!_.isEmpty(value.vfcInstanceGroups)) { + isVfc = true; + var queryData = { + serviceModelId: $scope.service.model.service.uuid, + serviceInstanceID: $scope.service.instance.id, + globalCustomerId: $scope.service.instance.globalCustomerId, + serviceType: $scope.service.instance.serviceType, + serviceInstanceName: $scope.service.instance.name, + modelCustomizationName: value.modelCustomizationName, + modelCustomizationId: value.customizationUuid, + subscriberName: $scope.service.instance.subscriberName + }; + + $scope.$broadcast(COMPONENT.IFRAME_DIALOG, queryData); + return; + } + } + }); + + DataService.setSubscriberName($scope.service.instance.subscriberName); + DataService.setGlobalCustomerId($scope.service.instance.globalCustomerId); + DataService.setServiceType($scope.service.instance.serviceType); + DataService.setServiceInstanceName($scope.service.instance.name); + 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 = ""; + var vnf_function = ""; + var vnf_code = ""; + + if (UtilityService.hasContents(vnf.nfType)) { + vnf_type = vnf.nfType; + } + if (UtilityService.hasContents(vnf.nfRole)) { + vnf_role = vnf.nfRole; + } + if (UtilityService.hasContents(vnf.nfFunction)) { + vnf_function = vnf.nfFunction; + } + if (UtilityService.hasContents(vnf.nfCode)) { + vnf_code = vnf.nfCode; + } + DataService.setModelInfo(COMPONENT.VNF, { + "modelType": vnf.isPnf ? "pnf" : "vnf", + "modelInvariantId": vnf.invariantUuid, + "modelVersion": vnf.version, + "modelNameVersionId": vnf.uuid, + "modelName": vnf.name, + "modelCustomizationName": vnf.modelCustomizationName, + "customizationUuid": vnf.customizationUuid, + "inputs": "", + "displayInputs": vnf.displayInputs, + "vnfType": vnf_type, + "vnfRole": vnf_role, + "vnfFunction": vnf_function, + "vnfCode": vnf_code, + "properties": vnf.properties + }); + + DataService.setModelInstanceName($scope.service.model.service.name); + 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 if (isVfc) { + //do nothing + } else { + $scope.$broadcast(COMPONENT.CREATE_COMPONENT, { + componentId: COMPONENT.VNF, + callbackFunction: createVnfCallbackFunction + }); + } + }; + + $scope.addVfModuleInstance = function (vnfInstance, vfModuleModel) { + + if (VIDCONFIGURATION.VNF_STATUS_CHECK_ENABLED) { + var msg = VnfService.isVnfStatusValid(vnfInstance); + if (msg != "") { + alert(msg); + return; + } + + } + var svcModel = $scope.service.convertedModel; + DataService.setSubscriberName($scope.service.instance.subscriberName); + DataService.setGlobalCustomerId($scope.service.instance.globalCustomerId); + DataService.setServiceType($scope.service.instance.serviceType); + DataService.setServiceInstanceName($scope.service.instance.name); + DataService.setServiceInstanceId($scope.service.instance.id); + DataService.setServiceName($scope.service.model.service.name); + + var vnfModelInvariantUuid = vnfInstance.object[FIELD.ID.MODEL_INVAR_ID]; + var vnfModelVersionId = vnfInstance.object[FIELD.ID.MODEL_VERSION_ID]; + var vnfModelCustomizationUuid = vnfInstance.object[FIELD.ID.MODEL_CUSTOMIZATION_ID]; + var vnfModel = null; + if (svcModel.isNewFlow) { + vnfModel = svcModel.vnfs[vnfModelCustomizationUuid]; + } + else { + vnfModel = svcModel.vnfs[vnfModelVersionId]; + } + + var availableVolumeGroupList = []; + angular.forEach(vnfInstance[FIELD.ID.AVAILABLEVOLUMEGROUPS], function (volumeGroupInstance, key) { + availableVolumeGroupList.push({"instance": volumeGroupInstance}); + }); + + DataService.setAvailableVolumeGroupList(availableVolumeGroupList); + setCurrentServiceModelInfoFromScope(); + + DataService.setVnfInstanceId(vnfInstance.object[FIELD.ID.VNF_ID]); + + DataService.setModelInfo(COMPONENT.VNF, { + "modelInvariantId": vnfModel.invariantUuid, + "modelVersion": vnfModel.version, + "modelNameVersionId": vnfModel.uuid, + "modelName": vnfModel.name, + "modelCustomizationName": vnfModel.modelCustomizationName, + "customizationUuid": vnfModel.customizationUuid, + "inputs": "" + }); + + DataService.setModelInfo(COMPONENT.VF_MODULE, { + "modelInvariantId": vfModuleModel.invariantUuid, + "modelVersion": vfModuleModel.version, + "modelNameVersionId": vfModuleModel.uuid, + "customizationUuid": vfModuleModel.customizationUuid, + "modelCustomizationName": vfModuleModel.modelCustomizationName, + "modelName": vfModuleModel.name, + "inputs": "" + }); + + $scope.$broadcast(COMPONENT.CREATE_COMPONENT, { + componentId: COMPONENT.VF_MODULE, + callbackFunction: createVfModuleCallbackFunction + }); + + }; + + $scope.addVolumeGroupInstance = function (vnfInstance, volumeGroupModel) { + if (VIDCONFIGURATION.VNF_STATUS_CHECK_ENABLED) { + var msg = VnfService.isVnfStatusValid(vnfInstance); + if (msg != "") { + alert(msg); + return; + } + } + var svcModel = $scope.service.convertedModel; + DataService.setSubscriberName($scope.service.instance.subscriberName); + DataService.setGlobalCustomerId($scope.service.instance.globalCustomerId); + DataService.setServiceType($scope.service.instance.serviceType); + 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, + "modelVersion": $scope.service.model.service.version, + "modelNameVersionId": $scope.service.model.service.uuid, + "modelName": $scope.service.model.service.name, + "inputs": "" + }); + + DataService.setVnfInstanceId(vnfInstance.object[FIELD.ID.VNF_ID]); + + var vnfModelInvariantUuid = vnfInstance.object[FIELD.ID.MODEL_INVAR_ID]; + var vnfModelVersionId = vnfInstance.object[FIELD.ID.MODEL_VERSION_ID]; + var vnfCustomizationUuid = vnfInstance.object[FIELD.ID.MODEL_CUSTOMIZATION_ID]; + var vnfModel = null; + + if (svcModel.isNewFlow) { + vnfModel = svcModel.vnfs[vnfCustomizationUuid]; + } + else { + vnfModel = svcModel.vnfs[vnfModelVersionId]; + } + + DataService.setModelInfo(COMPONENT.VNF, { + "modelInvariantId": vnfModel.invariantUuid, + "modelVersion": vnfModel.version, + "modelNameVersionId": vnfModel.uuid, + "modelName": vnfModel.name, + "modelCustomizationName": vnfModel.modelCustomizationName, + "customizationUuid": vnfModel.customizationUuid, + "inputs": "" + }); + + DataService.setModelInfo(COMPONENT.VOLUME_GROUP, { + "modelInvariantId": volumeGroupModel.invariantUuid, + "modelVersion": volumeGroupModel.version, + "modelNameVersionId": volumeGroupModel.uuid, + "modelName": volumeGroupModel.name, + "modelCustomizationName": volumeGroupModel.modelCustomizationName, + "customizationUuid": volumeGroupModel.customizationUuid, + "inputs": "" + }); + + $scope.$broadcast(COMPONENT.CREATE_COMPONENT, { + componentId: COMPONENT.VOLUME_GROUP, + callbackFunction: createVolumeGroupCallbackFunction + }); + }; + + $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_RESUME_COMPONENT, { + componentId: COMPONENT.CONFIGURATION, + dialogMethod: COMPONENT.DELETE, + callbackFunction: deleteCallbackFunction + }); + }; + + var deleteCallbackFunction = function () { + console.log('hi') + } + + $scope.resetProgress = function () { + $scope.percentProgress = 0; + $scope.progressClass = FIELD.STYLE.PROGRESS_BAR_INFO; + }; + + $scope.setProgress = function (percentProgress) { + percentProgress = parseInt(percentProgress); + if (percentProgress >= 100) { + $scope.progressClass = FIELD.STYLE.PROGRESS_BAR_SUCCESS; + } + + if (percentProgress < $scope.percentProgress) { + return; + } + + $scope.percentProgress = percentProgress; + $scope.progressWidth = {width: percentProgress + "%"}; + if (percentProgress >= 5) { + $scope.progressText = percentProgress + " %"; + } else { + // Hidden since color combination is barely visible when progress portion is narrow. + $scope.progressText = ""; + } + }; + $scope.isObjectEmpty = function (o) { + var len = 0; + if (UtilityService.hasContents(o)) { + var keys = Object.keys(o); + len = keys.length; + if (len == 0) { + return true; + } + else { + return false; + } + } + else { + return true; + } + } + $scope.isMacro = function () { + return $scope.service && AsdcService.isMacro($scope.service.model); + } + $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); + } + ); + } + + + function _setCr(data) { // data is the $scope.service.instance object + return CrService.getCr(data) + .then( + function success(response) { + return response.data.results; + // * 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; + $scope.callbackStyle = { + "background-color": color + }; + $scope.reloadRoute(); + /* + * 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; + + } else { + color = FIELD.ID.COLOR_F88; + } + $scope.callbackStyle = { + "background-color": color + }; + }, 500); + + }; + + var createVnfCallbackFunction = 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.reloadRoute(); + } else { + color = FIELD.ID.COLOR_F88; + } + $scope.callbackStyle = { + "background-color": color + }; + }, 500); + + + }; + + var deleteOrResumeCallback = 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.reloadRoute(); + } else { + color = FIELD.ID.COLOR_F88; + } + $scope.callbackStyle = { + "background-color": color + }; + }, 500); + + }; + + var createVfModuleCallbackFunction = 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.reloadRoute(); + } else { + color = FIELD.ID.COLOR_F88; + } + $scope.callbackStyle = { + "background-color": color + }; + }, 500); + + }; + + var deleteServiceInstanceCallbackFunction = 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; + $location.path(COMPONENT.SERVICEMODELS_MODELS_SERVICES_PATH) + } else { + color = FIELD.ID.COLOR_F88; + } + $scope.callbackStyle = { + "background-color": color + }; + }, 500); + + }; + + var createVolumeGroupCallbackFunction = 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.reloadRoute(); + } else { + color = FIELD.ID.COLOR_F88; + } + $scope.callbackStyle = { + "background-color": color + }; + }, 500); + + + }; + + }); })(); 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 b52b463b..c85e8652 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 @@ -22,17 +22,30 @@ 'use strict'; appDS2.controller("ServiceModelController", function ($scope, $http, $location, COMPONENT, VIDCONFIGURATION, FIELD, DataService, vidService, - PropertyService, UtilityService) { + PropertyService, UtilityService, AsdcService,$timeout) { $scope.popup = {}; - + var defaultViewPerPage = 10; // var baseEndpoint = "vid"; var pathQuery = COMPONENT.SERVICES_DIST_STATUS_PATH + VIDCONFIGURATION.ASDC_MODEL_STATUS; if ( VIDCONFIGURATION.ASDC_MODEL_STATUS === FIELD.STATUS.ALL) { pathQuery = COMPONENT.SERVICES_PATH; } - + window.addEventListener("message", receiveMessage, false); + + function receiveMessage(event){ + if(event.data == 'navigateTo') { + $location.path('/models/services').search({}); + $scope.$apply(); + $scope.rememberFilter = true; + } + if(event.data == 'navigateToInstantiationStatus') { + $location.path('/instantiationStatus').search({}); + $scope.$apply(); + } + } + $scope.getServiceModels = function() { $scope.status = FIELD.STATUS.FETCHING_SERVICE_CATALOG_ASDC; @@ -41,16 +54,28 @@ $scope.services = []; if (response.data && angular.isArray(response.data.services)) { wholeData = response.data.services; - $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.currentPageNum=1; - $scope.isSpinnerVisible = false; - $scope.isProgressVisible = false; + $scope.services = $scope.filterDataWithHigherVersion(wholeData); + $scope.viewPerPage = defaultViewPerPage; + $scope.totalPage=$scope.services.length/$scope.viewPerPage; + $scope.sortBy=COMPONENT.NAME; + $scope.scrollViewPerPage=2; + $scope.currentPage=1; + $scope.currentPageNum=1; + $scope.isSpinnerVisible = false; + $scope.isProgressVisible = false; + if (sessionStorage.getItem("searchKey")!='undefined' && ($scope.rememberFilter)) { + var searchKey = JSON.parse(sessionStorage.getItem("searchKey")); + $scope.searchString = searchKey.searchString || ''; + $scope.viewPerPage = searchKey.viewPerPage || defaultViewPerPage; + $scope.totalPage = $scope.services.length / $scope.viewPerPage; + $timeout(function () { + // the table controller handles the current page once + // data is loaded, therefore we're delying the paging + // override + $scope.currentPage = $scope.currentPageNum = searchKey.currentPage ? parseInt(searchKey.currentPage) : 1; + }, 0); + $scope.rememberFilter = false; + } } else { $scope.status = FIELD.STATUS.FAILED_SERVICE_MODELS_ASDC; $scope.error = true; @@ -99,25 +124,32 @@ //PropertyService.setMsoBaseUrl("testmso"); PropertyService.setServerResponseTimeoutMsec(30000); - } + }; $scope.prevPage = function() { $scope.currentPage--; - } + }; $scope.nextPage = function() { $scope.currentPage++; - } + }; + + $scope.createType = COMPONENT.A_LA_CARTE; $scope.deployService = function(service) { - + var searchKey = { + searchString: $scope.searchString, + viewPerPage: $scope.viewPerPage, + currentPage: $scope.currentPage + }; + sessionStorage.setItem("searchKey",JSON.stringify(searchKey)); console.log("Instantiating SDC service " + service.uuid); - + $http.get(COMPONENT.SERVICES_PATH + service.uuid) .then(function successCallback(getServiceResponse) { - + var serviceModel = getServiceResponse.data; //VID-233 bug fix when models doesn't exists @@ -157,41 +189,42 @@ DataService.setALaCarte (true); $scope.createType = COMPONENT.A_LA_CARTE; var broadcastType = COMPONENT.CREATE_COMPONENT; - - if (UtilityService.arrayContains (VIDCONFIGURATION.MACRO_SERVICES, serviceModel.service.invariantUuid )) { - DataService.setALaCarte (false); - $scope.createType = COMPONENT.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, - "serviceType": serviceModel.service.serviceType, - "serviceRole": serviceModel.service.serviceRole, - "displayInputs": convertedAsdcModel.completeDisplayInputs - }); - }; - + if (AsdcService.isMacro(serviceModel)) { + DataService.setALaCarte(false); + if(AsdcService.shouldExcludeMacroFromAsyncInstatiationFlow(serviceModel)){ + DataService.setShouldExcludeMacroFromAsyncInstatiationFlow(true); + $scope.createType = COMPONENT.MACRO; + var convertedAsdcModel = UtilityService.convertModel(serviceModel); + + 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, + "serviceType": serviceModel.service.serviceType, + "serviceRole": serviceModel.service.serviceRole, + "displayInputs": convertedAsdcModel.completeDisplayInputs + }); + + } + } + $scope.$broadcast(broadcastType, { componentId : COMPONENT.SERVICE, + modelNameVersionId: serviceModel.service.uuid, callbackFunction : function(response) { if (response.isSuccessful) { vidService.setModel(serviceModel); - + var subscriberId = FIELD.STATUS.NOT_FOUND; var serviceType = FIELD.STATUS.NOT_FOUND; - + var serviceInstanceId = response.instanceId; - + for (var i = 0; i < response.control.length; i++) { if (response.control[i].id == COMPONENT.SUBSCRIBER_NAME) { subscriberId = response.control[i].value; @@ -199,14 +232,13 @@ serviceType = response.control[i].value; } } - - + + $scope.refreshSubs(subscriberId,serviceType,serviceInstanceId); - + } } }); - }, function errorCallback(response) { console.log("Error: " + response); }); @@ -231,7 +263,7 @@ callbackFunction : function(response) { } }); - } + }; $scope.refreshSubs = function(subscriberId, serviceType, serviceInstanceId) { $scope.status = FIELD.STATUS.FETCHING_SUBSCRIBER_LIST_AAI; @@ -243,7 +275,7 @@ }).then(function(response){ if (response.data.status < 200 || response.data.status > 202) { - $scope.showError(FIELD.ERROR.MSO) + $scope.showError(FIELD.ERROR.MSO); return; } 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 index 6e7ad50c..5d17faa9 100644 --- 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 @@ -163,6 +163,9 @@ appDS2.controller("ServiceProxyConfigController", ["COMPONENT", "$log", "FIELD", }, requestParams: function () { return requestParams; + }, + configuration: function () { + return 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 6129fd96..e30bd385 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 @@ -73,6 +73,14 @@ controller: 'ServiceProxyConfigController', templateUrl: 'app/vid/scripts/view-models/serviceProxyConfig.htm' }) + .when('/servicePlanning', { + controller: 'iframeController', + templateUrl: 'app/vid/scripts/view-models/iframe.htm' + }) + .when('/instantiationStatus', { + controller: 'iframeController', + templateUrl: 'app/vid/scripts/view-models/iframe.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 aeac7f33..164c71c7 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", "$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) { +appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", "DataService", "PropertyService", "$scope", "$http", "$timeout", "$location", "$log", "$route", "$uibModal", "VIDCONFIGURATION", "UtilityService", "vidService", "AaiService", "MsoService", "OwningEntityService", "AsdcService","featureFlags", "$q", "_", + function (COMPONENT, FIELD, PARAMETER, DataService, PropertyService, $scope, $http, $timeout, $location, $log, $route, $uibModal, VIDCONFIGURATION, UtilityService, vidService, AaiService, MsoService, OwningEntityService, AsdcService, featureFlags, $q, _) { $scope.showVnfDetails = function (vnf) { console.log("showVnfDetails"); @@ -44,6 +44,8 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", $scope.serviceTypes = [FIELD.PROMPT.SELECT_SERVICE, COMPONENT.UCPE_VMS, COMPONENT.SDN_L3_BONDING, COMPONENT.SDN_ETHERNET_INTERNET]; $scope.defaultSubscriberName = [FIELD.PROMPT.SELECT_SUB]; + $scope.verifyButtonEnabled = true; + var callbackFunction = function (response) { alert(response); }; @@ -223,7 +225,8 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", $scope.createType = "a la carte"; var broadcastType = "createComponent"; - if (UtilityService.arrayContains(VIDCONFIGURATION.MACRO_SERVICES, serviceModel.service.invariantUuid)) { + if (AsdcService.isMacro(serviceModel)) { + DataService.setShouldExcludeMacroFromAsyncInstatiationFlow(AsdcService.shouldExcludeMacroFromAsyncInstatiationFlow(serviceModel)); DataService.setALaCarte(false); $scope.createType = "Macro"; var convertedAsdcModel = UtilityService.convertModel(serviceModel); @@ -464,6 +467,61 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", $scope.setProgress(2); // Show "a little" progress } + function getRelatedInstanceGroupsByVnfId(genericVnf) { + var model = vidService.getModel(); + if (model && model.vnfs && !_.isEmpty(model.vnfs)) { + Object.keys(model.vnfs).forEach(function (key) { + var vnf = model.vnfs[key]; + if (vnf.vfcInstanceGroups && !_.isEmpty(vnf.vfcInstanceGroups)) { + if (vnf.uuid === genericVnf.modelVersionId) { + AaiService.getInstanceGroupsByVNFInstanceId(genericVnf.nodeId, + function (response) { //success + handleGetRelatedInstanceGroupsResponseForVnf(response, genericVnf); + }, + function (response) { //failure + $scope.showError(FIELD.ERROR.AAI); + $scope.errorMsg = FIELD.ERROR.FETCHING_SERVICE_INSTANCE_DATA + response.status; + $scope.errorDetails = response.data; + } + ) + } + } + }) + } + } + + function resolveModelDataIfMissing(modelVersionId) { + var model = vidService.getModel(); + if (model && model.service && model.service.uuid === modelVersionId) { + return $q.resolve(); // no need to resolve anything + } else { + // resolve model and value of isPermitted + return resolveIfIsPermitted() + .then(function() { + return getAsdcModelByVersionId(modelVersionId); + }) + } + } + + function resolveIfIsPermitted() { + var deferred = $q.defer(); + AaiService.searchServiceInstances( + '?subscriberId=' + $location.search().subscriberId + + '&serviceInstanceIdentifier=' + $location.search().serviceInstanceId) + .then(function (response) { + if (response.displayData && response.displayData.length) { + var first = response.displayData[0]; + $scope.isPermitted = first.isPermitted; + deferred.resolve(first.isPermitted); + } else { + deferred.reject("some error while resolveIfIsPermitted") + } + }); + + return deferred.promise; + } + + $scope.getComponentList = function (event, request) { $scope.isSpinnerVisible = true; @@ -484,34 +542,70 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", //$scope.getAsdcModel($location.search().modelUuid); - $scope.namedQueryId = VIDCONFIGURATION.COMPONENT_LIST_NAMED_QUERY_ID; - $scope.status = FIELD.STATUS.FETCHING_SERVICE_INST_DATA + $scope.serviceInstanceId; - - AaiService.runNamedQuery($scope.namedQueryId, $scope.globalCustomerId, $scope.serviceType, $scope.serviceInstanceId, - function (response) { //success - $scope.handleInitialResponseInventoryItems(response); - $scope.setProgress(100); // done - $scope.status = FIELD.STATUS.DONE; - $scope.isSpinnerVisible = false; - }, - function (response) { //failure - $scope.showError(FIELD.ERROR.AAI); - $scope.errorMsg = FIELD.ERROR.FETCHING_SERVICE_INSTANCE_DATA + response.status; - $scope.errorDetails = response.data; - } - ); - - } + return getModelVersionIdForServiceInstance({ + globalCustomerId: $location.search().subscriberId, + serviceInstanceId: $location.search().serviceInstanceId, + aaiModelVersionId: $location.search().aaiModelVersionId + }) + .then(resolveModelDataIfMissing) + .then($scope.prepareScopeWithModel) + .then(function () { + + $scope.namedQueryId = VIDCONFIGURATION.COMPONENT_LIST_NAMED_QUERY_ID; + $scope.status = FIELD.STATUS.FETCHING_SERVICE_INST_DATA + $scope.serviceInstanceId; + + return AaiService.runNamedQuery($scope.namedQueryId, $scope.globalCustomerId, $scope.serviceType, $scope.serviceInstanceId, + function (response) { //success + $scope.handleInitialResponseInventoryItems(response); + $scope.setProgress(100); // done + $scope.status = FIELD.STATUS.DONE; + $scope.isSpinnerVisible = false; + //TODO + }, + function (response) { //failure + $scope.showError(FIELD.ERROR.AAI); + $scope.errorMsg = FIELD.ERROR.FETCHING_SERVICE_INSTANCE_DATA + response.status; + $scope.errorDetails = response.data; + } + ) + }) + }; $scope.handleServerError = function (response, status) { alert(response.statusText); } + function handleGetRelatedInstanceGroupsResponseForVnf(response, genericVnf) { + _.forEach(response.data, function (instanceGroup) { + var newInstanceGroup = { + name: instanceGroup.name, + type: instanceGroup.type + }; + genericVnf.instanceGroups.push(newInstanceGroup); + }) + } + + + function getModelVersionIdForServiceInstance(instance) { if (UtilityService.hasContents(instance.aaiModelVersionId)) { return $q.resolve(instance.aaiModelVersionId); + } else if ($scope.modelVersionIdForServiceInstance + && $scope.modelVersionIdForServiceInstance.globalCustomerId === instance.globalCustomerId + && $scope.modelVersionIdForServiceInstance.serviceInstanceId === instance.serviceInstanceId + ) { + return $q.resolve($scope.modelVersionIdForServiceInstance.aaiModelVersionId); } else { - return AaiService.getModelVersionId(instance.globalCustomerId, instance.serviceInstanceId); + $scope.status = FIELD.STATUS.FETCHING_SERVICE_INST_DATA + $scope.serviceInstanceId; + return AaiService.getModelVersionId(instance.globalCustomerId, instance.serviceInstanceId) + .then(function (aaiModelVersionId) { + $scope.modelVersionIdForServiceInstance = { + globalCustomerId: instance.globalCustomerId, + serviceInstanceId: instance.serviceInstanceId, + aaiModelVersionId: aaiModelVersionId + }; + return $q.resolve(aaiModelVersionId); + }); } } @@ -529,6 +623,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", COMPONENT.SUBSCRIBERNAME_SUB_PATH + disData.subscriberName + COMPONENT.SERVICETYPE_SUB_PATH + disData.serviceType + COMPONENT.SERVICEINSTANCEID_SUB_PATH + disData.serviceInstanceId + + COMPONENT.MODELVERSIONID_SUB_PATH + disData.aaiModelVersionId + COMPONENT.IS_PERMITTED_SUB_PATH + disData.isPermitted; } }; @@ -547,13 +642,22 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", method: 'GET', url: pathQuery }).then(function successCallback(response) { - vidService.setModel(response.data); - console.log("aaiSubscriber getAsdcModel DONE!!!!"); - }, function errorCallback(response) { + if (response.headers()['content-type'].includes('json')) { + vidService.setModel(response.data); + console.log("aaiSubscriber getAsdcModel DONE!!!!"); + } else { + // the response is erroneous + console.log("aaiSubscriber getAsdcModel BAD RESPONSE"); + errorCallback(response); + return $q.reject() + } + }, errorCallback); + + function errorCallback(response) { $log.error("aaiSubscriber getAsdcModel - " + FIELD.ERROR.NO_MATCHING_MODEL_AAI + aaiModelVersionId); $scope.errorMsg = FIELD.ERROR.NO_MATCHING_MODEL_AAI + aaiModelVersionId; alert($scope.errorMsg); - }); + } } function returnMatchingServiceSubscription(serviceSubs, serviceId){ @@ -580,15 +684,20 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", }); } + $scope.isConfigurationDataAvailiable = function (configuration) { + $log.debug(configuration); + return configuration.configData && (!configuration.configData.errorDescription); + } + $scope.isActivateDeactivateEnabled = function(btnType) { - if ($scope.serviceOrchestrationStatus && $scope.service.model.service.serviceType.toLowerCase().indexOf('transport') != -1) { + if ($scope.serviceOrchestrationStatus) { + var status = $scope.serviceOrchestrationStatus.toLowerCase(); switch (btnType) { case "activate": - return $scope.serviceOrchestrationStatus === 'Created' || - $scope.serviceOrchestrationStatus.toLowerCase() === 'pendingdelete' || $scope.serviceOrchestrationStatus.toLowerCase() === 'pending-delete'; + return _.includes(COMPONENT.ACTIVATE_SERVICE_STATUSES, status); break; case "deactivate": - return $scope.serviceOrchestrationStatus === 'Active'; + return status === 'active'; break; } } @@ -596,6 +705,58 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", return false; }; + $scope.isShowVerifyService = function () { + return featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_SHOW_VERIFY_SERVICE); + } + + $scope.isEnableVerifyService = function () { + //Button should only be enabled when the service type is A la carte + if (DataService.getALaCarte()) { + return $scope.verifyButtonEnabled; + } + return false; + }; + + $scope.activateVerifyService = function () { + $scope.verifyButtonEnabled = false; + let url = COMPONENT.VERIFY_SERVICE_URL; + + let config = { + headers: { + 'Content-Type': 'application/json' + } + }; + + let data = { + "serviceInstanceList": [ + { + "serviceInstanceId": $scope.serviceInstanceId, + "modelVersionId": $scope.service.model.service.uuid, + "modelInvariantId": $scope.service.model.service.invariantUuid, + "customerId": $scope.globalCustomerId, + "serviceType": $scope.service.instance.serviceType, + } + ] + }; + AaiService.postPOMBAverificationRequest(url, data, config); + + }; + + $scope.isShowAssignmentsEnabled = function () { + if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_SHOW_ASSIGNMENTS)) { + if ($scope.serviceOrchestrationStatus) { + return $scope.serviceOrchestrationStatus.toLowerCase() === 'assigned'; + } + } + return false; + }; + + $scope.isResumeShown = function (status) { + var vfModuleStatus = status.toLowerCase(); + var serviceStatus = $scope.serviceOrchestrationStatus && $scope.serviceOrchestrationStatus.toLowerCase(); + return _.includes(['pendingactivation', 'assigned'], vfModuleStatus) && !$scope.isActivateDeactivateEnabled("activate"); + }; + $scope.handleInitialResponseInventoryItems = function (response) { $scope.inventoryResponseItemList = response.data[FIELD.ID.INVENTORY_RESPONSE_ITEM]; // get data from json @@ -642,6 +803,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", "configurations": [] }; + var portMirroringConfigurationIds = []; if (inventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) { angular.forEach(inventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM], function (subInventoryResponseItem, key) { @@ -693,12 +855,23 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", "nodeType": genericVnfObject[FIELD.ID.VNF_TYPE], "nodeId": genericVnfObject[FIELD.ID.VNF_ID], "nodeStatus": genericVnfObject[FIELD.ID.ORCHESTRATION_STATUS], + "modelVersionId" : genericVnfObject[FIELD.ID.MODEL_VERSION_ID], "object": genericVnfObject, "vfModules": [], "volumeGroups": [], + "instanceGroups": [], "availableVolumeGroups": [] }; + if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_VLAN_TAGGING_VIEW_EDIT)) { + + //TODO should be changed after integration + genericVnf["instanceGroups"] = [{"name":"a2"}]; + + } $scope.service.instance[FIELD.ID.VNFS].push(genericVnf); + getRelatedInstanceGroupsByVnfId(genericVnf); + + // look for volume-groups if (subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) { @@ -787,6 +960,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", } } + if (subInventoryResponseItem[FIELD.ID.GENERIC_CONFIGURATION] != null) { var configObject = subInventoryResponseItem[FIELD.ID.GENERIC_CONFIGURATION]; var config = { @@ -800,36 +974,60 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", "modelVersionId": configObject[FIELD.ID.MODEL_VERSION_ID], "modelCustomizationId": configObject[FIELD.ID.MODEL_CUSTOMIZATION_ID], "object": configObject, - "ports": [] + "ports": [], + "configData" : null }; + portMirroringConfigurationIds.push(configObject[FIELD.ID.CONFIGURATION_ID]); $scope.allowConfigurationActions = [FIELD.STATUS.AAI_ACTIVE, FIELD.STATUS.AAI_INACTIVE, FIELD.STATUS.AAI_CREATED].indexOf(config.nodeStatus) != -1; - if (subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) { - angular.forEach(subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM], function (subSubInventoryResponseItem, key) { - var port = {}; - var portObject; - if (subSubInventoryResponseItem[FIELD.ID.PORT] != null) { - portObject = subSubInventoryResponseItem[FIELD.ID.PORT]; - port = { - "portId": portObject[FIELD.ID.PORT_ID], - "portName": portObject[FIELD.ID.PORT_NAME], - "portStatus": portObject[FIELD.ID.PORT_MIRRORED] === true ? FIELD.STATUS.AAI_ENABLED : FIELD.ID.AAI_DISABLED, - "object": portObject - }; - config.ports.push(port); - } - }); - } $scope.service.instance[FIELD.ID.CONFIGURATIONS].push(config); } }); + + AaiService.getPortMirroringData(portMirroringConfigurationIds).then(function(result){ + angular.forEach($scope.service.instance[FIELD.ID.CONFIGURATIONS], function(config){ + config['configData'] = result.data[config['nodeId']] + + if (config.configData && config.configData.errorDescription) { + $scope.errorMsg = ($scope.errorMsg ? $scope.errorMsg + "\n" : "") + + "Cannot read cloud-region for configuration \"" + config.name + "\": " + + config.configData.errorDescription; + } + }); + }); + + AaiService.getPortMirroringSourcePorts(portMirroringConfigurationIds).then(function(result){ + angular.forEach($scope.service.instance[FIELD.ID.CONFIGURATIONS], function(config){ + angular.forEach(result.data[config['nodeId']], function(port){ + if (port.errorDescription) { + $scope.errorMsg = ($scope.errorMsg ? $scope.errorMsg + "\n" : "") + + "Cannot read a source port for configuration \"" + config.name + "\": " + + port.errorDescription; + } else { + config.ports.push({ + "portId": port[FIELD.ID.PORT_ID], + "portName": port[FIELD.ID.PORT_NAME], + "portStatus": port[FIELD.ID.PORT_MIRRORED] === true ? FIELD.STATUS.AAI_ENABLED : FIELD.STATUS.AAI_DISABLED + }); + } + }); + }); + }); + } }); + }); + + + } + + + $scope.handleInitialResponse = function (response) { try { $scope.enableCloseButton(true); @@ -977,7 +1175,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", }); }; - var activateDeactivateServiceInstance = function(msoType) { + var activateDeactivateServiceInstance = function (msoType) { var requestParams = { model: $scope.service.model, instance: $scope.service.instance @@ -997,73 +1195,111 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", } }; - $scope.activateMSOInstance = function() { + $scope.showAssignmentsSDNC = function () { + + if ($scope.service && $scope.service.instance) { + return VIDCONFIGURATION.SDNC_SHOW_ASSIGNMENTS_URL.replace("" , $scope.service.instance.id); + } + return null; + }; + + $scope.activateMSOInstance = function () { activateDeactivateServiceInstance(COMPONENT.MSO_ACTIVATE_SERVICE_REQ); }; - $scope.deactivateMSOInstance = function() { + $scope.deactivateMSOInstance = function () { activateDeactivateServiceInstance(COMPONENT.MSO_DEACTIVATE_SERVICE_REQ); }; - $scope.toggleConfigurationStatus = function (serviceObject, configuration) { - + $scope.deleteConfiguration = function (serviceObject, configuration) { AaiService.getLoggedInUserID(function (response) { - DataService.setLoggedInUserId(response.data); - var requestParams = { - serviceModel: { - "modelType": "service", - "modelInvariantId": serviceObject.model.service.invariantUuid, - "modelVersionId": "uuid", - "modelName": serviceObject.model.service.name, - "modelVersion": serviceObject.model.service.version - }, - configurationModel: { - "modelType": "configuration", - "modelInvariantId": configuration.modelInvariantId, - "modelVersionId": configuration.modelVersionId, - "modelCustomizationId": configuration.modelCustomizationId - }, - serviceInstanceId: serviceObject.instance.serviceInstanceId, - configurationId: configuration.nodeId, - configStatus: configuration.nodeStatus, - userId: DataService.getLoggedInUserId() - }; + DataService.setLoggedInUserId(response.data); + var requestParams = { + serviceModel: { + "modelType": "configuration", + "modelInvariantId": serviceObject.model.service.invariantUuid, + "modelVersionId": serviceObject.model.service.uuid, + "modelName": serviceObject.model.service.name, + "modelVersion": serviceObject.model.service.version + }, + configurationModel: { + "modelType": "configuration", + "modelInvariantId": configuration.modelInvariantId, + "modelVersionId": configuration.modelVersionId, + "modelCustomizationId": configuration.modelCustomizationId + }, + serviceInstanceId: serviceObject.instance.serviceInstanceId, + configurationId: configuration.nodeId, + configStatus: configuration.DELETE, + userId: DataService.getLoggedInUserId() + }; - openMsoModal(COMPONENT.MSO_CHANGE_CONFIG_STATUS_REQ, requestParams); - }); + openMsoModal(COMPONENT.MSO_DELETE_CONFIGURATION_REQ, requestParams, configuration); + }); }; - $scope.togglePortStatus = function(serviceObject, configuration, port) { + $scope.toggleConfigurationStatus = function (serviceObject, configuration) { + AaiService.getLoggedInUserID(function (response) { + DataService.setLoggedInUserId(response.data); + var requestParams = { + serviceModel: { + "modelType": "service", + "modelInvariantId": serviceObject.model.service.invariantUuid, + "modelVersionId": serviceObject.model.service.uuid, + "modelName": serviceObject.model.service.name, + "modelVersion": serviceObject.model.service.version + }, + configurationModel: { + "modelType": "configuration", + "modelInvariantId": configuration.modelInvariantId, + "modelVersionId": configuration.modelVersionId, + "modelCustomizationId": configuration.modelCustomizationId + }, + serviceInstanceId: serviceObject.instance.serviceInstanceId, + configurationId: configuration.nodeId, + configStatus: configuration.nodeStatus, + userId: DataService.getLoggedInUserId() + }; + + openMsoModal(COMPONENT.MSO_CHANGE_CONFIG_STATUS_REQ, requestParams, configuration); + }); - var requestParams = { - serviceInstanceId: serviceObject.instance.serviceInstanceId, - configurationId: configuration.nodeId, - portId: port.portId, - portStatus: port.portStatus, - serviceModel: { - "modelType": "service", - "modelInvariantId": serviceObject.model.service.invariantUuid, - "modelVersionId": "uuid", - "modelName": serviceObject.model.service.name, - "modelVersion": serviceObject.model.service.version - }, - configurationModel: { - "modelType": "configuration", - "modelInvariantId": configuration.modelInvariantId, - "modelVersionId": configuration.modelVersionId, - "modelCustomizationId": configuration.modelCustomizationId - }, - userId: DataService.getLoggedInUserId() - }; + }; - openMsoModal(COMPONENT.MSO_CHANGE_PORT_STATUS_REQ, requestParams); + $scope.togglePortStatus = function (serviceObject, configuration, port) { + AaiService.getLoggedInUserID(function (response) { + DataService.setLoggedInUserId(response.data); + + var requestParams = { + serviceInstanceId: serviceObject.instance.serviceInstanceId, + configurationId: configuration.nodeId, + portId: port.portId, + portStatus: port.portStatus, + serviceModel: { + "modelType": "service", + "modelInvariantId": serviceObject.model.service.invariantUuid, + "modelVersionId": serviceObject.model.service.uuid, + "modelName": serviceObject.model.service.name, + "modelVersion": serviceObject.model.service.version + }, + configurationModel: { + "modelType": "configuration", + "modelInvariantId": configuration.modelInvariantId, + "modelVersionId": configuration.modelVersionId, + "modelCustomizationId": configuration.modelCustomizationId + }, + userId: DataService.getLoggedInUserId() + }; + + openMsoModal(COMPONENT.MSO_CHANGE_PORT_STATUS_REQ, requestParams, configuration); + }); }; - $scope.dissociatePnf = function(pnfName) { + $scope.dissociatePnf = function (pnfName) { var jobInfo = { status: "confirm", @@ -1098,12 +1334,14 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", }; if (DataService.getLoggedInUserId()) { + requestParams.userId = DataService.getLoggedInUserId(); requestParams.attuuid = DataService.getLoggedInUserId(); openMsoModal(COMPONENT.MSO_REMOVE_RELATIONSHIP, requestParams); } else { AaiService.getLoggedInUserID(function (response) { DataService.setLoggedInUserId(response.data); + requestParams.userId = response.data; requestParams.attuuid = response.data; openMsoModal(COMPONENT.MSO_REMOVE_RELATIONSHIP, requestParams); }); @@ -1114,35 +1352,38 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", }; - var openMsoModal = function (msoType, requestParams) { + var openMsoModal = function (msoType, requestParams, configuration) { var modalInstance = $uibModal.open({ templateUrl: 'app/vid/scripts/modals/mso-commit/mso-commit.html', - controller : "msoCommitModalController", + controller: "msoCommitModalController", backdrop: false, resolve: { msoType: function () { return msoType; }, - requestParams: function() { + requestParams: function () { requestParams.callbackFunction = updateViewCallbackFunction; return requestParams; + }, + configuration: function () { + return configuration; } } }); }; - var updateViewCallbackFunction = function(response) { + var updateViewCallbackFunction = function (response) { $scope.callbackResults = ""; var color = FIELD.ID.COLOR_NONE; $scope.callbackStyle = { - "background-color" : color + "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() { + $timeout(function () { $scope.callbackResults = UtilityService.getCurrentTime() + FIELD.STATUS.IS_SUCCESSFUL + response.isSuccessful; if (response.isSuccessful) { @@ -1152,7 +1393,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", color = FIELD.ID.COLOR_F88; } $scope.callbackStyle = { - "background-color" : color + "background-color": color }; }, 500); }; @@ -1198,7 +1439,8 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", } } }; - }]).directive('restrictInput', function () { + } +]).directive('restrictInput', function () { return { diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/change-management.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/change-management.controller.js index 488ada69..e15ce5fd 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/change-management.controller.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/change-management.controller.js @@ -8,6 +8,7 @@ vm.lastTimeUpdated = ""; vm.hasScheduler = !!VIDCONFIGURATION.SCHEDULER_PORTAL_URL; + vm.currModal = null; vm.init = function() { vm.lastTimeUpdated = $filter('date')(new Date(), "MM/dd/yyyy | HH:mm:ss"); @@ -15,11 +16,31 @@ loadSchedulerChangeManagements(); }; + var fuseMsoAndSchedulerTaks = function() { + if (vm.changeManagements && vm.pendingChangeManagements) { + var requestIdToVnfName = {} + vm.pendingChangeManagements.forEach(function(schedulerItem) { + if (schedulerItem.msoRequestId && schedulerItem.vnfName) { + requestIdToVnfName[schedulerItem.msoRequestId] = schedulerItem.vnfName; + } + }) + $log.debug("requestIdToVnfName", requestIdToVnfName); + + vm.changeManagements = vm.changeManagements.map(function(msoItem) { + msoItem['vnfNameFromScheduler'] = requestIdToVnfName[msoItem.requestId]; + return msoItem; + }) + } + }; + var loadMSOChangeManagements = function() { changeManagementService.getMSOChangeManagements() .then(function(response) { vm.changeManagements = response.data; }) + .then(function () { + fuseMsoAndSchedulerTaks(); + }) .catch(function (error) { $log.error(error); }); @@ -43,12 +64,16 @@ } }); }) + .then(function () { + fuseMsoAndSchedulerTaks(); + }) .catch(function(error) { $log.error(error); }); }; vm.createNewChange = function() { + vm.closeCurrentModalIfOpen(); var modalInstance = $uibModal.open({ templateUrl: 'app/vid/scripts/modals/new-change-management/new-change-management.html', controller: 'newChangeManagementModalController', @@ -56,6 +81,8 @@ resolve: {} }); + vm.currModal = modalInstance; + modalInstance.result.then(function (result) { console.log("This is the result of the new change management modal.", result); }); @@ -65,29 +92,18 @@ console.log("function for searching changes: " + vm.searchChangesTerm) }; - vm.openFailedModal = function(jobInfo) { - var modalInstance = $uibModal.open({ - templateUrl: 'app/vid/scripts/modals/failed-change-management/failed-change-management.html', - controller: 'changeManagementManualTasksController', - controllerAs: 'vm', - resolve: { - jobInfo: function () { - return jobInfo; - } - }, - }); + vm.openManualTasksPopup = function($event, jobInfo, templateUrl, message) { - modalInstance.result.then(function (result) { - console.log("This is the result of the failed change management modal.", result); - }); - }; + vm.closeCurrentModalIfOpen(); - vm.openInProgressModal = function(jobInfo) { var modalInstance = $uibModal.open({ - templateUrl: 'app/vid/scripts/modals/in-progress-modal-management/in-progress-change-management.html', + templateUrl: templateUrl, controller: 'changeManagementManualTasksController', controllerAs: 'vm', + backdrop: false, + animation: true, + appendTo: angular.element($event.currentTarget).parent(), resolve: { jobInfo: function () { return jobInfo; @@ -96,31 +112,38 @@ }); modalInstance.result.then(function (result) { - console.log("This is the result of the in progress change management modal.", result); + console.log(message, result); }); + + vm.currModal = modalInstance; }; - vm.openAlertModal = function(jobInfo) { - var modalInstance = $uibModal.open({ - templateUrl: 'app/vid/scripts/modals/alert-change-management/alert-change-management.html', - controller: 'changeManagementManualTasksController', - controllerAs: 'vm', - resolve: { - jobInfo: function () { - return jobInfo; - } - } - }); + vm.openFailedModal = function($event, jobInfo) { + vm.openManualTasksPopup($event, jobInfo, + 'app/vid/scripts/modals/failed-change-management/failed-change-management.html', + "This is the result of the failed change management modal.") + }; - modalInstance.result.then(function (result) { - console.log("This is the result of the alert change management modal.", result); - }); + vm.openInProgressModal = function($event, jobInfo) { + vm.openManualTasksPopup($event, jobInfo, + 'app/vid/scripts/modals/in-progress-modal-management/in-progress-change-management.html', + "This is the result of the in progress change management modal.") + }; + + vm.openAlertModal = function($event, jobInfo) { + vm.openManualTasksPopup($event, jobInfo, + 'app/vid/scripts/modals/alert-change-management/alert-change-management.html', + "This is the result of the alert change management modal.") }; + vm.openBasicAlertModal = function(jobInfo) { + vm.closeCurrentModalIfOpen(); var modalInstance = $uibModal.open({ templateUrl: 'app/vid/scripts/modals/alert-modal/alert-modal.html', controller: 'alertModalController', controllerAs: 'vm', + backdrop: false, + animation: true, appendTo: angular.element(".jobs-table").eq(0), resolve: { jobInfo: function () { @@ -128,12 +151,16 @@ } } }); + vm.currModal = modalInstance; modalInstance.result.then(function (result) { console.log("This is the result of the alert change management modal.", result); }); }; vm.openPendingModal = function($event, changeManagement) { + + vm.closeCurrentModalIfOpen(); + var modalInstance = $uibModal.open({ templateUrl: 'app/vid/scripts/modals/cancel-pending-workflow/cancel-pending-workflow.html', controller: 'cancelPendingWorkflowController', @@ -148,6 +175,8 @@ } }); + vm.currModal = modalInstance; + modalInstance.result.then(function (result) { // send to service if(result){ @@ -173,6 +202,16 @@ }}); }; + vm.isChangeManagementDeleted = function(changeManagement) { + return changeManagement.scheduleRequest.status!=='Deleted' + }; + + vm.closeCurrentModalIfOpen = function() { + if (vm.currModal != null) { + vm.currModal.close(); + vm.currModal = null; + } + } vm.init(); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/creationDialogController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/creationDialogController.js index 3d8cba5c..e8fa529f 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/creationDialogController.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/creationDialogController.js @@ -20,331 +20,357 @@ "use strict"; -var creationDialogController = function( COMPONENT, FIELD, PARAMETER, $scope, $http, $timeout, $log, - CreationService, UtilityService, DataService,VIDCONFIGURATION) { - - $scope.isDialogVisible = false; - $scope.summaryControl = {}; - $scope.userProvidedControl = {}; - - var callbackFunction = undefined; - var componentId = undefined; - - $scope.$on(COMPONENT.CREATE_COMPONENT, function(event, request) { - - $scope.isSpinnerVisible = true; - $scope.isErrorVisible = false; - $scope.isDataVisible = false; - $scope.isConfirmEnabled = false; - $scope.isDialogVisible = true; - $scope.popup.isVisible = true; - - callbackFunction = request.callbackFunction; - componentId = request.componentId; - CreationService.initializeComponent(request.componentId); - - CreationService.setHttpErrorHandler(function(response) { - showError(FIELD.ERROR.SYSTEM_FAILURE, UtilityService - .getHttpErrorMessage(response)); - }); - - $scope.componentName = CreationService.getComponentDisplayName(); - - CreationService.getParameters(handleGetParametersResponse); - - }); - - var handleGetParametersResponse = function(parameters) { - $scope.summaryControl.setList(parameters.summaryList); - $scope.userProvidedControl.setList(parameters.userProvidedList); - - $scope.isSpinnerVisible = false; - $scope.isDataVisible = true; - $scope.isConfirmEnabled = true; - }; - - var validateInstanceName = function(iname) { - var patt1 = /^([a-z])+([0-9a-z\-_\.]*)$/i; - - if ( iname == null ){ - return false; - } - if ( !iname.match(patt1) ) { - return false; - } - return true; - }; - var validateMap = function(mname) { - var patt1 = /^{(\s*\w+\s*:\s*\w+\s*)(\s*,\s*\w+\s*:\s*\w+\s*)*}$/im; - if ( mname == null ){ - return true; - } - if ( !mname.match(patt1) ) { - return false; - } - return true; - }; - - var validateList = function(lname) { - var patt1 = /^\[(\s*\w+\s*)(\s*,\s*\w+\s*)*\]$/i; - if ( lname == null ){ - return true; - } - if ( !lname.match(patt1) ) { - return false; - } - return true; - }; - - $scope.userParameterChanged = function(id) { - CreationService.updateUserParameterList(id, $scope.userProvidedControl); - } - - $scope.confirm = function() { - - var requiredFields = $scope.userProvidedControl.getRequiredFields(); - if (requiredFields !== "") { - showError(FIELD.ERROR.MISSING_DATA, requiredFields); - return; - } - - var isUploadAvailable = false; - var uploadIndex =0; - var paramList = $scope.userProvidedControl.getList(); - var isAnyError = false; - for (var i = 0; i < paramList.length; i++) { - if (paramList[i].id === FIELD.ID.SUPPLEMENTORY_DATA_FILE) { - isUploadAvailable = true; - uploadIndex=i; - } - if (paramList[i].id === FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE && paramList[i].value && document.getElementById(FIELD.ID.SUPPLEMENTORY_DATA_FILE).value=='' ) { - isAnyError = true; - } - } - - if(isUploadAvailable && isAnyError ){ - showError(FIELD.ERROR.MISSING_DATA, FIELD.ERROR.MISSING_FILE); - return; - }else if(isUploadAvailable && document.getElementById(FIELD.ID.SUPPLEMENTORY_DATA_FILE).value!='' ){ - var errorMsg = ""; - var fileInput = document.getElementById(FIELD.ID.SUPPLEMENTORY_DATA_FILE); - var file = fileInput.files[0]; - var reader = new FileReader(); - reader.onload = function(e) { - try{ - paramList[uploadIndex].value = JSON.parse(reader.result); - FIELD.PARAMETER.SUPPLEMENTORY_DATA_FILE['value'] = paramList[uploadIndex].value; - - var instanceName = ""; - - if ( DataService.getALaCarte() ) { - if ( paramList != null ) { - for (var i = 0; i < paramList.length; i++) { - if (paramList[i].id === FIELD.ID.INSTANCE_NAME) { - instanceName = paramList[i].value; - break; - } - } - } - var isValid = validateInstanceName (instanceName); - if ( isValid ) { - $scope.isErrorVisible = false; - } else { - showError(FIELD.ERROR.INVALID_INSTANCE_NAME + instanceName, - FIELD.ERROR.INSTANCE_NAME_VALIDATE); - return; - } - } - var arbitraryParametersList = DataService.getArbitraryParameters(); - var p = null; - if (UtilityService.hasContents (arbitraryParametersList)) { - for (var i = 0; i < arbitraryParametersList.length; i++) { - p = arbitraryParametersList[i]; - if (p.type === PARAMETER.MAP) { - //validate a map: { : , ... , : } - // need to find the value in paramList - for (var j = 0; j < paramList.length; j++) { - if (paramList[j].id === p.id) { - p.value = paramList[j].value; - var isValid = validateMap (p.value); - if ( isValid ) { - $scope.isErrorVisible = false; - break; - } - else { - showError(FIELD.ERROR.INVALID_MAP + p.id, - FIELD.ERROR.MAP_VALIDATE); - return; - } - } - } - } else if (p.type === PARAMETER.LIST) { - //validate a list: { value or a list of comma separated values } - // need to find the value in paramList - for (var j = 0; j < paramList.length; j++) { - if (paramList[j].id === p.id) { - p.value = paramList[j].value; - var isValid = validateList (p.value); - if ( isValid ) { - $scope.isErrorVisible = false; - break; - } - else { - showError(FIELD.ERROR.INVALID_LIST + p.id, - FIELD.ERROR.LIST_VALIDATE); - return; - } - } - } - } - } - } - var requestDetails = CreationService - .getMsoRequestDetails($scope.userProvidedControl.getList()); - - $scope.isDialogVisible = false; - - $scope.$broadcast(COMPONENT.MSO_CREATE_REQ, { - url : CreationService.getMsoUrl(), - requestDetails : requestDetails, - componentId: componentId, - callbackFunction : function(response) { - if (response.isSuccessful) { - $scope.popup.isVisible = false; - runCallback(response); - } else { - $scope.isDialogVisible = false; - $scope.popup.isVisible = false; - } - } - }); - - }catch(e){ - errorMsg = errorMsg+ FIELD.ERROR.INVALID_DATA_FORMAT; - } - if (errorMsg !== "") { - showError(FIELD.ERROR.SYSTEM_FAILURE, errorMsg); - return; - } - } - reader.readAsText(file); - }else{ - - var paramList = $scope.userProvidedControl.getList(); - var instanceName = ""; - - if ( DataService.getALaCarte() ) { - if ( paramList != null ) { - for (var i = 0; i < paramList.length; i++) { - if (paramList[i].id === FIELD.ID.INSTANCE_NAME) { - instanceName = paramList[i].value; - break; - } - } - } - var isValid = validateInstanceName (instanceName); - if ( isValid ) { - $scope.isErrorVisible = false; - } else { - showError(FIELD.ERROR.INVALID_INSTANCE_NAME + instanceName, - FIELD.ERROR.INSTANCE_NAME_VALIDATE); - return; - } - } - var arbitraryParametersList = DataService.getArbitraryParameters(); - var p = null; - if (UtilityService.hasContents (arbitraryParametersList)) { - for (var i = 0; i < arbitraryParametersList.length; i++) { - p = arbitraryParametersList[i]; - if (p.type === PARAMETER.MAP) { - //validate a map: { : , ... , : } - // need to find the value in paramList - for (var j = 0; j < paramList.length; j++) { - if (paramList[j].id === p.id) { - p.value = paramList[j].value; - var isValid = validateMap (p.value); - if ( isValid ) { - $scope.isErrorVisible = false; - break; - } - else { - showError(FIELD.ERROR.INVALID_MAP + p.id, - FIELD.ERROR.MAP_VALIDATE); - return; - } - } - } - } else if (p.type === PARAMETER.LIST) { - //validate a list: { value or a list of comma separated values } - // need to find the value in paramList - for (var j = 0; j < paramList.length; j++) { - if (paramList[j].id === p.id) { - p.value = paramList[j].value; - var isValid = validateList (p.value); - if ( isValid ) { - $scope.isErrorVisible = false; - break; - } - else { - showError(FIELD.ERROR.INVALID_LIST + p.id, - FIELD.ERROR.LIST_VALIDATE); - return; - } - } - } - } - } - } - var requestDetails = CreationService - .getMsoRequestDetails($scope.userProvidedControl.getList()); - - $scope.isDialogVisible = false; - - $scope.$broadcast(COMPONENT.MSO_CREATE_REQ, { - url : CreationService.getMsoUrl(), - requestDetails : requestDetails, - componentId: componentId, - callbackFunction : function(response) { - if (response.isSuccessful) { - $scope.popup.isVisible = false; - runCallback(response); - } else { - $scope.isDialogVisible = false; - $scope.popup.isVisible = false; - } - } - }); - } - } - - $scope.cancel = function() { - $scope.isDialogVisible = false; - $scope.popup.isVisible = false; - runCallback(false); - } - - var runCallback = function(response) { - if (angular.isFunction(callbackFunction)) { - callbackFunction({ - isSuccessful : response.isSuccessful, - control : $scope.userProvidedControl.getList(), - instanceId : response.instanceId - }); - } - } - - var showError = function(summary, details) { - var message = summary; - if (UtilityService.hasContents(details)) { - message += " (" + details + ")"; - } - $scope.isSpinnerVisible = false; - $scope.isErrorVisible = true; - $scope.error = message; - } - -} - -appDS2.controller("creationDialogController", [ "COMPONENT", "FIELD", "PARAMETER", "$scope", "$http", - "$timeout", "$log", "CreationService", "UtilityService", "DataService","VIDCONFIGURATION", - creationDialogController ]); +var creationDialogController = function (COMPONENT, FIELD, PARAMETER, $scope, $http, $timeout, $log, + CreationService, UtilityService, DataService, VIDCONFIGURATION, $location) { + + $scope.isDialogVisible = false; + $scope.summaryControl = {}; + $scope.userProvidedControl = {}; + + var callbackFunction = undefined; + var componentId = undefined; + + $scope.shouldShowOldPopup = function () { + return DataService.getALaCarte() || DataService.getShouldExcludeMacroFromAsyncInstatiationFlow() + }; + + function receiveMessage(event) { + if (event.data == 'closeIframe') { + window.removeEventListener("message", receiveMessage, false); + + $scope.cancel(); + } + else if (event.data.eventId == 'submitIframe') { + { + $location.path('/servicePlanning').search({serviceModelId: event.data.data.serviceModelId}); + } + } + $scope.$apply(); + } + + $scope.$on(COMPONENT.CREATE_COMPONENT, function (event, request) { + $scope.isSpinnerVisible = true; + $scope.isErrorVisible = false; + $scope.isDataVisible = false; + $scope.isConfirmEnabled = false; + $scope.isDialogVisible = true; + $scope.popup.isVisible = true; + + + if (!$scope.shouldShowOldPopup()) { + $scope.url = COMPONENT.SERVICE_POPUP_IFRAME_URL + request.modelNameVersionId + "&isCreate=true&r=" + Math.random(); + window.addEventListener("message", receiveMessage, false); + + } + else { + callbackFunction = request.callbackFunction; + componentId = request.componentId; + CreationService.initializeComponent(request.componentId); + + CreationService.setHttpErrorHandler(function (response) { + showError(FIELD.ERROR.SYSTEM_FAILURE, UtilityService + .getHttpErrorMessage(response)); + }); + + $scope.componentName = CreationService.getComponentDisplayName(); + + CreationService.getParameters(handleGetParametersResponse); + } + + }); + + var handleGetParametersResponse = function (parameters) { + $scope.summaryControl.setList(parameters.summaryList); + $scope.userProvidedControl.setList(parameters.userProvidedList); + + $scope.isSpinnerVisible = false; + $scope.isDataVisible = true; + $scope.isConfirmEnabled = true; + }; + + var validateInstanceName = function (iname) { + var patt1 = /^([a-z])+([0-9a-z\-_\.]*)$/i; + + if (iname == null) { + return false; + } + if (!iname.match(patt1)) { + return false; + } + return true; + }; + var validateMap = function (mname) { + var patt1 = /^{(\s*\w+\s*:\s*\w+\s*)(\s*,\s*\w+\s*:\s*\w+\s*)*}$/im; + if (mname == null) { + return true; + } + if (!mname.match(patt1)) { + return false; + } + return true; + }; + + var validateList = function (lname) { + var patt1 = /^\[(\s*\w+\s*)(\s*,\s*\w+\s*)*\]$/i; + if (lname == null) { + return true; + } + if (!lname.match(patt1)) { + return false; + } + return true; + }; + + $scope.userParameterChanged = function (id) { + CreationService.updateUserParameterList(id, $scope.userProvidedControl); + }; + + $scope.confirm = function () { + + var requiredFields = $scope.userProvidedControl.getRequiredFields(); + if (requiredFields !== "") { + showError(FIELD.ERROR.MISSING_DATA, requiredFields); + return; + } + + var isUploadAvailable = false; + var uploadIndex = 0; + var paramList = $scope.userProvidedControl.getList(); + var isAnyError = false; + for (var i = 0; i < paramList.length; i++) { + if (paramList[i].id === FIELD.ID.SUPPLEMENTORY_DATA_FILE) { + isUploadAvailable = true; + uploadIndex = i; + } + if (paramList[i].id === FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE && paramList[i].value && document.getElementById(FIELD.ID.SUPPLEMENTORY_DATA_FILE).value == '') { + isAnyError = true; + } + } + + if (isUploadAvailable && isAnyError) { + showError(FIELD.ERROR.MISSING_DATA, FIELD.ERROR.MISSING_FILE); + + } else if (isUploadAvailable && document.getElementById(FIELD.ID.SUPPLEMENTORY_DATA_FILE).value != '') { + var errorMsg = ""; + var fileInput = document.getElementById(FIELD.ID.SUPPLEMENTORY_DATA_FILE); + var file = fileInput.files[0]; + var reader = new FileReader(); + reader.onload = function (e) { + try { + paramList[uploadIndex].value = JSON.parse(reader.result); + FIELD.PARAMETER.SUPPLEMENTORY_DATA_FILE['value'] = paramList[uploadIndex].value; + + var instanceName = ""; + + if (DataService.getALaCarte()) { + if (paramList != null) { + for (var i = 0; i < paramList.length; i++) { + if (paramList[i].id === FIELD.ID.INSTANCE_NAME) { + instanceName = paramList[i].value; + break; + } + } + } + var isValid = validateInstanceName(instanceName); + if (isValid) { + $scope.isErrorVisible = false; + } else { + showError(FIELD.ERROR.INVALID_INSTANCE_NAME + instanceName, + FIELD.ERROR.INSTANCE_NAME_VALIDATE); + return; + } + } + var arbitraryParametersList = DataService.getArbitraryParameters(); + var p = null; + if (UtilityService.hasContents(arbitraryParametersList)) { + for (var i = 0; i < arbitraryParametersList.length; i++) { + p = arbitraryParametersList[i]; + if (p.type === PARAMETER.MAP) { + //validate a map: { : , ... , : } + // need to find the value in paramList + for (var j = 0; j < paramList.length; j++) { + if (paramList[j].id === p.id) { + p.value = paramList[j].value; + var isValid = validateMap(p.value); + if (isValid) { + $scope.isErrorVisible = false; + break; + } + else { + showError(FIELD.ERROR.INVALID_MAP + p.id, + FIELD.ERROR.MAP_VALIDATE); + return; + } + } + } + } else if (p.type === PARAMETER.LIST) { + //validate a list: { value or a list of comma separated values } + // need to find the value in paramList + for (var j = 0; j < paramList.length; j++) { + if (paramList[j].id === p.id) { + p.value = paramList[j].value; + var isValid = validateList(p.value); + if (isValid) { + $scope.isErrorVisible = false; + break; + } + else { + showError(FIELD.ERROR.INVALID_LIST + p.id, + FIELD.ERROR.LIST_VALIDATE); + return; + } + } + } + } + } + } + var requestDetails = CreationService + .getMsoRequestDetails($scope.userProvidedControl.getList()); + + $scope.isDialogVisible = false; + + $scope.$broadcast(COMPONENT.MSO_CREATE_REQ, { + url: CreationService.getMsoUrl(), + requestDetails: requestDetails, + componentId: componentId, + callbackFunction: function (response) { + if (response.isSuccessful) { + $scope.popup.isVisible = false; + runCallback(response); + } else { + $scope.isDialogVisible = false; + $scope.popup.isVisible = false; + } + } + }); + + } catch (e) { + errorMsg = errorMsg + FIELD.ERROR.INVALID_DATA_FORMAT; + } + if (errorMsg !== "") { + showError(FIELD.ERROR.SYSTEM_FAILURE, errorMsg); + + } + }; + reader.readAsText(file); + } else { + + var paramList = $scope.userProvidedControl.getList(); + var instanceName = ""; + + if (DataService.getALaCarte()) { + if (paramList != null) { + for (var i = 0; i < paramList.length; i++) { + if (paramList[i].id === FIELD.ID.INSTANCE_NAME) { + instanceName = paramList[i].value; + break; + } + } + } + var isValid = validateInstanceName(instanceName); + if (isValid) { + $scope.isErrorVisible = false; + } else { + showError(FIELD.ERROR.INVALID_INSTANCE_NAME + instanceName, + FIELD.ERROR.INSTANCE_NAME_VALIDATE); + return; + } + } + var arbitraryParametersList = DataService.getArbitraryParameters(); + var p = null; + if (UtilityService.hasContents(arbitraryParametersList)) { + for (var i = 0; i < arbitraryParametersList.length; i++) { + p = arbitraryParametersList[i]; + if (p.type === PARAMETER.MAP) { + //validate a map: { : , ... , : } + // need to find the value in paramList + for (var j = 0; j < paramList.length; j++) { + if (paramList[j].id === p.id) { + p.value = paramList[j].value; + var isValid = validateMap(p.value); + if (isValid) { + $scope.isErrorVisible = false; + break; + } + else { + showError(FIELD.ERROR.INVALID_MAP + p.id, + FIELD.ERROR.MAP_VALIDATE); + return; + } + } + } + } else if (p.type === PARAMETER.LIST) { + //validate a list: { value or a list of comma separated values } + // need to find the value in paramList + for (var j = 0; j < paramList.length; j++) { + if (paramList[j].id === p.id) { + p.value = paramList[j].value; + var isValid = validateList(p.value); + if (isValid) { + $scope.isErrorVisible = false; + break; + } + else { + showError(FIELD.ERROR.INVALID_LIST + p.id, + FIELD.ERROR.LIST_VALIDATE); + return; + } + } + } + } + } + } + var requestDetails = CreationService + .getMsoRequestDetails($scope.userProvidedControl.getList()); + + $scope.isDialogVisible = false; + + $scope.$broadcast(COMPONENT.MSO_CREATE_REQ, { + url: CreationService.getMsoUrl(), + requestDetails: requestDetails, + componentId: componentId, + callbackFunction: function (response) { + if (response.isSuccessful) { + $scope.popup.isVisible = false; + runCallback(response); + } else { + $scope.isDialogVisible = false; + $scope.popup.isVisible = false; + } + } + }); + } + }; + + $scope.cancel = function () { + $scope.isDialogVisible = false; + $scope.popup.isVisible = false; + runCallback(false); + }; + + + var runCallback = function (response) { + if (angular.isFunction(callbackFunction)) { + callbackFunction({ + isSuccessful: response.isSuccessful, + control: $scope.userProvidedControl.getList(), + instanceId: response.instanceId + }); + } + }; + + var showError = function (summary, details) { + var message = summary; + if (UtilityService.hasContents(details)) { + message += " (" + details + ")"; + } + $scope.isSpinnerVisible = false; + $scope.isErrorVisible = true; + $scope.error = message; + } + +}; + +appDS2.controller("creationDialogController", ["COMPONENT", "FIELD", "PARAMETER", "$scope", "$http", + "$timeout", "$log", "CreationService", "UtilityService", "DataService", "VIDCONFIGURATION", "$location", + creationDialogController]); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/deleteResumeDialogController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/deleteResumeDialogController.js index cdda3a14..e71f2ac1 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/deleteResumeDialogController.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/deleteResumeDialogController.js @@ -26,77 +26,76 @@ var deleteResumeDialogController = function( COMPONENT, FIELD, $scope, $http, $t $scope.isDialogVisible = false; $scope.summaryControl = {}; $scope.userProvidedControl = {}; - + var callbackFunction = undefined; var componentId = undefined; + $scope.dialogMethod = COMPONENT.DELETE; $scope.$on(COMPONENT.DELETE_RESUME_COMPONENT, function(event, request) { $scope.isE2EService = false; - $scope.isDataVisible = false; - $scope.isSpinnerVisible = false; - $scope.isErrorVisible = false; - $scope.isDialogVisible = true; - $scope.popup.isVisible = true; - $scope.isConfirmEnabled = false; - $scope.dialogMethod = request.dialogMethod; - callbackFunction = request.callbackFunction; - componentId = request.componentId; - $scope.isServiceInstance = componentId === "service"; - - DeleteResumeService.initializeComponent(request.componentId); + $scope.isDataVisible = false; + $scope.isSpinnerVisible = false; + $scope.isErrorVisible = false; + $scope.isDialogVisible = true; + $scope.popup.isVisible = true; + $scope.isConfirmEnabled = false; + $scope.dialogMethod = request.dialogMethod; + $scope.serviceStatus = request.serviceStatus; + callbackFunction = request.callbackFunction; + componentId = request.componentId; - $scope.componentName = DeleteResumeService.getComponentDisplayName(); + DeleteResumeService.initializeComponent(request.componentId); - $scope.summaryControl.setList(DeleteResumeService.getSummaryList()); + $scope.componentName = DeleteResumeService.getComponentDisplayName(); + $scope.summaryControl.setList(DeleteResumeService.getSummaryList()); - DeleteResumeService.getParameters(handleGetParametersResponse); + DeleteResumeService.getParameters(handleGetParametersResponse); }); - + var handleGetParametersResponse = function(parameters, dontshow) { - $scope.summaryControl.setList(parameters.summaryList); - $scope.userProvidedControl.setList(parameters.userProvidedList); - - $scope.isSpinnerVisible = false; - if (dontshow) - $scope.isDataVisible = false; - else - $scope.isDataVisible = true; - $scope.isConfirmEnabled = true; - }; - - $scope.userParameterChanged = function(id) { + $scope.summaryControl.setList(parameters.summaryList); + $scope.userProvidedControl.setList(parameters.userProvidedList); + + $scope.isSpinnerVisible = false; + if (dontshow) + $scope.isDataVisible = false; + else + $scope.isDataVisible = true; + $scope.isConfirmEnabled = true; + }; + + $scope.userParameterChanged = function(id) { DeleteResumeService.updateUserParameterList(id, $scope.userProvidedControl); - } + } $scope.confirm = function() { DataService.setE2EService($scope.isE2EService); //VoLTE support + var requiredFields = $scope.userProvidedControl.getRequiredFields(); + if (requiredFields === "") { + $scope.isErrorVisible = false; + } else { + showError(FIELD.ERROR.MISSING_DATA, requiredFields); + return; + } - var requiredFields = $scope.userProvidedControl.getRequiredFields(); - if (requiredFields === "") { - $scope.isErrorVisible = false; - } else { - showError(FIELD.ERROR.MISSING_DATA, requiredFields); - return; - } - - var callbackAfterMSO = function(isSuccessful) { + var callbackAfterMSO = function(isSuccessful) { if (isSuccessful) { $scope.popup.isVisible = false; runCallback(true); } else { - $scope.isDialogVisible = true; + $scope.isDialogVisible = true; } }; - $scope.isDialogVisible = false; + $scope.isDialogVisible = false; - if ($scope.dialogMethod == COMPONENT.DELETE) - { + if ($scope.dialogMethod == COMPONENT.DELETE) + { var requestDetails = DeleteResumeService.getMsoRequestDetails($scope.userProvidedControl.getList()); @@ -105,13 +104,13 @@ var deleteResumeDialogController = function( COMPONENT, FIELD, $scope, $http, $t } $scope.$broadcast(COMPONENT.MSO_DELETE_REQ, { - url : DeleteResumeService.getMsoUrl(), + url : DeleteResumeService.getMsoUrl($scope.serviceStatus), requestDetails : requestDetails, - componentId: componentId, + componentId: componentId, callbackFunction : callbackAfterMSO }); - } - else + } + else if ($scope.dialogMethod == COMPONENT.RESUME) { CreationService.initializeComponent(componentId); @@ -133,17 +132,17 @@ var deleteResumeDialogController = function( COMPONENT, FIELD, $scope, $http, $t } $scope.cancel = function() { - $scope.isDialogVisible = false; - $scope.popup.isVisible = false; - runCallback(false); + $scope.isDialogVisible = false; + $scope.popup.isVisible = false; + runCallback(false); } var runCallback = function(isSuccessful) { - if (angular.isFunction(callbackFunction)) { - callbackFunction({ - isSuccessful : isSuccessful - }); - } + if (angular.isFunction(callbackFunction)) { + callbackFunction({ + isSuccessful : isSuccessful + }); + } } } diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/msoCommitModalController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/msoCommitModalController.js index 148b4cce..631d0122 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/msoCommitModalController.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/msoCommitModalController.js @@ -21,7 +21,7 @@ "use strict"; var msoCommitModalController = function(COMPONENT, FIELD, $scope, $http, $timeout, $window, $log, - MsoService, PropertyService, UtilityService, DataService, $uibModalInstance, msoType, requestParams, vidService) { + MsoService, PropertyService, UtilityService, DataService, $uibModalInstance, msoType, requestParams, configuration, vidService, featureFlags) { $scope.isSpinnerVisible = true; $scope.isProgressVisible = true; @@ -153,12 +153,14 @@ var msoCommitModalController = function(COMPONENT, FIELD, $scope, $http, $timeou var init = function(msoType) { switch(msoType) { + case COMPONENT.MSO_DELETE_CONFIGURATION_REQ : + return MsoService.deleteConfiguration(requestParams, configuration); case COMPONENT.MSO_CREATE_REQ: return MsoService.createConfigurationInstance(requestParams); case COMPONENT.MSO_CHANGE_CONFIG_STATUS_REQ: - return MsoService.toggleConfigurationStatus(requestParams); + return MsoService.toggleConfigurationStatus(requestParams, configuration); case COMPONENT.MSO_CHANGE_PORT_STATUS_REQ: - return MsoService.togglePortStatus(requestParams); + return MsoService.togglePortStatus(requestParams, configuration); case COMPONENT.MSO_CREATE_REALATIONSHIP: return MsoService.associatePnf(requestParams); case COMPONENT.MSO_REMOVE_RELATIONSHIP: @@ -223,6 +225,7 @@ var msoCommitModalController = function(COMPONENT, FIELD, $scope, $http, $timeou _this.msoRequestType = msoType; + init(_this.msoRequestType) .then(function (response) { successCallbackFunction(response); @@ -233,5 +236,5 @@ var msoCommitModalController = function(COMPONENT, FIELD, $scope, $http, $timeou }; appDS2.controller("msoCommitModalController", [ "COMPONENT", "FIELD", "$scope", "$http", "$timeout", - "$window", "$log", "MsoService", "PropertyService", "UtilityService", "DataService", "$uibModalInstance", "msoType", "requestParams", "vidService", + "$window", "$log", "MsoService", "PropertyService", "UtilityService", "DataService", "$uibModalInstance", "msoType", "requestParams", "configuration", "vidService", "featureFlags", 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 index 22a20abf..04717c5f 100644 --- 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 @@ -94,6 +94,9 @@ appDS2.controller("pnfSearchAssociationController", ["COMPONENT", "$log", "FIELD requestParams: function () { requestParams.callbackFunction = updateViewCallbackFunction; return requestParams; + }, + configuration: function () { + return null; } } }) 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 index f5c3a0e0..63ddac2f 100644 --- 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 @@ -53,7 +53,7 @@ _.find(relatedEcompEnv.relationshipData, {"relationshipKey": "operational-environment.operational-environment-id"}) .relationshipValue; var relatedInstanceName = - _.find(relatedEcompEnv.relatedToProperty, {"propertyKey": "operational-environment.operational-name"}) + _.find(relatedEcompEnv.relatedToProperty, {"propertyKey": "operational-environment.operational-environment-name"}) .propertyValue; var workloadContext = testEnv.workloadContext; diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/filters/change-managements-by-statuses.filter.js b/vid-app-common/src/main/webapp/app/vid/scripts/filters/change-managements-by-statuses.filter.js index 6f0ae2c6..82dbebcb 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/filters/change-managements-by-statuses.filter.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/filters/change-managements-by-statuses.filter.js @@ -7,12 +7,16 @@ var result = []; if(changeManagements && metadata && metadata.statuses) { angular.forEach(changeManagements, function(changeManagement) { - angular.forEach(metadata.statuses, function(status) { - if(changeManagement.requestStatus.requestState === status) { - result.push(changeManagement); - return; - } - }); + var found = metadata.statuses + .map(function(c) { return c.toLowerCase(); }) + .indexOf(changeManagement.requestStatus.requestState.toLowerCase()) !== -1; + + if (metadata.notContains && !found) { + result.push(changeManagement); + } + if (! metadata.notContains && found) { + result.push(changeManagement); + } }); } diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/alert-change-management/alert-change-management.html b/vid-app-common/src/main/webapp/app/vid/scripts/modals/alert-change-management/alert-change-management.html index 60596f49..6988aab9 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/alert-change-management/alert-change-management.html +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/alert-change-management/alert-change-management.html @@ -1,5 +1,6 @@ +