X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=vid-app-common%2Fsrc%2Fmain%2Fwebapp%2Fapp%2Fvid%2Fscripts%2Fcontroller%2FaaiSubscriberController.js;h=110f24ec61f5aaf48852ea9d6b5e26c4cda7dd02;hb=88e5a40c125893a5600bdd81ef943b921e9f8f08;hp=74f7471d4e732e9da1f1eafd666a03f2f5637936;hpb=c3f38b5abe20df0e8ab8455dcc9d0599aba75bfd;p=vid.git 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 74f7471d4..110f24ec6 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 @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * VID * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 IBM. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +21,29 @@ "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", "AsdcService","featureFlags", "$q", "_", + function (COMPONENT, FIELD, PARAMETER, DataService, PropertyService, $scope, $http, $timeout, $location, $log, $route, $uibModal, VIDCONFIGURATION, UtilityService, vidService, AaiService, MsoService, OwningEntityService, AsdcService, featureFlags, $q, _) { + + $scope.showReportWindow = function() { + let GuiMessage; + + if ($scope.errorMsg !== undefined && $scope.errorMsg !== null) { + GuiMessage = $scope.errorMsg; + } else { + GuiMessage = $scope.status; + } + + const modalWindow = $uibModal.open({ + templateUrl: 'app/vid/scripts/modals/report-modal/report-modal.html', + controller: 'reportModalController', + controllerAs: 'vm', + resolve: { + errorMsg: function () { + return GuiMessage; + } + } + }); + }; $scope.showVnfDetails = function (vnf) { console.log("showVnfDetails"); @@ -33,7 +55,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", componentId: COMPONENT.VNF, callbackFunction: callbackFunction }); - } + }; $scope.popup = new Object(); @@ -44,6 +66,8 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", $scope.serviceTypes = [FIELD.PROMPT.SELECT_SERVICE, COMPONENT.UCPE_VMS, COMPONENT.SDN_L3_BONDING, COMPONENT.SDN_ETHERNET_INTERNET]; $scope.defaultSubscriberName = [FIELD.PROMPT.SELECT_SUB]; + $scope.verifyButtonEnabled = true; + var callbackFunction = function (response) { alert(response); }; @@ -52,29 +76,27 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", $scope.init(); $scope.fetchSubs(FIELD.PROMPT.FETCHING_SUBS); $scope.fetchServices(); - }; $scope.cancelCreateSI = function () { window.location.href = COMPONENT.WELCOME_PATH; - }; $scope.getServiceTypes = function (globalCustomerId) { DataService.setGlobalCustomerId(globalCustomerId); - DataService.setServiceIdList($scope.customerList) + DataService.setServiceIdList($scope.customerList); if (globalCustomerId !== "" && globalCustomerId !== undefined) { window.location.href = COMPONENT.SERVICE_TYPE_LIST_PATH + $scope.serviceTypeList; } - } + }; $scope.refreshServiceTypes = function (globalCustomerId) { DataService.setGlobalCustomerId(globalCustomerId); $scope.getServiceTypesList(); - } + }; $scope.subId = ""; $scope.createSubscriberName = ""; @@ -116,258 +138,221 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", $scope.subList = []; $scope.getAaiServiceModels = function (selectedServicetype, subName) { DataService.setGlobalCustomerId(selectedServicetype); - DataService.setServiceIdList($scope.serviceTypeList) + DataService.setServiceIdList($scope.serviceTypeList); DataService.setSubscriberName(subName); DataService.setSubscribers($scope.custSubList); - if (selectedServicetype !== "" && selectedServicetype !== 'undefined') { - $location.path(COMPONENT.CREATE_INSTANCE_PATH); - } - }; - - $scope.serviceTypeName=""; - $scope.getAaiServiceModelsList = function(){ - var globalCustomerId=""; - var serviceTypeId = DataService.getGlobalCustomerId(); - $scope.serviceTypeList = DataService.getServiceIdList(); - $scope.createSubscriberName = DataService.getSubscriberName(); - $scope.status = FIELD.STATUS.FETCHING_SERVICE_CATALOG; - $scope.custSubList = DataService.getSubscribers(); - for(var i=0; i<$scope.serviceTypeList.length;i++){ - if(parseInt(serviceTypeId) === i ){ - $scope.serviceTypeName = $scope.serviceTypeList[i].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; - } - 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, + } + ; + 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 SDC."; + $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 (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"; + + DataService.setShouldIncludeInAsyncInstantiationFlow(AsdcService.shouldTakeTheAsyncInstantiationFlow(serviceModel)); + + if (AsdcService.isMacro(serviceModel)) { + DataService.setALaCarte(false); + $scope.createType = "Macro"; + var convertedAsdcModel = UtilityService.convertModel(serviceModel); + + //console.log ("display inputs "); + //console.log (JSON.stringify ( convertedAsdcModel.completeDisplayInputs)); + + DataService.setModelInfo(COMPONENT.SERVICE, { + "modelInvariantId": serviceModel.service.invariantUuid, + "modelVersion": serviceModel.service.version, + "modelNameVersionId": serviceModel.service.uuid, + "modelName": serviceModel.service.name, + "description": serviceModel.service.description, + "category": serviceModel.service.category, + "serviceEcompNaming": serviceModel.service.serviceEcompNaming, + "inputs": serviceModel.service.inputs, + "displayInputs": convertedAsdcModel.completeDisplayInputs, + "serviceTypeName": serviceModel.service.serviceTypeName, + "createSubscriberName": serviceModel.service.createSubscriberName, + "serviceType": serviceModel.service.serviceType, "serviceRole": serviceModel.service.serviceRole - });} - ; - - $scope.$broadcast(broadcastType, { - componentId : COMPONENT.SERVICE, - callbackFunction : function(response) { - if (response.isSuccessful) { - vidService.setModel(serviceModel); - - var subscriberId = "Not Found"; - var serviceType = "Not Found"; - - var serviceInstanceId = response.instanceId; - - for (var i = 0; i < response.control.length; i++) { - if (response.control[i].id == "subscriberName") { - subscriberId = response.control[i].value; - } else if (response.control[i].id == "serviceType") { - serviceType = response.control[i].value; - } - } - - - $scope.refreshSubs(subscriberId,serviceType,serviceInstanceId); - - } - } - }); - - }, function errorCallback(response) { - console.log("Error: " + response); - }); - }; - $scope.isFiltered=function(arr,obj){ - var filtered = false; - if(arr.length>0){ - for(var i=0;i=parseFloat(serviceData[i]['extra-properties']['extra-property'][6]['property-value']))){ - var data = $scope.isThisHigher(fiterDataServices,serviceData[j]); - if(data.isHigher){ - fiterDataServices[data.index] = serviceData[j]; - } - } - } - } - } - return fiterDataServices; - } - - $scope.isThisHigher = function(arr,obj){ - var returnObj = { - isHigher:false, - index:0 - }; - if(arr.length>0){ - var isNotMatched = true; - for(var i=0;i= 0; }); + if (aaiNetworkIds.length && !isContains) { + $log.error("vlansByNetworks contain network that not found in service instance", aaiNetworkIds, serviceInstanceNetworkIds); + } + }); - } + }; + + + $scope.handleInitialResponse = function (response) { try { @@ -901,64 +1248,309 @@ 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); + }); + } + }; + + + var activateFabricConfigurationInstance = function (msoType) { + var requestParams = { + model: $scope.service.model, + service: $scope.service, + serviceInstanceId: $scope.serviceInstanceId + }; + + if (DataService.getLoggedInUserId()) { + requestParams.userId = DataService.getLoggedInUserId(); + openMsoModal(COMPONENT.MSO_ACTIVATE_FABRIC_CONFIGURATION_REQ, requestParams); + } else { + AaiService.getLoggedInUserID(function (response) { + var userID = response.data; + DataService.setLoggedInUserId(userID); + requestParams.userId = userID; + openMsoModal(COMPONENT.MSO_ACTIVATE_FABRIC_CONFIGURATION_REQ, requestParams); + }); + } + }; + + $scope.showAssignmentsSDNC = function () { + + if ($scope.service && $scope.service.instance) { + return VIDCONFIGURATION.SDNC_SHOW_ASSIGNMENTS_URL.replace("" , $scope.service.instance.id); + } + return null; + }; + + $scope.activateFabricConfigurationMSO = function () { + activateFabricConfigurationInstance(COMPONENT.MSO_ACTIVATE_FABRIC_CONFIGURATION_REQ); + }; + + $scope.activateMSOInstance = function () { + + activateDeactivateServiceInstance(COMPONENT.MSO_ACTIVATE_SERVICE_REQ); + }; + + $scope.deactivateMSOInstance = function () { + + activateDeactivateServiceInstance(COMPONENT.MSO_DEACTIVATE_SERVICE_REQ); + }; + + + $scope.deleteConfiguration = function (serviceObject, configuration) { + AaiService.getLoggedInUserID(function (response) { + DataService.setLoggedInUserId(response.data); + var requestParams = { + serviceModel: { + "modelType": "configuration", + "modelInvariantId": serviceObject.model.service.invariantUuid, + "modelVersionId": serviceObject.model.service.uuid, + "modelName": serviceObject.model.service.name, + "modelVersion": serviceObject.model.service.version + }, + configurationModel: { + "modelType": "configuration", + "modelInvariantId": configuration.modelInvariantId, + "modelVersionId": configuration.modelVersionId, + "modelCustomizationId": configuration.modelCustomizationId + }, + serviceInstanceId: serviceObject.instance.serviceInstanceId, + configurationId: configuration.nodeId, + configStatus: configuration.DELETE, + userId: DataService.getLoggedInUserId() + }; + + openMsoModal(COMPONENT.MSO_DELETE_CONFIGURATION_REQ, requestParams, configuration); + }); + + }; + + $scope.toggleConfigurationStatus = function (serviceObject, configuration) { + AaiService.getLoggedInUserID(function (response) { + DataService.setLoggedInUserId(response.data); + var requestParams = { + serviceModel: { + "modelType": "service", + "modelInvariantId": serviceObject.model.service.invariantUuid, + "modelVersionId": serviceObject.model.service.uuid, + "modelName": serviceObject.model.service.name, + "modelVersion": serviceObject.model.service.version + }, + configurationModel: { + "modelType": "configuration", + "modelInvariantId": configuration.modelInvariantId, + "modelVersionId": configuration.modelVersionId, + "modelCustomizationId": configuration.modelCustomizationId + }, + serviceInstanceId: serviceObject.instance.serviceInstanceId, + configurationId: configuration.nodeId, + configStatus: configuration.nodeStatus, + userId: DataService.getLoggedInUserId() + }; + + openMsoModal(COMPONENT.MSO_CHANGE_CONFIG_STATUS_REQ, requestParams, configuration); + }); + + }; + + $scope.togglePortStatus = function (serviceObject, configuration, port) { + AaiService.getLoggedInUserID(function (response) { + DataService.setLoggedInUserId(response.data); + + var requestParams = { + serviceInstanceId: serviceObject.instance.serviceInstanceId, + configurationId: configuration.nodeId, + portId: port.portId, + portStatus: port.portStatus, + serviceModel: { + "modelType": "service", + "modelInvariantId": serviceObject.model.service.invariantUuid, + "modelVersionId": serviceObject.model.service.uuid, + "modelName": serviceObject.model.service.name, + "modelVersion": serviceObject.model.service.version + }, + configurationModel: { + "modelType": "configuration", + "modelInvariantId": configuration.modelInvariantId, + "modelVersionId": configuration.modelVersionId, + "modelCustomizationId": configuration.modelCustomizationId + }, + userId: DataService.getLoggedInUserId() + }; + + openMsoModal(COMPONENT.MSO_CHANGE_PORT_STATUS_REQ, requestParams, configuration); + }); + }; + + $scope.dissociatePnf = function (pnfName) { + + 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.userId = DataService.getLoggedInUserId(); + requestParams.attuuid = DataService.getLoggedInUserId(); + openMsoModal(COMPONENT.MSO_REMOVE_RELATIONSHIP, requestParams); + } else { + AaiService.getLoggedInUserID(function (response) { + DataService.setLoggedInUserId(response.data); + + requestParams.userId = response.data; + requestParams.attuuid = response.data; + openMsoModal(COMPONENT.MSO_REMOVE_RELATIONSHIP, requestParams); + }); + } + } + }); + + + }; + + var openMsoModal = function (msoType, requestParams, configuration) { + 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; + }, + configuration: function () { + return configuration; + } + } + }); + }; + + 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 () { + } + }; + } +]).directive('restrictInput', function () { return { @@ -1022,7 +1614,6 @@ appDS2.controller('TreeCtrl', ['$scope', function ($scope) { $scope.$broadcast(FIELD.ID.ANGULAR_UI_TREE_EXPANDALL); }; - }]);