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/asdcService.js | 63 +++++++++++++++++----- 1 file changed, 49 insertions(+), 14 deletions(-) (limited to 'vid-app-common/src/main/webapp/app/vid/scripts/services/asdcService.js') diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/asdcService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/asdcService.js index 68fdce44f..753f9fd19 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/services/asdcService.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/asdcService.js @@ -20,21 +20,56 @@ "use strict"; -var AsdcService = function($http, $log, PropertyService, UtilityService) { +var AsdcService = function ($http, $log, PropertyService, UtilityService, VIDCONFIGURATION, COMPONENT, featureFlags) { return { - getModel : function(modelId, successCallbackFunction) { - $log.debug("AsdcService:getModel: modelId: " + modelId); - $http.get( - "asdc/getModel/" + modelId - + "?r=" + Math.random(), - { - timeout : PropertyService - .getServerResponseTimeoutMsec() - }).then(successCallbackFunction)["catch"] - (UtilityService.runHttpErrorHandler); - } + getModel: function (modelId, successCallbackFunction) { + $log.debug("AsdcService:getModel: modelId: " + modelId); + $http.get( + "asdc/getModel/" + modelId + + "?r=" + Math.random(), + { + timeout: PropertyService + .getServerResponseTimeoutMsec() + }).then(successCallbackFunction)["catch"] + (UtilityService.runHttpErrorHandler); + }, + + shouldExcludeMacroFromAsyncInstatiationFlow: function(serviceModel){ + if (!featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_ASYNC_INSTANTIATION)) + return true; + if (!_.isEmpty(serviceModel.pnfs)) + return true; + if (!_.isEmpty(serviceModel.collectionResource)) + return true; + if (!_.isEmpty(serviceModel.networks) && !featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_NETWORK_TO_ASYNC_INSTANTIATION)) + return true; + if(serviceModel.service.instantiationType === "ClientConfig") + return true; + return false; + }, + + isMacro: function (serviceModel) { + if (serviceModel && serviceModel.service) { + switch (serviceModel.service.instantiationType) { + case 'Macro': + case 'Both': + return true; + case 'A-La-Carte': + return false; + case 'ClientConfig': + console.debug("Looking for " + serviceModel.service.invariantUuid + " by Client Config"); + return UtilityService.arrayContains(VIDCONFIGURATION.MACRO_SERVICES, serviceModel.service.invariantUuid); + default: + console.debug("Unexpected serviceModel.service.instantiationType: " + serviceModel.service.instantiationType); + return true; + } + } else { + $log.debug("isMscro=false, because serviceModel.service is undefined"); + return false; + } + } } } -appDS2.factory("AsdcService", [ "$http", "$log", "PropertyService", - "UtilityService", AsdcService ]); +appDS2.factory("AsdcService", ["$http", "$log", "PropertyService", + "UtilityService", "VIDCONFIGURATION","COMPONENT", "featureFlags", AsdcService]); -- cgit 1.2.3-korg