diff options
author | Ofir Sonsino <os0695@att.com> | 2018-01-31 17:19:00 +0200 |
---|---|---|
committer | Ofir Sonsino <os0695@att.com> | 2018-01-31 17:19:00 +0200 |
commit | 1cfb08779ea0e00be69e072a940b3063e049fe6b (patch) | |
tree | 6602a900387c8393ed0dcd81c0539381632903c6 /vid-app-common/src/main/webapp/app/vid/scripts/controller | |
parent | 2f20b001b9243e0f8b44aecc768ec265fd538732 (diff) |
org.onap migration
Change-Id: I52f0b2851f2c765752b6d21f49b32136d7d72a3d
Issue-ID: VID-86
Signed-off-by: Ofir Sonsino <os0695@att.com>
Diffstat (limited to 'vid-app-common/src/main/webapp/app/vid/scripts/controller')
12 files changed, 2047 insertions, 684 deletions
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/AddNetworkNodeController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/AddNetworkNodeController.js new file mode 100644 index 00000000..458da3f7 --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/AddNetworkNodeController.js @@ -0,0 +1,78 @@ +/*- +* ============LICENSE_START======================================================= +* VID +* ================================================================================ +* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +* ================================================================================ +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* ============LICENSE_END========================================================= +*/ + +/** + * The Instantiation (or View/Edit) Controller controls the instantiation/removal of + * deployable objects (Services, VNFs, VF-Modules, Networks, and Volume-Groups) + */ + +"use strict"; + +appDS2.controller("AddNetworkNodeController", ["COMPONENT", "FIELD", "PARAMETER", "DataService", "CreationService", "$scope", "$window", "$location", + function (COMPONENT, FIELD, PARAMETER, DataService, CreationService, $scope, $window, $location) { + + $scope.serviceMetadataFields = []; + $scope.tenantList = []; + $scope.nodeTemplateFields = {}; + + $scope.regexInstanceName = /^([a-z])+([0-9a-z\-_\.]*)$/i; + $scope.errorMsg = FIELD.ERROR.INSTANCE_NAME_VALIDATE; + + var handleGetParametersResponse = function(parameters) { + $scope.serviceMetadataFields = parameters.summaryList; + $scope.tenantList = DataService.getCloudRegionTenantList(); + + if(DataService.getPortMirroningConfigFields()){ + $scope.nodeTemplateFields =DataService.getPortMirroningConfigFields(); + }else { + $scope.nodeTemplateFields = angular.copy(_.keyBy(parameters.userProvidedList, 'id')); + } + + $scope.modelName = DataService.getModelInfo(COMPONENT.VNF).modelCustomizationName; + }; + + CreationService.initializeComponent(COMPONENT.VNF); + + CreationService.getParameters(handleGetParametersResponse); + + $scope.setTenant = function(field) { + $scope.nodeTemplateFields.tenant.optionList = _.filter($scope.tenantList, {'cloudRegionId': field.value, 'isPermitted': true}); + }; + + $scope.cancel = function() { + $window.history.back(); + }; + + $scope.next = function() { + // DataService.setLcpRegion($scope.nodeTemplateFields.lcpRegion.value); + // DataService.setModelInstanceName($scope.nodeTemplateFields.instanceName.value); + // DataService.setTenant($scope.nodeTemplateFields.tenant.value); + // var suppressRollback = ($scope.nodeTemplateFields.suppressRollback.value) ? true : false; + // DataService.setSuppressRollback(suppressRollback); + DataService.setPortMirroningConfigFields($scope.nodeTemplateFields); + $location.path("/serviceProxyConfig"); + }; + + $scope.$on('$routeChangeStart', function (event, next, current) { + if(next.$$route.originalPath !=="/serviceProxyConfig"){ + DataService.setPortMirroningConfigFields(null); + } + }); + }]); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/InstantiationController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/InstantiationController.js index f0653f68..f1dc384c 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/InstantiationController.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/InstantiationController.js @@ -26,14 +26,18 @@ "use strict";
appDS2.requires.push('ui.tree');
-
- appDS2.controller("InstantiationController", function ($scope, $route, $location, $timeout, COMPONENT, VIDCONFIGURATION, FIELD, DataService, PropertyService, UtilityService, VnfService, $http, vidService) {
-
+
+ appDS2.controller("InstantiationController", function ($scope, $route, $location, $timeout, COMPONENT, VIDCONFIGURATION, FIELD, DataService, PropertyService, UtilityService, VnfService, $http, vidService, AaiService,PnfService, $q) {
+
$scope.popup = new Object();
$scope.defaultBaseUrl = "";
$scope.responseTimeoutMsec = 60000;
$scope.properties = UtilityService.getProperties();
- $scope.isPermitted = $location.search().isPermitted;
+ $scope.resumeStatus = COMPONENT.RESUME_STATUS;
+ //isPermitted - returned as string from url and converted into boolean
+ $scope.isPermitted = $location.search().isPermitted == "true";
+ $scope.STATUS_CONSTANTS = FIELD.STATUS;
+ $scope.pnfs = [];// PNF data init;
$scope.init = function() {
/*
@@ -63,8 +67,9 @@ // DataService.setServiceInstanceId("mmsc-test-service-instance");
// DataService.setServiceUuid("XXXX-YYYY-ZZZZ");
// DataService.setUserServiceInstanceName("USER_SERVICE_INSTANCE_NAME");
+
}
-
+
//PropertyService.setMsoBaseUrl("testmso");
$scope.convertModel = function(asdcModel) {
@@ -78,7 +83,23 @@ "convertedModel": $scope.convertModel(vidService.getModel()),
"instance": vidService.getInstance()
};
-
+
+ preparePnfs();
+
+
+ function preparePnfs(){
+ var serviceInstance = {
+ globalCustomerId: $location.search().subscriberId,
+ serviceType: $location.search().serviceType,
+ serviceInstanceId: $location.search().serviceInstanceId
+ };
+
+ _setPnf(serviceInstance).then(function(data){
+ $scope.pnfs = data;
+ });
+ }
+
+
$scope.returnVfModules = function (vnfInstance) {
var svcModel = $scope.service.convertedModel;
@@ -213,9 +234,10 @@ DataService.setServiceUuid($scope.service.model.service.uuid);
DataService.setNetworkInstanceId(network.object[FIELD.ID.NETWORK_ID]);
- $scope.$broadcast(COMPONENT.DELETE_COMPONENT, {
+ $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, {
componentId : COMPONENT.NETWORK,
- callbackFunction : deleteCallbackFunction
+ callbackFunction : deleteOrResumeCallback,
+ dialogMethod: COMPONENT.DELETE
});
};
@@ -233,14 +255,8 @@ }
DataService.setMacro($scope.isMacro());
DataService.setInventoryItem(serviceInstance);
-
- DataService.setModelInfo(COMPONENT.SERVICE, {
- "modelInvariantId": $scope.service.model.service.invariantUuid,
- "modelVersion": $scope.service.model.service.version,
- "modelNameVersionId": $scope.service.model.service.uuid,
- "modelName": $scope.service.model.service.name,
- "inputs": ""
- });
+ setCurrentServiceModelInfoFromScope();
+
DataService.setSubscriberName(serviceObject[FIELD.ID.SUBSCRIBER_NAME]);
DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]);
@@ -253,105 +269,150 @@ DataService.setServiceUuid($scope.service.model.service.uuid);
- $scope.$broadcast(COMPONENT.DELETE_COMPONENT, {
+ $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, {
componentId : COMPONENT.SERVICE,
- callbackFunction : deleteServiceInstanceCallbackFunction
+ callbackFunction : deleteServiceInstanceCallbackFunction,
+ dialogMethod: COMPONENT.DELETE
});
};
- $scope.deleteVfModule = function(serviceObject, vfModule, vnf) {
-
- console.log("Removing VF-Module " + vfModule.name);
-
+ function populate_popup_vfModule(serviceObject, vfModule, vnf){
var serviceInstance = serviceObject.object;
- DataService.setInventoryItem(vfModule.object);
-
- var svcModel = $scope.service.convertedModel;
+ DataService.setInventoryItem(vfModule.object);
- //var vnfModelInvariantUuid = vnf.object[FIELD.ID.MODEL_INVAR_ID];
- var vnfModelVersionId = vnf.object[FIELD.ID.MODEL_VERSION_ID];
- var vnfModelCustomizationUuid = vnf.object[FIELD.ID.MODEL_CUSTOMIZATION_ID];;
- var vfModuleInstanceID = vfModule.object[FIELD.ID.VF_MODULE_ID];
- if (vfModuleInstanceID == null) {
- vfModuleInstanceID = "";
- }
-
- var vnfModel = null;
- var vfModuleModel = null;
-
- DataService.setModelInfo(COMPONENT.VF_MODULE, {
- "modelInvariantId": "",
- "modelVersion": "",
- "modelNameVersionId": "",
- "modelCustomizationName": "",
- "customizationUuid": "",
- "modelName": "",
- "inputs": ""
- });
-
- if ( (!($scope.isObjectEmpty(svcModel))) && ( !($scope.isObjectEmpty(svcModel.vnfs) ) ) ) {
- if ( (svcModel.isNewFlow) && (vnfModelCustomizationUuid != null ) ) {
- vnfModel = svcModel.vnfs[vnfModelCustomizationUuid];
-
- var vfModuleCustomizationUuid = vfModule.object[FIELD.ID.MODEL_CUSTOMIZATION_ID];
- if ( !($scope.isObjectEmpty(vnfModel.vfModules) ) && UtilityService.hasContents(vfModuleCustomizationUuid) ) {
-
- vfModuleModel = vnfModel.vfModules[vfModuleCustomizationUuid];
-
- }
- }
- else {
- // old flow
- if (vnfModelVersionId != null ) {
- vnfModel = svcModel.vnfs[vnfModelVersionId];
- }
- //var vfModuleInvariantUuid = vfModule.object[FIELD.ID.MODEL_INVAR_ID];
- var vfModuleModelVersionId = vfModule.object[FIELD.ID.MODEL_VERSION_ID];
- if ( (!($scope.isObjectEmpty(vnfModel))) && (!($scope.isObjectEmpty(vnfModel.vfModules))) &&
- UtilityService.hasContents(vfModuleModelVersionId) ) {
- vfModuleModel = vnfModel.vfModules[vfModuleModelVersionId];
- }
- }
- if ( !($scope.isObjectEmpty(vfModuleModel)) ) {
- DataService.setModelInfo(COMPONENT.VF_MODULE, {
- "modelInvariantId": vfModuleModel.invariantUuid,
- "modelVersion": vfModuleModel.version,
- "modelNameVersionId": vfModuleModel.uuid,
- "modelCustomizationName": vfModuleModel.modelCustomizationName,
- "customizationUuid": vfModuleModel.customizationUuid,
- "modelName": vfModuleModel.name,
- "inputs": ""
- });
- }
- }
+ var svcModel = $scope.service.convertedModel;
- DataService.setVnfInstanceId(vnf.object[FIELD.ID.VNF_ID]);
- DataService.setVfModuleInstanceId(vfModuleInstanceID);
-
- DataService.setSubscriberName(serviceObject[COMPONENT.SUBSCRIBER_NAME]);
- DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]);
- DataService.setServiceInstanceId(serviceInstance[FIELD.ID.SERVICE_INSTANCE_ID]);
-
- DataService.setGlobalCustomerId(serviceObject[FIELD.ID.GLOBAL_CUST_ID]);
- DataService.setServiceInstanceName($scope.service.instance.name);
-
- DataService.setServiceName($scope.service.model.service.name);
-
- DataService.setServiceUuid($scope.service.model.service.uuid);
+ //var vnfModelInvariantUuid = vnf.object[FIELD.ID.MODEL_INVAR_ID];
+ var vnfModelVersionId = vnf.object[FIELD.ID.MODEL_VERSION_ID];
+ var vnfModelCustomizationUuid = vnf.object[FIELD.ID.MODEL_CUSTOMIZATION_ID];;
+ var vfModuleInstanceID = vfModule.object[FIELD.ID.VF_MODULE_ID];
+ if (vfModuleInstanceID == null) {
+ vfModuleInstanceID = "";
+ }
+
+ var vnfModel = null;
+ var vfModuleModel = null;
+
+ DataService.setModelInfo(COMPONENT.VF_MODULE, {
+ "modelInvariantId": "",
+ "modelVersion": "",
+ "modelNameVersionId": "",
+ "modelCustomizationName": "",
+ "customizationUuid": "",
+ "modelName": "",
+ "inputs": ""
+ });
+
+ if ( (!($scope.isObjectEmpty(svcModel))) && ( !($scope.isObjectEmpty(svcModel.vnfs) ) ) ) {
+ if ( (svcModel.isNewFlow) && (vnfModelCustomizationUuid != null ) ) {
+ vnfModel = svcModel.vnfs[vnfModelCustomizationUuid];
+
+ var vfModuleCustomizationUuid = vfModule.object[FIELD.ID.MODEL_CUSTOMIZATION_ID];
+ if ( !($scope.isObjectEmpty(vnfModel.vfModules) ) && UtilityService.hasContents(vfModuleCustomizationUuid) ) {
+
+ vfModuleModel = vnfModel.vfModules[vfModuleCustomizationUuid];
+
+ }
+ }
+ else {
+ // old flow
+ if (vnfModelVersionId != null ) {
+ vnfModel = svcModel.vnfs[vnfModelVersionId];
+ }
+ //var vfModuleInvariantUuid = vfModule.object[FIELD.ID.MODEL_INVAR_ID];
+ var vfModuleModelVersionId = vfModule.object[FIELD.ID.MODEL_VERSION_ID];
+ if ( (!($scope.isObjectEmpty(vnfModel))) && (!($scope.isObjectEmpty(vnfModel.vfModules))) &&
+ UtilityService.hasContents(vfModuleModelVersionId) ) {
+ vfModuleModel = vnfModel.vfModules[vfModuleModelVersionId];
+ }
+ }
+ if ( !($scope.isObjectEmpty(vfModuleModel)) ) {
+ DataService.setModelInfo(COMPONENT.VF_MODULE, {
+ "modelInvariantId": vfModuleModel.invariantUuid,
+ "modelVersion": vfModuleModel.version,
+ "modelNameVersionId": vfModuleModel.uuid,
+ "modelCustomizationName": vfModuleModel.modelCustomizationName,
+ "customizationUuid": vfModuleModel.customizationUuid,
+ "modelName": vfModuleModel.name,
+ "inputs": ""
+ });
+ }
+ }
+
+ DataService.setVnfInstanceId(vnf.object[FIELD.ID.VNF_ID]);
+ DataService.setVfModuleInstanceId(vfModuleInstanceID);
+
+ DataService.setSubscriberName(serviceObject[COMPONENT.SUBSCRIBER_NAME]);
+ DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]);
+ DataService.setServiceInstanceId(serviceInstance[FIELD.ID.SERVICE_INSTANCE_ID]);
+
+ DataService.setGlobalCustomerId(serviceObject[FIELD.ID.GLOBAL_CUST_ID]);
+ DataService.setServiceInstanceName($scope.service.instance.name);
+
+ DataService.setServiceName($scope.service.model.service.name);
+
+ DataService.setServiceUuid($scope.service.model.service.uuid);
+ }
+
+ $scope.deleteVfModule = function(serviceObject, vfModule, vnf) {
+
+ console.log("Removing VF-Module " + vfModule.name);
+
+ populate_popup_vfModule(serviceObject, vfModule, vnf);
- $scope.$broadcast(COMPONENT.DELETE_COMPONENT, {
+ $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, {
componentId : COMPONENT.VF_MODULE,
- callbackFunction : deleteCallbackFunction
+ callbackFunction : deleteOrResumeCallback,
+ dialogMethod: COMPONENT.DELETE
});
return;
};
- $scope.deleteVnf = function(serviceObject, vnf) {
+ function setCurrentServiceModelInfoFromScope(){
+ DataService.setModelInfo(COMPONENT.SERVICE, {
+ "modelInvariantId": $scope.service.model.service.invariantUuid,
+ "modelVersion": $scope.service.model.service.version,
+ "modelNameVersionId": $scope.service.model.service.uuid,
+ "modelName": $scope.service.model.service.name,
+ "inputs": ""
+ });
+ };
+
+ function setCurrentVNFModelInfo(vnf){
+ var svcModel = $scope.service.convertedModel;
+ var vnfModel;
+ var vnfModelCustomizationUuid = vnf.object[FIELD.ID.MODEL_CUSTOMIZATION_ID];
+ var vnfModelVersionId = vnf.object[FIELD.ID.MODEL_VERSION_ID];
+ if ( (!($scope.isObjectEmpty(svcModel))) && ( !($scope.isObjectEmpty(svcModel.vnfs) ) ) ) {
+ if ( (svcModel.isNewFlow) && (vnfModelCustomizationUuid != null ) ) {
+ vnfModel = svcModel.vnfs[vnfModelCustomizationUuid];
+ }
+ else {
+ vnfModel = svcModel.vnfs[vnfModelVersionId];
+ }
+ if ( !($scope.isObjectEmpty(vnfModel) ) ) {
+
+ DataService.setModelInfo(COMPONENT.VNF, {
+ "modelInvariantId": vnfModel.invariantUuid,
+ "modelVersion": vnfModel.version,
+ "modelNameVersionId": vnfModel.uuid,
+ "modelCustomizationName": vnfModel.modelCustomizationName,
+ "customizationUuid": vnfModel.customizationUuid,
+ "modelName": vnfModel.name,
+ "inputs": ""
+ });
+ }
+ }
+
+
+
+ }
+ $scope.deleteVnf = function(serviceObject, vnf) {
console.log("Removing VNF " + vnf.name);
var serviceInstance = serviceObject.object;
@@ -424,9 +485,10 @@ DataService.setServiceUuid($scope.service.model.service.uuid);
- $scope.$broadcast(COMPONENT.DELETE_COMPONENT, {
+ $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, {
componentId : COMPONENT.VNF,
- callbackFunction : deleteCallbackFunction
+ callbackFunction : deleteOrResumeCallback,
+ dialogMethod: COMPONENT.DELETE
});
};
@@ -517,8 +579,9 @@ DataService.setVnfInstanceId(vnf.nodeId);
DataService.setVolumeGroupInstanceId(volumeGroup.nodeId);
- $scope.$broadcast(COMPONENT.DELETE_COMPONENT, {
+ $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, {
componentId : COMPONENT.VOLUME_GROUP,
+ dialogMethod: COMPONENT.DELETE
});
};
@@ -585,10 +648,11 @@ DataService.setVnfInstanceId(vnf.nodeId);
DataService.setVolumeGroupInstanceId(volumeGroup.nodeId);
- $scope.$broadcast(COMPONENT.DELETE_COMPONENT, {
- componentId : COMPONENT.VOLUME_GROUP,
- callbackFunction : deleteCallbackFunction
- });
+ $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, {
+ componentId : COMPONENT.VOLUME_GROUP,
+ callbackFunction : deleteOrResumeCallback,
+ dialogMethod: COMPONENT.DELETE
+ });
};
$scope.describeNetwork = function(serviceObject, networkObject) {
@@ -783,14 +847,8 @@ "inputs": "",
"displayInputs": netModel.displayInputs
});
-
- DataService.setModelInfo(COMPONENT.SERVICE, {
- "modelInvariantId": $scope.service.model.service.invariantUuid,
- "modelVersion": $scope.service.model.service.version,
- "modelNameVersionId": $scope.service.model.service.uuid,
- "modelName": $scope.service.model.service.name,
- "inputs": ""
- });
+ setCurrentServiceModelInfoFromScope();
+
$scope.$broadcast(COMPONENT.CREATE_COMPONENT, {
componentId : COMPONENT.NETWORK,
@@ -814,6 +872,8 @@ DataService.setServiceInstanceId($scope.service.instance.id);
DataService.setServiceName($scope.service.model.service.name);
+ console.log ( "existingVnfs: " );
+ console.log (JSON.stringify ( existingVnfs, null, 4));
console.log ( "existingVnfs: " ); console.log (JSON.stringify ( existingVnfs, null, 4));
var vnf_type = "";
var vnf_role = "";
@@ -833,7 +893,7 @@ vnf_code = vnf.nfCode;
}
DataService.setModelInfo(COMPONENT.VNF, {
- "modelType": "vnf",
+ "modelType": vnf.isPnf ? "pnf" : "vnf",
"modelInvariantId": vnf.invariantUuid,
"modelVersion": vnf.version,
"modelNameVersionId": vnf.uuid,
@@ -845,23 +905,27 @@ "vnfType": vnf_type,
"vnfRole": vnf_role,
"vnfFunction": vnf_function,
- "vnfCode": vnf_code
+ "vnfCode": vnf_code,
+ "properties": vnf.properties
});
DataService.setModelInstanceName($scope.service.model.service.name);
-
- DataService.setModelInfo(COMPONENT.SERVICE, {
- "modelInvariantId": $scope.service.model.service.invariantUuid,
- "modelVersion": $scope.service.model.service.version,
- "modelNameVersionId": $scope.service.model.service.uuid,
- "modelName": $scope.service.model.service.name,
- "inputs": ""
- });
-
- $scope.$broadcast(COMPONENT.CREATE_COMPONENT, {
- componentId : COMPONENT.VNF,
- callbackFunction : createVnfCallbackFunction
- });
+ setCurrentServiceModelInfoFromScope();
+
+ if (vnf.isConfig) {
+ DataService.setServiceProxies($scope.service.model.serviceProxies);
+ DataService.setSourceServiceProxies(vnf.sourceNodes);
+ DataService.setCollectorServiceProxies(vnf.collectorNodes);
+ DataService.setConfigurationByPolicy(vnf.isConfigurationByPolicy);
+ $location.path("/addNetworkNode");
+ } else if(vnf.isPnf){
+ $location.path("/pnfSearchAssociation");
+ } else {
+ $scope.$broadcast(COMPONENT.CREATE_COMPONENT, {
+ componentId: COMPONENT.VNF,
+ callbackFunction: createVnfCallbackFunction
+ });
+ }
};
$scope.addVfModuleInstance = function(vnfInstance, vfModuleModel) {
@@ -898,20 +962,11 @@ availableVolumeGroupList.push({"instance": volumeGroupInstance});
});
- if (vfModuleModel.volumeGroupAllowed) {
- DataService.setAvailableVolumeGroupList(availableVolumeGroupList);
- }
-
- DataService.setModelInfo(COMPONENT.SERVICE, {
- "modelInvariantId": $scope.service.model.service.invariantUuid,
- "modelVersion": $scope.service.model.service.version,
- "modelNameVersionId": $scope.service.model.service.uuid,
- "modelName": $scope.service.model.service.name,
- "inputs": ""
- });
+ DataService.setAvailableVolumeGroupList(availableVolumeGroupList);
+ setCurrentServiceModelInfoFromScope();
DataService.setVnfInstanceId(vnfInstance.object[FIELD.ID.VNF_ID]);
-
+
DataService.setModelInfo(COMPONENT.VNF, {
"modelInvariantId": vnfModel.invariantUuid,
"modelVersion": vnfModel.version,
@@ -954,6 +1009,7 @@ DataService.setServiceInstanceName($scope.service.instance.name);
DataService.setServiceInstanceId($scope.service.instance.id);
DataService.setServiceName($scope.service.model.service.name);
+ setCurrentServiceModelInfoFromScope();
DataService.setModelInfo(COMPONENT.SERVICE, {
"modelInvariantId": $scope.service.model.service.invariantUuid,
@@ -976,7 +1032,7 @@ else {
vnfModel = svcModel.vnfs[vnfModelVersionId];
}
-
+
DataService.setModelInfo(COMPONENT.VNF, {
"modelInvariantId": vnfModel.invariantUuid,
"modelVersion": vnfModel.version,
@@ -1003,6 +1059,76 @@ });
};
+ $scope.resume = function(serviceObject, vfModule, vnfModel) {
+ populate_popup_vfModule(serviceObject, vfModule, vnfModel);
+ setCurrentVNFModelInfo(vnfModel);
+ DataService.setVfModuleInstanceName(vfModule.object[FIELD.ID.VF_MODULE_NAME]);
+ setCurrentServiceModelInfoFromScope();
+ $scope.$broadcast(COMPONENT.DELETE_RESUME_COMPONENT, {
+ componentId : COMPONENT.VF_MODULE,
+ callbackFunction : deleteOrResumeCallback,
+ dialogMethod: COMPONENT.RESUME
+ });
+ };
+
+ $scope.deleteConfiguration = function (serviceObject, configuration) {
+ console.log("Deleting Configuration " + configuration.name);
+
+ var serviceInstance = serviceObject.object;
+ var svcModel = $scope.service.convertedModel;
+ var configModel;
+ DataService.setInventoryItem(configuration.object);
+ // set model default and override later if found
+ DataService.setModelInfo(COMPONENT.CONFIGURATION, {});
+
+ if ( configuration.object != null ) {
+
+ //var netModelInvariantUuid = network.object[FIELD.ID.MODEL_INVAR_ID];
+ var configModelVersionId = configuration.object[FIELD.ID.MODEL_VERSION_ID]; // model uuid
+ var configModelCustomizationUuid = configuration.object[FIELD.ID.MODEL_CUSTOMIZATION_ID];
+
+ //configurations added to vnfs list, in order to be part of the "Add VNF" drop-down list
+ if ( (!($scope.isObjectEmpty(svcModel))) && ( !($scope.isObjectEmpty(svcModel.vnfs) ) ) ) {
+ if ( (svcModel.isNewFlow) && (UtilityService.hasContents(configModelCustomizationUuid) ) ) {
+ configModel = svcModel.vnfs[configModelCustomizationUuid];
+ }
+ else {
+
+ if ( UtilityService.hasContents(configModelVersionId) ) {
+ configModel = svcModel.vnfs[configModelVersionId];
+ }
+
+ }
+ }
+ }
+ if (!($scope.isObjectEmpty(configModel) ) ) {
+ DataService.setModelInfo(COMPONENT.CONFIGURATION, {
+ "modelInvariantId": configModel.invariantUuid,
+ "modelVersion": configModel.version,
+ "modelNameVersionId": configModel.uuid,
+ "modelCustomizationName": configModel.modelCustomizationName,
+ "customizationUuid": configModel.customizationUuid,
+ "modelName": configModel.name,
+ "inputs": ""
+ });
+ }
+
+ DataService.setSubscriberName(serviceObject[COMPONENT.SUBSCRIBER_NAME]);
+ DataService.setServiceType(serviceObject[COMPONENT.SERVICE_TYPE]);
+ DataService.setServiceInstanceId(serviceInstance[FIELD.ID.SERVICE_INSTANCE_ID]);
+
+ DataService.setGlobalCustomerId(serviceObject[FIELD.ID.GLOBAL_CUST_ID]);
+ DataService.setServiceInstanceName($scope.service.instance.name);
+ DataService.setServiceName($scope.service.model.service.name);
+ DataService.setServiceUuid($scope.service.model.service.uuid);
+ DataService.setConfigurationInstanceId(configuration.object[FIELD.ID.CONFIGURATION_ID]);
+
+ $scope.$broadcast(COMPONENT.DELETE_COMPONENT, {
+ componentId : COMPONENT.CONFIGURATION,
+ callbackFunction : deleteCallbackFunction
+ });
+ };
+
$scope.resetProgress = function() {
$scope.percentProgress = 0;
$scope.progressClass = FIELD.STYLE.PROGRESS_BAR_INFO;
@@ -1055,7 +1181,35 @@ $scope.reloadRoute = function() {
$route.reload();
}
-
+
+
+
+ /*
+ Private metthods
+ */
+
+ /*
+ setPnf
+ * set the controller pnf param using api call
+ * return: void
+ */
+ function _setPnf(data){ // data is the $scope.service.instance object
+ return PnfService.getPnfs(data)
+ .then(
+ function success(response){
+ return response.data;
+ // * can add here changes on the data that are needed to the view ( filter, ect..)
+ },
+ function error(error){
+ console.error(error);
+ }
+ );
+ }
+
+ /*
+ Callbaks functions
+
+ */
var updateProvStatusVnfCallbackFunction = function(response) {
$scope.callbackResults = "";
var color = FIELD.ID.COLOR_NONE;
@@ -1112,7 +1266,7 @@ };
- var deleteCallbackFunction = function(response) {
+ var deleteOrResumeCallback = function(response) {
$scope.callbackResults = "";
var color = FIELD.ID.COLOR_NONE;
$scope.callbackStyle = {
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js index 8844d40a..967a3900 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js @@ -41,14 +41,13 @@ $scope.services = [];
if (response.data && angular.isArray(response.data.services)) {
wholeData = response.data.services;
- $scope.services = $scope.filterDataWithHigerVersion(wholeData);
+ $scope.services = $scope.filterDataWithHigherVersion(wholeData);
$scope.viewPerPage=10;
$scope.totalPage=$scope.services.length/$scope.viewPerPage;
$scope.sortBy=COMPONENT.NAME;
$scope.scrollViewPerPage=2;
$scope.currentPage=1;
$scope.searchCategory;
- $scope.searchString="";
$scope.currentPageNum=1;
$scope.isSpinnerVisible = false;
$scope.isProgressVisible = false;
@@ -61,67 +60,35 @@ }, function errorCallback(response) {
console.log("Error: " + response);
});
- }
- $scope.isFiltered=function(arr,obj){
- var filtered = false;
- if(arr.length>0){
- for(var i=0;i<arr.length;i++){
- if((arr[i].name == obj.name) && (obj.invariantUUID == arr[i].invariantUUID)){
- filtered = true;
- }
- }
- }
- return filtered;
- }
+ };
+
var wholeData=[];
- $scope.filterDataWithHigerVersion = function(serviceData){
- var fiterDataServices = [];
- for(var i=0;i<serviceData.length;i++){
- var higherVersion = serviceData[i];
- if(!$scope.isFiltered(fiterDataServices,serviceData[i])){
- for(var j=i;j<serviceData.length;j++){
- if((serviceData[i].invariantUUID.trim() == serviceData[j].invariantUUID.trim()) && (serviceData[i].name.trim() == serviceData[j].name.trim()) && (parseFloat(serviceData[j].version.trim())>=parseFloat(serviceData[i].version.trim()))){
- var data = $scope.isThisHigher(fiterDataServices,serviceData[j]);
- if(data.isHigher){
- fiterDataServices[data.index] = serviceData[j];
- }
- }
- }
- }
- }
- return fiterDataServices;
- }
- $scope.isThisHigher = function(arr,obj){
- var returnObj = {
- isHigher:false,
- index:0
- };
- if(arr.length>0){
- var isNotMatched = true;
- for(var i=0;i<arr.length;i++){
- if((arr[i].name == obj.name) && (arr[i].invariantUUID == obj.invariantUUID ) && (arr[i].version<obj.version) ){
- isNotMatched = false;
- returnObj = {
- isHigher:true,
- index:i
- };
+ $scope.filterDataWithHigherVersion = function(serviceData){
+ var delimiter = '$$';
+ var fiterDataServices = {};
+ for(var i=0;i<serviceData.length;i++) {
+ var index = serviceData[i].invariantUUID.trim() + delimiter + serviceData[i].name.trim();
+ if(!fiterDataServices[index]) {
+ var hasPreviousVersion = false;
+ fiterDataServices[index] = {
+ service: serviceData[i],
+ hasPreviousVersion: false
+ };
+ }
+ else {
+ fiterDataServices[index].hasPreviousVersion = true;
+ if(parseFloat(serviceData[i].version.trim())>parseFloat(fiterDataServices[index].service.version.trim())) {
+ fiterDataServices[index].service = serviceData[i];
}
}
- if(isNotMatched && !$scope.isFiltered(arr,obj)){
- returnObj = {
- isHigher:true,
- index:arr.length
- };
- }
- }else{
- returnObj = {
- isHigher:true,
- index:0
- }
}
- return returnObj;
- }
+ return Object.keys(fiterDataServices).map(function(key) {
+ var service = fiterDataServices[key].service;
+ service.hasPreviousVersion = fiterDataServices[key].hasPreviousVersion;
+ return service;
+ });
+ };
$scope.init = function() {
var msecs = PropertyService.retrieveMsoMaxPollingIntervalMsec();
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceProxyConfigController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceProxyConfigController.js new file mode 100644 index 00000000..6e7ad50c --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceProxyConfigController.js @@ -0,0 +1,342 @@ +/*- +* ============LICENSE_START======================================================= +* VID +* ================================================================================ +* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +* ================================================================================ +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* ============LICENSE_END========================================================= +*/ + +/** + * The Instantiation (or View/Edit) Controller controls the instantiation/removal of + * deployable objects (Services, VNFs, VF-Modules, Networks, and Volume-Groups) + */ + +"use strict"; + +appDS2.controller("ServiceProxyConfigController", ["COMPONENT", "$log", "FIELD", "PARAMETER", "DataService", "CreationService", "$scope", "$window", "$location", "AaiService", "$uibModal", "UtilityService", "$timeout", + function (COMPONENT, $log, FIELD, PARAMETER, DataService, CreationService, $scope, $window, $location, AaiService, $uibModal, UtilityService, $timeout) { + + $scope.selectedMetadata = {}; + + $scope.serviceMetadataFields = []; + $scope.nodeTemplateFields = {}; + + $scope.configurationByPolicy = DataService.getConfigurationByPolicy(); + + $scope.collectorType = $scope.configurationByPolicy ? 'pnf' : 'vnf'; //default + $scope.collectorInstance; + $scope.collectorInstanceName = ""; + $scope.collectorInstanceList = null; + $scope.collectorMetadata = []; + $scope.collectorNoResults = false; + + $scope.sourceInstance; + $scope.sourceInstanceName = ""; + $scope.sourceInstanceList = null; + $scope.sourceMetadata = []; + $scope.sourceNoResults = false; + + $scope.errorMsg = FIELD.ERROR.INSTANCE_NAME_VALIDATE; + + $scope.modelName = DataService.getModelInfo(COMPONENT.VNF).modelCustomizationName; + + $scope.serviceTypes = []; + + function init() { + loadServiceTypes(); + + generateMetadata(sourceServiceProxy); + generateMetadata(collectorServiceProxy); + + } + + function setDefaultCollectorServiceType() { + const configServiceType = DataService.getServiceType(); + $scope.collectorServiceType = mustFind($scope.serviceTypes, {"service-type": configServiceType}); + loadCollectorProxies(); + } + + function handleGetServiceTypesResponse(response) { + $scope.serviceTypes = response.data; + setDefaultCollectorServiceType(); + } + + var handleGetParametersResponse = function(parameters) { + $scope.serviceMetadataFields = parameters.summaryList; + $scope.nodeTemplateFields = DataService.getPortMirroningConfigFields(); + }; + + var mustFind = function (collection, predicate) { + const result = _.find(collection, predicate); + const description = "result for find " + JSON.stringify(predicate); + UtilityService.checkUndefined(description, result); + $log.debug(description, result); + return result; + }; + + + $scope.back = function() { + $window.history.back(); + }; + + + function loadServiceTypes() { + const subscriberId = DataService.getGlobalCustomerId(); + AaiService.getSubscriberServiceTypes(subscriberId) + .then(handleGetServiceTypesResponse) + .catch(function (error) { + $log.error(error); + }); + } + + var modalInstance; + + $scope.create = function() { + $scope.disableCreate= true; + var portMirroringConfigFields = DataService.getPortMirroningConfigFields(); + portMirroringConfigFields.sourceInstance = mustFind($scope.sourceInstanceList, {'id': $scope.sourceInstance}); + portMirroringConfigFields.destinationInstance = mustFind($scope.collectorInstanceList, {'id': $scope.collectorInstance}); + + var selectedVnfsList; + + if ($scope.configurationByPolicy) { + selectedVnfsList = [ + portMirroringConfigFields.sourceInstance.properties + ]; + } else { + selectedVnfsList = [ + portMirroringConfigFields.sourceInstance.properties, + portMirroringConfigFields.destinationInstance.properties + ]; + } + + AaiService.getVnfVersionsByInvariantId( + selectedVnfsList.map(function(x) { + return UtilityService.checkUndefined("model-invariant-id", x['model-invariant-id']); + }) + ) + .then(function (response) { + $log.debug("getVnfVersionsByInvariantId: response", response); + + selectedVnfsList + .map(function (inOutProperties) { + const model = mustFind(response.data.model, {'model-invariant-id': inOutProperties['model-invariant-id']}); + + const modelVer = mustFind(model["model-vers"]["model-ver"], {'model-version-id': inOutProperties['model-version-id']}); + + inOutProperties['model-version'] = modelVer['model-version']; + inOutProperties['model-name'] = modelVer['model-name']; + UtilityService.checkUndefined("model-version", modelVer); + }); + }) + + .then(function () { + var requestParams = { + configurationModelInfo: DataService.getModelInfo(COMPONENT.VNF), + relatedTopModelsInfo: DataService.getModelInfo(COMPONENT.SERVICE), + portMirroringConfigFields:portMirroringConfigFields, + attuuid: DataService.getLoggedInUserId(), + topServiceInstanceId: DataService.getServiceInstanceId(), + configurationByPolicy: $scope.configurationByPolicy, + callbackFunction: updateViewCallbackFunction + }; + + modalInstance = $uibModal.open({ + templateUrl: 'app/vid/scripts/modals/mso-commit/mso-commit.html', + controller : "msoCommitModalController", + backdrop: true, + resolve: { + msoType: function () { + return COMPONENT.MSO_CREATE_REQ; + }, + requestParams: function () { + return requestParams; + } + } + }); + }) + .catch(function (error) { + $log.error("error while configuration create", error); + $scope.disableCreate= false; + }); + }; + + $scope.openMetadataModal = function(name) { + $scope.selectedMetadata = $scope[name]; + modalInstance = $uibModal.open({ + templateUrl: 'app/vid/scripts/modals/service-metadata/service-metadata.html', + backdrop: false, + scope : $scope, + resolve: { + } + }); + }; + + $scope.cancel = function() { + modalInstance.dismiss('cancel'); + }; + + var updateViewCallbackFunction = function(response) { + $scope.callbackResults = ""; + var color = FIELD.ID.COLOR_NONE; + $scope.callbackStyle = { + "background-color" : color + }; + + /* + * This 1/2 delay was only added to visually highlight the status + * change. Probably not needed in the real application code. + */ + $timeout(function() { + $scope.callbackResults = UtilityService.getCurrentTime() + + FIELD.STATUS.IS_SUCCESSFUL + response.isSuccessful; + if (response.isSuccessful) { + color = FIELD.ID.COLOR_8F8; + $window.history.go(-2); + } else { + $scope.disableCreate=false; + color = FIELD.ID.COLOR_F88; + } + $scope.callbackStyle = { + "background-color" : color + }; + }, 500); + }; + + CreationService.initializeComponent(COMPONENT.VNF); + CreationService.initializeComponent(COMPONENT.SERVICE); + CreationService.getParameters(handleGetParametersResponse); + + var sourceServiceProxies = DataService.getSourceServiceProxies(); + var collectorServiceProxies = DataService.getCollectorServiceProxies(); + var serviceProxiesList = DataService.getServiceProxies(); + + var sourceServiceProxy = { + serviceList: sourceServiceProxies, + instanceListScopePropertyName: "sourceInstanceList", + name: "sourceInstanceName", + metadata: "sourceMetadata", + noResults: "sourceNoResults" + }; + + var collectorServiceProxy = { + serviceList: collectorServiceProxies, + instanceListScopePropertyName: "collectorInstanceList", + name: "collectorInstanceName", + metadata: "collectorMetadata", + noResults: "collectorNoResults" + }; + + $scope.onSourceServiceTypeSelected = function() { + clearSourceProxySelection(); + loadSourceProxies(); + }; + + $scope.onCollectorServiceTypeSelected = function() { + clearCollectorProxySelection(); + loadCollectorProxies(); + }; + + function clearSourceProxySelection() { + $scope.sourceInstance = undefined; + } + + function clearCollectorProxySelection() { + $scope.collectorInstance = undefined; + } + + function loadSourceProxies() { + var serviceProxy = serviceProxiesList[(sourceServiceProxy.serviceList)[0]]; + var selectedServiceType = $scope.sourceServiceType['service-type']; + loadProxyInstances(sourceServiceProxy, selectedServiceType, serviceProxy); + } + + function loadCollectorProxies() { + var serviceProxy = serviceProxiesList[(collectorServiceProxy.serviceList)[0]]; + var selectedServiceType = $scope.collectorServiceType['service-type']; + loadProxyInstances(collectorServiceProxy, selectedServiceType, serviceProxy); + } + + function loadProxyInstances(service, serviceType, serviceProxy) { + $scope[service.instanceListScopePropertyName] = null; + // $scope.collectorType = $scope.configurationByPolicy ? 'pnf' : 'vnf'; + var configNodeTemplateFields = DataService.getPortMirroningConfigFields(); + if (service.name == "collectorInstanceName" && $scope.configurationByPolicy) { + var configurationModel = DataService.getModelInfo(COMPONENT.VNF); + AaiService.getPnfInstancesList( + DataService.getGlobalCustomerId(), + serviceType, + serviceProxy.sourceModelUuid, + serviceProxy.sourceModelInvariant, + configNodeTemplateFields.lcpRegion.value, + configurationModel.properties.equip_vendor, + configurationModel.properties.equip_model + ) + .then(function (response) { + var results = response.results || []; + $scope[service.instanceListScopePropertyName] = results; + $scope[service.noResults] = (results.length === 0); + }) + .catch(function (error) { + $scope[service.noResults] = true; + $log.error("No pnf instance found for " + service.name, error); + }); + } else { + AaiService.getVnfInstancesList( + DataService.getGlobalCustomerId(), + serviceType, + serviceProxy.sourceModelUuid, + serviceProxy.sourceModelInvariant, + configNodeTemplateFields.lcpRegion.value + ) + .then(function (response) { + var results = response.results || []; + $scope[service.instanceListScopePropertyName] = results; + $scope[service.noResults] = (results.length === 0); + }) + .catch(function (error) { + $scope[service.noResults] = true; + $log.error("No vnf instance found for " + service.name, error); + }); + } + } + + function generateMetadata(service) { + const serviceProxy = serviceProxiesList[(service.serviceList)[0]]; + $scope[service.name] = serviceProxy.name; + + $scope[service.metadata] = [ + {"name" :"Name" ,"value" : serviceProxy.name}, + {"name" :"Version",value : serviceProxy.version}, + {"name" :"Description", value : serviceProxy.description}, + {"name" :"Type", value : serviceProxy.type}, + {"name" :"Invariant UUID", value : serviceProxy.invariantUuid}, + {"name" :"UUID", value : serviceProxy.uuid}, + {"name" :"Customization UUID", value : serviceProxy.customizationUuid}, + {"name" :"Source Model Uuid", value : serviceProxy.sourceModelUuid}, + {"name" :"Source Model Invariant", value : serviceProxy.sourceModelInvariant}, + {"name" :"Source Model Name", value : serviceProxy.sourceModelName} + ]; + } + + init(); + $scope.$on('$routeChangeStart', function (event, next, current) { + if(next.$$route.originalPath!=="/addNetworkNode"){ + DataService.setPortMirroningConfigFields(null); + } + }); + }]); + + diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/VidApp.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/VidApp.js index b611def4..6129fd96 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/VidApp.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/VidApp.js @@ -20,7 +20,7 @@ (function () {
'use strict';
-
+
appDS2.config(['$routeProvider', '$locationProvider', function ($routeProvider) {
$routeProvider
.when('/models/services', {
@@ -32,30 +32,47 @@ templateUrl: 'app/vid/scripts/view-models/createInstanceServiceModels.htm'
})
.when('/instances/services', {
- templateUrl : "app/vid/scripts/view-models/aaiGetSubs.htm",
+ templateUrl : "app/vid/scripts/view-models/aaiGetSubs.htm",
controller : "aaiSubscriberController"
})
.when('/instances/subscribers', {
- templateUrl : "app/vid/scripts/view-models/aaiGetSubscriberList.htm",
+ templateUrl : "app/vid/scripts/view-models/aaiGetSubscriberList.htm",
controller : "aaiSubscriberController"
})
.when('/instances/serviceTypes', {
- templateUrl : "app/vid/scripts/view-models/aaiServiceTypes.htm",
+ templateUrl : "app/vid/scripts/view-models/aaiServiceTypes.htm",
controller : "aaiSubscriberController"
})
.when('/instances/subdetails', {
- templateUrl : "app/vid/scripts/view-models/aaiSubDetails.htm",
+ templateUrl : "app/vid/scripts/view-models/aaiSubDetails.htm",
controller : "aaiSubscriberController"
})
.when('/change-management', {
templateUrl : "app/vid/scripts/view-models/change-management.html",
controller : "changeManagementController",
controllerAs: 'vm'
- })
+ })
+ .when('/testEnvironments', {
+ templateUrl : "app/vid/scripts/view-models/testEnvironments.htm",
+ controller : "testEnvironmentsController",
+ controllerAs: 'vm'
+ })
.when('/instantiate', {
controller: 'InstantiationController',
templateUrl: 'app/vid/scripts/view-models/instantiate.htm'
})
+ .when('/addNetworkNode', {
+ controller: 'AddNetworkNodeController',
+ templateUrl: 'app/vid/scripts/view-models/addNetworkNode.htm'
+ })
+ .when('/pnfSearchAssociation', {
+ controller: 'pnfSearchAssociationController',
+ templateUrl: 'app/vid/scripts/view-models/pnfSearchAssociation.htm'
+ })
+ .when('/serviceProxyConfig', {
+ controller: 'ServiceProxyConfigController',
+ templateUrl: 'app/vid/scripts/view-models/serviceProxyConfig.htm'
+ })
.otherwise({
redirectTo: '/models/services'
});
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js index a86c1b1b..d58b83f6 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js @@ -20,8 +20,8 @@ "use strict";
-appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", "DataService", "PropertyService", "$scope", "$http", "$timeout", "$location", "$log", "$route", "VIDCONFIGURATION", "UtilityService", "vidService", "AaiService", "MsoService",
- function (COMPONENT, FIELD, PARAMETER, DataService, PropertyService, $scope, $http, $timeout, $location, $log, $route, VIDCONFIGURATION, UtilityService, vidService, AaiService, MsoService) {
+appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", "DataService", "PropertyService", "$scope", "$http", "$timeout", "$location", "$log", "$route", "$uibModal", "VIDCONFIGURATION", "UtilityService", "vidService", "AaiService", "MsoService", "OwningEntityService", "$q",
+ function (COMPONENT, FIELD, PARAMETER, DataService, PropertyService, $scope, $http, $timeout, $location, $log, $route, $uibModal, VIDCONFIGURATION, UtilityService, vidService, AaiService, MsoService, OwningEntityService, $q) {
$scope.showVnfDetails = function (vnf) {
console.log("showVnfDetails");
@@ -121,253 +121,215 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", DataService.setSubscribers($scope.custSubList);
- if (selectedServicetype !== "" && selectedServicetype !== 'undefined') {
- $location.path(COMPONENT.CREATE_INSTANCE_PATH);
- }
- };
-
- $scope.serviceTypeName="";
- $scope.getAaiServiceModelsList = function(){
- var globalCustomerId="";
- var serviceTypeId = DataService.getGlobalCustomerId();
- $scope.serviceTypeList = DataService.getServiceIdList();
- $scope.createSubscriberName = DataService.getSubscriberName();
- $scope.status = FIELD.STATUS.FETCHING_SERVICE_CATALOG;
- $scope.custSubList = DataService.getSubscribers();
- for(var i=0; i<$scope.serviceTypeList.length;i++){
- if(parseInt(serviceTypeId) === i ){
- $scope.serviceTypeName = $scope.serviceTypeList[i].name;
+ if (selectedServicetype !== "" && selectedServicetype !== 'undefined'&& selectedServicetype !== undefined) {
+ $location.path(COMPONENT.CREATE_INSTANCE_PATH);
+ }
+ };
+
+ $scope.serviceTypeName = "";
+ $scope.getAaiServiceModelsList = function () {
+ var globalCustomerId = "";
+ var serviceTypeId = DataService.getGlobalCustomerId();
+ $scope.serviceTypeList = DataService.getServiceIdList();
+ $scope.createSubscriberName = DataService.getSubscriberName();
+ $scope.status = FIELD.STATUS.FETCHING_SERVICE_CATALOG;
+ $scope.custSubList = DataService.getSubscribers();
+ for (var i = 0; i < $scope.serviceTypeList.length; i++) {
+ if (parseInt(serviceTypeId) === i) {
+ $scope.serviceTypeName = $scope.serviceTypeList[i].name;
+ }
+ }
+ ;
+ for (var i = 0; i < $scope.custSubList.length; i++) {
+ if ($scope.createSubscriberName === $scope.custSubList[i].subscriberName) {
+ globalCustomerId = $scope.custSubList[i].globalCustomerId;
+ globalCustId = globalCustomerId;
+ }
+ }
+ ;
+ var pathQuery = "";
+
+ if (null !== globalCustomerId && "" !== globalCustomerId && undefined !== globalCustomerId
+ && null !== serviceTypeId && "" !== serviceTypeId && undefined !== serviceTypeId) {
+ pathQuery = COMPONENT.SERVICES_PATH + globalCustomerId + "/" + $scope.serviceTypeName;
+ }
+
+ var namedQueryId = '6e806bc2-8f9b-4534-bb68-be91267ff6c8';
+ AaiService.getServiceModelsByServiceType(namedQueryId, globalCustomerId, $scope.serviceTypeName, function (response) { // success
+ $scope.services = [];
+ if (angular.isArray(response.data['inventory-response-item']) && response.data['inventory-response-item'].length > 0 && response.data['inventory-response-item'][0]['inventory-response-items']) {
+ wholeData = response.data['inventory-response-item'][0]['inventory-response-items']['inventory-response-item'];
+ $scope.services = $scope.filterDataWithHigerVersion(response.data['inventory-response-item'][0]['inventory-response-items']['inventory-response-item']);
+ $scope.serviceType = response.data['inventory-response-item'][0]['service-subscription']['service-type'];
+ $scope.viewPerPage = 10;
+ $scope.totalPage = $scope.services.length / $scope.viewPerPage;
+ $scope.sortBy = "name";
+ $scope.scrollViewPerPage = 2;
+ $scope.currentPage = 1;
+ $scope.searchCategory;
+ $scope.searchString = "";
+ $scope.currentPageNum = 1;
+ $scope.isSpinnerVisible = false;
+ $scope.isProgressVisible = false;
+ } else {
+ $scope.status = "Failed to get service models from ASDC.";
+ $scope.error = true;
+ $scope.isSpinnerVisible = false;
}
- }
- ;
- for(var i=0; i<$scope.custSubList.length;i++){
- if($scope.createSubscriberName === $scope.custSubList[i].subscriberName){
- globalCustomerId = $scope.custSubList[i].globalCustomerId;
- globalCustId = globalCustomerId;
- }
- }
- ;
- var pathQuery ="";
-
- if(null !== globalCustomerId && "" !== globalCustomerId && undefined !== globalCustomerId
- && null !== serviceTypeId && "" !== serviceTypeId && undefined !== serviceTypeId){
- pathQuery = COMPONENT.SERVICES_PATH +globalCustomerId+"/"+$scope.serviceTypeName;
- }
-
- var namedQueryId='6e806bc2-8f9b-4534-bb68-be91267ff6c8';
- AaiService.getServiceModelsByServiceType(namedQueryId,globalCustomerId,$scope.serviceTypeName,function(response) { // success
- $scope.services = [];
- if (angular.isArray(response.data['inventory-response-item']) && response.data['inventory-response-item'].length > 0 && response.data['inventory-response-item'][0]['inventory-response-items']) {
- wholeData = response.data['inventory-response-item'][0]['inventory-response-items']['inventory-response-item'];
- $scope.services = $scope.filterDataWithHigerVersion(response.data['inventory-response-item'][0]['inventory-response-items']['inventory-response-item']);
- $scope.serviceType = response.data['inventory-response-item'][0]['service-subscription']['service-type'];
- $scope.viewPerPage=10;
- $scope.totalPage=$scope.services.length/$scope.viewPerPage;
- $scope.sortBy="name";
- $scope.scrollViewPerPage=2;
- $scope.currentPage=1;
- $scope.searchCategory;
- $scope.searchString="";
- $scope.currentPageNum=1;
- $scope.isSpinnerVisible = false;
- $scope.isProgressVisible = false;
- } else {
- $scope.status = "Failed to get service models from A&AI.";
- $scope.error = true;
- $scope.isSpinnerVisible = false;
- }
- DataService.setServiceIdList(response);
- }, function(response) { // failure
- $scope.showError(FIELD.ERROR.AAI);
- $scope.errorMsg = FIELD.ERROR.FETCHING_SERVICES+ response.status;
- $scope.errorDetails = response.data;
- });
-
- };
-
- var globalCustId;// This value will be assigned only on create new service instance screen-macro
- $scope.createType = "a la carte";
- $scope.deployService = function(service,hideServiceFields) {
- hideServiceFields = hideServiceFields|| false;
- var temp = service;
- service.uuid = service['service-instance']['model-version-id'];
-
- console.log("Instantiating ASDC service " + service.uuid);
-
- $http.get('rest/models/services/' + service.uuid)
- .then(function successCallback(getServiceResponse) {
- getServiceResponse.data['service'].serviceTypeName =$scope.serviceTypeName ;
- getServiceResponse.data['service'].createSubscriberName =$scope.createSubscriberName ;
- var serviceModel = getServiceResponse.data;
- DataService.setServiceName(serviceModel.service.name);
-
- DataService.setModelInfo(COMPONENT.SERVICE, {
- "modelInvariantId": serviceModel.service.invariantUuid,
- "modelVersion": serviceModel.service.version,
- "modelNameVersionId": serviceModel.service.uuid,
- "modelName": serviceModel.service.name,
- "description": serviceModel.service.description,"serviceType": serviceModel.service.serviceType,
+ DataService.setServiceIdList(response);
+ }, function (response) { // failure
+ $scope.showError(FIELD.ERROR.AAI);
+ $scope.errorMsg = FIELD.ERROR.FETCHING_SERVICES + response.status;
+ $scope.errorDetails = response.data;
+ });
+
+ };
+
+ var globalCustId;// This value will be assigned only on create new service instance screen-macro
+ $scope.createType = "a la carte";
+ $scope.deployService = function (service, hideServiceFields) {
+ hideServiceFields = hideServiceFields || false;
+ var temp = service;
+ service.uuid = service['service-instance']['model-version-id'];
+
+ console.log("Instantiating ASDC service " + service.uuid);
+
+ $http.get('rest/models/services/' + service.uuid)
+ .then(function successCallback(getServiceResponse) {
+ getServiceResponse.data['service'].serviceTypeName = $scope.serviceTypeName;
+ getServiceResponse.data['service'].createSubscriberName = $scope.createSubscriberName;
+ var serviceModel = getServiceResponse.data;
+ DataService.setServiceName(serviceModel.service.name);
+
+ DataService.setModelInfo(COMPONENT.SERVICE, {
+ "modelInvariantId": serviceModel.service.invariantUuid,
+ "modelVersion": serviceModel.service.version,
+ "modelNameVersionId": serviceModel.service.uuid,
+ "modelName": serviceModel.service.name,
+ "description": serviceModel.service.description,
+ "serviceType": serviceModel.service.serviceType,
"serviceRole": serviceModel.service.serviceRole,
- "category":serviceModel.service.category,
- "serviceTypeName":serviceModel.service.serviceTypeName,
- "createSubscriberName":serviceModel.service.createSubscriberName
- });
- DataService.setHideServiceFields(hideServiceFields);
- if(hideServiceFields){
- DataService.setServiceType($scope.serviceTypeName);
- DataService.setGlobalCustomerId(globalCustId);
- }
-
- DataService.setALaCarte (true);
- $scope.createType = "a la carte";
- var broadcastType = "createComponent";
-
- if (UtilityService.arrayContains (VIDCONFIGURATION.MACRO_SERVICES, serviceModel.service.invariantUuid )) {
- DataService.setALaCarte (false);
- $scope.createType = "Macro";
- var convertedAsdcModel = UtilityService.convertModel(serviceModel);
-
- //console.log ("display inputs ");
- //console.log (JSON.stringify ( convertedAsdcModel.completeDisplayInputs));
-
- DataService.setModelInfo(COMPONENT.SERVICE, {
- "modelInvariantId": serviceModel.service.invariantUuid,
- "modelVersion": serviceModel.service.version,
- "modelNameVersionId": serviceModel.service.uuid,
- "modelName": serviceModel.service.name,
- "description": serviceModel.service.description,
- "category":serviceModel.service.category,
- "serviceEcompNaming": serviceModel.service.serviceEcompNaming,
- "inputs": serviceModel.service.inputs,
- "displayInputs": convertedAsdcModel.completeDisplayInputs,
- "serviceTypeName":serviceModel.service.serviceTypeName,
- "createSubscriberName":serviceModel.service.createSubscriberName,
- "serviceType": serviceModel.service.serviceType,
+ "category": serviceModel.service.category,
+ "serviceTypeName": serviceModel.service.serviceTypeName,
+ "createSubscriberName": serviceModel.service.createSubscriberName
+ });
+ DataService.setHideServiceFields(hideServiceFields);
+ if (hideServiceFields) {
+ DataService.setServiceType($scope.serviceTypeName);
+ DataService.setGlobalCustomerId(globalCustId);
+ }
+
+ DataService.setALaCarte(true);
+ $scope.createType = "a la carte";
+ var broadcastType = "createComponent";
+
+ if (UtilityService.arrayContains(VIDCONFIGURATION.MACRO_SERVICES, serviceModel.service.invariantUuid)) {
+ DataService.setALaCarte(false);
+ $scope.createType = "Macro";
+ var convertedAsdcModel = UtilityService.convertModel(serviceModel);
+
+ //console.log ("display inputs ");
+ //console.log (JSON.stringify ( convertedAsdcModel.completeDisplayInputs));
+
+ DataService.setModelInfo(COMPONENT.SERVICE, {
+ "modelInvariantId": serviceModel.service.invariantUuid,
+ "modelVersion": serviceModel.service.version,
+ "modelNameVersionId": serviceModel.service.uuid,
+ "modelName": serviceModel.service.name,
+ "description": serviceModel.service.description,
+ "category": serviceModel.service.category,
+ "serviceEcompNaming": serviceModel.service.serviceEcompNaming,
+ "inputs": serviceModel.service.inputs,
+ "displayInputs": convertedAsdcModel.completeDisplayInputs,
+ "serviceTypeName": serviceModel.service.serviceTypeName,
+ "createSubscriberName": serviceModel.service.createSubscriberName,
+ "serviceType": serviceModel.service.serviceType,
"serviceRole": serviceModel.service.serviceRole
- });}
- ;
-
- $scope.$broadcast(broadcastType, {
- componentId : COMPONENT.SERVICE,
- callbackFunction : function(response) {
- if (response.isSuccessful) {
- vidService.setModel(serviceModel);
-
- var subscriberId = "Not Found";
- var serviceType = "Not Found";
-
- var serviceInstanceId = response.instanceId;
-
- for (var i = 0; i < response.control.length; i++) {
- if (response.control[i].id == "subscriberName") {
- subscriberId = response.control[i].value;
- } else if (response.control[i].id == "serviceType") {
- serviceType = response.control[i].value;
- }
- }
-
-
- $scope.refreshSubs(subscriberId,serviceType,serviceInstanceId);
-
- }
- }
- });
-
- }, function errorCallback(response) {
- console.log("Error: " + response);
- });
- };
- $scope.isFiltered=function(arr,obj){
- var filtered = false;
- if(arr.length>0){
- for(var i=0;i<arr.length;i++){
- if(obj['extra-properties']['extra-property'] && (obj['extra-properties']['extra-property'][2]['property-value'] == arr[i]['extra-properties']['extra-property'][2]['property-value'])
- && (obj['extra-properties']['extra-property'][4]['property-value'] == arr[i]['extra-properties']['extra-property'][4]['property-value'])){
- filtered = true;
- }
- }
- }
- return filtered;
- }
- var wholeData=[];
- $scope.filterDataWithHigerVersion = function(serviceData){
- var fiterDataServices = [];
- for(var i=0;i<serviceData.length;i++){
- var higherVersion = serviceData[i];
- if(!$scope.isFiltered(fiterDataServices,serviceData[i])){
- for(var j=i;j<serviceData.length;j++){
- if(serviceData[i]['extra-properties']['extra-property'] && serviceData[j]['extra-properties']['extra-property'] && (serviceData[i]['extra-properties']['extra-property'][4]['property-value'] == serviceData[j]['extra-properties']['extra-property'][4]['property-value'])
- && (serviceData[i]['extra-properties']['extra-property'][2]['property-value'] == serviceData[j]['extra-properties']['extra-property'][2]['property-value'])
- && (parseFloat(serviceData[j]['extra-properties']['extra-property'][6]['property-value'])>=parseFloat(serviceData[i]['extra-properties']['extra-property'][6]['property-value']))){
- var data = $scope.isThisHigher(fiterDataServices,serviceData[j]);
- if(data.isHigher){
- fiterDataServices[data.index] = serviceData[j];
- }
- }
- }
- }
- }
- return fiterDataServices;
- }
-
- $scope.isThisHigher = function(arr,obj){
- var returnObj = {
- isHigher:false,
- index:0
- };
- if(arr.length>0){
- var isNotMatched = true;
- for(var i=0;i<arr.length;i++){
- if(arr[i]['extra-properties']['extra-property'] && (arr[i]['extra-properties']['extra-property'][2]['property-value'] == obj['extra-properties']['extra-property'][2]['property-value'])
- && (arr[i]['extra-properties']['extra-property'][4]['property-value'] == obj['extra-properties']['extra-property'][4]['property-value'] )
- && (arr[i]['extra-properties']['extra-property'][6]['property-value'] < obj['extra-properties']['extra-property'][6]['property-value']) ){
- isNotMatched = false;
- returnObj = {
- isHigher:true,
- index:i
- };
- }
- }
- if(isNotMatched && !$scope.isFiltered(arr,obj)){
- returnObj = {
- isHigher:true,
- index:arr.length
- };
- }
- }else{
- returnObj = {
- isHigher:true,
- index:0
- }
- }
- return returnObj;
- }
-
- $scope.tableData=[];
- var oldData=[];
- $scope.loadPreviousVersionData=function(version,invariantUUID){
- $scope.tableData =[];
- oldData=[];
- for(var i=0;i<wholeData.length;i++){
- if(wholeData[i]['extra-properties']['extra-property'] && wholeData[i]['extra-properties']['extra-property'][4]['property-value'] == invariantUUID && version!=wholeData[i]['extra-properties']['extra-property'][6]['property-value']){
- oldData.push(wholeData[i]);
- }
- }
- $scope.tableData = oldData;
- $scope.createType = "Previous Version";
- var broadcastType = "createTableComponent";
- $scope.componentName = invariantUUID;
- $scope.$broadcast(broadcastType, {
- componentId : COMPONENT.OLDVERSION,
- callbackFunction : function(response) {
- }
- });
- }
- $scope.cancelCreateSIType = function(){
-
- window.location.href = COMPONENT.SERVICE_MODLES_INSTANCES_SUBSCRIBERS_PATH;
-
- }
+ });
+ }
+ ;
+
+ $scope.$broadcast(broadcastType, {
+ componentId: COMPONENT.SERVICE,
+ callbackFunction: function (response) {
+ if (response.isSuccessful) {
+ vidService.setModel(serviceModel);
+
+ var subscriberId = "Not Found";
+ var serviceType = "Not Found";
+
+ var serviceInstanceId = response.instanceId;
+
+ for (var i = 0; i < response.control.length; i++) {
+ if (response.control[i].id == "subscriberName") {
+ subscriberId = response.control[i].value;
+ } else if (response.control[i].id == "serviceType") {
+ serviceType = response.control[i].value;
+ }
+ }
+
+
+ $scope.refreshSubs(subscriberId, serviceType, serviceInstanceId);
+
+ }
+ }
+ });
+
+ }, function errorCallback(response) {
+ $log.error("Error: ", response);
+ });
+ };
+
+ var wholeData=[];
+ //extract all models from service instances properties and filter by the higher model version
+ $scope.filterDataWithHigerVersion = function(serviceData){
+
+ //get all service instances & models collected into array. key = model invariant id
+ var servicesByModelInvariant = _.reduce(serviceData, function(result, item) {
+ if (item['extra-properties']['extra-property']) {
+ var invariantId = item['extra-properties']['extra-property'][4];
+ if (invariantId) {
+ (result[invariantId["property-value"]] || (result[invariantId["property-value"]] = [])).push(item);
+ }
+ }
+ return result;
+ }, {});
+
+ //iterate over the array and get the highest model version for each group of services
+ var filterDataServicesByVersion = [];
+ _.forEach(servicesByModelInvariant, function(items) {
+ var maxVersionItem = _.maxBy(items, function(item) { return parseFloat(item['extra-properties']['extra-property'][6]["property-value"]); });
+ filterDataServicesByVersion.push(maxVersionItem);
+ });
+
+ return filterDataServicesByVersion;
+ };
+
+ $scope.tableData = [];
+ var oldData = [];
+ $scope.loadPreviousVersionData = function (version, invariantUUID) {
+ $scope.tableData = [];
+ oldData = [];
+ for (var i = 0; i < wholeData.length; i++) {
+ if (wholeData[i]['extra-properties']['extra-property'] && wholeData[i]['extra-properties']['extra-property'][4]['property-value'] == invariantUUID && version != wholeData[i]['extra-properties']['extra-property'][6]['property-value']) {
+ oldData.push(wholeData[i]);
+ }
+ }
+ $scope.tableData = oldData;
+ $scope.createType = "Previous Version";
+ var broadcastType = "createTableComponent";
+ $scope.componentName = invariantUUID;
+ $scope.$broadcast(broadcastType, {
+ componentId: COMPONENT.OLDVERSION,
+ callbackFunction: function (response) {
+ }
+ });
+ }
+ $scope.cancelCreateSIType = function () {
+
+ window.location.href = COMPONENT.SERVICE_MODLES_INSTANCES_SUBSCRIBERS_PATH;
+
+ }
$scope.fetchServices = function () {
var serviceIdList = [];
@@ -379,7 +341,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", $scope.errorMsg = FIELD.ERROR.FETCHING_SERVICES + response.status;
$scope.errorDetails = response.data;
});
- }
+ };
$scope.refreshSubs = function () {
$scope.init();
@@ -387,10 +349,20 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", $scope.fetchServices();
};
+ $scope.loadOwningEntity = function () {
+ OwningEntityService.getOwningEntityProperties(function (response) {
+ $scope.owningEntities = response.owningEntity;
+ $scope.projects = response.project;
+
+ // working project name: owning-entity-id-val-cp8128
+ // working owning entity name: owning-entity-id-val-cp8128
+ });
+ };
+
$scope.fetchSubs = function (status) {
$scope.status = status;
- AaiService.getSubList(function (response) { // sucesss
+ AaiService.getSubList(function (response) {
$scope.setProgress(100); // done
$scope.status = FIELD.STATUS.DONE;
$scope.isSpinnerVisible = false;
@@ -408,16 +380,23 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", }
- $scope.getSubDetails = function (request) {
+ $scope.getSubDetails = function () {
$scope.init();
- $scope.selectedSubscriber = $location.search().selectedSubscriber;
- $scope.selectedServiceInstance = $location.search().selectedServiceInstance;
+ //$scope.selectedSubscriber = $location.search().selectedSubscriber;
+ // $scope.selectedServiceInstance = $location.search().selectedServiceInstance;
$scope.status = FIELD.STATUS.FETCHING_SUB_DETAILS + $scope.selectedSubscriber;
+ var query = $location.url().replace($location.path(),'');
$scope.displayData = [];
- AaiService.getSubDetails($scope.selectedSubscriber, $scope.selectedServiceInstance, function (displayData, subscriberName) {
- $scope.displayData = displayData;
+ AaiService.searchServiceInstances(query).then(function (response) {
+ $scope.displayData = response.displayData;
+ if (response.displayData.length)
+ {
+ var first = response.displayData[0];
+ $scope.selectedSubscriberId = first.globalCustomerId;
+ $scope.selectedSubscriberName = first.subscriberName;
+ }
$scope.viewPerPage = 10;
$scope.totalPage = $scope.displayData.length / $scope.viewPerPage;
$scope.scrollViewPerPage = 2;
@@ -429,13 +408,13 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", $scope.setProgress(100); // done
$scope.status = FIELD.STATUS.DONE;
$scope.isSpinnerVisible = false;
- $scope.subscriberName = subscriberName;
- }, function (response) {
+
+ }).catch(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) {
@@ -452,7 +431,6 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", });
$scope.init = function () {
-
//PropertyService.setAaiBaseUrl("testaai");
//PropertyService.setAsdcBaseUrl("testasdc");
@@ -529,37 +507,67 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", alert(response.statusText);
}
- $scope.getAsdcModel = function (disData) {
+ function getModelVersionIdForServiceInstance(instance) {
+ if (UtilityService.hasContents(instance.aaiModelVersionId)) {
+ return $q.resolve(instance.aaiModelVersionId);
+ } else {
+ return AaiService.getModelVersionId(instance.globalCustomerId, instance.serviceInstanceId);
+ }
+ }
- console.log("disData");
- console.log(JSON.stringify(disData, null, 4));
+ $scope.onViewEditClick = function (disData) {
+ $log.debug("disData", disData, null, 4);
- // if ( !(UtilityService.hasContents (disData.aaiModelVersionId)) ) {
- // $scope.errorMsg = FIELD.ERROR.MODEL_VERSION_ID_MISSING;
- // alert($scope.errorMsg);
- // return;
- // }
+ getModelVersionIdForServiceInstance(disData)
+ .then(getAsdcModelByVersionId, handleErrorGettingModelVersion)
+ .then(navigateToViewEditPage);
- // 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);
+
+ function navigateToViewEditPage() {
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 +
COMPONENT.IS_PERMITTED_SUB_PATH + disData.isPermitted;
+ }
+ };
+
+ function handleErrorGettingModelVersion(err) {
+ $log.error("aaiSubscriber getModelVersionIdForServiceInstance - " + err);
+ $scope.errorMsg = err;
+ alert($scope.errorMsg);
+ return $q.reject();
+ }
+
+ function getAsdcModelByVersionId(aaiModelVersionId) {
+ // aaiModelVersionId is the model uuid
+ var pathQuery = COMPONENT.SERVICES_PATH + aaiModelVersionId;
+ return $http({
+ method: 'GET',
+ url: pathQuery
+ }).then(function successCallback(response) {
+ vidService.setModel(response.data);
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;
+ $log.error("aaiSubscriber getAsdcModel - " + FIELD.ERROR.NO_MATCHING_MODEL_AAI + aaiModelVersionId);
+ $scope.errorMsg = FIELD.ERROR.NO_MATCHING_MODEL_AAI + aaiModelVersionId;
alert($scope.errorMsg);
});
+ }
+ function returnMatchingServiceSubscription(serviceSubs, serviceId){
+ var orchStatus;
+ serviceSubs.forEach(function(item){
+ if (item[FIELD.ID.SERVICE_INSTANCES] != null) {
+ item[FIELD.ID.SERVICE_INSTANCES][FIELD.ID.SERVICE_INSTANCE].forEach(function (service) {
+ if (service[FIELD.ID.SERVICE_INSTANCE_ID] === serviceId) {
+ orchStatus = service['orchestration-status']
+ }
+ })
+ }
+ });
+ return orchStatus;
}
$scope.getTenants = function (globalCustomerId) {
@@ -572,10 +580,26 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", });
}
+ $scope.isActivateDeactivateEnabled = function(btnType) {
+ if ($scope.serviceOrchestrationStatus && $scope.service.model.service.serviceType.toLowerCase().indexOf('transport') != -1) {
+ switch (btnType) {
+ case "activate":
+ return $scope.serviceOrchestrationStatus === 'Created' ||
+ $scope.serviceOrchestrationStatus.toLowerCase() === 'pendingdelete' || $scope.serviceOrchestrationStatus.toLowerCase() === 'pending-delete';
+ break;
+ case "deactivate":
+ return $scope.serviceOrchestrationStatus === 'Active';
+ break;
+ }
+ }
+
+ return false;
+ };
+
$scope.handleInitialResponseInventoryItems = function (response) {
$scope.inventoryResponseItemList = response.data[FIELD.ID.INVENTORY_RESPONSE_ITEM]; // get data from json
- console.log($scope.inventoryResponseItemList.toString());
+ $log.debug($scope.inventoryResponseItemList);
$scope.displayData = [];
$scope.vnfs = [];
@@ -585,8 +609,9 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", $scope.subscriberName = "";
// just look up the subscriber name in A&AI here...
AaiService.getSubscriberName($scope.globalCustomerId, function (response) {
- $scope.subscriberName = response;
+ $scope.subscriberName = response.subscriberName;
DataService.setSubscriberName($scope.subscriberName);
+ $scope.serviceOrchestrationStatus = returnMatchingServiceSubscription(response.serviceSubscriptions[FIELD.ID.SERVICE_SUBSCRIPTION], $scope.serviceInstanceId);
angular.forEach($scope.inventoryResponseItemList, function (inventoryResponseItem, key) {
@@ -609,12 +634,13 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", "type": PARAMETER.STRING,
"description": FIELD.PROMPT.VAR_DESCRIPTION_B,
"default": FIELD.PROMPT.DEFAULT_B
- },
+ }
},
"object": $scope.inventoryResponseItem[FIELD.ID.SERVICE_INSTANCE],
"vnfs": [],
- "networks": []
- }
+ "networks": [],
+ "configurations": []
+ };
if (inventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) {
@@ -760,6 +786,44 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", });
}
}
+
+ if (subInventoryResponseItem[FIELD.ID.GENERIC_CONFIGURATION] != null) {
+ var configObject = subInventoryResponseItem[FIELD.ID.GENERIC_CONFIGURATION];
+ var config = {
+ "id": $scope.counter++,
+ "name": configObject[FIELD.ID.CONFIGURATION_NAME],
+ "itemType": FIELD.ID.CONFIGURATION,
+ "nodeId": configObject[FIELD.ID.CONFIGURATION_ID],
+ "nodeType": configObject[FIELD.ID.CONFIGURATION_TYPE],
+ "nodeStatus": configObject[FIELD.ID.ORCHESTRATION_STATUS],
+ "modelInvariantId": configObject[FIELD.ID.MODEL_INVAR_ID],
+ "modelVersionId": configObject[FIELD.ID.MODEL_VERSION_ID],
+ "modelCustomizationId": configObject[FIELD.ID.MODEL_CUSTOMIZATION_ID],
+ "object": configObject,
+ "ports": []
+ };
+
+ $scope.allowConfigurationActions = [FIELD.STATUS.AAI_ACTIVE, FIELD.STATUS.AAI_INACTIVE, FIELD.STATUS.AAI_CREATED].indexOf(config.nodeStatus) != -1;
+
+ if (subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) {
+ angular.forEach(subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM], function (subSubInventoryResponseItem, key) {
+ var port = {};
+ var portObject;
+ if (subSubInventoryResponseItem[FIELD.ID.PORT] != null) {
+ portObject = subSubInventoryResponseItem[FIELD.ID.PORT];
+ port = {
+ "portId": portObject[FIELD.ID.PORT_ID],
+ "portName": portObject[FIELD.ID.PORT_NAME],
+ "portStatus": portObject[FIELD.ID.PORT_MIRRORED] === true ? FIELD.STATUS.AAI_ENABLED : FIELD.ID.AAI_DISABLED,
+ "object": portObject
+ };
+ config.ports.push(port);
+ }
+ });
+ }
+ $scope.service.instance[FIELD.ID.CONFIGURATIONS].push(config);
+ }
+
});
}
});
@@ -901,63 +965,239 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", $scope.currentPage--;
}
- $scope.activateMSOInstance = function() {
- MsoService.activateInstance($scope.service.instance, $scope.service.model)
- .then(function(response) {
- alert("Activation succeeded");
- })
- .catch(function (error) {
- $log.error(error);
+ var getAicZoneAndSendToMso = function (msoType, requestParams) {
+ AaiService.getAicZoneForPNF(
+ $scope.service.instance.globalCustomerId,
+ $scope.service.instance.serviceType,
+ $scope.service.instance.serviceInstanceId, function (aicZone) {
+
+ requestParams.aicZone = aicZone;
+
+ openMsoModal(msoType, requestParams);
});
- ;
+ };
+
+ var activateDeactivateServiceInstance = function(msoType) {
+ var requestParams = {
+ model: $scope.service.model,
+ instance: $scope.service.instance
+ };
+
+ if (DataService.getLoggedInUserId()) {
+ requestParams.userId = DataService.getLoggedInUserId();
+ getAicZoneAndSendToMso(msoType, requestParams)
+ } else {
+ AaiService.getLoggedInUserID(function (response) {
+ var userID = response.data;
+ DataService.setLoggedInUserId(userID);
+ requestParams.userId = userID;
+
+ getAicZoneAndSendToMso(msoType, requestParams);
+ });
+ }
+ };
+
+ $scope.activateMSOInstance = function() {
+
+ activateDeactivateServiceInstance(COMPONENT.MSO_ACTIVATE_SERVICE_REQ);
+ };
+
+ $scope.deactivateMSOInstance = function() {
+
+ activateDeactivateServiceInstance(COMPONENT.MSO_DEACTIVATE_SERVICE_REQ);
+ };
+
+ $scope.toggleConfigurationStatus = function (serviceObject, configuration) {
+
+
+ AaiService.getLoggedInUserID(function (response) {
+ DataService.setLoggedInUserId(response.data);
+ var requestParams = {
+ serviceModel: {
+ "modelType": "service",
+ "modelInvariantId": serviceObject.model.service.invariantUuid,
+ "modelVersionId": "uuid",
+ "modelName": serviceObject.model.service.name,
+ "modelVersion": serviceObject.model.service.version
+ },
+ configurationModel: {
+ "modelType": "configuration",
+ "modelInvariantId": configuration.modelInvariantId,
+ "modelVersionId": configuration.modelVersionId,
+ "modelCustomizationId": configuration.modelCustomizationId
+ },
+ serviceInstanceId: serviceObject.instance.serviceInstanceId,
+ configurationId: configuration.nodeId,
+ configStatus: configuration.nodeStatus,
+ userId: DataService.getLoggedInUserId()
+ };
+
+ openMsoModal(COMPONENT.MSO_CHANGE_CONFIG_STATUS_REQ, requestParams);
+ });
+
+ };
+
+ $scope.togglePortStatus = function(serviceObject, configuration, port) {
+
+ var requestParams = {
+ serviceInstanceId: serviceObject.instance.serviceInstanceId,
+ configurationId: configuration.nodeId,
+ portId: port.portId,
+ portStatus: port.portStatus,
+ serviceModel: {
+ "modelType": "service",
+ "modelInvariantId": serviceObject.model.service.invariantUuid,
+ "modelVersionId": "uuid",
+ "modelName": serviceObject.model.service.name,
+ "modelVersion": serviceObject.model.service.version
+ },
+ configurationModel: {
+ "modelType": "configuration",
+ "modelInvariantId": configuration.modelInvariantId,
+ "modelVersionId": configuration.modelVersionId,
+ "modelCustomizationId": configuration.modelCustomizationId
+ },
+ userId: DataService.getLoggedInUserId()
+ };
+
+ openMsoModal(COMPONENT.MSO_CHANGE_PORT_STATUS_REQ, requestParams);
+ };
+
+ $scope.dissociatePnf = function(pnfName) {
+
+ var jobInfo = {
+ status: "confirm",
+ message: "Are you sure you would like to dissociate " + pnfName + " from the service instance?"
+ };
+
+ var modalInstance = $uibModal.open({
+ templateUrl: 'app/vid/scripts/modals/alert-modal/alert-modal.html',
+ controller: 'alertModalController',
+ controllerAs: 'vm',
+ appendTo: angular.element("#pnfs-tree"),
+ resolve: {
+ jobInfo: function () {
+ return jobInfo;
+ }
+ }
+ });
+
+ modalInstance.result.then(function (result) {
+ console.log("This is the result of the alert modal.", result);
+
+ if (result) {
+ var requestParams = {
+ pnf: pnfName,
+ serviceModelInfo: {
+ invariantUuid: $scope.service.model.service.invariantUuid,
+ uuid: $scope.service.model.service.uuid,
+ version: $scope.service.model.service.version,
+ name: $scope.service.model.service.name
+ },
+ serviceInstanceId: $scope.service.instance.serviceInstanceId
+ };
+
+ if (DataService.getLoggedInUserId()) {
+ requestParams.attuuid = DataService.getLoggedInUserId();
+ openMsoModal(COMPONENT.MSO_REMOVE_RELATIONSHIP, requestParams);
+ } else {
+ AaiService.getLoggedInUserID(function (response) {
+ DataService.setLoggedInUserId(response.data);
+
+ requestParams.attuuid = response.data;
+ openMsoModal(COMPONENT.MSO_REMOVE_RELATIONSHIP, requestParams);
+ });
+ }
+ }
+ });
+
+
+ };
+
+ var openMsoModal = function (msoType, requestParams) {
+ var modalInstance = $uibModal.open({
+ templateUrl: 'app/vid/scripts/modals/mso-commit/mso-commit.html',
+ controller : "msoCommitModalController",
+ backdrop: false,
+ resolve: {
+ msoType: function () {
+ return msoType;
+ },
+ requestParams: function() {
+ requestParams.callbackFunction = updateViewCallbackFunction;
+ return requestParams;
+ }
+ }
+ });
+ };
+
+ var updateViewCallbackFunction = function(response) {
+ $scope.callbackResults = "";
+ var color = FIELD.ID.COLOR_NONE;
+ $scope.callbackStyle = {
+ "background-color" : color
+ };
+
+ /*
+ * This 1/2 delay was only added to visually highlight the status
+ * change. Probably not needed in the real application code.
+ */
+ $timeout(function() {
+ $scope.callbackResults = UtilityService.getCurrentTime()
+ + FIELD.STATUS.IS_SUCCESSFUL + response.isSuccessful;
+ if (response.isSuccessful) {
+ color = FIELD.ID.COLOR_8F8;
+ $scope.reloadRoute();
+ } else {
+ color = FIELD.ID.COLOR_F88;
+ }
+ $scope.callbackStyle = {
+ "background-color" : color
+ };
+ }, 500);
};
$scope.nextPage = function () {
$scope.currentPage++;
+ };
+
+ $scope.serviceInstanceses = [{"sinstance": FIELD.NAME.SERVICE_INSTANCE_Id}, {"sinstance": FIELD.NAME.SERVICE_INSTANCE_NAME}];
+
+ function navigateToSearchResultsPage(globalCustomerId, selectedServiceInstance, selectedProjects, selectedOwningEntities) {
+ var projectQuery = AaiService.getMultipleValueParamQueryString(_.map(selectedProjects, 'id'), COMPONENT.PROJECT_SUB_PATH);
+ var owningEntityQuery = AaiService.getMultipleValueParamQueryString(_.map(selectedOwningEntities, 'id'), COMPONENT.OWNING_ENTITY_SUB_PATH);
+ var globalCustomerIdQuery = globalCustomerId ? COMPONENT.SELECTED_SUBSCRIBER_SUB_PATH + globalCustomerId : null;
+ var serviceInstanceQuery = selectedServiceInstance ? COMPONENT.SELECTED_SERVICE_INSTANCE_SUB_PATH + selectedServiceInstance : null;
+ var query = AaiService.getJoinedQueryString([projectQuery, owningEntityQuery, globalCustomerIdQuery, serviceInstanceQuery]);
+
+ window.location.href = COMPONENT.SELECTED_SERVICE_SUB_PATH + query;
}
- $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;
- }
+ $scope.getServiceInstancesSearchResults =
+ function (selectedCustomer, selectedInstanceIdentifierType, selectedServiceInstance, selectedProject, selectedOwningEntity) {
+ var isSelectionValid = UtilityService.hasContents(selectedCustomer) || UtilityService.hasContents(selectedProject)
+ || UtilityService.hasContents(selectedOwningEntity) || UtilityService.hasContents(selectedServiceInstance);
+
+ if (isSelectionValid) {
+ if (UtilityService.hasContents(selectedServiceInstance)) {
+ AaiService
+ .getGlobalCustomerIdByInstanceIdentifier(selectedServiceInstance, selectedInstanceIdentifierType)
+ .then(handleCustomerIdResponse);
+ } else {
+ navigateToSearchResultsPage(selectedCustomer, null, selectedProject, selectedOwningEntity);
}
- if (notFound) {
+ } else {
+ alert(FIELD.ERROR.SELECT);
+ }
+
+ function handleCustomerIdResponse(globalCustomerId) {
+ if (UtilityService.hasContents(globalCustomerId)) {
+ navigateToSearchResultsPage(globalCustomerId, selectedServiceInstance, selectedProject, selectedOwningEntity);
+ } else {
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 {
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/change-management.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/change-management.controller.js index 662b10ec..273f1301 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/change-management.controller.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/change-management.controller.js @@ -1,12 +1,15 @@ (function () { 'use strict'; - appDS2.controller("changeManagementController", ["$uibModal", "changeManagementService", "_", "$log", changeManagementController]); + appDS2.controller("changeManagementController", ["$uibModal", "changeManagementService", "_", "$log", "SchedulerService", "$filter", changeManagementController]); - function changeManagementController($uibModal, changeManagementService, _, $log) { + function changeManagementController($uibModal, changeManagementService, _, $log, SchedulerService, $filter) { var vm = this; - var init = function() { + vm.lastTimeUpdated = ""; + + vm.init = function() { + vm.lastTimeUpdated = $filter('date')(new Date(), "MM/dd/yyyy | HH:mm:ss"); loadMSOChangeManagements(); loadSchedulerChangeManagements(); }; @@ -26,16 +29,16 @@ .then(function(response) { vm.pendingChangeManagements = response.data; _.forEach(vm.pendingChangeManagements, function(changeManagement) { - var callbackData = _.filter(changeManagement.scheduleRequest.domainData, {name: "CallbackData"}); + var callbackData = _.filter(changeManagement.scheduleRequest.domainData, {name: "WorkflowName"}); if(callbackData) { var parsedModel = {}; try { - parsedModel = JSON.parse(callbackData[0].value); + parsedModel = callbackData[0].value; } catch(exception) { $log.error(exception); } - changeManagement.workflow = parsedModel.requestType || 'No workflow'; + changeManagement.workflow = parsedModel; } }); }) @@ -57,10 +60,6 @@ }); }; - vm.openScheduler = function() { - console.log("function for opening the scheduler app") - }; - vm.searchChanges = function() { console.log("function for searching changes: " + vm.searchChangesTerm) }; @@ -74,7 +73,8 @@ jobInfo: function () { return jobInfo; } - } + }, + }); modalInstance.result.then(function (result) { @@ -115,12 +115,12 @@ console.log("This is the result of the alert change management modal.", result); }); }; - - vm.openPendingModal = function(jobInfo) { + vm.openBasicAlertModal = function(jobInfo) { var modalInstance = $uibModal.open({ - templateUrl: 'app/vid/scripts/modals/pending-change-management/pending-change-management.html', - controller: 'changeManagementManualTasksController', + templateUrl: 'app/vid/scripts/modals/alert-modal/alert-modal.html', + controller: 'alertModalController', controllerAs: 'vm', + appendTo: angular.element(".jobs-table").eq(0), resolve: { jobInfo: function () { return jobInfo; @@ -129,10 +129,51 @@ }); modalInstance.result.then(function (result) { - console.log("This is the result of the pending change management modal.", result); + console.log("This is the result of the alert change management modal.", result); }); }; + vm.openPendingModal = function($event, changeManagement) { + var modalInstance = $uibModal.open({ + templateUrl: 'app/vid/scripts/modals/cancel-pending-workflow/cancel-pending-workflow.html', + controller: 'cancelPendingWorkflowController', + controllerAs: 'vm', + backdrop: false, + animation: true, + appendTo: angular.element($event.currentTarget).parent(), + resolve: { + changeManagement: function () { + return changeManagement; + } + } + }); + + modalInstance.result.then(function (result) { + // send to service + if(result){ + SchedulerService.cancelScheduleRequest(changeManagement.scheduleRequest.scheduleId, + function(response) { + + //success popup + var jobInfo= { + status:"success", + message: "Cancel workflow "+changeManagement.scheduleRequest.scheduleName+" succeeded."}; + vm.openBasicAlertModal(jobInfo); + + return response; + }, function(error) { + + //failed popup + var jobInfo = { + status:"failed", + message: "Cancel workflow "+changeManagement.scheduleRequest.scheduleName+" failed due to an unexpected error."}; + vm.openBasicAlertModal(jobInfo); + + }); + }}); + + }; + - init(); + vm.init(); } })();
\ No newline at end of file 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/deleteResumeDialogController.js index 499a1ec0..9715484d 100755..100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/deletionDialogController.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/deleteResumeDialogController.js @@ -1,123 +1,148 @@ -/*-
- * ============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());
-
- if(DeletionService.isMacro === true){
- requestDetails.requestParameters.aLaCarte = false;
- }
-
- $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 ]);
+/*- + * ============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 deleteResumeDialogController = function( COMPONENT, FIELD, $scope, $http, $timeout, $log, + DeleteResumeService, CreationService, UtilityService) { + + $scope.isDialogVisible = false; + $scope.summaryControl = {}; + $scope.userProvidedControl = {}; + + var callbackFunction = undefined; + var componentId = undefined; + + $scope.$on(COMPONENT.DELETE_RESUME_COMPONENT, function(event, request) { + + $scope.isDataVisible = false; + $scope.isSpinnerVisible = false; + $scope.isErrorVisible = false; + $scope.isDialogVisible = true; + $scope.popup.isVisible = true; + $scope.isConfirmEnabled = false; + $scope.dialogMethod = request.dialogMethod; + callbackFunction = request.callbackFunction; + componentId = request.componentId; + + DeleteResumeService.initializeComponent(request.componentId); + + $scope.componentName = DeleteResumeService.getComponentDisplayName(); + + $scope.summaryControl.setList(DeleteResumeService.getSummaryList()); + + DeleteResumeService.getParameters(handleGetParametersResponse); + + }); + + var handleGetParametersResponse = function(parameters, dontshow) { + $scope.summaryControl.setList(parameters.summaryList); + $scope.userProvidedControl.setList(parameters.userProvidedList); + + $scope.isSpinnerVisible = false; + if (dontshow) + $scope.isDataVisible = false; + else + $scope.isDataVisible = true; + $scope.isConfirmEnabled = true; + }; + + $scope.userParameterChanged = function(id) { + DeleteResumeService.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 callbackAfterMSO = function(isSuccessful) { + if (isSuccessful) { + $scope.popup.isVisible = false; + runCallback(true); + } else { + $scope.isDialogVisible = true; + } + }; + + + $scope.isDialogVisible = false; + + if ($scope.dialogMethod == COMPONENT.DELETE) + { + + var requestDetails = DeleteResumeService.getMsoRequestDetails($scope.userProvidedControl.getList()); + + if(DeleteResumeService.isMacro === true){ + requestDetails.requestParameters.aLaCarte = false; + } + + $scope.$broadcast(COMPONENT.MSO_DELETE_REQ, { + url : DeleteResumeService.getMsoUrl(), + requestDetails : requestDetails, + componentId: componentId, + callbackFunction : callbackAfterMSO + }); + } + else + if ($scope.dialogMethod == COMPONENT.RESUME) + { + CreationService.initializeComponent(componentId); + CreationService.setInventoryInfo(); + + var requestDetails = CreationService.getMsoRequestDetails($scope.userProvidedControl.getList()); + + + $scope.$broadcast(COMPONENT.MSO_CREATE_REQ, { + url : CreationService.getMsoUrl(), + requestDetails : requestDetails, + componentId: componentId, + callbackFunction : callbackAfterMSO + }); + + + } + + } + + $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("deleteResumeDialogController", [ "COMPONENT", "FIELD", "$scope", "$http", + "$timeout", "$log", "DeleteResumeService","CreationService", "UtilityService", + deleteResumeDialogController]); 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 index 65fac289..dd3ba50f 100755 --- 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 @@ -64,25 +64,42 @@ */
var msoCommitController = function(COMPONENT, FIELD, $scope, $http, $timeout, $window, $log,
- MsoService, PropertyService, UtilityService, DataService) {
+ MsoService, PropertyService, UtilityService, TestEnvironmentsService) {
$scope.isViewVisible = false;
$scope.progressBarControl = {};
$scope.popupWindowControl = {};
-
+ var getRequestStatusFunc = getOrchestrationRequestStatus; //default
var _this = this;
$scope.$on("createInstance", function(event, request) {
- init(request, COMPONENT.MSO_CREATE_REQ );
+ init(request, COMPONENT.MSO_CREATE_REQ, getOrchestrationRequestStatus );
MsoService.createInstance(request, handleInitialResponse);
});
$scope.$on("deleteInstance", function(event, request) {
- init(request, COMPONENT.MSO_DELETE_REQ);
+ init(request, COMPONENT.MSO_DELETE_REQ, getOrchestrationRequestStatus);
MsoService.deleteInstance(request, handleInitialResponse);
});
- var init = function(request, msoRequestType ) {
+ $scope.$on(COMPONENT.MSO_CREATE_ENVIRONMENT, function(event, request) {
+ init(request, COMPONENT.MSO_CREATE_ENVIRONMENT, getCloudResourcesRequestStatus);
+ TestEnvironmentsService.createApplicationEnv(request).then(handleInitialResponse);
+ });
+
+ $scope.$on(COMPONENT.MSO_DEACTIVATE_ENVIRONMENT, function(event, request) {
+ init(request, COMPONENT.MSO_DEACTIVATE_ENVIRONMENT, getCloudResourcesRequestStatus);
+ TestEnvironmentsService.deactivateApplicationEnv(request).then(handleInitialResponse)
+ });
+
+ $scope.$on(COMPONENT.MSO_ACTIVATE_ENVIRONMENT, function(event, request) {
+ init(request, COMPONENT.MSO_ACTIVATE_ENVIRONMENT, getCloudResourcesRequestStatus);
+ TestEnvironmentsService.activateApplicationEnv(request).then(handleInitialResponse)
+ });
+
+
+ var init = function(request, msoRequestType, getStatusRequest ) {
+ getRequestStatusFunc = getStatusRequest;
$scope.status = FIELD.STATUS.SUBMITTING_REQUEST;
$scope.isSpinnerVisible = true;
$scope.isProgressVisible = true;
@@ -109,13 +126,13 @@ var msoCommitController = function(COMPONENT, FIELD, $scope, $http, $timeout, $w showError(FIELD.ERROR.SYSTEM_FAILURE, UtilityService
.getHttpErrorMessage(response));
});
- }
+ };
var handleInitialResponse = function(response) {
try {
updateViewAfterInitialResponse(response);
- _this.timer = $timeout(getRequestStatus, PropertyService
+ _this.timer = $timeout(getRequestStatusFunc, PropertyService
.getMsoMaxPollingIntervalMsec());
$scope.instanceId = response.data.entity.instanceId;
@@ -133,11 +150,16 @@ var msoCommitController = function(COMPONENT, FIELD, $scope, $http, $timeout, $w }
}
- var getRequestStatus = function() {
- MsoService.getOrchestrationRequest(_this.requestId, handleGetResponse);
+ function getOrchestrationRequestStatus() {
+ MsoService.getOrchestrationRequest(_this.requestId, handleGetStatusResponse);
}
- var handleGetResponse = function(response) {
+ function getCloudResourcesRequestStatus() {
+ TestEnvironmentsService.getRequestStatus(_this.requestId, handleGetStatusResponse);
+ }
+
+
+ var handleGetStatusResponse = function(response) {
try {
if (isUpdateViewAfterGetResponseComplete(response)) {
return;
@@ -147,7 +169,7 @@ var msoCommitController = function(COMPONENT, FIELD, $scope, $http, $timeout, $w _this.isMsoError = true;
showError(FIELD.ERROR.MAX_POLLS_EXCEEDED);
} else {
- _this.timer = $timeout(getRequestStatus, PropertyService
+ _this.timer = $timeout(getRequestStatusFunc, PropertyService
.getMsoMaxPollingIntervalMsec());
}
} catch (error) {
@@ -296,5 +318,5 @@ var msoCommitController = function(COMPONENT, FIELD, $scope, $http, $timeout, $w }
appDS2.controller("msoCommitController", [ "COMPONENT", "FIELD", "$scope", "$http", "$timeout",
- "$window", "$log", "MsoService", "PropertyService", "UtilityService",
+ "$window", "$log", "MsoService", "PropertyService", "UtilityService", "TestEnvironmentsService",
msoCommitController ]);
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/msoCommitModalController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/msoCommitModalController.js new file mode 100644 index 00000000..148b4cce --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/msoCommitModalController.js @@ -0,0 +1,237 @@ +/*- + * ============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 msoCommitModalController = function(COMPONENT, FIELD, $scope, $http, $timeout, $window, $log, + MsoService, PropertyService, UtilityService, DataService, $uibModalInstance, msoType, requestParams, vidService) { + + $scope.isSpinnerVisible = true; + $scope.isProgressVisible = true; + $scope.status = FIELD.STATUS.SUBMITTING_REQUEST; + $scope.error = ""; + $scope.log = ""; + $scope.progressBarControl = {}; + $scope.isCloseEnabled = false; + + var _this = this; + _this.pollAttempts = 0; + _this.callbackFunction = requestParams.callbackFunction; + _this.isMsoError = false; + + + if (angular.isFunction($scope.progressBarControl.reset)) { + $scope.progressBarControl.reset(); + } + $scope.percentProgress = 2; // Show "a little" progress + + + /* + * Updates the view and returns "true" if the MSO operation has returned a + * "Complete" status. + */ + var isUpdateViewAfterGetResponseComplete = function(response) { + //console.log("msoCommitController isUpdateViewAfterGetResponseComplete"); + updateLogFinalResponse(response); + + var requestStatus = UtilityService.checkUndefined(FIELD.ID.REQUEST_STATUS, + UtilityService.checkUndefined(FIELD.ID.REQUEST, + response.data.entity.request).requestStatus); + + var requestState = requestStatus.requestState; + console.log("msoCommitController requestState=" + requestState); + // look for "progress" or "pending" + var patt1 = /progress/i; + var patt2 = /pending/i; + var result1 = patt1.test(requestState); + var result2 = patt2.test(requestState); + if (result1 || result2) { + requestState = FIELD.STATUS.IN_PROGRESS; + } + var statusMessage = requestStatus.statusMessage; + console.log("msoCommitController statusMessage=" + statusMessage); + if (UtilityService.hasContents(statusMessage)) { + $scope.status = requestState + " - " + statusMessage; + } else { + $scope.status = requestState; + } + if (UtilityService.hasContents(requestStatus.percentProgress)) { + $scope.percentProgress = requestStatus.percentProgress; + } + + if ( (requestState.toLowerCase() === FIELD.STATUS.FAILED.toLowerCase()) || (requestState.toLowerCase() === FIELD.STATUS.UNLOCKED.toLowerCase())) { + throw { + type : FIELD.STATUS.MSO_FAILURE + }; + } + + if (requestState.toLowerCase() === FIELD.STATUS.COMPLETE.toLowerCase()) { + $scope.isSpinnerVisible = false; + return true; + } + + return false; + }; + + var handleGetResponse = function(response) { + try { + if (isUpdateViewAfterGetResponseComplete(response)) { + return; + } + if (++_this.pollAttempts > PropertyService.getMsoMaxPolls()) { + _this.isMsoError = true; + showError(FIELD.ERROR.MAX_POLLS_EXCEEDED); + } else { + _this.timer = $timeout(getRequestStatus, PropertyService + .getMsoMaxPollingIntervalMsec()); + } + } catch (error) { + _this.isMsoError = true; + MsoService.showResponseContentError(error, showError); + } + }; + + var showError = function(summary, details) { + var message = summary; + if (UtilityService.hasContents(details)) { + message += " (" + details + ")"; + } + $scope.isSpinnerVisible = false; + $scope.isProgressVisible = false; + $scope.error = message; + $scope.status = FIELD.STATUS.ERROR; + }; + + var getRequestStatus = function() { + MsoService.getOrchestrationRequest(_this.requestId, handleGetResponse); + }; + + var updateLog = function(response) { + $scope.log = MsoService.getFormattedCommonResponse(response) + + $scope.log; + UtilityService.checkUndefined("entity", response.data.entity); + UtilityService.checkUndefined("status", response.data.status); + MsoService.checkValidStatus(response); + }; + + var updateLogFinalResponse = function(response) { + $scope.log = MsoService.getFormattedSingleGetOrchestrationRequestResponse(response) + + $scope.log; + UtilityService.checkUndefined("entity", response.data.entity); + UtilityService.checkUndefined("status", response.data.status); + MsoService.checkValidStatus(response); + }; + + var updateViewAfterInitialResponse = function(response) { + $scope.isCloseEnabled = true; + updateLog(response); + + _this.requestId = UtilityService.checkUndefined(FIELD.ID.REQUEST_ID, + UtilityService.checkUndefined(FIELD.ID.REQUEST_REFERENCES, + response.data.entity.requestReferences).requestId); + + $scope.percentProgress = 4; // Show "a little more" progress + $scope.status = FIELD.STATUS.IN_PROGRESS; + }; + + var init = function(msoType) { + switch(msoType) { + case COMPONENT.MSO_CREATE_REQ: + return MsoService.createConfigurationInstance(requestParams); + case COMPONENT.MSO_CHANGE_CONFIG_STATUS_REQ: + return MsoService.toggleConfigurationStatus(requestParams); + case COMPONENT.MSO_CHANGE_PORT_STATUS_REQ: + return MsoService.togglePortStatus(requestParams); + case COMPONENT.MSO_CREATE_REALATIONSHIP: + return MsoService.associatePnf(requestParams); + case COMPONENT.MSO_REMOVE_RELATIONSHIP: + return MsoService.dissociatePnf(requestParams); + case COMPONENT.MSO_ACTIVATE_SERVICE_REQ: + return MsoService.activateInstance(requestParams); + case COMPONENT.MSO_DEACTIVATE_SERVICE_REQ: + return MsoService.deactivateInstance(requestParams); + } + }; + + var successCallbackFunction = function(response) { + try { + updateViewAfterInitialResponse(response); + _this.timer = $timeout(getRequestStatus, PropertyService + .getMsoMaxPollingIntervalMsec()); + + $scope.instanceId = response.data.entity.instanceId; + if ($scope.instanceId == null) { + $scope.instanceId = response.data.entity.requestReferences.instanceId; + } + } catch (error) { + if ( response.data != null && response.data.status != null ) { + if (response.data.status > 299 || response.data.status < 200 ) { + // MSO returned an error + _this.isMsoError = true; + } + } + MsoService.showResponseContentError(error, showError); + } + }; + + var errorCallbackFunction = function (error) { + UtilityService.setHttpErrorHandler(function(error) { + $scope.isCloseEnabled = true; + _this.isMsoError = true; + showError(FIELD.ERROR.SYSTEM_FAILURE, UtilityService + .getHttpErrorMessage(error)); + }); + }; + + $scope.close = function() { + $uibModalInstance.dismiss('cancel'); + + if (_this.timer !== undefined) { + $timeout.cancel(_this.timer); + } + + if (angular.isFunction(_this.callbackFunction)) { + if ($scope.error === "") { + _this.callbackFunction({ + isSuccessful : true, + instanceId : $scope.instanceId + }); + } else { + _this.callbackFunction({ + isSuccessful : false + }); + } + } + }; + + _this.msoRequestType = msoType; + + init(_this.msoRequestType) + .then(function (response) { + successCallbackFunction(response); + }) + .catch(function (error) { + errorCallbackFunction(error); + }); +}; + +appDS2.controller("msoCommitModalController", [ "COMPONENT", "FIELD", "$scope", "$http", "$timeout", + "$window", "$log", "MsoService", "PropertyService", "UtilityService", "DataService", "$uibModalInstance", "msoType", "requestParams", "vidService", + msoCommitModalController ]); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/pnfSearchAssociationController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/pnfSearchAssociationController.js new file mode 100644 index 00000000..22a20abf --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/pnfSearchAssociationController.js @@ -0,0 +1,138 @@ +/*- +* ============LICENSE_START======================================================= +* VID +* ================================================================================ +* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +* ================================================================================ +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* ============LICENSE_END========================================================= +*/ + +/** + * The Instantiation (or View/Edit) Controller controls the instantiation/removal of + * deployable objects (Services, VNFs, VF-Modules, Networks, and Volume-Groups) + */ + +"use strict"; + +appDS2.controller("pnfSearchAssociationController", ["COMPONENT", "$log", "FIELD", "PARAMETER", "DataService", "CreationService", "$scope", "$window", "$location", "AaiService", "$uibModal", "UtilityService", "vidService", "$timeout", + function (COMPONENT, $log, FIELD, PARAMETER, DataService, CreationService, $scope, $window, $location, AaiService, $uibModal, UtilityService, vidService, $timeout) { + + var requestParams = {}; + + $scope.selectedMetadata = {}; + + $scope.serviceMetadataFields = []; + $scope.nodeTemplateFields = {}; + + $scope.pnfInstance= false; + $scope.notFound= false; + + $scope.pnfMetadata = []; + + $scope.errorMsg = FIELD.ERROR.INSTANCE_NAME_VALIDATE; + + $scope.modelName = DataService.getModelInfo(COMPONENT.VNF).modelCustomizationName; + + var handleGetParametersResponse = function(parameters) { + $scope.serviceMetadataFields = parameters.summaryList; + $scope.serviceMetadataFields.forEach(function (t, number) { + $scope.serviceMetadataFields[number].key = $scope.serviceMetadataFields[number].name.split(' ').join('') + }) + $scope.nodeTemplateFields = _.keyBy(parameters.userProvidedList, 'id'); + }; + + CreationService.initializeComponent(COMPONENT.VNF); + + CreationService.getParameters(handleGetParametersResponse); + + $scope.back = function() { + $window.history.back(); + }; + + $scope.searchPnf = function(pnfName) { + $scope.pnfInstance= false; + $scope.notFound=false; + + AaiService.getPnfByName(pnfName) + .then(function (response) { + $scope.pnfInstance = response.data; + requestParams.pnf = response.data.pnfName; + }) + .catch(function (error) { + $scope.pnfNameNotFound= pnfName; + $scope.notFound= true; + }); + + } + var modalInstance; + + $scope.associate = function() { + + requestParams.serviceModelInfo = vidService.getModel().service; + requestParams.attuuid = DataService.getLoggedInUserId(); + requestParams.instanceId = DataService.getServiceInstanceId(); + + modalInstance = $uibModal.open({ + templateUrl: 'app/vid/scripts/modals/mso-commit/mso-commit.html', + controller: "msoCommitModalController", + backdrop: false, + resolve: { + msoType: function () { + return COMPONENT.MSO_CREATE_REALATIONSHIP; + }, + requestParams: function () { + requestParams.callbackFunction = updateViewCallbackFunction; + return requestParams; + } + } + }) + + + }; + + var updateViewCallbackFunction = function(response) { + $scope.callbackResults = ""; + var color = FIELD.ID.COLOR_NONE; + $scope.callbackStyle = { + "background-color" : color + }; + + /* + * This 1/2 delay was only added to visually highlight the status + * change. Probably not needed in the real application code. + */ + $timeout(function() { + $scope.callbackResults = UtilityService.getCurrentTime() + + FIELD.STATUS.IS_SUCCESSFUL + response.isSuccessful; + if (response.isSuccessful) { + color = FIELD.ID.COLOR_8F8; + $scope.back(); + } else { + color = FIELD.ID.COLOR_F88; + } + $scope.callbackStyle = { + "background-color" : color + }; + }, 500); + }; + + + $scope.cancel = function() { + modalInstance.dismiss('cancel'); + }; + + + }]); + + diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/testEnvironmentsController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/testEnvironmentsController.js new file mode 100644 index 00000000..f5c3a0e0 --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/testEnvironmentsController.js @@ -0,0 +1,102 @@ +(function () { + 'use strict'; + + appDS2.controller("testEnvironmentsController", ["$uibModal", "TestEnvironmentsService", "$log", "$rootScope", "$scope", "COMPONENT", testEnvironmentsController]); + + function testEnvironmentsController($uibModal, TestEnvironmentsService, $log, $rootScope, $scope, COMPONENT) { + var vm = this; + + var toggleValue; + + var init = function() { + vm.loadAAIestEnvironments(); + }; + + vm.loadAAIestEnvironments = function() { + TestEnvironmentsService.loadAAIestEnvironments("VNF") + .then(function(response) { + vm.environments = response.operationalEnvironment; + vm.connectError = false; + if(!vm.environments.length) { + vm.emptyData = true; + } + }) + .catch(function (error) { + vm.connectError = error.message || "Unknown error"; + $log.error(error); + }); + }; + + function handleEnvActionComplete(result) { + if (result.isSuccessful) { + vm.loadAAIestEnvironments(); + } + $scope.popup.isVisible = false; + } + + vm.onTestEnvActivateClick = function(testEnv) { + var modalInstance = $uibModal.open({ + templateUrl: 'app/vid/scripts/modals/attach-test-env-manifest/attach-test-env-manifest.html', + controller: 'attachTestEnvManifestController', + controllerAs: 'vm', + resolve: {} + }); + + modalInstance.result.then(function (result) { + if (result) { + + var relatedEcompEnv = _.find(testEnv.relationshipList.relationship, { relatedTo: "operational-environment" }); + + var manifest = result; + var envId = testEnv.operationalEnvironmentId; + var relatedInstanceId = + _.find(relatedEcompEnv.relationshipData, {"relationshipKey": "operational-environment.operational-environment-id"}) + .relationshipValue; + var relatedInstanceName = + _.find(relatedEcompEnv.relatedToProperty, {"propertyKey": "operational-environment.operational-name"}) + .propertyValue; + var workloadContext = testEnv.workloadContext; + + $rootScope.$broadcast(COMPONENT.MSO_ACTIVATE_ENVIRONMENT, { + url: COMPONENT.MSO_ACTIVATE_ENVIRONMENT, + envId: envId, + relatedInstanceId: relatedInstanceId, + relatedInstanceName: relatedInstanceName, + workloadContext: workloadContext, + manifest: manifest, + callbackFunction: handleEnvActionComplete + }); + + } + }); + }; + + vm.onTestEnvDeactivateClick = function(testEnv) { + var envId = testEnv.operationalEnvironmentId; + $rootScope.$broadcast(COMPONENT.MSO_DEACTIVATE_ENVIRONMENT, { + url : COMPONENT.MSO_DEACTIVATE_ENVIRONMENT, + envId : envId, + callbackFunction: handleEnvActionComplete + }); + }; + + vm.isEnvActive = function(testEnv) { + return testEnv.operationalEnvironmentStatus==='Activate'; + }; + + vm.getEnvStatus = function (testEnv) { + return this.isEnvActive(testEnv) ? "Active" : "Inactive"; + }; + + vm.createNewTestEnvironment = function() { + var modalInstance = $uibModal.open({ + templateUrl: 'app/vid/scripts/modals/new-test-environment/new-test-environment.html', + controller: 'newTestEnvironmentModalController', + controllerAs: 'vm', + resolve: {} + }); + }; + + init(); + } +})();
\ No newline at end of file |