diff options
Diffstat (limited to 'testapi/opnfv_testapi/ui')
6 files changed, 95 insertions, 53 deletions
diff --git a/testapi/opnfv_testapi/ui/Gruntfile.js b/testapi/opnfv_testapi/ui/Gruntfile.js index 805ad9f..ab59475 100644 --- a/testapi/opnfv_testapi/ui/Gruntfile.js +++ b/testapi/opnfv_testapi/ui/Gruntfile.js @@ -6,7 +6,22 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-wait'); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-connect'); + grunt.loadNpmTasks('grunt-convert'); grunt.initConfig({ + convert: { + options: { + explicitArray: false, + }, + json2xml: { + options: { + xml: { + header: true + } + }, + src: ['../tests/UI/coverage/coverage.json'], + dest: '../tests/UI/coverage/coverage.xml' + } + }, connect: { server: { options: { @@ -159,6 +174,7 @@ module.exports = function (grunt) { 'wait:default', 'protractor_coverage', 'makeReport', + 'convert', 'shell:deleteFiles' ]); } diff --git a/testapi/opnfv_testapi/ui/components/pods/pods.html b/testapi/opnfv_testapi/ui/components/pods/pods.html index 8e66a9c..b5dadf5 100644 --- a/testapi/opnfv_testapi/ui/components/pods/pods.html +++ b/testapi/opnfv_testapi/ui/components/pods/pods.html @@ -19,22 +19,18 @@ <div class="col-sm-1 pull-right"> <button type="button" class="btn btn-success" ng-click="ctrl.listPods()"> <i class="fa fa-search"></i> Filter</button> + <div ng-class="{'show': ctrl.showError}" id="toast" class="error"> + <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true" ></span> + {{ctrl.error}}</div> + <div ng-class="{'show': ctrl.showSuccess}" id="toast" class="success"> + <span class="glyphicon glyphicon-ok" aria-hidden="true"></span> + {{ctrl.success}}</div> </div> <div class="col-sm-3 pull-right"> <span style="margin-top:6px">Search: </span> <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"> - <div ng-show="ctrl.showError" class="col-md-12 alert alert-danger" role="alert"> - <span class="pull-right"> {{ctrl.error}}</span> - <span class="glyphicon glyphicon-exclamation-sign pull-right" aria-hidden="true" >Error:</span> - </div> - <div ng-show="ctrl.showSuccess" class="col-md-12 alert alert-success" role="alert"> - <span class="pull-right"> {{ctrl.success}}</span> - <span class="glyphicon glyphicon-ok pull-right" aria-hidden="true"></span> - </div> -</div> <div class="col-md-12" style="padding-right:0px"> <div class="table-responsive"> <table class="table table-bordered table-hover" ng-data="ctrl.data.pods"> diff --git a/testapi/opnfv_testapi/ui/components/pods/podsController.js b/testapi/opnfv_testapi/ui/components/pods/podsController.js index c50fa5a..3b6ab97 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', 'keepState', 'sortService' + 'confirmModal', 'keepState', 'sortService', '$timeout' ]; /** @@ -30,7 +30,7 @@ * through pods declared in TestAPI. */ function PodsController($scope, $http, $filter, $state, $window, $uibModal, testapiApiUrl, - raiseAlert, confirmModal, keepState, sortService) { + raiseAlert, confirmModal, keepState, sortService, $timeout) { var ctrl = this; ctrl.url = testapiApiUrl + '/pods'; ctrl.checkBox = [] @@ -48,6 +48,18 @@ ctrl.batchDelete = batchDelete; ctrl.viewPod = viewPod ctrl.sortBy = sortBy + ctrl.toastError = toastError + ctrl.toastSuccess = toastSuccess + + function toastError() { + ctrl.showError = true + $timeout(function(){ ctrl.showError = false;}, 3000); + } + + function toastSuccess() { + ctrl.showSuccess = true + $timeout(function(){ ctrl.showSuccess = false;}, 3000); + } function sortBy(field){ ctrl.data.pods = sortService.sortFunction(ctrl.data.pods, field , ctrl.sorting[field] ) @@ -82,19 +94,21 @@ role: pod.role, details: pod.details }; - ctrl.podsRequest = - $http.post(pods_url, body).success(function (data) { - ctrl.showSuccess = true ; + ctrl.podsRequest = $http.post(pods_url, body) + + ctrl.podsRequest.success(function (data) { ctrl.success = "Create Success" + ctrl.toastSuccess() ctrl.listPods(); }).catch(function (data) { - ctrl.showError = true; ctrl.error = data.statusText; + ctrl.toastError() }); + return ctrl.podsRequest } else{ - ctrl.showError = true; ctrl.error = 'Name is missing.' + ctrl.toastError() } } @@ -124,8 +138,8 @@ } }).catch(function (data) { ctrl.data = null; - ctrl.showError = true; ctrl.error = data.statusText; + ctrl.toastError() }); } @@ -139,12 +153,12 @@ function podDelete(podName){ var pods_url = ctrl.url + "/" + podName $http.delete(pods_url).success(function(){ - ctrl.showSuccess = true ; ctrl.success = "Delete Success" + ctrl.toastSuccess() ctrl.listPods(); }).catch(function (data) { - ctrl.showError = true; ctrl.error = data.statusText; + ctrl.toastError() }); } @@ -247,9 +261,10 @@ * inputs. */ function confirm() { - $uibModalInstance.close(); if (angular.isDefined(ctrl.data.successHandler)) { - ctrl.data.successHandler(ctrl.pod); + ctrl.data.successHandler(ctrl.pod).success( function(data){ + $uibModalInstance.close(); + }) } } diff --git a/testapi/opnfv_testapi/ui/components/projects/projects.html b/testapi/opnfv_testapi/ui/components/projects/projects.html index 5d514d1..3098aa2 100644 --- a/testapi/opnfv_testapi/ui/components/projects/projects.html +++ b/testapi/opnfv_testapi/ui/components/projects/projects.html @@ -21,16 +21,12 @@ <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'> - <div ng-show="ctrl.showError" class="alert alert-danger" role="alert"> - <span class="pull-right"> {{ctrl.error}}</span> - <span class="glyphicon glyphicon-exclamation-sign pull-right" aria-hidden="true" >Error:</span> - </div> - <div ng-show="ctrl.showSuccess" class="alert alert-success" role="alert"> - <span class="pull-right"> {{ctrl.success}}</span> - <span class="glyphicon glyphicon-ok pull-right" aria-hidden="true"></span> - </div> -</div> +<div ng-class="{'show': ctrl.showError}" id="toast" class="error"> + <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true" ></span> + {{ctrl.error}}</div> +<div ng-class="{'show': ctrl.showSuccess}" id="toast" class="success"> + <span class="glyphicon glyphicon-ok" aria-hidden="true"></span> + {{ctrl.success}}</div> <div class='clo-md-12' style="padding-right:0px"> <div class="table-responsive"> <table class="table table-bordered table-hover" ng-data="ctrl.data.projects"> diff --git a/testapi/opnfv_testapi/ui/components/projects/projectsController.js b/testapi/opnfv_testapi/ui/components/projects/projectsController.js index 4f0af0f..42100bd 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', 'keepState', 'sortService' + 'raiseAlert', 'confirmModal', 'authenticate', 'keepState', 'sortService', '$timeout' ]; /** @@ -30,7 +30,7 @@ * through projects declared in TestAPI. */ function ProjectsController($scope, $http, $filter, $state, $window, $uibModal, testapiApiUrl, - raiseAlert, confirmModal, authenticate, keepState, sortService) { + raiseAlert, confirmModal, authenticate, keepState, sortService, $timeout) { var ctrl = this; ctrl.url = testapiApiUrl + '/projects'; @@ -51,27 +51,41 @@ ctrl.name = ''; ctrl.details = ''; ctrl.ascending = false; + ctrl.toastError = toastError + ctrl.toastSuccess = toastSuccess + + function toastError() { + ctrl.showError = true + $timeout(function(){ ctrl.showError = false;}, 7000); + } + + function toastSuccess() { + ctrl.showSuccess = true + $timeout(function(){ ctrl.showSuccess = false;}, 7000); + } /** * This will contact the TestAPI to create a new project. */ function create(project) { - ctrl.showError = false; - ctrl.showSuccess = false; var projects_url = ctrl.url; var body = { name: project.name, description: project.description }; - ctrl.projectsRequest = - $http.post(projects_url, body).success(function (data){ - ctrl.showSuccess = true ; - ctrl.success = "Project is successfully created." + ctrl.projectsRequest = $http.post(projects_url, body) + ctrl.projectsRequest.success(function (data){ + ctrl.success = "Project is successfully created."; ctrl.listProjects(); + ctrl.toastSuccess(); + ctrl.request = true; }).catch(function (data) { - ctrl.showError = true; ctrl.error = data.statusText; + ctrl.toastError(); + ctrl.request = false; }); + + return ctrl.projectsRequest } function sortByName(){ @@ -135,16 +149,17 @@ ctrl.showError = false; ctrl.showSuccess = false; var projectUrl = ctrl.url + '/' + name; - ctrl.testCasesRequest = - $http.put(projectUrl, project).success(function (data){ - ctrl.showSuccess = true ; + ctrl.projectRequest = $http.put(projectUrl, project) + ctrl.projectRequest.success(function (data){ ctrl.success = "Project is successfully updated." - listProjects(); + ctrl.listProjects(); + ctrl.toastSuccess(); }) .catch(function (data) { - ctrl.showError = true; ctrl.error = data.statusText; + ctrl.toastError(); }); + return ctrl.projectRequest } /** @@ -174,8 +189,8 @@ } }).catch(function (data) { ctrl.data = null; - ctrl.showError = true; ctrl.error = data.statusText; + ctrl.toastError(); }); } @@ -190,13 +205,12 @@ function projectDelete(projectName){ var projectUrl = ctrl.url + "/" + projectName $http.delete(projectUrl).success(function(){ - ctrl.showSuccess = true ; ctrl.success = "Projects is successfully deleted" + ctrl.toastSuccess(); ctrl.listProjects(); }).catch(function (data) { - ctrl.showError = true; - ctrl.showSuccess = false; ctrl.error = data.statusText; + ctrl.toastError(); }); } @@ -277,11 +291,15 @@ function confirm() { if (angular.isDefined(ctrl.data.successHandler)) { if(ctrl.project.name != ""){ - $uibModalInstance.close(); + var success = false; if(ctrl.data.project){ - ctrl.data.successHandler(ctrl.projectName, ctrl.project); + ctrl.data.successHandler(ctrl.projectName, ctrl.project).success(function (data){ + $uibModalInstance.close(); + }) }else{ - ctrl.data.successHandler(ctrl.project); + ctrl.data.successHandler(ctrl.project).success(function (data){ + $uibModalInstance.close(); + }) } }else{ ctrl.showCreateError = true; diff --git a/testapi/opnfv_testapi/ui/package.json b/testapi/opnfv_testapi/ui/package.json index dc99239..2d4eb6e 100644 --- a/testapi/opnfv_testapi/ui/package.json +++ b/testapi/opnfv_testapi/ui/package.json @@ -3,6 +3,7 @@ "grunt": "~1.0.1", "grunt-contrib-connect": "^1.0.2", "grunt-contrib-copy": "^1.0.0", + "grunt-convert": "^0.1.12", "grunt-karma": "~2.0.0", "grunt-protractor-coverage": "^0.2.18", "grunt-protractor-runner": "~5.0.0", |