diff options
author | Jack Chan <chenjiankun1@huawei.com> | 2018-03-16 09:01:07 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2018-03-16 09:01:07 +0000 |
commit | a6a54f115cb55a4cf91df24e9b894f89b232dae8 (patch) | |
tree | a18847a270f64710d5daefd73cfdb5622134c3e6 /gui/app/scripts/controllers | |
parent | 8fe2c9fd13783fc5aa0f3b488274b5f892f2f260 (diff) | |
parent | 1d2acc900a695bee5c1d83d7631725e4d8b18df0 (diff) |
Merge "Supporting user config task parameters in GUI"
Diffstat (limited to 'gui/app/scripts/controllers')
-rw-r--r-- | gui/app/scripts/controllers/projectDetail.controller.js | 34 | ||||
-rw-r--r-- | gui/app/scripts/controllers/taskModify.controller.js | 63 |
2 files changed, 84 insertions, 13 deletions
diff --git a/gui/app/scripts/controllers/projectDetail.controller.js b/gui/app/scripts/controllers/projectDetail.controller.js index e8468045d..353e02bcf 100644 --- a/gui/app/scripts/controllers/projectDetail.controller.js +++ b/gui/app/scripts/controllers/projectDetail.controller.js @@ -439,15 +439,36 @@ angular.module('yardStickGui2App') $scope.displayTable = false; $scope.contentInfo = response.result.testcase; + $scope.optionalParams = response.result.args; } }, function(error) { - toaster.pop({ - type: 'error', - title: 'fail', - body: 'unknow error', - timeout: 3000 - }); + mainFactory.errorHandler2(error); + }) + } + + + function addParamsToTask(){ + var params = {} + angular.forEach($scope.optionalParams, function(value, name){ + if(value.value){ + params[name] = value.value; + } + }); + + mainFactory.taskAddParams().put({ + 'taskId': $scope.newUUID, + 'action': 'add_params', + 'args': { + 'params': params + } + }).$promise.then(function(resp) { + if (resp.status == 1) { + } else { + mainFactory.errorHandler1(resp); + } + }, function(error) { + mainFactory.errorHandler2(error); }) } @@ -530,6 +551,7 @@ angular.module('yardStickGui2App') function confirmAddCaseOrSuite(content) { if ($scope.selectType.name == "Test Case") { addCasetoTask(content); + addParamsToTask(); } else { addSuitetoTask(content); } diff --git a/gui/app/scripts/controllers/taskModify.controller.js b/gui/app/scripts/controllers/taskModify.controller.js index 757d65866..c9672fea8 100644 --- a/gui/app/scripts/controllers/taskModify.controller.js +++ b/gui/app/scripts/controllers/taskModify.controller.js @@ -20,6 +20,7 @@ angular.module('yardStickGui2App') $scope.constructTestSuit = constructTestSuit; $scope.constructTestCase = constructTestCase; $scope.getTestDeatil = getTestDeatil; + $scope.getTestcaseArgs = getTestcaseArgs; $scope.confirmToServer = confirmToServer; $scope.addEnvToTask = addEnvToTask; } @@ -46,6 +47,8 @@ angular.module('yardStickGui2App') getItemIdDetail($scope.taskDetailData.environment_id); } + getTestcaseArgs(); + } }, function(error) { toaster.pop({ @@ -277,7 +280,6 @@ angular.module('yardStickGui2App') function getTestDeatil() { - if ($scope.selectType.name == 'Test Case') { getTestcaseDetail(); } else { @@ -307,6 +309,29 @@ angular.module('yardStickGui2App') } + function getTestcaseArgs(){ + mainFactory.getTestcaseDetail().get({ + 'testcasename': $scope.taskDetailData.case_name + }).$promise.then(function(resp){ + if(resp.status == 1){ + $scope.optionalParams = resp.result.args; + var params = $scope.taskDetailData.params; + if(params){ + angular.forEach($scope.optionalParams, function(value, name){ + if(name in params){ + value.value = params[name]; + } + }); + } + }else{ + mainFactory.errorHandler1(resp); + } + }, function(error){ + mainFactory.errorHandler2(error); + }); + } + + function getTestcaseDetail() { mainFactory.getTestcaseDetail().get({ 'testcasename': $scope.selectCase @@ -316,15 +341,13 @@ angular.module('yardStickGui2App') $scope.displayTable = false; $scope.contentInfo = response.result.testcase; + $scope.optionalParams = response.result.args; + }else{ + mainFactory.errorHandler1(response); } }, function(error) { - toaster.pop({ - type: 'error', - title: 'fail', - body: 'unknow error', - timeout: 3000 - }); + mainFactory.errorHandler2(error); }) } @@ -426,12 +449,38 @@ angular.module('yardStickGui2App') if ($scope.selectCase == 'Test Case' || $scope.taskDetailData.suite == false) { addCasetoTask(content); + addParamsToTask(); } else { addSuitetoTask(content); } } + function addParamsToTask(){ + var params = {} + angular.forEach($scope.optionalParams, function(value, name){ + if(value.value){ + params[name] = value.value; + } + }); + + mainFactory.taskAddParams().put({ + 'taskId': $stateParams.taskId, + 'action': 'add_params', + 'args': { + 'params': params + } + }).$promise.then(function(resp) { + if (resp.status == 1) { + } else { + mainFactory.errorHandler1(resp); + } + }, function(error) { + mainFactory.errorHandler2(error); + }) + } + + function addEnvToTask() { mainFactory.taskAddEnv().put({ |