diff options
author | xudan <xudan16@huawei.com> | 2019-08-29 03:39:06 -0400 |
---|---|---|
committer | xudan <xudan16@huawei.com> | 2019-08-29 03:39:06 -0400 |
commit | 6f69c36f312efe9c2e2367aafce451d1e5d3152a (patch) | |
tree | 818ce8371a95182b4ac69aa87d0cb5bae1640fc0 | |
parent | 590ffcdc7732b700f054fb45aad262a4b95f8f3e (diff) |
Update portal to get portal_key_file from results.json
Change-Id: I210a9c240b720e3367134112ad2cdb5c3fdeffe0
Signed-off-by: xudan <xudan16@huawei.com>
-rw-r--r-- | 3rd_party/static/onap-ui/components/results-report/resultsReportController.js | 62 | ||||
-rw-r--r-- | 3rd_party/static/testapi-ui/components/results-report/resultsReportController.js | 65 |
2 files changed, 93 insertions, 34 deletions
diff --git a/3rd_party/static/onap-ui/components/results-report/resultsReportController.js b/3rd_party/static/onap-ui/components/results-report/resultsReportController.js index 09601ad..1997c3d 100644 --- a/3rd_party/static/onap-ui/components/results-report/resultsReportController.js +++ b/3rd_party/static/onap-ui/components/results-report/resultsReportController.js @@ -78,24 +78,54 @@ } function gotoResultLog(case_name) { - var case_area = case_name.split(".")[0]; - var log_url = "/logs/" + ctrl.testId + "/results/"; - log_url += case_area + "_logs/" + case_name + ".out"; - 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."); + 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); } - }); + } - if (is_reachable == true) { - window.open(log_url); + var log_url = "/logs/" + ctrl.testId + "/results/"; + if (ctrl.version == '2019.04') { + var case_area = case_name.split(".")[0]; + log_url += case_area + "_logs/" + case_name + ".out"; + openFile(log_url); + } else { + var test_url = testapiApiUrl + '/onap/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'); + }); } } 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'); + }); } } |