diff options
Diffstat (limited to '3rd_party/static/testapi-ui/components/results-report/resultsReportController.js')
-rw-r--r-- | 3rd_party/static/testapi-ui/components/results-report/resultsReportController.js | 65 |
1 files changed, 47 insertions, 18 deletions
diff --git a/3rd_party/static/testapi-ui/components/results-report/resultsReportController.js b/3rd_party/static/testapi-ui/components/results-report/resultsReportController.js index 7db6cb9..3a20227 100644 --- a/3rd_party/static/testapi-ui/components/results-report/resultsReportController.js +++ b/3rd_party/static/testapi-ui/components/results-report/resultsReportController.js @@ -90,8 +90,27 @@ } function gotoResultLog(case_name) { - var case_area = case_name.split(".")[1]; + function openFile(log_url) { + var is_reachable = false; + + $.ajax({ + url: log_url, + async: false, + success: function (response) { + is_reachable = true; + }, + error: function (response){ + alert("Log file could not be found. Please confirm this case has been executed successfully."); + } + }); + + if(is_reachable == true){ + window.open(log_url); + } + } + var log_url = "/logs/"+ctrl.testId+"/results/"; + var case_area = case_name.split(".")[1]; if (ctrl.version == '2018.01') { if (case_area == "vping") { log_url += "functest.log"; @@ -100,29 +119,39 @@ } else { log_url += case_area+"_logs/"+case_name+".log"; } - } else { + openFile(log_url); + } else if (ctrl.version == '2018.09') { log_url += case_area + "_logs/"; if (case_area == "tempest" || case_area == "security") { log_url += case_name + ".html"; } else { log_url += case_name + ".log"; } - } - var is_reachable = false; - - $.ajax({ - url: log_url, - async: false, - success: function (response) { - is_reachable = true; - }, - error: function (response){ - alert("Log file could not be found. Please confirm this case has been executed successfully."); - } - }); - - if(is_reachable == true){ - window.open(log_url); + openFile(log_url); + } else { + var test_url = testapiApiUrl + '/tests/' + ctrl.innerId; + $http.get(test_url).then(function(test_resp){ + var result_url = testapiApiUrl + '/results/' + test_resp.data.results[0]; + $http.get(result_url).then(function(result_resp){ + var keepGoing = true; + angular.forEach(result_resp.data.testcases_list, function(testcase, index) { + if (keepGoing == true) { + if (testcase.name == case_name) { + log_url += testcase.portal_key_file; + openFile(log_url); + keepGoing = false; + } + } + }); + if (keepGoing == true) { + alert("Log file could not be found. Please confirm this case has been executed successfully."); + } + }, function(result_error) { + alert('Error when get result record'); + }); + }, function(test_error) { + alert('Error when get test record'); + }); } } |