From bd2e91686de6bc61b97ac66af47f830d1c82786a Mon Sep 17 00:00:00 2001 From: thuva4 Date: Mon, 29 Jan 2018 14:23:29 +0530 Subject: add suggestions in result page filter suggestions in results page fix ui in results page Change-Id: Id0eebd9575b5f494061130afe2c7d42c74985cec Signed-off-by: thuva4 --- .../ui/components/results/results.html | 13 ++-- .../ui/components/results/resultsController.js | 79 +++++++++++++++++++++- 2 files changed, 85 insertions(+), 7 deletions(-) (limited to 'testapi/opnfv_testapi/ui/components') diff --git a/testapi/opnfv_testapi/ui/components/results/results.html b/testapi/opnfv_testapi/ui/components/results/results.html index b0c05ba..2756bb0 100644 --- a/testapi/opnfv_testapi/ui/components/results/results.html +++ b/testapi/opnfv_testapi/ui/components/results/results.html @@ -31,8 +31,11 @@
Search:   - + + +
Start Date:   @@ -64,7 +67,7 @@
Filter:   - @@ -79,9 +82,9 @@
-
+
{{key}} : {{tag}} -
+
×
@@ -143,4 +146,4 @@ Error: {{ctrl.error}} -
+
\ No newline at end of file diff --git a/testapi/opnfv_testapi/ui/components/results/resultsController.js b/testapi/opnfv_testapi/ui/components/results/resultsController.js index 73f3c15..24f9f55 100644 --- a/testapi/opnfv_testapi/ui/components/results/resultsController.js +++ b/testapi/opnfv_testapi/ui/components/results/resultsController.js @@ -56,8 +56,12 @@ ctrl.filterList= filterList; ctrl.testFilter = testFilter ctrl.viewResult = viewResult; + ctrl.filter = "pod" + ctrl.filterValue = "pod_name" + ctrl.encodeFilter = encodeFilter ctrl.tagArray = {} + ctrl.filterOption=[] /** Mappings of Interop WG components to marketing program names. */ ctrl.targetMappings = { @@ -121,6 +125,75 @@ // ctrl.filterList(); // } + function encodeFilter(){ + ctrl.filterText = '' + ctrl.filterOption=[] + if(ctrl.filter=="pod" || ctrl.filter=="project" || ctrl.filter=="scenario"){ + var reqURL = testapiApiUrl +"/" + ctrl.filter + "s" + ctrl.datasRequest = + $http.get(reqURL).success(function (data) { + ctrl.filterData = data; + for(var index in ctrl.filterData[ctrl.filter + "s"]){ + if( ctrl.filterOption.indexOf(ctrl.filterData[ctrl.filter + "s"][index]["name"]) < 0){ + ctrl.filterOption.push(ctrl.filterData[ctrl.filter + "s"][index]["name"]) + } + } + }).catch(function (data) { + ctrl.data = null; + ctrl.showError = true; + ctrl.error = data.statusText; + }); + + } + else if(ctrl.filter=="case"){ + if("project" in ctrl.tagArray){ + var reqURL = testapiApiUrl +"/projects/"+ctrl.tagArray["project"]+"/cases" + ctrl.dataRequest = + $http.get(reqURL).success(function (data) { + ctrl.filterData = data; + for(var index in ctrl.filterData.testcases){ + if( ctrl.filterOption.indexOf(ctrl.filterData.testcases[index]["name"]) < 0){ + ctrl.filterOption.push(ctrl.filterData.testcases[index]["name"]) + } + } + }).catch(function (data) { + ctrl.data = null; + ctrl.showError = true; + ctrl.error = data.statusText; + }); + + } + else{ + var reqURL = testapiApiUrl +"/projects" + ctrl.dataRequest = + $http.get(reqURL).success(function (data) { + ctrl.projectsData = data; + for(var indexP in ctrl.projectsData.projects){ + reqURL = testapiApiUrl +"/projects/" + ctrl.projectsData.projects[indexP]["name"] +"/cases" + ctrl.datasRequest = + $http.get(reqURL).success(function (data) { + ctrl.filterData = data; + for(var index in ctrl.filterData.testcases){ + if( ctrl.filterOption.indexOf(ctrl.filterData.testcases[index]["name"]) < 0){ + ctrl.filterOption.push(ctrl.filterData.testcases[index]["name"]) + } + } + }).catch(function (data) { + ctrl.data = null; + ctrl.showError = true; + ctrl.error = data.statusText; + }); + } + }).catch(function (data) { + ctrl.data = null; + ctrl.showError = true; + ctrl.error = data.statusText; + }); + } + + } + } + function viewResult(_id){ $state.go('result', {'_id':_id}, {reload: true}); } @@ -144,7 +217,7 @@ * results. */ function filterList(){ - if(ctrl.filter && ctrl.filterText!=""){ + if(ctrl.filter && ctrl.filterText!="" && ctrl.filterText!=undefined){ ctrl.tagArray[ctrl.filter] = ctrl.filterText; } ctrl.showError = false; @@ -176,6 +249,7 @@ ctrl.data = data; ctrl.totalItems = ctrl.data.pagination.total_pages * ctrl.itemsPerPage; ctrl.currentPage = ctrl.data.pagination.current_page; + ctrl.encodeFilter(); }).error(function (error) { ctrl.data = null; ctrl.totalItems = 0; @@ -188,6 +262,7 @@ } ctrl.filterList(); + /** * This is called when the date filter calendar is opened. It * does some event handling, and sets a scope variable so the UI @@ -211,4 +286,4 @@ ctrl.filterList(); } } -})(); +})(); \ No newline at end of file -- cgit 1.2.3-korg