From 3982f4f67314ec37fd9b22ae54049958af777c1b Mon Sep 17 00:00:00 2001 From: jimmydot Date: Sun, 7 May 2017 14:58:24 -0400 Subject: [VID-6] Initial rebase push Change-Id: I9077be9663754d9b22f77c6a7b3109b361b39346 Signed-off-by: jimmydot --- .../scripts/controller/InstantiationController.js | 1217 ++++++++++++++++++++ .../scripts/controller/ServiceModelController.js | 227 ++++ .../webapp/app/vid/scripts/controller/VidApp.js | 79 ++ .../scripts/controller/aaiSubscriberController.js | 821 +++++++++++++ .../scripts/controller/creationDialogController.js | 163 +++ .../scripts/controller/deletionDialogController.js | 119 ++ .../scripts/controller/detailsDialogController.js | 84 ++ .../vid/scripts/controller/msoCommitController.js | 300 +++++ .../scripts/controller/statusDialogController.js | 233 ++++ .../app/vid/scripts/controller/subscriberSearch.js | 246 ++++ 10 files changed, 3489 insertions(+) create mode 100755 vid-app-common/src/main/webapp/app/vid/scripts/controller/InstantiationController.js create mode 100755 vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js create mode 100755 vid-app-common/src/main/webapp/app/vid/scripts/controller/VidApp.js create mode 100755 vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js create mode 100755 vid-app-common/src/main/webapp/app/vid/scripts/controller/creationDialogController.js create mode 100755 vid-app-common/src/main/webapp/app/vid/scripts/controller/deletionDialogController.js create mode 100755 vid-app-common/src/main/webapp/app/vid/scripts/controller/detailsDialogController.js create mode 100755 vid-app-common/src/main/webapp/app/vid/scripts/controller/msoCommitController.js create mode 100755 vid-app-common/src/main/webapp/app/vid/scripts/controller/statusDialogController.js create mode 100755 vid-app-common/src/main/webapp/app/vid/scripts/controller/subscriberSearch.js (limited to 'vid-app-common/src/main/webapp/app/vid/scripts/controller') diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/InstantiationController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/InstantiationController.js new file mode 100755 index 00000000..f928f4ec --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/InstantiationController.js @@ -0,0 +1,1217 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +/** + * The Instantiation (or View/Edit) Controller controls the instantiation/removal of + * deployable objects (Services, VNFs, VF-Modules, Networks, and Volume-Groups) + */ +(function () { + "use strict"; + + appDS2.requires.push('ui.tree'); + + appDS2.controller("InstantiationController", function ($scope, $route, $location, $timeout, COMPONENT, VIDCONFIGURATION, FIELD, DataService, PropertyService, UtilityService, VnfService, $http, vidService) { + + $scope.popup = new Object(); + $scope.defaultBaseUrl = ""; + $scope.responseTimeoutMsec = 60000; + $scope.properties = UtilityService.getProperties(); + $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(10000); + + /* + * Common parameters that shows an example of how the view edit screen + * is expected to pass some common service instance values to the + * popups. + */ + +// DataService.setSubscriberName("Mobility"); +// DataService.setGlobalCustomerId("CUSTID12345") +// DataService.setServiceType("Mobility Type 1"); +// DataService.setServiceInstanceName("Example Service Instance Name"); +// DataService.setServiceName("Mobility Service 1"); +// DataService.setServiceInstanceId("mmsc-test-service-instance"); +// DataService.setServiceUuid("XXXX-YYYY-ZZZZ"); +// DataService.setUserServiceInstanceName("USER_SERVICE_INSTANCE_NAME"); + } + + //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.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_COMPONENT, { + componentId : COMPONENT.NETWORK, + callbackFunction : deleteCallbackFunction + }); + }; + + $scope.deleteService = function(serviceObject) { + + var serviceInstance = serviceObject.object; + + console.log("Removing Service " + $scope.service.instance.name); + + DataService.setALaCarte (true); + DataService.setInventoryItem(serviceInstance); + + DataService.setModelInfo(COMPONENT.SERVICE, { + "modelInvariantId": serviceInstance[FIELD.ID.MODEL_INVAR_ID], + "modelVersion": $scope.service.model.service.version, + "modelNameVersionId": $scope.service.model.service.uuid, + "modelName": $scope.service.model.service.name, + "inputs": "" + }); + + DataService.setSubscriberName(serviceObject[FIELD.ID.SUBSCRIBER_NAME]); + DataService.setServiceType(serviceObject[FIELD.ID.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_COMPONENT, { + componentId : COMPONENT.SERVICE, + callbackFunction : deleteServiceInstanceCallbackFunction + }); + + }; + + $scope.deleteVfModule = function(serviceObject, vfModule, vnf) { + + console.log("Removing VF-Module " + vfModule.name); + + var serviceInstance = serviceObject.object; + + DataService.setInventoryItem(vfModule.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 vfModuleInstanceID = vfModule.object[FIELD.ID.VF_MODULE_ID]; + if (vfModuleInstanceID == null) { + vfModuleInstanceID = ""; + } + + var vnfModel = null; + var vfModuleModel = null; + + DataService.setModelInfo(COMPONENT.VF_MODULE, { + "modelInvariantId": "", + "modelVersion": "", + "modelNameVersionId": "", + "modelCustomizationName": "", + "customizationUuid": "", + "modelName": "", + "inputs": "" + }); + + if ( (!($scope.isObjectEmpty(svcModel))) && ( !($scope.isObjectEmpty(svcModel.vnfs) ) ) ) { + if ( (svcModel.isNewFlow) && (vnfModelCustomizationUuid != null ) ) { + vnfModel = svcModel.vnfs[vnfModelCustomizationUuid]; + + var vfModuleCustomizationUuid = vfModule.object[FIELD.ID.MODEL_CUSTOMIZATION_ID]; + if ( !($scope.isObjectEmpty(vnfModel.vfModules) ) && UtilityService.hasContents(vfModuleCustomizationUuid) ) { + + vfModuleModel = vnfModel.vfModules[vfModuleCustomizationUuid]; + + } + } + else { + // old flow + if (vnfModelVersionId != null ) { + vnfModel = svcModel.vnfs[vnfModelVersionId]; + } + //var vfModuleInvariantUuid = vfModule.object[FIELD.ID.MODEL_INVAR_ID]; + var vfModuleModelVersionId = vfModule.object[FIELD.ID.MODEL_VERSION_ID]; + if ( (!($scope.isObjectEmpty(vnfModel))) && (!($scope.isObjectEmpty(vnfModel.vfModules))) && + UtilityService.hasContents(vfModuleModelVersionId) ) { + vfModuleModel = vnfModel.vfModules[vfModuleModelVersionId]; + } + } + if ( !($scope.isObjectEmpty(vfModuleModel)) ) { + DataService.setModelInfo(COMPONENT.VF_MODULE, { + "modelInvariantId": vfModuleModel.invariantUuid, + "modelVersion": vfModuleModel.version, + "modelNameVersionId": vfModuleModel.uuid, + "modelCustomizationName": vfModuleModel.modelCustomizationName, + "customizationUuid": vfModuleModel.customizationUuid, + "modelName": vfModuleModel.name, + "inputs": "" + }); + } + } + + DataService.setVnfInstanceId(vnf.object[FIELD.ID.VNF_ID]); + DataService.setVfModuleInstanceId(vfModuleInstanceID); + + DataService.setSubscriberName(serviceObject[COMPONENT.SUBSCRIBER_NAME]); + DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]); + DataService.setServiceInstanceId(serviceInstance[FIELD.ID.SERVICE_INSTANCE_ID]); + + DataService.setGlobalCustomerId(serviceObject[FIELD.ID.GLOBAL_CUST_ID]); + DataService.setServiceInstanceName($scope.service.instance.name); + + DataService.setServiceName($scope.service.model.service.name); + + DataService.setServiceUuid($scope.service.model.service.uuid); + + $scope.$broadcast(COMPONENT.DELETE_COMPONENT, { + componentId : COMPONENT.VF_MODULE, + callbackFunction : deleteCallbackFunction + }); + + return; + + }; + + $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; + + 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_COMPONENT, { + componentId : COMPONENT.VNF, + callbackFunction : deleteCallbackFunction + }); + + }; + + + + $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; + + 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_COMPONENT, { + componentId : COMPONENT.VOLUME_GROUP, + }); + }; + + $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_COMPONENT, { + componentId : COMPONENT.VOLUME_GROUP, + callbackFunction : deleteCallbackFunction + }); + }; + + $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 + }); + + DataService.setModelInfo(COMPONENT.SERVICE, { + "modelInvariantId": $scope.service.model.service.invariantUuid, + "modelVersion": $scope.service.model.service.version, + "modelNameVersionId": $scope.service.model.service.uuid, + "modelName": $scope.service.model.service.name, + "inputs": "" + }); + + $scope.$broadcast(COMPONENT.CREATE_COMPONENT, { + componentId : COMPONENT.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)); + 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", + "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 + }); + + DataService.setModelInstanceName($scope.service.model.service.name); + + DataService.setModelInfo(COMPONENT.SERVICE, { + "modelInvariantId": $scope.service.model.service.invariantUuid, + "modelVersion": $scope.service.model.service.version, + "modelNameVersionId": $scope.service.model.service.uuid, + "modelName": $scope.service.model.service.name, + "inputs": "" + }); + + $scope.$broadcast(COMPONENT.CREATE_COMPONENT, { + componentId : COMPONENT.VNF, + callbackFunction : createVnfCallbackFunction + }); + }; + + $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}); + }); + + if (vfModuleModel.volumeGroupAllowed) { + DataService.setAvailableVolumeGroupList(availableVolumeGroupList); + } + + DataService.setModelInfo(COMPONENT.SERVICE, { + "modelInvariantId": $scope.service.model.service.invariantUuid, + "modelVersion": $scope.service.model.service.version, + "modelNameVersionId": $scope.service.model.service.uuid, + "modelName": $scope.service.model.service.name, + "inputs": "" + }); + + DataService.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); + + 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.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(); + } + + 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 deleteCallbackFunction = 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 new file mode 100755 index 00000000..5d382e9e --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js @@ -0,0 +1,227 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +(function () { + 'use strict'; + + appDS2.controller("ServiceModelController", function ($scope, $http, $location, COMPONENT, VIDCONFIGURATION, FIELD, DataService, vidService, + PropertyService, UtilityService) { + + $scope.popup = {}; + + // 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; + } + + $scope.getServiceModels = function() { + $scope.status = FIELD.STATUS.FETCHING_SERVICE_CATALOG_ASDC; + + $http.get(pathQuery) + .then(function successCallback(response) { + $scope.services = []; + if (angular.isArray(response.data)) { + $scope.services = response.data; + $scope.viewPerPage=10; + $scope.totalPage=$scope.services.length/$scope.viewPerPage; + $scope.sortBy=COMPONENT.NAME; + $scope.scrollViewPerPage=2; + $scope.currentPage=1; + $scope.searchCategory; + $scope.searchString=""; + $scope.currentPageNum=1; + $scope.isSpinnerVisible = false; + $scope.isProgressVisible = false; + } else { + $scope.status = FIELD.STATUS.FAILED_SERVICE_MODELS_ASDC; + $scope.error = true; + $scope.isSpinnerVisible = false; + } + }, function errorCallback(response) { + console.log("Error: " + response); + }); + } + + $scope.init = function() { + var msecs = PropertyService.retrieveMsoMaxPollingIntervalMsec(); + PropertyService.setMsoMaxPollingIntervalMsec(msecs); + + var polls = PropertyService.retrieveMsoMaxPolls(); + PropertyService.setMsoMaxPolls(polls); + + //PropertyService.setMsoBaseUrl("testmso"); + PropertyService.setServerResponseTimeoutMsec(10000); + } + + $scope.prevPage = function() { + $scope.currentPage--; + } + + $scope.nextPage = function() { + $scope.currentPage++; + } + + $scope.createType = COMPONENT.A_LA_CARTE; + $scope.deployService = function(service) { + + + console.log("Instantiating SDC service " + service.uuid); + + $http.get(COMPONENT.SERVICES_PATH + service.uuid) + .then(function successCallback(getServiceResponse) { + + var serviceModel = getServiceResponse.data; + DataService.setServiceName(serviceModel.service.name); + + DataService.setModelInfo(COMPONENT.SERVICE, { + "modelInvariantId": serviceModel.service.invariantUuid, + "modelVersion": serviceModel.service.version, + "modelNameVersionId": serviceModel.service.uuid, + "modelName": serviceModel.service.name, + "description": serviceModel.service.description, + "category":serviceModel.service.category + }); + 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, + "displayInputs": convertedAsdcModel.completeDisplayInputs + }); + }; + + $scope.$broadcast(broadcastType, { + componentId : COMPONENT.SERVICE, + 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; + } else if (response.control[i].id == "service-type") { + serviceType = response.control[i].value; + } + } + + + $scope.refreshSubs(subscriberId,serviceType,serviceInstanceId); + + } + } + }); + + }, function errorCallback(response) { + console.log("Error: " + response); + }); + }; + + $scope.refreshSubs = function(subscriberId, serviceType, serviceInstanceId) { + $scope.status = FIELD.STATUS.FETCHING_SUBSCRIBER_LIST_AAI; + $scope.init(); + $http.get( FIELD.ID.AAI_REFRESH_FULL_SUBSCRIBERS, { + + },{ + timeout: $scope.responseTimeoutMsec + }).then(function(response){ + + if (response.data.status < 200 || response.data.status > 202) { + $scope.showError(FIELD.ERROR.MSO) + return; + } + + $scope.customer = response.data.customer; // get data from json + + $scope.customerList = []; + + $scope.serviceInstanceToCustomer = []; + + angular.forEach($scope.customer, function(subVal, subKey) { + var cust = { "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID], "subscriberName": subVal[FIELD.ID.SUBNAME] }; + $scope.customerList.push(cust); + if (subVal[FIELD.ID.SERVICE_SUBSCRIPTIONS] != null) { + angular.forEach(subVal[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION], function(serviceSubscription, key) { + $scope.serviceInstanceId = []; + if (serviceSubscription[FIELD.ID.SERVICE_TYPE] != null) { + $scope.serviceType = serviceSubscription[FIELD.ID.SERVICE_TYPE]; + } else { + $scope.serviceType = FIELD.STATUS.NO_SERVICE_SUBSCRIPTION_FOUND; + } + if (serviceSubscription[FIELD.ID.SERVICE_INSTANCES] != null) { + angular.forEach(serviceSubscription[FIELD.ID.SERVICE_INSTANCES][FIELD.ID.SERVICE_INSTANCE], function(instValue, instKey) { + var foo = { "serviceInstanceId": instValue[FIELD.ID.SERVICE_INSTANCE_ID], + "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID], + "subscriberName": subVal[FIELD.ID.SUBNAME] }; + $scope.serviceInstanceToCustomer.push(foo); + }); + } + }); + } + }); + DataService.setServiceInstanceToCustomer($scope.serviceInstanceToCustomer); + var serviceIdList = []; + $http.get( FIELD.ID.AAI_GET_SERVICES, { + },{ + timeout: $scope.responseTimeoutMsec + }).then(function(response) { + angular.forEach(response.data, function(value, key) { + angular.forEach(value, function(subVal, key) { + var newVal = { "id" : subVal[FIELD.ID.SERVICE_ID], "description" : subVal[FIELD.ID.SERVICE_DESCRIPTION] }; + serviceIdList.push(newVal); + DataService.setServiceIdList(serviceIdList); + + $location.search({ + "subscriberId": subscriberId, + "serviceType": serviceType, + "serviceInstanceId": serviceInstanceId + }); + + $location.path(COMPONENT.INSTANTIATE_PATH); + }); + }); + }); + }) + ["catch"]($scope.handleServerError); + }; + }); +})(); 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 new file mode 100755 index 00000000..dcde2ecc --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/VidApp.js @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +(function () { + 'use strict'; + + appDS2.config(['$routeProvider', '$locationProvider', function ($routeProvider) { + $routeProvider + .when('/models/services', { + controller: 'ServiceModelController', + templateUrl: 'app/vid/scripts/view-models/serviceModels.htm' + }) + .when('/models/services/createInstance', { + controller: 'aaiSubscriberController', + templateUrl: 'app/vid/scripts/view-models/createInstanceServiceModels.htm' + }) + .when('/instances/services', { + templateUrl : "app/vid/scripts/view-models/aaiGetSubs.htm", + controller : "aaiSubscriberController" + }) + .when('/instances/subscribers', { + templateUrl : "app/vid/scripts/view-models/aaiGetSubscriberList.htm", + controller : "aaiSubscriberController" + }) + .when('/instances/serviceTypes', { + templateUrl : "app/vid/scripts/view-models/aaiServiceTypes.htm", + controller : "aaiSubscriberController" + }) + .when('/instances/subdetails', { + templateUrl : "app/vid/scripts/view-models/aaiSubDetails.htm", + controller : "aaiSubscriberController" + }) + .when('/instantiate', { + controller: 'InstantiationController', + templateUrl: 'app/vid/scripts/view-models/instantiate.htm' + }) + .otherwise({ + redirectTo: '/models/services' + }); + }]); + + appDS2.service('vidService', function() { + var _model = undefined; + var _instance = undefined; + + this.setModel = function(model) { + _model = model; + }; + + this.getModel = function() { + return _model; + }; + + this.setInstance = function(instance) { + _instance = instance; + }; + + this.getInstance = function() { + return _instance; + }; + }); +})(); 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 new file mode 100755 index 00000000..5caa3298 --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js @@ -0,0 +1,821 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +"use strict"; + +appDS2.controller("aaiSubscriberController", [ "COMPONENT", "FIELD", "PARAMETER", "DataService", "PropertyService", "$scope", "$http", "$timeout", "$location", "$log", "$route", "VIDCONFIGURATION", "UtilityService", "vidService","AaiService", + function(COMPONENT, FIELD, PARAMETER, DataService, PropertyService, $scope, $http, $timeout, $location, $log, $route, VIDCONFIGURATION, UtilityService, vidService, AaiService) { + + $scope.showVnfDetails = function(vnf) { + console.log("showVnfDetails"); + DataService.setVnfInstanceId(COMPONENT.VNF_INSTANCE_ID); + DataService + .setInventoryItem(aaiResult[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM][0]); + + $scope.$broadcast(COMPONENT.SHOW_COMPONENT_DETAILS, { + componentId : COMPONENT.VNF, + callbackFunction : callbackFunction + }); + } + $scope.popup = new Object(); + + + $scope.isPopupVisible = false; + $scope.defaultBaseUrl = ""; + $scope.responseTimeoutMsec = 60000; + + $scope.serviceTypes=[ FIELD.PROMPT.SELECT_SERVICE ]; + $scope.defaultSubscriberName=[ FIELD.PROMPT.SELECT_SUB ]; + + var callbackFunction = function(response) { + alert(response); + }; + + $scope.getSubs = function() { + $scope.init(); + $scope.fetchSubs(FIELD.PROMPT.FETCHING_SUBS); + $scope.fetchServices(); + + }; + + $scope.cancelCreateSI = function(){ + + window.location.href = COMPONENT.WELCOME_PATH; + + }; + + $scope.getServiceTypes = function(globalCustomerId){ + DataService.setGlobalCustomerId(globalCustomerId); + DataService.setServiceIdList($scope.customerList) + + if (globalCustomerId !== "" && globalCustomerId !== undefined ) { + window.location.href = COMPONENT.SERVICE_TYPE_LIST_PATH + $scope.serviceTypeList; + } + } + + $scope.refreshServiceTypes = function(globalCustomerId){ + DataService.setGlobalCustomerId(globalCustomerId); + + $scope.getServiceTypesList(); + } + + $scope.subId=""; + $scope.createSubscriberName=""; + $scope.serviceTypeList={}; + $scope.custSubList=[]; + $scope.getServiceTypesList = function(){ + var notFound = true; + var globalCustomerId = DataService.getGlobalCustomerId(); + $scope.custSubList = DataService.getServiceIdList(); + if(globalCustomerId !== "" && globalCustomerId !== undefined ){ + $scope.subId=globalCustomerId; + $scope.init(); + $scope.status = FIELD.PROMPT.FETCHING_SERVICE_TYPES; + DataService.setGlobalCustomerId(globalCustomerId); + + AaiService.getSubscriptionServiceTypeList(DataService + .getGlobalCustomerId(), function(response) { + notFound = false; + $scope.setProgress(100); // done + $scope.status = FIELD.STATUS.DONE; + $scope.isSpinnerVisible = false; + $scope.serviceTypeList = response; + for(var i=0; i<$scope.custSubList.length;i++){ + if(globalCustomerId === $scope.custSubList[i].globalCustomerId){ + $scope.createSubscriberName = $scope.custSubList[i].subscriberName; + } + } + }, function(response) { // failure + $scope.showError(FIELD.ERROR.AAI); + $scope.errorMsg = FIELD.ERROR.FETCHING_SERVICE_TYPES + response.status; + $scope.errorDetails = response.data; + }); + } else { + alert(FIELD.ERROR.SELECT); + } + + }; + + $scope.subList = []; + $scope.getAaiServiceModels = function(selectedServicetype,subName){ + DataService.setGlobalCustomerId(selectedServicetype); + DataService.setServiceIdList($scope.serviceTypeList) + DataService.setSubscriberName(subName); + + DataService.setSubscribers($scope.custSubList); + + if (selectedServicetype !== "" && selectedServicetype !== 'undefined') { + $location.path(COMPONENT.CREATE_INSTANCE_PATH); + } + }; + + $scope.serviceTypeName=""; + $scope.getAaiServiceModelsList = function(){ + var globalCustomerId=""; + var serviceTypeId = DataService.getGlobalCustomerId(); + $scope.serviceTypeList = DataService.getServiceIdList(); + $scope.createSubscriberName = DataService.getSubscriberName(); + $scope.status = FIELD.STATUS.FETCHING_SERVICE_CATALOG; + $scope.custSubList = DataService.getSubscribers(); + for(var i=0; i<$scope.serviceTypeList.length;i++){ + if(parseInt(serviceTypeId) === i ){ + $scope.serviceTypeName = $scope.serviceTypeList[i]; + } + }; + for(var i=0; i<$scope.custSubList.length;i++){ + if($scope.createSubscriberName === $scope.custSubList[i].subscriberName){ + globalCustomerId = $scope.custSubList[i].globalCustomerId; + } + }; + + var pathQuery =""; + + if(null !== globalCustomerId && "" !== globalCustomerId && undefined !== globalCustomerId + && null !== serviceTypeId && "" !== serviceTypeId && undefined !== serviceTypeId){ + pathQuery = COMPONENT.SERVICES_PATH +globalCustomerId+"/"+$scope.serviceTypeName; + } + + AaiService.getServiceModels(globalCustomerId,$scope.serviceTypeName,function(response) { // success + console.log("service models : "+response.data); + DataService.setServiceIdList(response); + }, function(response) { // failure + $scope.showError(FIELD.ERROR.AAI); + $scope.errorMsg = FIELD.ERROR.FETCHING_SERVICES+ response.status; + $scope.errorDetails = response.data; + }); + + /*$http.get('/aai_get_services/'+globalCustomerId+''+$scope.serviceTypeName) + .then(function successCallback(response) { + $scope.services = []; + if (angular.isArray(response.data)) { + $scope.services = response.data; + $scope.viewPerPage=10; + $scope.totalPage=$scope.services.length/$scope.viewPerPage; + $scope.sortBy="name"; + $scope.scrollViewPerPage=2; + $scope.currentPage=1; + $scope.searchCategory; + $scope.searchString=""; + $scope.currentPageNum=1; + $scope.isSpinnerVisible = false; + $scope.isProgressVisible = false; + } else { + $scope.status = "Failed to get service models from SDC."; + $scope.error = true; + $scope.isSpinnerVisible = false; + } + }, function errorCallback(response) { + console.log("Error: " + response); + }); */ + + + }; + + $scope.cancelCreateSIType = function(){ + + window.location.href = COMPONENT.SERVICE_MODLES_INSTANCES_SUBSCRIBERS_PATH; + + } + + $scope.fetchServices = function() { + var serviceIdList = []; + + AaiService.getServices2(function(response) { // success + DataService.setServiceIdList(response); + }, function(response) { // failure + $scope.showError(FIELD.ERROR.AAI); + $scope.errorMsg = FIELD.ERROR.FETCHING_SERVICES + response.status; + $scope.errorDetails = response.data; + }); + } + + $scope.refreshSubs = function() { + $scope.fetchSubs(FIELD.PROMPT.REFRESH_SUB_LIST); + $scope.fetchServices(); + }; + + $scope.fetchSubs = function(status) { + $scope.status = status; + + AaiService.getSubList(function(response) { // sucesss + $scope.setProgress(100); // done + $scope.status = FIELD.STATUS.DONE; + $scope.isSpinnerVisible = false; + $scope.customerList = response; + }, function(response) { // failure + $scope.showError(FIELD.ERROR.AAI); + $scope.errorMsg = FIELD.ERROR.AAI_FETCHING_CUST_DATA + response.status; + $scope.errorDetails = response.data; + }); + } + + + $scope.getSubDetails = function(request) { + + $scope.init(); + $scope.selectedSubscriber = $location.search().selectedSubscriber; + $scope.selectedServiceInstance = $location.search().selectedServiceInstance; + $scope.status = FIELD.STATUS.FETCHING_SUB_DETAILS + $scope.selectedSubscriber; + + $scope.displayData = []; + AaiService.getSubDetails($scope.selectedSubscriber, $scope.selectedServiceInstance, function(displayData, subscriberName) { + $scope.displayData = displayData; + $scope.viewPerPage=10; + $scope.totalPage=$scope.displayData.length/$scope.viewPerPage; + $scope.scrollViewPerPage=2; + $scope.currentPage=1; + $scope.searchCategory; + $scope.searchString=""; + $scope.currentPageNum=1; + $scope.defaultSort=COMPONENT.SUBSCRIBER_NAME; + $scope.setProgress(100); // done + $scope.status = FIELD.STATUS.DONE; + $scope.isSpinnerVisible = false; + $scope.subscriberName = subscriberName; + }, function(response) { + $scope.showError(FIELD.ERROR.AAI); + $scope.errorMsg = FIELD.ERROR.AAI_FETCHING_CUST_DATA + response.status; + $scope.errorDetails = response.data; + }); + } + + + $scope.$on(COMPONENT.MSO_DELETE_REQ, function(event, request) { + // $log.debug("deleteInstance: request:"); + // $log.debug(request); + $scope.init(); + + $http.post($scope.baseUrl + request.url, { + requestDetails: request.requestDetails + },{ + timeout: $scope.responseTimeoutMsec + }).then($scope.handleInitialResponse) + ["catch"]($scope.handleServerError); + }); + + $scope.init = function() { + + //PropertyService.setAaiBaseUrl("testaai"); + //PropertyService.setAsdcBaseUrl("testasdc"); + + // 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.setMsoBaseUrl("testmso"); + PropertyService.setServerResponseTimeoutMsec(); + + /* + * Common parameters that would typically be set when the page is + * displayed for a specific service instance id. + */ + + $scope.baseUrl = $scope.defaultBaseUrl; + + $scope.isSpinnerVisible = true; + $scope.isProgressVisible = true; + $scope.isPopupVisible = true; + $scope.requestId = ""; + $scope.error = ""; + $scope.pollAttempts = 0; + $scope.log = ""; + $scope.enableCloseButton(false); + $scope.resetProgress(); + $scope.setProgress(2); // Show "a little" progress + } + + $scope.getComponentList = function(event, request) { + + $scope.isSpinnerVisible = true; + $scope.isProgressVisible = true; + $scope.isPopupVisible = true; + $scope.requestId = ""; + $scope.error = ""; + $scope.pollAttempts = 0; + $scope.log = ""; + + $scope.resetProgress(); + $scope.setProgress(2); // Show "a little" progress + + $scope.globalCustomerId = $location.search().subscriberId; + $scope.serviceType = $location.search().serviceType; + $scope.serviceInstanceId = $location.search().serviceInstanceId; + $scope.subscriberName = $location.search().subscriberName; + + //$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; + } + ); + + } + + $scope.handleServerError = function(response, status) { + alert(response.statusText); + } + + $scope.getAsdcModel = function(disData) { + + console.log ("disData"); console.log (JSON.stringify (disData, null, 4)); + + if ( !(UtilityService.hasContents (disData.aaiModelVersionId)) ) { + $scope.errorMsg = FIELD.ERROR.MODEL_VERSION_ID_MISSING; + alert($scope.errorMsg); + return; + } + + // aaiModelVersionId is the model uuid + var pathQuery = COMPONENT.SERVICES_PATH + disData.aaiModelVersionId; + $http({ + method: 'GET', + url: pathQuery + }).then(function successCallback(response) { + vidService.setModel(response.data); + window.location.href = COMPONENT.INSTANTIATE_ROOT_PATH + disData.globalCustomerId + COMPONENT.SUBSCRIBERNAME_SUB_PATH + disData.subscriberName + COMPONENT.SERVICETYPE_SUB_PATH + disData.serviceType + COMPONENT.SERVICEINSTANCEID_SUB_PATH + disData.serviceInstanceId; + console.log("aaiSubscriber getAsdcModel DONE!!!!"); + }, function errorCallback(response) { + console.log("aaiSubscriber getAsdcModel - No matching model found matching the A&AI model version ID = " + disData.aaiModelVersionId); + $scope.errorMsg = FIELD.ERROR.NO_MATCHING_MODEL_AAI + disData.aaiModelVersionId; + alert($scope.errorMsg); + }); + + } + + $scope.getTenants = function(globalCustomerId) { + $http.get(FIELD.ID.AAI_GET_TENTANTS + globalCustomerId) + .then(function successCallback(response) { + return response.data; + //$location.path("/instantiate"); + }, function errorCallback(response) { + //TODO + }); + } + + $scope.handleInitialResponseInventoryItems = function(response) { + + $scope.inventoryResponseItemList = response.data[FIELD.ID.INVENTORY_RESPONSE_ITEM]; // get data from json + console.log($scope.inventoryResponseItemList.toString()); + + $scope.displayData = []; + $scope.vnfs = []; + + $scope.counter = 100; + + $scope.subscriberName = ""; + // just look up the subscriber name in A&AI here... + AaiService.getSubscriberName($scope.globalCustomerId, function(response) { + $scope.subscriberName = response; + DataService.setSubscriberName($scope.subscriberName); + + angular.forEach($scope.inventoryResponseItemList, function(inventoryResponseItem, key) { + + $scope.inventoryResponseItem = inventoryResponseItem; + + $scope.service.instance = { + "name": $scope.inventoryResponseItem[FIELD.ID.SERVICE_INSTANCE][FIELD.ID.SERVICE_INSTANCE_NAME], + "serviceInstanceId": $scope.serviceInstanceId, + "serviceType": $scope.serviceType, + "globalCustomerId": $scope.globalCustomerId, + "subscriberName": $scope.subscriberName, + "id": $scope.serviceInstanceId, + "inputs": { + "a": { + "type": PARAMETER.STRING, + "description": FIELD.PROMPT.VAR_DESCRIPTION_A, + "default": FIELD.PROMPT.DEFAULT_A + }, + "b": { + "type": PARAMETER.STRING, + "description": FIELD.PROMPT.VAR_DESCRIPTION_B, + "default": FIELD.PROMPT.DEFAULT_B + }, + }, + "object": $scope.inventoryResponseItem[FIELD.ID.SERVICE_INSTANCE], + "vnfs": [], + "networks": [] + } + + if (inventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) { + + angular.forEach(inventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM], function(subInventoryResponseItem, key) { + // i expect to find vnfs now + + if (subInventoryResponseItem[FIELD.ID.L3_NETWORK] != null) { + var l3NetworkObject = subInventoryResponseItem[FIELD.ID.L3_NETWORK]; + var l3Network = { "id": $scope.counter++, + "name": l3NetworkObject[FIELD.ID.NETWORK_NAME], + "itemType": FIELD.ID.L3_NETWORK, + "nodeId": l3NetworkObject[FIELD.ID.NETWORK_ID], + "nodeType": l3NetworkObject[FIELD.ID.NETWORK_TYPE], + "nodeStatus": l3NetworkObject[FIELD.ID.ORCHESTRATION_STATUS], + "object": l3NetworkObject, + "nodes": [], + "subnets": [] + }; + if (subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) { + //console.log ("subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS]="); + //console.log (JSON.stringify (subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS], null, 4 )); + angular.forEach(subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM], function(subSubInventoryResponseItem, key) { + //console.log (JSON.stringify (subSubInventoryResponseItem, null, 4 )); + var subnet = {}; + var subnetObject; + if (subSubInventoryResponseItem[FIELD.ID.SUB_NET] != null) { + subnetObject = subSubInventoryResponseItem[FIELD.ID.SUB_NET]; + subnet = { + "subnet-id": subnetObject[FIELD.ID.SUBNET_ID], + "subnet-name": subnetObject[FIELD.ID.SUBNET_NAME], + "gateway-address": subnetObject[FIELD.ID.GATEWAY_ADDRESS], + "network-start-address": subnetObject[FIELD.ID.NETWORK_START_ADDRESS], + "cidr-mask": subnetObject[FIELD.ID.CIDR_MASK] + }; + l3Network.subnets.push(subnet); + } + }); + } + $scope.service.instance[FIELD.ID.NETWORKS].push(l3Network); + } + + if (subInventoryResponseItem[FIELD.ID.GENERIC_VNF] != null) { + var genericVnfObject = subInventoryResponseItem[FIELD.ID.GENERIC_VNF]; + + var genericVnf = { + "name": genericVnfObject[FIELD.ID.VNF_NAME], + "id": $scope.counter++, + "itemType": COMPONENT.VNF, + "nodeType": genericVnfObject[FIELD.ID.VNF_TYPE], + "nodeId": genericVnfObject[FIELD.ID.VNF_ID], + "nodeStatus": genericVnfObject[FIELD.ID.ORCHESTRATION_STATUS], + "object": genericVnfObject, + "vfModules": [], + "volumeGroups": [], + "availableVolumeGroups": [] + }; + $scope.service.instance[FIELD.ID.VNFS].push(genericVnf); + + // look for volume-groups + if (subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) { + angular.forEach(subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM], function(vfmodules, key) { + + if (vfmodules[FIELD.ID.VOLUME_GROUP] != null) { + var volumeGroupObject = vfmodules[FIELD.ID.VOLUME_GROUP]; + var volumeGroup = { "id": $scope.counter++, + "name": volumeGroupObject[FIELD.ID.VOLUME_GROUP_NAME], + "itemType": FIELD.ID.VOLUME_GROUP, + "nodeId": volumeGroupObject[FIELD.ID.VOLUME_GROUP_ID], + "nodeType": volumeGroupObject[FIELD.ID.VNF_TYPE], + "nodeStatus": volumeGroupObject[FIELD.ID.ORCHESTRATION_STATUS], + "object": volumeGroupObject, + "nodes": [] + }; + genericVnf[FIELD.ID.VOLUMEGROUPS].push(volumeGroup); + genericVnf[FIELD.ID.AVAILABLEVOLUMEGROUPS].push(volumeGroup); + } + }); + } + // now we've loaded up the availableVolumeGroups, we can use it + if (subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) { + angular.forEach(subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM], function(vfmodules, key) { + + if (vfmodules[FIELD.ID.VF_MODULE] != null) { + var vfModuleObject = vfmodules[FIELD.ID.VF_MODULE]; + var vfModule = { "id": $scope.counter++, + "name": vfModuleObject[FIELD.ID.VF_MODULE_NAME], + "itemType": FIELD.ID.VF_MODULE, + "nodeType": FIELD.ID.VF_MODULE, + "nodeStatus": vfModuleObject[FIELD.ID.ORCHESTRATION_STATUS], + "volumeGroups": [], + "object": vfModuleObject, + "networks": [] + }; + genericVnf[FIELD.ID.VF_MODULES].push(vfModule); + if (vfmodules[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) { + angular.forEach(vfmodules[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM], function(networks, key) { + if (networks[FIELD.ID.L3_NETWORK] != null) { + var l3NetworkObject = networks[FIELD.ID.L3_NETWORK]; + var l3Network = { "id": $scope.counter++, + "name": l3NetworkObject[FIELD.ID.NETWORK_NAME], + "itemType": FIELD.ID.L3_NETWORK, + "nodeId": l3NetworkObject[FIELD.ID.NETWORK_ID], + "nodeType": l3NetworkObject[FIELD.ID.NETWORK_TYPE], + "nodeStatus": l3NetworkObject[FIELD.ID.ORCHESTRATION_STATUS], + "object": l3NetworkObject, + "nodes": [] + }; + vfModule[FIELD.ID.NETWORKS].push(l3Network); + } + if (networks[FIELD.ID.VOLUME_GROUP] != null) { + var volumeGroupObject = networks[FIELD.ID.VOLUME_GROUP]; + + var volumeGroup = { "id": $scope.counter++, + "name": volumeGroupObject[FIELD.ID.VOLUME_GROUP_NAME], + "itemType": FIELD.ID.VOLUME_GROUP, + "nodeId": volumeGroupObject[FIELD.ID.VOLUME_GROUP_ID], + "nodeType": volumeGroupObject[FIELD.ID.VNF_TYPE], + "nodeStatus": volumeGroupObject[FIELD.ID.ORCHESTRATION_STATUS], + "object": volumeGroupObject, + "nodes": [] + }; + var tmpVolGroup = []; + + angular.forEach(genericVnf[FIELD.ID.AVAILABLEVOLUMEGROUPS], function(avgroup, key) { + if (avgroup.name != volumeGroup.name) { + tmpVolGroup.push(avgroup); + } + }); + + genericVnf[FIELD.ID.AVAILABLEVOLUMEGROUPS] = tmpVolGroup; + + vfModule[FIELD.ID.VOLUMEGROUPS].push(volumeGroup); + } + + }); + } + } + }); + } + } + }); + } + }); + }); + } + + $scope.handleInitialResponse = function(response) { + try { + $scope.enableCloseButton(true); + $scope.updateLog(response); + if (response.data.status < 200 || response.data.status > 202) { + $scope.showError(FIELD.ERROR.MSO); + $scope.status = FIELD.ERROR.AAI_FETCHING_CUST_DATA + response.data.status; + + return; + } + + $scope.setProgress(100); // done + $scope.status = FIELD.STATUS.DONE; + $scope.isSpinnerVisible = false; + + $scope.customer = response.data.customer; // get data from json + + $scope.customerList = []; + + angular.forEach($scope.customer, function(subVal, subKey) { + var cust = { "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID], "subscriberName": subVal[FIELD.ID.SUBNAME] }; + $scope.customerList.push(cust); + }); + + } catch (error) { + $scope.showContentError(error); + } + } + + $scope.autoGetSubs = function() { + /* + * Optionally comment in / out one of these method calls (or add a similar + * entry) to auto-invoke an entry when the test screen is redrawn. + */ + $scope.getSubs(); + + } + + $scope.updateLog = function(response) { +// $scope.log = UtilityService.getCurrentTime() + " HTTP Status: " + +// UtilityService.getHttpStatusText(response.data.status) + "\n" + +// angular.toJson(response.data.entity, true) + "\n\n" + $scope.log; +// UtilityService.checkUndefined("entity", response.data.entity); +// UtilityService.checkUndefined("status", response.data.status); + } + + $scope.handleServerError = function(response, status) { + $scope.enableCloseButton(true); + var message = UtilityService.getHttpErrorMessage(response); + if (message != ""){ + message = " (" + message + ")"; + } + $scope.showError(FIELD.ERROR.SYSTEM_ERROR + message); + } + + $scope.showContentError = function(message) { + // $log.debug(message); + console.log(message); + if (UtilityService.hasContents(message)) { + $scope.showError("System failure (" + message + ")"); + } else { + $scope.showError(FIELD.ERROR.SYSTEM_ERROR); + } + } + + $scope.showError = function(message) { + $scope.isSpinnerVisible = false; + $scope.isProgressVisible = false; + $scope.error = message; + $scope.status = FIELD.STATUS.ERROR; + } + + $scope.close = function() { + if ($scope.timer != undefined) { + $timeout.cancel($scope.timer); + } + $scope.isPopupVisible = false; + } + + + + /* + * Consider converting the progress bar mechanism, the disabled button handling + * and the following methods to generic Angular directive(s) and/or approach. + */ + + $scope.enableCloseButton = function(isEnabled) { + var selector = FIELD.STYLE.MSO_CTRL_BTN; + + $scope.isCloseEnabled = isEnabled; + + if (isEnabled) { + $(selector).addClass(FIELD.STYLE.BTN_PRIMARY).removeClass(FIELD.STYLE.BTN_INACTIVE).attr(FIELD.STYLE.BTN_TYPE, FIELD.STYLE.PRIMARY); + } else { + $(selector).removeClass(FIELD.STYLE.BTN_PRIMARY).addClass(FIELD.STYLE.BTN_INACTIVE).attr(FIELD.STYLE.BTN_TYPE, FIELD.STYLE.DISABLED); + } + } + + $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.reloadRoute = function() { + $route.reload(); + } + + $scope.prevPage = function() { + $scope.currentPage--; + } + + $scope.nextPage = function() { + $scope.currentPage++; + } + $scope.serviceInstanceses = [{"sinstance":FIELD.NAME.SERVICE_INSTANCE_Id},{"sinstance":FIELD.NAME.SERVICE_INSTANCE_NAME}] + $scope.getSubscriberDet = function(selectedCustomer,selectedserviceinstancetype,selectedServiceInstance){ + + var sintype =selectedserviceinstancetype; + if (selectedServiceInstance != "" && selectedServiceInstance != undefined) { + selectedServiceInstance.trim(); + + // check with A&AI + $http.get(COMPONENT.AAI_GET_SERVICE_INSTANCE_PATH + selectedServiceInstance+"/"+sintype + "?r=" + Math.random(), { + + },{ + timeout: $scope.responseTimeoutMsec + }).then(function(response) { + var notFound = true; + if (angular.isArray(response.data[FIELD.ID.RESULT_DATA])) { + var item = []; + var urlParts = []; + item = response.data[FIELD.ID.RESULT_DATA][0]; + var url = item[FIELD.ID.RESOURCE_LINK]; + var globalCustomerId = ""; + var serviceSubscription = ""; + // split it and find the customer Id and service-subscription + urlParts = url.split("/"); + if (urlParts[7] === FIELD.ID.CUSTOMER) { + globalCustomerId = urlParts[8]; + } + if (urlParts[10] === FIELD.ID.SERVICE_SUBSCRIPTION) { + serviceSubscription = urlParts[11]; + } + + if (globalCustomerId !== "") { + notFound = false; + window.location.href = COMPONENT.SELECTED_SERVICE_SUB_PATH + serviceSubscription + COMPONENT.SELECTEDSUBSCRIBER_SUB_PATH + globalCustomerId + COMPONENT.SELECTEDSERVICEINSTANCE_SUB_PATH + selectedServiceInstance; + } + } + if (notFound) { + alert(FIELD.ERROR.SERVICE_INST_DNE); + } + }); // add a failure callback... + } else if (selectedCustomer != null) { + window.location.href = COMPONENT.SELECTED_SUB_PATH + selectedCustomer; + } else { + alert(FIELD.ERROR.SELECT); + } + }; + }]).directive('restrictInput', function(){ + + return { + + restrict: 'A', + require: 'ngModel', + link: function($scope, element, attr, ctrl){ + ctrl.$parsers.unshift(function(viewValue){ + + var types = $scope.$eval(attr.restrictInput); + if(!types.regex && types.type){ + + switch(types.type){ + case 'Service Instance Name' : types.regex = '^[a-zA-Z0-9-_]*$'; break; + default: types.regex= ''; + } + } + var reg = new RegExp(types.regex); + if(reg.test(viewValue)){ + return viewValue; + } else { + var overrideValue = (reg.test(viewValue) ? viewValue : ''); + element.val(overrideValue); + return overrideValue; + } + }); + } + }; + + }); +appDS2.controller('TreeCtrl', ['$scope', function ($scope) { + $scope.remove = function (scope) { + scope.remove(); + }; + + $scope.toggle = function (scope) { + scope.toggle(); + }; + + $scope.moveLastToTheBeginning = function () { + var a = $scope.data.pop(); + $scope.data.splice(0, 0, a); + }; + + $scope.newSubItem = function (scope) { + var nodeData = scope.$modelValue; + nodeData.nodes.push({ + id: nodeData.id * 10 + nodeData.nodes.length, + title: nodeData.title + '.' + (nodeData.nodes.length + 1), + nodes: [] + }); + }; + + $scope.collapseAll = function () { + $scope.$broadcast(FIELD.ID.ANGULAR_UI_TREE_COLLAPSEALL); + }; + + $scope.expandAll = function () { + $scope.$broadcast(FIELD.ID.ANGULAR_UI_TREE_EXPANDALL); + }; + + +}]); + + + 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 new file mode 100755 index 00000000..6a1c14c5 --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/creationDialogController.js @@ -0,0 +1,163 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +"use strict"; + +var creationDialogController = function( COMPONENT, FIELD, $scope, $http, $timeout, $log, + CreationService, UtilityService, DataService) { + + $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; + } + + $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 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 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", "$scope", "$http", + "$timeout", "$log", "CreationService", "UtilityService", "DataService", + creationDialogController ]); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/deletionDialogController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/deletionDialogController.js new file mode 100755 index 00000000..137673d4 --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/deletionDialogController.js @@ -0,0 +1,119 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +"use strict"; + +var deletionDialogController = function( COMPONENT, FIELD, $scope, $http, $timeout, $log, + DeletionService, UtilityService) { + + $scope.isDialogVisible = false; + $scope.summaryControl = {}; + $scope.userProvidedControl = {}; + + var callbackFunction = undefined; + var componentId = undefined; + + $scope.$on(COMPONENT.DELETE_COMPONENT, function(event, request) { + + $scope.isDataVisible = false; + $scope.isSpinnerVisible = false; + $scope.isErrorVisible = false; + $scope.isDialogVisible = true; + $scope.popup.isVisible = true; + $scope.isConfirmEnabled = false; + + callbackFunction = request.callbackFunction; + componentId = request.componentId; + + DeletionService.initializeComponent(request.componentId); + + $scope.componentName = DeletionService.getComponentDisplayName(); + + $scope.summaryControl.setList(DeletionService.getSummaryList()); + + DeletionService.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) { + DeletionService.updateUserParameterList(id, $scope.userProvidedControl); + } + + $scope.confirm = function() { + + var requiredFields = $scope.userProvidedControl.getRequiredFields(); + if (requiredFields === "") { + $scope.isErrorVisible = false; + } else { + showError(FIELD.ERROR.MISSING_DATA, requiredFields); + return; + } + + + var requestDetails = DeletionService.getMsoRequestDetails($scope.userProvidedControl.getList()); + + $scope.isDialogVisible = false; + + $scope.$broadcast(COMPONENT.MSO_DELETE_REQ, { + url : DeletionService.getMsoUrl(), + requestDetails : requestDetails, + componentId: componentId, + callbackFunction : function(isSuccessful) { + if (isSuccessful) { + $scope.popup.isVisible = false; + runCallback(true); + } else { + $scope.isDialogVisible = true; + } + } + }); + + } + + $scope.cancel = function() { + $scope.isDialogVisible = false; + $scope.popup.isVisible = false; + runCallback(false); + } + + var runCallback = function(isSuccessful) { + if (angular.isFunction(callbackFunction)) { + callbackFunction({ + isSuccessful : isSuccessful + }); + } + } +} + +appDS2.controller("deletionDialogController", [ "COMPONENT", "FIELD", "$scope", "$http", + "$timeout", "$log", "DeletionService", "UtilityService", + deletionDialogController ]); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/detailsDialogController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/detailsDialogController.js new file mode 100755 index 00000000..ddb1ac1d --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/detailsDialogController.js @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +"use strict"; + +var detailsDialogController = function($scope, $http, $timeout, $log, + MsoService, DetailsService, UtilityService, COMPONENT, FIELD) { + + $scope.isDialogVisible = false; + $scope.summaryControl = {}; + $scope.detailsControl = {}; + + $scope.$on(COMPONENT.SHOW_COMPONENT_DETAILS, function(event, request) { + + $scope.log = ""; + $scope.isSpinnerVisible = true; + $scope.isErrorVisible = false; + $scope.isDialogVisible = true; + $scope.popup.isVisible = true; + + DetailsService.initializeComponent(request.componentId); + + $scope.componentName = DetailsService.getComponentDisplayName(); + + $scope.summaryControl.setList(DetailsService.getSummaryList()); + + $scope.detailsControl.setList(DetailsService.getDetailsList()); + + UtilityService.setHttpErrorHandler(function(response) { + showError(FIELD.ERROR.SYSTEM_FAILURE, UtilityService + .getHttpErrorMessage(response)); + }); + + MsoService.getOrchestrationRequests( + DetailsService.getMsoFilterString(), handleGetResponse); + }); + + var handleGetResponse = function(response) { + $scope.isSpinnerVisible = false; + try { + $scope.log = MsoService + .getFormattedGetOrchestrationRequestsResponse(response); + } catch (error) { + $scope.log = MsoService.getFormattedCommonResponse(response); + MsoService.showResponseContentError(error, showError); + } + } + + $scope.close = function() { + $scope.isDialogVisible = false; + $scope.popup.isVisible = false; + } + + 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("detailsDialogController", [ "$scope", "$http", "$timeout", + "$log", "MsoService", "DetailsService", "UtilityService", "COMPONENT", "FIELD", + detailsDialogController ]); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/msoCommitController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/msoCommitController.js new file mode 100755 index 00000000..65fac289 --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/msoCommitController.js @@ -0,0 +1,300 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +"use strict"; + +/* + * "msoCommitController.js" provides controller code to commit MSO requests. + * + * HIGHLIGHTS: + * + * Parent HTML/JSP code is expected to include "msoCommit.htm" (via + * "ng-include") and this file (via "