From d350d5ac25c8df2846e4f0d9082cb4d364a17a83 Mon Sep 17 00:00:00 2001 From: "Sonsino, Ofir (os0695)" Date: Mon, 6 Aug 2018 16:14:59 +0300 Subject: UI Feature flagging support Change-Id: Ic2151dab6306c42364483e9064c01bab3dd7378b Issue-ID: VID-208 Signed-off-by: Sonsino, Ofir (os0695) --- .../webapp/app/vid/scripts/services/aaiService.js | 109 ++++++++++++++++++--- 1 file changed, 97 insertions(+), 12 deletions(-) (limited to 'vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js') diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js index 4b1d77134..ceb5a7541 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js @@ -20,7 +20,7 @@ "use strict"; -var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONENT, FIELD, $q) { +var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONENT, FIELD, $q, featureFlags) { function getServiceInstance(serviceInstanceIdentifier, findBy) { serviceInstanceIdentifier.trim(); @@ -44,9 +44,7 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE }); return deferred.promise; - }; - - + } function getGlobalCustomerIdFromServiceInstanceResponse(response) { var globalCustomerId = ""; if (angular.isArray(response.data[FIELD.ID.RESULT_DATA])) { @@ -69,7 +67,7 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE timeout : PropertyService.getServerResponseTimeoutMsec() }).then(function (response) { var displayData = response.data[FIELD.ID.SERVICE_INSTANCES]; - if (!displayData.length) { + if (!displayData || !displayData.length) { displayData = [{ globalCustomerId : null, subscriberName : null, @@ -115,7 +113,7 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE COMPONENT.FORWARD_SLASH + encodeURIComponent(globalCustomerId) + COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceType) + COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceInstanceId); - $http.get(url, {}, { + return $http.get(url, {}, { timeout : PropertyService.getServerResponseTimeoutMsec() @@ -169,6 +167,26 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE }); }, + getCRInformationByInstanceId : function (serviceInstanceId) { + + var deferred = $q.defer(); + + var url = COMPONENT.AAI_GET_CR_INSTANCE + + COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceInstanceId); + $http.get(url, {}, { + timeout : PropertyService.getServerResponseTimeoutMsec() + }).then(function(response) { + if (response.data != null) { + deferred.resolve(response); + } else { + deferred.resolve(response); + } + }, function(response) { + deferred.resolve(response); + }); + return deferred.promise; + }, + searchServiceInstances: searchServiceInstances, getModelVersionId: function (subscriberId, instanceId) { @@ -329,6 +347,44 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE }); }, + getPortMirroringData : function (ids) { + var defer = $q.defer(); + if(featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_REGION_ID_FROM_REMOTE)){ + var url = COMPONENT.AAI_GET_PORT_MIRRORING_CONFIGS_DATA +'?configurationIds=' + ids.join(','); + $http.get(url).then(function(res){ + defer.resolve(res); + }).catch(function(err) { + $log.error(err); + defer.resolve({}); + }); + }else { + var staticConfigurationData = {}; + angular.forEach(ids, function(id) { + staticConfigurationData[id] = { + "cloudRegionId": "mdt1" + } + }); + defer.resolve({ + "data": staticConfigurationData + }); + } + + return defer.promise; + + }, + + getPortMirroringSourcePorts : function (ids) { + var defer = $q.defer(); + var url = COMPONENT.AAI_GET_PORT_MIRRORING_SOURCE_PORTS +'?configurationIds=' + ids.join(','); + $http.get(url).then(function(res){ + defer.resolve(res); + }).catch(function(err) { + $log.error(err); + defer.resolve({}); + }); + return defer.promise; + }, + getSubscriptionServiceTypeList : function(globalCustomerId, successCallbackFunction) { $log @@ -444,11 +500,12 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE } else { successCallbackFunction([]); } - },function(failure){console.log("failure")})["catch"] - if(catchCallbackFunction) { + })["catch"] (function(response, status) { + if (catchCallbackFunction) { catchCallbackFunction(); } - (UtilityService.runHttpErrorHandler); + UtilityService.runHttpErrorHandler(response, status); + }) }, getServices : function(successCallbackFunction) { $log @@ -565,7 +622,7 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE var deferred = $q.defer(); if (UtilityService.hasContents(modelInvariantId)) { - var body = {"versions" : modelInvariantId} + var body = {"versions": modelInvariantId}; $http.post(( COMPONENT.AAI_GET_VERSION_BY_INVARIANT_ID),body) .success(function (response) { @@ -657,8 +714,36 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE }); return deferred.promise; + }, + + getInstanceGroupsByVNFInstanceId: function (vnf_instance_id, successCallback, errorCallback) { + var url = COMPONENT.AAI_GET_INSTANCE_GROUPS_BY_VNF_INSTANCE_ID_PATH + "/" + vnf_instance_id; + + $http.get(url, {}, { + timeout: PropertyService.getServerResponseTimeoutMsec() + }).then(function (response) { + successCallback(response); + }, function (response) { + errorCallback(response); + }); + }, + + postPOMBAverificationRequest: function (url, data, config) { + $http.post(url, data, config) + .success(function (data, status, headers, config) { + //If at some point in the future the result should be handled - this should be the entry point. + log.debug("POMBA was called successfully with data: " + data); + }) + .error(function (data, status, header, config) { + log.debug("Error: " + + "Data: " + data + + "status: " + status + + "headers: " + header + + "config: " + config); + }); } - }}; + } +}; appDS2.factory("AaiService", ["$http", "$log", "PropertyService", - "UtilityService", "COMPONENT", "FIELD", "$q", AaiService]); + "UtilityService", "COMPONENT", "FIELD", "$q", "featureFlags", AaiService]); -- cgit 1.2.3-korg