diff options
Diffstat (limited to 'testapi/opnfv_testapi/ui')
22 files changed, 382 insertions, 87 deletions
diff --git a/testapi/opnfv_testapi/ui/Gruntfile.js b/testapi/opnfv_testapi/ui/Gruntfile.js index d439764..805ad9f 100644 --- a/testapi/opnfv_testapi/ui/Gruntfile.js +++ b/testapi/opnfv_testapi/ui/Gruntfile.js @@ -130,7 +130,7 @@ module.exports = function (grunt) { }, local: { options: { - configFile: '../tests/UI/protractor-conf.js' + configFile: 'protractor-conf.js' } } }, diff --git a/testapi/opnfv_testapi/ui/app.js b/testapi/opnfv_testapi/ui/app.js index ae50166..ada7577 100644 --- a/testapi/opnfv_testapi/ui/app.js +++ b/testapi/opnfv_testapi/ui/app.js @@ -28,6 +28,42 @@ angular .module('testapiApp') + .service("keepState", function(){ + this.filter = {}; + }); + + angular + .module('testapiApp') + .service('sortService', function(){ + + this.sortFunction = function(data, field, ascending){ + if(ascending){ + data.sort(function(a,b) { + if (a[field].toLowerCase() > b[field].toLowerCase()) { + return -1; + } + if (a[field].toLowerCase() < b[field].toLowerCase()) { + return 1; + } + return 0; + }); + }else{ + data.sort(function(a,b) { + if (a[field].toLowerCase() < b[field].toLowerCase()) { + return -1; + } + if (a[field].toLowerCase() > b[field].toLowerCase()) { + return 1; + } + return 0; + }); + } + return data + } + }); + + angular + .module('testapiApp') .directive('dynamicModel', ['$compile', '$parse', function ($compile, $parse) { return { restrict: 'A', @@ -42,6 +78,21 @@ }; }]); + angular + .module('testapiApp') + .directive('ngEnter', function () { + return function (scope, element, attrs) { + element.bind("keydown keypress", function (event) { + if(event.which === 13) { + scope.$apply(function (){ + scope.$eval(attrs.ngEnter); + }); + event.preventDefault(); + } + }); + }; + }); + configureRoutes.$inject = ['$stateProvider', '$urlRouterProvider']; /** diff --git a/testapi/opnfv_testapi/ui/components/deploy-results/deployResults.html b/testapi/opnfv_testapi/ui/components/deploy-results/deployResults.html index 6fbaaea..380416f 100644 --- a/testapi/opnfv_testapi/ui/components/deploy-results/deployResults.html +++ b/testapi/opnfv_testapi/ui/components/deploy-results/deployResults.html @@ -15,7 +15,7 @@ <div class="col-sm-2 pull-right" ng-class="{'hidden': ctrl.filter=='start_date' || ctrl.filter=='end_date'}"> <span style="margin-top:6px">Search: </span> <input list="filter" name="filter" class="form-control search" style="display:inline;width:105px;padding-left:6px;" - ng-Model="ctrl.filterText" placeholder="Search String"> + ng-enter="ctrl.filterList()" ng-Model="ctrl.filterText" placeholder="Search String"> <datalist id="filter" ng-class="{ 'hidden' : ctrl.filterOption.length<0}"> <option ng-repeat="(index, filterValue) in ctrl.filterOption " value="{{filterValue}}">{{filterValue}}</option> </datalist> @@ -24,6 +24,7 @@ <span style="margin-top:6px">Start Date: </span> <p class="input-group" style="width:48%;display:inline-flex;"> <input type="text" class="form-control" + ng-enter="ctrl.filterList()" uib-datepicker-popup="{{ctrl.format}}" ng-model="ctrl.filterText" is-open="ctrl.startOpen" close-text="Close" /> @@ -38,6 +39,7 @@ <span style="margin-top:6px">End Date: </span> <p class="input-group" style="width:48%;display:inline-flex;"> <input type="text" class="form-control" + ng-enter="ctrl.filterList()" uib-datepicker-popup="{{ctrl.format}}" ng-model="ctrl.filterText" is-open="ctrl.endOpen" close-text="Close" /> diff --git a/testapi/opnfv_testapi/ui/components/deploy-results/deployResultsController.js b/testapi/opnfv_testapi/ui/components/deploy-results/deployResultsController.js index 5230a75..1128825 100644 --- a/testapi/opnfv_testapi/ui/components/deploy-results/deployResultsController.js +++ b/testapi/opnfv_testapi/ui/components/deploy-results/deployResultsController.js @@ -20,7 +20,8 @@ .controller('DeployResultsController', DeployResultsController); DeployResultsController.$inject = [ - '$scope', '$http', '$filter', '$state', 'testapiApiUrl','raiseAlert' + '$scope', '$http', '$filter', '$state', 'testapiApiUrl','raiseAlert', + 'keepState' ]; /** @@ -29,7 +30,7 @@ * a listing of community uploaded results. */ function DeployResultsController($scope, $http, $filter, $state, testapiApiUrl, - raiseAlert) { + raiseAlert, keepState) { var ctrl = this; ctrl.open = open; @@ -122,6 +123,15 @@ function filterList(){ if(ctrl.filter && ctrl.filterText!="" && ctrl.filterText!=undefined){ ctrl.tagArray[ctrl.filter] = ctrl.filterText; + if(!keepState.filter.deployResultFilter){ + keepState.filter.deployResultFilter = {} + } + keepState.filter.deployResultFilter[ctrl.filter] = ctrl.filterText + } + else if(Object.keys(ctrl.tagArray).length==0){ + if(keepState.filter.deployResultFilter){ + ctrl.tagArray = keepState.filter.deployResultFilter + } } ctrl.showError = false; var content_url = testapiApiUrl + '/deployresults' + diff --git a/testapi/opnfv_testapi/ui/components/pods/pod/pod.html b/testapi/opnfv_testapi/ui/components/pods/pod/pod.html index b78eb2d..6aace92 100644 --- a/testapi/opnfv_testapi/ui/components/pods/pod/pod.html +++ b/testapi/opnfv_testapi/ui/components/pods/pod/pod.html @@ -12,8 +12,8 @@ <td width="90%" class="podsTableLeftTd">{{ctrl.data.name}}</td> </tr> <tr style="padding:9px"> - <td class="podsTableTd">Owner :</td> - <td width="90%" class="podsTableLeftTd">{{ctrl.data.owner}}</td> + <td class="podsTableTd">Creator :</td> + <td width="90%" class="podsTableLeftTd">{{ctrl.data.creator}}</td> </tr> <tr style="padding:9px"> <td class="podsTableTd">Role :</td> diff --git a/testapi/opnfv_testapi/ui/components/pods/pods.html b/testapi/opnfv_testapi/ui/components/pods/pods.html index 4fa8fb1..8e66a9c 100644 --- a/testapi/opnfv_testapi/ui/components/pods/pods.html +++ b/testapi/opnfv_testapi/ui/components/pods/pods.html @@ -22,7 +22,7 @@ </div> <div class="col-sm-3 pull-right"> <span style="margin-top:6px">Search: </span> - <input type="text" class="form-control search" ng-Model="ctrl.filterText" placeholder="Search String"> + <input type="text" class="form-control search" ng-enter="ctrl.listPods()" ng-Model="ctrl.filterText" placeholder="Search String"> </div> </div> <div class="col-md-12"> @@ -42,9 +42,30 @@ <tr style=" text-align: center;"> <th style="width:1%">Bulk Select</th> - <th>Name</th> - <th>Role</th> - <th>Mode</th> + <th>Name + <a class="text-danger" ng-click="ctrl.sortBy('name')" ng-class="{ 'hidden': !ctrl.sorting['name'] }" > + <span class="glyphicon glyphicon-sort-by-alphabet pull-right" aria-hidden="true"></span> + </a> + <a class="text-danger" ng-click="ctrl.sortBy('name')" ng-class="{ 'hidden': ctrl.sorting['name'] }" > + <span class="glyphicon glyphicon-sort-by-alphabet-alt pull-right" aria-hidden="true"></span> + </a> + </th> + <th>Role + <a class="text-danger" ng-click="ctrl.sortBy('role')" ng-class="{ 'hidden': !ctrl.sorting['role']}" > + <span class="glyphicon glyphicon-sort-by-alphabet pull-right" aria-hidden="true"></span> + </a> + <a class="text-danger" ng-click="ctrl.sortBy('role')" ng-class="{ 'hidden': ctrl.sorting['role']}" > + <span class="glyphicon glyphicon-sort-by-alphabet-alt pull-right" aria-hidden="true"></span> + </a> + </th> + <th>Mode + <a class="text-danger" ng-click="ctrl.sortBy('mode')" ng-class="{ 'hidden': !ctrl.sorting['mode'] }" > + <span class="glyphicon glyphicon-sort-by-alphabet pull-right" aria-hidden="true"></span> + </a> + <a class="text-danger" ng-click="ctrl.sortBy('mode')" ng-class="{ 'hidden': ctrl.sorting['mode'] }" > + <span class="glyphicon glyphicon-sort-by-alphabet-alt pull-right" aria-hidden="true"></span> + </a> + </th> <th ng-class="{ 'hidden': !auth.isAuthenticated }">Operation</th> </tr> </thead> diff --git a/testapi/opnfv_testapi/ui/components/pods/podsController.js b/testapi/opnfv_testapi/ui/components/pods/podsController.js index 95e3571..f405ecb 100644 --- a/testapi/opnfv_testapi/ui/components/pods/podsController.js +++ b/testapi/opnfv_testapi/ui/components/pods/podsController.js @@ -21,7 +21,7 @@ PodsController.$inject = [ '$scope', '$http', '$filter', '$state', '$window', '$uibModal', 'testapiApiUrl','raiseAlert', - 'confirmModal' + 'confirmModal', 'keepState', 'sortService' ]; /** @@ -30,11 +30,12 @@ * through pods declared in TestAPI. */ function PodsController($scope, $http, $filter, $state, $window, $uibModal, testapiApiUrl, - raiseAlert, confirmModal) { + raiseAlert, confirmModal, keepState, sortService) { var ctrl = this; ctrl.url = testapiApiUrl + '/pods'; ctrl.checkBox = [] ctrl.checkBoxList = []; + ctrl.sorting = {}; ctrl.create = create; ctrl.listPods = listPods; @@ -46,7 +47,12 @@ ctrl.podDelete = podDelete ctrl.batchDelete = batchDelete; ctrl.viewPod = viewPod - ctrl.filterText = '' + ctrl.sortBy = sortBy + + function sortBy(field){ + ctrl.data.pods = sortService.sortFunction(ctrl.data.pods, field , ctrl.sorting[field] ) + ctrl.sorting[field]=!ctrl.sorting[field] + } /** * This is called when the date filter calendar is opened. It @@ -68,7 +74,6 @@ function create(pod) { ctrl.showError = false; ctrl.showSuccess = false; - console.log(pod); if(pod.name != ""){ var pods_url = ctrl.url; var body = { @@ -99,12 +104,22 @@ function listPods() { ctrl.showError = false; var reqURL = ctrl.url; - if(ctrl.filterText!=''){ + if(ctrl.filterText!=undefined){ reqURL = ctrl.url + "?name=" + ctrl.filterText } + else if(keepState.filter.podFilter){ + for (var filter in keepState.filter.podFilter){ + reqURL = ctrl.url + '?' + filter + '=' + keepState.filter.podFilter[filter] + ctrl.filterText = keepState.filter.podFilter[filter] + } + } ctrl.podsRequest = $http.get(reqURL).success(function (data) { ctrl.data = data; + ctrl.sortBy("name") + keepState.filter.podFilter = { + 'name': ctrl.filterText + } }).catch(function (data) { ctrl.data = null; ctrl.showError = true; @@ -137,7 +152,6 @@ function batchDelete(){ var index; var checkedBox = []; - console.log(ctrl.checkBox) for(index in ctrl.checkBox){ if(!ctrl.showError){ if(ctrl.checkBox[index]){ @@ -153,7 +167,13 @@ * message */ function openBatchDeleteModal() { - confirmModal("Delete",ctrl.batchDelete); + var deleteObjects = [] + for(var index in ctrl.checkBox){ + if(ctrl.checkBox[index]){ + deleteObjects.push(ctrl.data.pods[index].name) + } + } + confirmModal("Delete", 'pods', ctrl.batchDelete, deleteObjects); } /** @@ -161,8 +181,7 @@ * message */ function openDeleteModal(name) { - console.log(name) - confirmModal("Delete", ctrl.podDelete, name); + confirmModal("Delete", 'pod', ctrl.podDelete, name); } /** diff --git a/testapi/opnfv_testapi/ui/components/projects/project/project.html b/testapi/opnfv_testapi/ui/components/projects/project/project.html index 2921bd9..b6a751c 100644 --- a/testapi/opnfv_testapi/ui/components/projects/project/project.html +++ b/testapi/opnfv_testapi/ui/components/projects/project/project.html @@ -25,8 +25,8 @@ <td width="90%" class="podsTableLeftTd">{{ctrl.data.name}}</td> </tr> <tr style="padding:9px"> - <td class="podsTableTd">Owner :</td> - <td width="90%" class="podsTableLeftTd">{{ctrl.data.owner}}</td> + <td class="podsTableTd">Creator :</td> + <td width="90%" class="podsTableLeftTd">{{ctrl.data.creator}}</td> </tr> <tr style="padding:9px"> <td class="podsTableTd">Created at :</td> diff --git a/testapi/opnfv_testapi/ui/components/projects/project/testCases/testCase/testCase.html b/testapi/opnfv_testapi/ui/components/projects/project/testCases/testCase/testCase.html index 70c026a..f4bae41 100644 --- a/testapi/opnfv_testapi/ui/components/projects/project/testCases/testCase/testCase.html +++ b/testapi/opnfv_testapi/ui/components/projects/project/testCases/testCase/testCase.html @@ -16,6 +16,10 @@ <td width="90%" class="podsTableLeftTd">{{ctrl.data.project_name}}</td> </tr> <tr style="padding:9px"> + <td class="podsTableTd">Creator :</td> + <td width="90%" class="podsTableLeftTd">{{ctrl.data.creator}}</td> + </tr> + <tr style="padding:9px"> <td class="podsTableTd">Tier :</td> <td width="90%" class="podsTableLeftTd">{{ctrl.data.tier}}</td> </tr> diff --git a/testapi/opnfv_testapi/ui/components/projects/project/testCases/testCasesController.js b/testapi/opnfv_testapi/ui/components/projects/project/testCases/testCasesController.js index 6d3c245..9a865d3 100644 --- a/testapi/opnfv_testapi/ui/components/projects/project/testCases/testCasesController.js +++ b/testapi/opnfv_testapi/ui/components/projects/project/testCases/testCasesController.js @@ -84,7 +84,15 @@ * message */ function openBatchDeleteModal() { - confirmModal("Delete",ctrl.batchDelete); + var deleteObjects = [] + ctrl.checkBox.forEach(function(testcase, index){ + if(!ctrl.showError){ + if(testcase){ + deleteObjects.push(ctrl.data.testcases[index].name) + } + } + }); + confirmModal("Delete", 'testcases', ctrl.batchDelete, deleteObjects); } /** @@ -149,7 +157,7 @@ * message */ function openDeleteTestModal(name) { - confirmModal("Delete", ctrl.deleteTestCase, name); + confirmModal("Delete", 'testcases', ctrl.deleteTestCase, name); } /** diff --git a/testapi/opnfv_testapi/ui/components/projects/projects.html b/testapi/opnfv_testapi/ui/components/projects/projects.html index b6b73d4..5d514d1 100644 --- a/testapi/opnfv_testapi/ui/components/projects/projects.html +++ b/testapi/opnfv_testapi/ui/components/projects/projects.html @@ -18,7 +18,7 @@ </div> <div class="col-sm-3 pull-right"> <span style="margin-top:6px">Search: </span> - <input type="text" class="form-control search" ng-Model="ctrl.filterText" style="width:80%;" placeholder="Search By Name"> + <input type="text" class="form-control search" ng-enter="ctrl.listProjects()" ng-Model="ctrl.filterText" style="width:80%;" placeholder="Search By Name"> </div> </div> <div class='clo-md-12'> @@ -38,7 +38,14 @@ <tr style=" text-align: center;"> <th style="width: 1%;">Bulk Select</th> - <th style="width: 19%;">Name</th> + <th style="width: 19%;">Name + <a class="text-danger" ng-click="ctrl.sortByName()" ng-class="{ 'hidden': !ctrl.sortName }" > + <span class="glyphicon glyphicon-sort-by-alphabet pull-right" aria-hidden="true"></span> + </a> + <a class="text-danger" ng-click="ctrl.sortByName()" ng-class="{ 'hidden': ctrl.sortName }" > + <span class="glyphicon glyphicon-sort-by-alphabet-alt pull-right" aria-hidden="true"></span> + </a> + </th> <th style="width: 70%;">Description</th> <th style="width: 10%;" ng-class="{'hidden': ! ((auth.projectNames.length>0) && auth.isAuthenticated) && authenticate}">Operations</th> </tr> diff --git a/testapi/opnfv_testapi/ui/components/projects/projectsController.js b/testapi/opnfv_testapi/ui/components/projects/projectsController.js index 940c1e2..07a58fe 100644 --- a/testapi/opnfv_testapi/ui/components/projects/projectsController.js +++ b/testapi/opnfv_testapi/ui/components/projects/projectsController.js @@ -21,7 +21,7 @@ ProjectsController.$inject = [ '$scope', '$http', '$filter', '$state', '$window', '$uibModal', 'testapiApiUrl', - 'raiseAlert', 'confirmModal', 'authenticate' + 'raiseAlert', 'confirmModal', 'authenticate', 'keepState', 'sortService' ]; /** @@ -30,7 +30,7 @@ * through projects declared in TestAPI. */ function ProjectsController($scope, $http, $filter, $state, $window, $uibModal, testapiApiUrl, - raiseAlert, confirmModal, authenticate) { + raiseAlert, confirmModal, authenticate, keepState, sortService) { var ctrl = this; ctrl.url = testapiApiUrl + '/projects'; @@ -44,12 +44,13 @@ ctrl.openBatchDeleteModal = openBatchDeleteModal; ctrl.projectDelete = projectDelete; ctrl.batchDelete = batchDelete; + ctrl.sortByName = sortByName ctrl.checkBox = []; ctrl.checkBoxList = []; ctrl.name = ''; ctrl.details = ''; - ctrl.filterText=''; + ctrl.ascending = false; /** * This will contact the TestAPI to create a new project. @@ -73,6 +74,11 @@ }); } + function sortByName(){ + ctrl.data.projects = sortService.sortFunction(ctrl.data.projects, 'name', ctrl.ascending) + ctrl.ascending = !ctrl.ascending + } + /** * This will open the modal that will show the create * project view @@ -148,13 +154,22 @@ ctrl.showError = false; var content_url = ctrl.url + '?'; var filterText = ctrl.filterText; - if(filterText != ''){ + if(filterText != undefined){ content_url = content_url + 'name=' + filterText; } + else if(keepState.filter.projectFilter){ + for (var filter in keepState.filter.projectFilter){ + content_url = content_url + filter + '=' + keepState.filter.projectFilter[filter] + ctrl.filterText = keepState.filter.projectFilter[filter] + } + } ctrl.resultsRequest = $http.get(content_url).success(function (data) { ctrl.data = data; + keepState.filter.projectFilter = { + 'name': ctrl.filterText + } }).catch(function (data) { ctrl.data = null; ctrl.showError = true; @@ -204,7 +219,15 @@ * message */ function openBatchDeleteModal() { - confirmModal("Delete",ctrl.batchDelete); + var deleteObjects = [] + ctrl.checkBox.forEach(function(project, index){ + if(!ctrl.showError){ + if(project){ + deleteObjects.push(ctrl.data.projects[index].name) + } + } + }); + confirmModal("Delete", 'projects', ctrl.batchDelete, deleteObjects); } /** @@ -212,7 +235,7 @@ * message */ function openDeleteModal(name) { - confirmModal("Delete", ctrl.projectDelete, name); + confirmModal("Delete",'projects', ctrl.projectDelete, name); } ctrl.listProjects(); diff --git a/testapi/opnfv_testapi/ui/components/results/results.html b/testapi/opnfv_testapi/ui/components/results/results.html index b0c05ba..e1413d5 100644 --- a/testapi/opnfv_testapi/ui/components/results/results.html +++ b/testapi/opnfv_testapi/ui/components/results/results.html @@ -1,22 +1,5 @@ <h3>{{ctrl.pageHeader}}</h3> <p>{{ctrl.pageParagraph}}</p> -<form class="form-inline" ng-show="ctrl.isUserResults"> -<h4>Upload Results</h4> -<div class="form-group col-m-3"> - <input class="form-contrl btn btn-default" type = "file" file-model = "resultFile"/> -</div> -<div class="checkbox col-m-1"> - <label> - <input type="checkbox" ng-model="ctrl.isPublic">public - </label> -</div> -<div class="form-group col-m-3"> - <button class="btn btn-primary" ng-click = "ctrl.uploadFile()">upload result</button> -</div> -<div> -<lable>{{ctrl.uploadState}}</label> -</div> -</form> <div class="row" style="margin-bottom:24px;"></div> <div class="result-filters" style="border-top: none;"> <div class="row podTable" style="vertical-align:middle"> @@ -31,13 +14,17 @@ </div> <div class="col-sm-2 pull-right" ng-class="{'hidden': ctrl.filter=='start_date' || ctrl.filter=='end_date'}"> <span style="margin-top:6px">Search: </span> - <input type="text" class="form-control search" style="display:inline;width:105px;padding-left:6px;" + <input list="filter" ng-enter="ctrl.filterList()" name="filter" class="form-control search" style="display:inline;width:105px;padding-left:6px;" ng-Model="ctrl.filterText" placeholder="Search String"> + <datalist id="filter" ng-class="{ 'hidden' : ctrl.filterOption.length<0}"> + <option ng-repeat="(index, filterValue) in ctrl.filterOption " value="{{filterValue}}">{{filterValue}}</option> + </datalist> </div> <div class="col-sm-3 pull-right" style="width:20%" ng-class="{'hidden': ctrl.filter!='start_date'}"> <span style="margin-top:6px">Start Date: </span> <p class="input-group" style="width:48%;display:inline-flex;"> <input type="text" class="form-control" + ng-enter="ctrl.filterList()" uib-datepicker-popup="{{ctrl.format}}" ng-model="ctrl.filterText" is-open="ctrl.startOpen" close-text="Close" /> @@ -52,6 +39,7 @@ <span style="margin-top:6px">End Date: </span> <p class="input-group" style="width:48%;display:inline-flex;"> <input type="text" class="form-control" + ng-enter="ctrl.filterList()" uib-datepicker-popup="{{ctrl.format}}" ng-model="ctrl.filterText" is-open="ctrl.endOpen" close-text="Close" /> @@ -64,7 +52,7 @@ </div> <div class="col-md-2 row pull-right" style="width: 20%;"> <span style="margin-top:6px">Filter: </span> - <select ng-model="ctrl.filter" class="form-control" style="display:inline; width:150px;"> + <select ng-model="ctrl.filter" ng-change="ctrl.encodeFilter()" class="form-control" style="display:inline; width:150px;"> <option value="pod" ng-disabled="ctrl.testFilter('pod')" >Pod Name</option> <option value="project" ng-disabled="ctrl.testFilter('project')" >Project Name</option> <option value="case" ng-disabled="ctrl.testFilter('case')">Case Name</option> @@ -79,9 +67,9 @@ </div> <div class='filter-box'> - <div class='filter-tag' ng-repeat="(key, tag) in ctrl.tagArray"> + <div class='filter-tag col-md-1' ng-repeat="(key, tag) in ctrl.tagArray" style="background-color: #f5f5f5;border: 1px solid #e3e3e3;/* border: 1px; */margin-top: 3px;padding: 4px;margin-left: 15px;width: 13%;"> {{key}} : {{tag}} - <div class='delete-tag' ng-click='ctrl.deleteTag(key)'> + <div class='delete-tag btn btn-danger btn-xs' ng-click='ctrl.deleteTag(key)'> × </div> </div> @@ -143,4 +131,4 @@ <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> <span class="sr-only">Error:</span> {{ctrl.error}} -</div> +</div>
\ 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..13ead6e 100644 --- a/testapi/opnfv_testapi/ui/components/results/resultsController.js +++ b/testapi/opnfv_testapi/ui/components/results/resultsController.js @@ -38,7 +38,8 @@ }]); ResultsController.$inject = [ - '$scope', '$http', '$filter', '$state', 'testapiApiUrl','raiseAlert' + '$scope', '$http', '$filter', '$state', 'testapiApiUrl', 'raiseAlert', + 'keepState' ]; /** @@ -47,7 +48,7 @@ * a listing of community uploaded results. */ function ResultsController($scope, $http, $filter, $state, testapiApiUrl, - raiseAlert) { + raiseAlert, keepState) { var ctrl = this; ctrl.open = open; @@ -56,8 +57,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 +126,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,8 +218,17 @@ * results. */ function filterList(){ - if(ctrl.filter && ctrl.filterText!=""){ + if(ctrl.filter && ctrl.filterText!="" && ctrl.filterText!=undefined){ ctrl.tagArray[ctrl.filter] = ctrl.filterText; + if(!keepState.filter.resultFilter){ + keepState.filter.resultFilter = {} + } + keepState.filter.resultFilter[ctrl.filter] = ctrl.filterText + } + else if(Object.keys(ctrl.tagArray).length==0){ + if(keepState.filter.resultFilter){ + ctrl.tagArray = keepState.filter.resultFilter + } } ctrl.showError = false; var content_url = testapiApiUrl + '/results' + @@ -176,6 +259,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; @@ -186,8 +270,10 @@ }); ctrl.filterText = '' } + 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 @@ -208,7 +294,8 @@ function clearFilters() { ctrl.tagArray = {} ctrl.filter = undefined + keepState.filter.resultFilter = {} ctrl.filterList(); } } -})(); +})();
\ No newline at end of file diff --git a/testapi/opnfv_testapi/ui/components/scenarios/modals/customModal.html b/testapi/opnfv_testapi/ui/components/scenarios/modals/customModal.html index 987cb1e..0cd2663 100644 --- a/testapi/opnfv_testapi/ui/components/scenarios/modals/customModal.html +++ b/testapi/opnfv_testapi/ui/components/scenarios/modals/customModal.html @@ -6,11 +6,19 @@ <legend>{{customModalCtrl.data.text}}</legend> <div class="row"> <div class="update-project"> - <label for="cpid" class="control-label col-sm-4">Custom: </label> - <div class="col-sm-6"> - <input type="text" class="form-control" ng-model="customModalCtrl.custom"/> - <p class="help-block"></p> - </div> + <label for="cpid" class="control-label col-sm-4">Custom: </label> + <table cellpadding="0" cellspacing="0"> + <tbody> + <tr> + <td> + <div class="col-sm-12"> + <input type="text" class="form-control" ng-model="customModalCtrl.custom"/> + <p class="help-block"></p> + </div> + </td> + </tr> + </tbody> + </table> </div> </div> </div> diff --git a/testapi/opnfv_testapi/ui/components/scenarios/modals/projectModal.html b/testapi/opnfv_testapi/ui/components/scenarios/modals/projectModal.html index 0a14be9..171cc33 100644 --- a/testapi/opnfv_testapi/ui/components/scenarios/modals/projectModal.html +++ b/testapi/opnfv_testapi/ui/components/scenarios/modals/projectModal.html @@ -38,7 +38,7 @@ </tr> </thead> <tbody> - <tr ng-repeat-start="(index, custom) in projectModalCtrl.project.customs" style="padding:9px"> + <tr ng-repeat-start="custom in projectModalCtrl.project.customs" style="padding:9px"> <td>{{custom}}</td> </tr> <tr ng-repeat-end=> diff --git a/testapi/opnfv_testapi/ui/components/scenarios/scenario/scenario.html b/testapi/opnfv_testapi/ui/components/scenarios/scenario/scenario.html index 2a73e9b..4f0a580 100644 --- a/testapi/opnfv_testapi/ui/components/scenarios/scenario/scenario.html +++ b/testapi/opnfv_testapi/ui/components/scenarios/scenario/scenario.html @@ -12,6 +12,10 @@ <td width="90%" class="podsTableLeftTd">{{ctrl.data.scenarios[0].name}}</td> </tr> <tr style="padding:9px"> + <td class="podsTableTd">Creator :</td> + <td width="90%" class="podsTableLeftTd">{{ctrl.data.scenarios[0].creator}}</td> + </tr> + <tr style="padding:9px"> <td class="podsTableTd">Created at :</td> <td width="90%" class="podsTableLeftTd">{{ctrl.data.scenarios[0].creation_date}}</td> </tr> diff --git a/testapi/opnfv_testapi/ui/components/scenarios/scenario/scenarioController.js b/testapi/opnfv_testapi/ui/components/scenarios/scenario/scenarioController.js index 9935649..a0cd5eb 100644 --- a/testapi/opnfv_testapi/ui/components/scenarios/scenario/scenarioController.js +++ b/testapi/opnfv_testapi/ui/components/scenarios/scenario/scenarioController.js @@ -219,7 +219,7 @@ var data = { "installers": installers } - confirmModal("Delete",ctrl.deleteInstaller,data); + confirmModal("Delete", 'installers', ctrl.deleteInstaller, data); } function addInstaller(installer){ @@ -273,7 +273,7 @@ "version": versions, "installer": installer } - confirmModal("Delete",ctrl.deleteVersion,data); + confirmModal("Delete", "version", ctrl.deleteVersion, data); } function deleteVersion(data){ @@ -359,7 +359,7 @@ "version": version, "installer": installer } - confirmModal("Delete",ctrl.deleteCustom,data); + confirmModal("Delete", 'customs', ctrl.deleteCustom, data); } function deleteCustom(data){ @@ -402,7 +402,7 @@ "version": version, "installer": installer } - confirmModal("Delete",ctrl.deleteProject,data); + confirmModal("Delete", 'projects', ctrl.deleteProject, data); } function deleteProject(data){ @@ -434,16 +434,15 @@ ctrl.confirm = confirm; ctrl.cancel = cancel; ctrl.data = angular.copy(data); - ctrl.open = open; + ctrl.customs = []; - /** - * Initiate confirmation and call the success handler with the - * inputs. - */ function confirm() { - ctrl.customs = [] - ctrl.customs.push(ctrl.custom) + var custom = ctrl.custom; + if(custom!="" && custom!=undefined ){ + ctrl.customs = custom.split(/[ ,]+/).filter(Boolean); + } + console.log(ctrl.customs) ctrl.data.successHandler(ctrl.customs,ctrl.data.project,ctrl.data.version,ctrl.data.installer); $uibModalInstance.dismiss('cancel'); diff --git a/testapi/opnfv_testapi/ui/components/scenarios/scenariosController.js b/testapi/opnfv_testapi/ui/components/scenarios/scenariosController.js index fd137e5..98e4089 100644 --- a/testapi/opnfv_testapi/ui/components/scenarios/scenariosController.js +++ b/testapi/opnfv_testapi/ui/components/scenarios/scenariosController.js @@ -65,7 +65,7 @@ } function openDeleteModal(name){ - confirmModal("Delete",ctrl.deleteScenario,name); + confirmModal("Delete", 'scenarios', ctrl.deleteScenario,name); } function deleteScenario(name){ @@ -82,15 +82,23 @@ } function openBatchDeleteModal(){ - confirmModal("Delete",ctrl.deleteBatchScenario); + var deleteObjects = [] + ctrl.checkBox.forEach(function(scenario, index){ + if(!ctrl.showError){ + if(scenario){ + deleteObjects.push(ctrl.data.scenarios[index].name); + } + } + }); + confirmModal("Delete", 'scenarios', ctrl.deleteBatchScenario, deleteObjects); } function deleteBatchScenario(){ var index; var checkedBox = []; - ctrl.checkBox.forEach(function(project, index){ + ctrl.checkBox.forEach(function(scenario, index){ if(!ctrl.showError){ - if(project){ + if(scenario){ deleteScenario(ctrl.data.scenarios[index].name); } } @@ -119,7 +127,6 @@ } function createScenario(scenario) { - console.log(scenario) ctrl.scenarioRequest = $http.post(ctrl.url, scenario).success(function (data){ ctrl.showCreateSuccess = true; @@ -262,7 +269,6 @@ } function openVersionModal(){ - console.log("Hello"); $uibModal.open({ templateUrl: 'testapi-ui/components/scenarios/modals/versionModal.html', controller: 'versionModalCtrl as versionModalCtrl', @@ -375,8 +381,10 @@ $uibModalInstance.dismiss('cancel'); } - function handleModalCustom(custom){ - ctrl.project.customs.push(custom); + function handleModalCustom(customs){ + for (var custom in customs){ + ctrl.project.customs.push(customs[custom]); + } } function openCustomModal(){ @@ -410,6 +418,7 @@ ctrl.cancel = cancel; ctrl.data = angular.copy(data); ctrl.open = open; + ctrl.customs = [] /** @@ -417,7 +426,11 @@ * inputs. */ function confirm() { - ctrl.data.successHandler(ctrl.custom); + var custom = ctrl.custom; + if(custom!="" && custom!=undefined ){ + ctrl.customs = custom.split(/[ ,]+/).filter(Boolean); + } + ctrl.data.successHandler(ctrl.customs); $uibModalInstance.dismiss('cancel'); } diff --git a/testapi/opnfv_testapi/ui/protractor-conf.js b/testapi/opnfv_testapi/ui/protractor-conf.js new file mode 100644 index 0000000..affbe5d --- /dev/null +++ b/testapi/opnfv_testapi/ui/protractor-conf.js @@ -0,0 +1,18 @@ +exports.config = { + seleniumAddress: 'http://localhost:4444/wd/hub', + capabilities: { + 'browserName': 'chrome', + 'chromeOptions': { + 'args': ['show-fps-counter=true', '--disable-web-security', "no-sandbox", "--headless", "--disable-gpu"] + } + }, + jasmineNodeOpts: { + showColors: true, + defaultTimeoutInterval: 30000 + }, + onPrepare: function(){ + require('protractor-http-mock').config = { + rootDirectory: __dirname + }; + } +}; diff --git a/testapi/opnfv_testapi/ui/shared/alerts/confirmModal.html b/testapi/opnfv_testapi/ui/shared/alerts/confirmModal.html index e5397e0..417af37 100644 --- a/testapi/opnfv_testapi/ui/shared/alerts/confirmModal.html +++ b/testapi/opnfv_testapi/ui/shared/alerts/confirmModal.html @@ -10,7 +10,7 @@ </div> <div class="Delete" ng-class="{ 'hidden': confirmModal.data.text!='Delete' }"> <div class="form-group"> - <label for="confirmText"> You are about to delete.</label> + <label for="confirmText"> You are about to delete following {{confirmModal.data.resource}} : {{confirmModal.deleteObjects}} </label> <br> Do you want to proceed? </div> diff --git a/testapi/opnfv_testapi/ui/shared/alerts/confirmModalFactory.js b/testapi/opnfv_testapi/ui/shared/alerts/confirmModalFactory.js index 5e79775..0286341 100644 --- a/testapi/opnfv_testapi/ui/shared/alerts/confirmModalFactory.js +++ b/testapi/opnfv_testapi/ui/shared/alerts/confirmModalFactory.js @@ -11,17 +11,19 @@ * Opens confirm modal dialog with input textbox */ function confirmModal($uibModal) { - return function(text, successHandler, name) { + return function(text, resource, successHandler, name) { $uibModal.open({ - templateUrl: '/testapi-ui/shared/alerts/confirmModal.html', + templateUrl: 'testapi-ui/shared/alerts/confirmModal.html', controller: 'CustomConfirmModalController as confirmModal', size: 'md', resolve: { data: function () { return { text: text, + resource: resource, successHandler: successHandler, name: name + }; } } @@ -44,8 +46,37 @@ ctrl.confirm = confirm; ctrl.cancel = cancel; - + ctrl.buildDeleteObjects = buildDeleteObjects; ctrl.data = angular.copy(data); + + function buildDeleteObjects(){ + ctrl.deleteObjects = ''; + if (typeof ctrl.data.name === 'string') { + ctrl.deleteObjects = ctrl.data.name + } + else if (ctrl.data.name instanceof Array){ + for(var index in ctrl.data.name){ + if(index==0){ + ctrl.deleteObjects += ctrl.data.name[index] + } + else{ + ctrl.deleteObjects += ", "+ ctrl.data.name[index] + } + + } + } + else{ + for(var index in ctrl.data.name[ctrl.data.resource]){ + if(index==0){ + ctrl.deleteObjects += ctrl.data.name[ctrl.data.resource][index] + } + else{ + ctrl.deleteObjects += ", "+ ctrl.data.name[ctrl.data.resource][index] + } + + } + } + } /** * Initiate confirmation and call the success handler with the * input text. @@ -63,5 +94,7 @@ function cancel() { $uibModalInstance.dismiss('cancel'); } + + ctrl.buildDeleteObjects(); } })(); |