From da620c17769c0357e4a9137eedbb7cf044cc38d4 Mon Sep 17 00:00:00 2001 From: Panagiotis Karalis Date: Thu, 18 Apr 2019 18:48:22 +0300 Subject: Bug fix for ONAP/OVP portals During portal review, some errors have been noticed and fixed. - 'no role', In the 'My Results' page are displayed also results from other users. - 'user,reviewer' role, In the 'My Results' page are appeared all results and not only for the current user. - 'administrator' role, The applications are not appeared in the application page - 'reviewer' role, Reviewers cannot submit votes and after few seconds a 'time out' is received. Change-Id: Ia9bc3c4fdcac1b37ac03adff64ff689ca2428c0f Signed-off-by: Panagiotis Karalis --- .../onap-ui/components/application/application.html | 5 +++-- .../components/application/applicationController.js | 20 ++++++++++++++++---- .../onap-ui/components/results/resultsController.js | 21 +++++++++++++++++++++ 3 files changed, 40 insertions(+), 6 deletions(-) (limited to '3rd_party/static/onap-ui') diff --git a/3rd_party/static/onap-ui/components/application/application.html b/3rd_party/static/onap-ui/components/application/application.html index 2238ca4..5a0a199 100644 --- a/3rd_party/static/onap-ui/components/application/application.html +++ b/3rd_party/static/onap-ui/components/application/application.html @@ -56,7 +56,8 @@ - + {{ app.creation_date | limitTo: 10 }} {{ app.owner }} {{ app.onap_version }} @@ -80,7 +81,7 @@ - diff --git a/3rd_party/static/onap-ui/components/application/applicationController.js b/3rd_party/static/onap-ui/components/application/applicationController.js index 094ffdc..134b002 100644 --- a/3rd_party/static/onap-ui/components/application/applicationController.js +++ b/3rd_party/static/onap-ui/components/application/applicationController.js @@ -20,17 +20,28 @@ .controller('ApplicationController', ApplicationController); ApplicationController.$inject = [ - '$http', '$stateParams', '$window', '$sce', + '$http', '$state', '$stateParams', '$window', '$sce', '$uibModal', 'testapiApiUrl', 'raiseAlert', 'ngDialog', '$scope' ]; /** */ - function ApplicationController($http, $stateParams, $window, $sce, + function ApplicationController($http, $state, $stateParams, $window, $sce, $uibModal, testapiApiUrl, raiseAlert, ngDialog, $scope) { var ctrl = this; + /** Check to see if this page should display community results. */ + ctrl.isAdministrator = $scope.auth.currentUser.role.indexOf('administrator') != -1; + // Should only be on user-results-page if authenticated. + if (!$scope.auth.isAuthenticated) { + $state.go('home'); + } + // Should only be on applications if administrator + if (!ctrl.isAdministrator) { + $state.go('home'); + } + function init() { ctrl.applications = []; @@ -65,7 +76,7 @@ }); } - ctrl.toggleApproveApp = function(id, approved) { + ctrl.toggleApproveApp = function(id, approved, owner) { if (approved === 'true') { var text = 'Are you sure you want to approve this application?'; } else { @@ -80,6 +91,7 @@ var data = {}; data['item'] = 'approved'; data['approved'] = approved; + data['owner'] = owner; $http.put(updateUrl, JSON.stringify(data), { transformRequest: angular.identity, @@ -95,7 +107,7 @@ } function getApplication() { - $http.get(testapiApiUrl + "/onap/cvp/applications?page=" + ctrl.currentPage + "&signed&per_page=" + ctrl.itemsPerPage).then(function(response) { + $http.get(testapiApiUrl + "/onap/cvp/applications?page=" + ctrl.currentPage + "&signed&per_page=" + ctrl.itemsPerPage + "&applications").then(function(response) { ctrl.applications = response.data.applications; ctrl.totalItems = response.data.pagination.total_pages * ctrl.itemsPerPage; ctrl.currentPage = response.data.pagination.current_page; diff --git a/3rd_party/static/onap-ui/components/results/resultsController.js b/3rd_party/static/onap-ui/components/results/resultsController.js index 5983dd8..e8187f3 100644 --- a/3rd_party/static/onap-ui/components/results/resultsController.js +++ b/3rd_party/static/onap-ui/components/results/resultsController.js @@ -552,6 +552,7 @@ var start = $filter('date')(ctrl.startDate, 'yyyy-MM-dd'); var end = $filter('date')(ctrl.endDate, 'yyyy-MM-dd'); + ctrl.PageName = null; content_url += '?page=' + ctrl.currentPage; content_url += '&per_page=' + ctrl.itemsPerPage; if (start) { @@ -562,6 +563,7 @@ } if (ctrl.isUserResults) { content_url += '&signed'; + ctrl.PageName = 'MyResults'; } else { content_url += '&status={"$ne":"private"}&review'; } @@ -572,6 +574,25 @@ ctrl.totalItems = ctrl.data.pagination.total_pages * ctrl.itemsPerPage; ctrl.currentPage = ctrl.data.pagination.current_page; ctrl.numPages = ctrl.data.pagination.total_pages; + if (ctrl.PageName === 'MyResults') { + for (var i=0; i