+\r
+ gbp.register.controller('actionReferenceWizardCtrl', ['$scope', '$filter', 'GBPRuleServices', 'GBPActionInstanceServices', function($scope, $filter, GBPRuleServices, GBPActionInstanceServices){ \r
+ $scope.wizardPage = null;\r
+ $scope.path = {};\r
+ $scope.rule = {};\r
+\r
+ $scope.actionInstanceNames = {'options' : [], 'labels' : "name"};\r
+\r
+ var actionInstanceNamesLoad = function() {\r
+ var actionInstancePath = GBPActionInstanceServices.createPathObj($scope.selectedTenant.id);\r
+ GBPActionInstanceServices.load(actionInstancePath, function(data){\r
+ $scope.actionInstanceNames.options = data;\r
+ },function(){\r
+ //TODO: error cbk\r
+ });\r
+ };\r
+\r
+ $scope.init = function() {\r
+ $scope.setPage('reference');\r
+ };\r
+\r
+ $scope.setPage = function(pageName, object) {\r
+ $scope.wizardPage = pageName;\r
+ };\r
+\r
+ $scope.submit = function() {\r
+ //if($scope.validateForm($scope.actionsForm)){\r
+ $scope.actionInstanceNames.options.forEach(function(i) {\r
+ path = GBPActionInstanceServices.createPathObj($scope.path.tenantId, i.name);\r
+ //saveParams();\r
+\r
+ GBPActionInstanceServices.send(path, i, function(data){\r
+ $scope.sendReloadEventFromRoot('GBP_ACTION_INSTANCE_RELOAD');\r
+ }, function(){\r
+ //TODO: error cbk\r
+ });\r
+ });\r
+ \r
+ //}\r
+\r
+ //if($scope.validateForm($scope.rulesForm)){\r
+ path = GBPRuleServices.createPathObj($scope.path.tenantId, $scope.path.contractId, $scope.path.subjectId, $scope.path.ruleId);\r
+ GBPRuleServices.send(path, $scope.rule, function(data){\r
+\r
+ $scope.wizards.actionReferenceWizard = false;\r
+ \r
+ //$scope.sendReloadEventFromRoot('GBP_TENANT_RELOAD');\r
+ }, function(){\r
+ //TODO: error cbk\r
+ });\r
+ //}\r
+ //$scope.\r
+ };\r
+\r
+ $scope.$on('ACTION_RULE_WIZARD_LOAD', function(event, data){\r
+ $scope.rule = angular.copy(data.data);\r
+ $scope.path = data.path;\r
+ });\r
+\r
+ $scope.$on('WIZARD_ACTIONREF_ADD', function(event, data){\r
+ if(!$scope.rule['action-ref']) {\r
+ $scope.rule['action-ref'] = [];\r
+ }\r
+ $scope.updateList($scope.rule['action-ref'], data, "name");\r
+ });\r
+\r
+ $scope.$on('WIZARD_ACTIONREF_DELETE', function(event, data){\r
+ $scope.rule['action-ref'].splice(data, 1);\r
+ });\r
+\r
+ $scope.$on('WIZARD_ACTIONINSTANCE_ADD', function(event, data){\r
+ $scope.updateList($scope.actionInstanceNames.options, data, "name");\r
+\r
+ $scope.setPage('reference');\r
+ });\r
+\r
+ $scope.$on('GBP_TENANT_RELOAD',function(){\r
+ actionInstanceNamesLoad();\r
+ });\r
+\r
+ }]);\r
+\r
+ gbp.register.controller('actionsRefListCtrl', ['$scope', '$filter', function($scope, $filter){ \r
+ \r
+ $scope.actionReferenceForm = false;\r
+\r
+ $scope.showForm = function(object) {\r
+ $scope.actionReferenceForm = true;\r
+ $scope.newActionRefObj = object || null;\r
+ };\r
+\r
+ $scope.closeForm = function() {\r
+ $scope.actionReferenceForm = false;\r
+ };\r
+\r
+ $scope.save = function(){\r
+ $scope.$emit('WIZARD_ACTIONREF_ADD', $scope.newActionRefObj);\r
+ $scope.resetObject();\r
+ };\r
+\r
+ $scope.deleteElemAt = function(index) {\r
+ $scope.$emit('WIZARD_ACTIONREF_DELETE', index);\r
+ $scope.resetObject();\r
+ };\r
+\r
+ $scope.resetObject = function() {\r
+ $scope.newActionRefObj = null;\r
+ };\r
+\r
+ \r
+\r
+ }]);\r
+\r
+ gbp.register.controller('actionInstanceWizardCtrl', ['$scope', '$filter', 'GPBServices', 'GBPActionInstanceServices', function($scope, $filter, GPBServices, GBPActionInstanceServices){ \r
+ $scope.actionDefinitions = {'options' : [], 'labels' : "name"};\r
+ $scope.newActionObj = GBPActionInstanceServices.createObj();\r
+\r
+ var loadDefinitions = function() {\r
+ GPBServices.getDefinitions(function(classifierDefs, actionDefs) {\r
+ $scope.actionDefinitions.options = actionDefs;\r
+ //$scope.getDisplayLabelsFromCtrl('GBP_ACTIONS_LABEL', $scope.actionDefinitions);\r
+ });\r
+ };\r
+\r
+ $scope.reloadDefs = function(){\r
+ $scope.defs = angular.copy($scope.getDefinitionObjParams($scope.newActionObj['action-definition-id']));\r
+\r
+ //TODO: rework\r
+ if($scope.defs.length && $scope.defs[0].name === 'sfc-chain-name') {\r
+ GPBServices.getServiceFunctionChains(function(data) {\r
+ $scope.serviceFunctionChains = data;\r
+ });\r
+ }\r
+ };\r
+\r
+ $scope.getDefinitionObjParams = function(id){\r
+ return GPBServices.getDefinitionObjParams($scope.actionDefinitions.options, id);\r
+ };\r
+\r
+ $scope.save = function(){\r
+ $scope.newActionObj['parameter-value'] = [];\r
+ $scope.$broadcast('GBP_SAVE_PARAM');\r
+ $scope.$emit('WIZARD_ACTIONINSTANCE_ADD', $scope.newActionObj);\r
+ $scope.resetObject();\r
+ };\r
+\r
+ $scope.resetObject = function() {\r
+ $scope.newActionObj = GBPActionInstanceServices.createObj();\r
+ };\r
+\r
+ $scope.saveParam = function() {\r
+ \r
+ };\r
+\r
+ $scope.addParam = function(name, type, value) {\r
+ $scope.newActionObj['parameter-value'].push(GPBServices.createParamObj(name, type, value));\r
+ };\r
+\r
+ loadDefinitions();\r
+\r
+ }]);\r
+\r