diff --git a/static/resources/js/components/details/retrieve-projects.directive.js b/static/resources/js/components/details/retrieve-projects.directive.js index a8d18e6bf..9d8e8731f 100644 --- a/static/resources/js/components/details/retrieve-projects.directive.js +++ b/static/resources/js/components/details/retrieve-projects.directive.js @@ -44,7 +44,7 @@ } function getProjectSuccess(data, status) { - vm.projects = data; + vm.projects = data || []; if(!angular.isDefined(vm.projects)) { vm.isPublic = 1; @@ -77,11 +77,11 @@ }); } - function getProjectFailed(response) { - $scope.$emit('modalTitle', $filter('tr')('error')); - $scope.$emit('modalMessage', $filter('tr')('failed_to_get_project')); - $scope.$emit('raiseError', true); - console.log('Failed to list projects:' + response); + function getProjectFailed() { +// $scope.$emit('modalTitle', $filter('tr')('error')); +// $scope.$emit('modalMessage', $filter('tr')('failed_to_get_project')); +// $scope.$emit('raiseError', true); + console.log('Failed to list projects.'); } function selectItem(item) { diff --git a/static/resources/js/components/inline-help/inline-help.directive.html b/static/resources/js/components/inline-help/inline-help.directive.html index 3855f535b..4d32d2971 100644 --- a/static/resources/js/components/inline-help/inline-help.directive.html +++ b/static/resources/js/components/inline-help/inline-help.directive.html @@ -1,5 +1,3 @@ - + \ No newline at end of file diff --git a/static/resources/js/components/project-member/edit-project-member.directive.html b/static/resources/js/components/project-member/edit-project-member.directive.html index 7dff549c5..09627f501 100644 --- a/static/resources/js/components/project-member/edit-project-member.directive.html +++ b/static/resources/js/components/project-member/edit-project-member.directive.html @@ -2,7 +2,7 @@ - + diff --git a/static/resources/js/components/project/add-project.directive.html b/static/resources/js/components/project/add-project.directive.html index 16fa3c9d5..52c0d50d3 100644 --- a/static/resources/js/components/project/add-project.directive.html +++ b/static/resources/js/components/project/add-project.directive.html @@ -14,7 +14,7 @@
 // 'public' | tr // - +
diff --git a/static/resources/js/components/project/publicity-button.directive.js b/static/resources/js/components/project/publicity-button.directive.js index 5d86eb0f1..84c1f4322 100644 --- a/static/resources/js/components/project/publicity-button.directive.js +++ b/static/resources/js/components/project/publicity-button.directive.js @@ -6,19 +6,38 @@ .module('harbor.project') .directive('publicityButton', publicityButton); - PublicityButtonController.$inject = ['ToggleProjectPublicityService']; + PublicityButtonController.$inject = ['$scope', 'ToggleProjectPublicityService', '$filter', 'trFilter']; - function PublicityButtonController(ToggleProjectPublicityService) { + function PublicityButtonController($scope, ToggleProjectPublicityService, $filter, trFilter) { var vm = this; vm.toggle = toggle; - if(vm.isPublic === 1) { - vm.isPublic = true; - }else{ - vm.isPublic = false; + function toggle() { + if(vm.isPublic) { + vm.isPublic = false; + }else{ + vm.isPublic = true; + } + ToggleProjectPublicityService(vm.projectId, vm.isPublic) + .success(toggleProjectPublicitySuccess) + .error(toggleProjectPublicityFailed); } - - function toggle() { + + function toggleProjectPublicitySuccess(data, status) { + + console.log('Successful toggle project publicity.'); + } + + function toggleProjectPublicityFailed(e, status) { + $scope.$emit('modalTitle', $filter('tr')('error')); + var message; + if(status === 403) { + message = $filter('tr')('failed_to_toggle_publicity_insuffient_permissions'); + }else{ + message = $filter('tr')('failed_to_toggle_publicity'); + } + $scope.$emit('modalMessage', message); + $scope.$emit('raiseError', true); if(vm.isPublic) { vm.isPublic = false; @@ -26,16 +45,6 @@ vm.isPublic = true; } - ToggleProjectPublicityService(vm.projectId, vm.isPublic) - .success(toggleProjectPublicitySuccess) - .error(toggleProjectPublicityFailed); - } - - function toggleProjectPublicitySuccess(data, status) { - console.log('Successful toggle project publicity.'); - } - - function toggleProjectPublicityFailed(e) { console.log('Failed to toggle project publicity:' + e); } } @@ -57,7 +66,11 @@ return directive; function link(scope, element, attr, ctrl) { - + scope.$watch('vm.isPublic', function(current, origin) { + if(current) { + ctrl.isPublic = current; + } + }); } } diff --git a/static/resources/js/components/repository/list-tag.directive.js b/static/resources/js/components/repository/list-tag.directive.js index 38b3abb79..c797bd5cf 100644 --- a/static/resources/js/components/repository/list-tag.directive.js +++ b/static/resources/js/components/repository/list-tag.directive.js @@ -31,13 +31,13 @@ function retrieve() { ListTagService(vm.repoName) - .then(getTagComplete) - .catch(getTagFailed); + .success(getTagSuccess) + .error(getTagFailed); } - function getTagComplete(response) { + function getTagSuccess(data) { - vm.tags = response.data; + vm.tags = data || []; vm.tagCount[vm.repoName] = vm.tags.length; $scope.$emit('tags', vm.tags); @@ -48,11 +48,11 @@ }); } - function getTagFailed(response) { + function getTagFailed(data) { $scope.$emit('modalTitle', $filter('tr')('error')); $scope.$emit('modalMessage', $filter('tr')('failed_to_get_tag') + response); $scope.$emit('raiseError', true); - console.log('Failed to get tag:' + response); + console.log('Failed to get tag:' + data); } function deleteTag(e) { diff --git a/static/resources/js/components/system-management/create-destination.directive.html b/static/resources/js/components/system-management/create-destination.directive.html index a5f1f5064..04f076570 100644 --- a/static/resources/js/components/system-management/create-destination.directive.html +++ b/static/resources/js/components/system-management/create-destination.directive.html @@ -49,7 +49,7 @@
- +
diff --git a/static/resources/js/components/system-management/create-destination.directive.js b/static/resources/js/components/system-management/create-destination.directive.js index e9ca2f635..a1f39b42d 100644 --- a/static/resources/js/components/system-management/create-destination.directive.js +++ b/static/resources/js/components/system-management/create-destination.directive.js @@ -21,7 +21,7 @@ vm.pingDestination = pingDestination; vm.editable = true; - vm.notAvailable = true; + vm.notAvailable = false; vm.pingAvailable = true; vm.pingMessage = ''; @@ -40,7 +40,6 @@ }); function addNew() { - vm.editable = true; vm.modalTitle = $filter('tr')('add_new_destination', []); vm0.name = ''; vm0.endpoint = ''; @@ -153,7 +152,7 @@ function pingDestinationFailed(data, status) { vm.pingTIP = false; - vm.pingMessage = $filter('tr')('failed_to_ping_target', []) + (data && data.length > 0 ? ':' + data : '.'); + vm.pingMessage = $filter('tr')('failed_to_ping_target', []) + (data && data.length > 0 ? ':' + data : ''); } } @@ -176,34 +175,34 @@ function link(scope, element, attrs, ctrl) { element.find('#createDestinationModal').on('show.bs.modal', function() { - - scope.form.$setPristine(); - scope.form.$setUntouched(); - - ctrl.notAvailble = true; - ctrl.pingAvailable = true; - ctrl.pingMessage = ''; - - ctrl.pingTIP = false; - ctrl.toggleErrorMessage = false; - ctrl.errorMessages = []; - - switch(ctrl.action) { - case 'ADD_NEW': - ctrl.addNew(); - break; - case 'EDIT': - ctrl.edit(ctrl.targetId); - break; - } - - scope.$watch('vm.errorMessages', function(current) { - if(current && current.length > 0) { - ctrl.toggleErrorMessage = true; + scope.$apply(function(){ + scope.form.$setPristine(); + scope.form.$setUntouched(); + + ctrl.notAvailble = false; + ctrl.pingAvailable = true; + ctrl.pingMessage = ''; + + ctrl.pingTIP = false; + ctrl.toggleErrorMessage = false; + ctrl.errorMessages = []; + + switch(ctrl.action) { + case 'ADD_NEW': + ctrl.addNew(); + break; + case 'EDIT': + ctrl.edit(ctrl.targetId); + break; } - }, true); - - scope.$apply(); + + scope.$watch('vm.errorMessages', function(current) { + if(current && current.length > 0) { + ctrl.toggleErrorMessage = true; + } + }, true); + + }); }); ctrl.save = save; diff --git a/static/resources/js/components/system-management/destination.directive.html b/static/resources/js/components/system-management/destination.directive.html index c811465c0..8dccd16b5 100644 --- a/static/resources/js/components/system-management/destination.directive.html +++ b/static/resources/js/components/system-management/destination.directive.html @@ -33,9 +33,9 @@ //r.endpoint// //r.creation_time | dateL : 'YYYY-MM-DD HH:mm:ss'// - +   - + diff --git a/static/resources/js/components/system-management/replication.directive.html b/static/resources/js/components/system-management/replication.directive.html index b687cb1ef..e55aeec48 100644 --- a/static/resources/js/components/system-management/replication.directive.html +++ b/static/resources/js/components/system-management/replication.directive.html @@ -42,11 +42,11 @@
- - + +
  - +   diff --git a/static/resources/js/components/user/toggle-admin.directive.js b/static/resources/js/components/user/toggle-admin.directive.js index 999e7962f..d0eac1686 100644 --- a/static/resources/js/components/user/toggle-admin.directive.js +++ b/static/resources/js/components/user/toggle-admin.directive.js @@ -34,6 +34,11 @@ $scope.$emit('modalTitle', $filter('tr')('error')); $scope.$emit('modalMessage', $filter('tr')('failed_to_toggle_admin')); $scope.$emit('raiseError', true); + if(vm.isAdmin) { + vm.isAdmin = false; + }else{ + vm.isAdmin = true; + } console.log('Failed to toggle admin:' + data); } } diff --git a/static/resources/js/harbor.config.js b/static/resources/js/harbor.config.js index 2196a1f57..8e8c392ca 100644 --- a/static/resources/js/harbor.config.js +++ b/static/resources/js/harbor.config.js @@ -20,17 +20,36 @@ function RedirectInterceptorService($q, $window) { return { 'responseError': function(rejection) { - var pathname = $window.location.pathname; - var exclusion = ['/', '/search', '/reset_password', '/sign_up', '/forgot_password', '/repository']; + var url = rejection.config.url; + console.log('url:' + url); + var exclusion = [ + '/', + '/search', + '/reset_password', + '/sign_up', + '/forgot_password', + '/api/targets/ping', + '/api/users/current', + '/api/repositories', + /^\/api\/projects\/[0-9]+\/members\/current$/ + ]; var isExcluded = false; for(var i in exclusion) { - if(exclusion[i] === pathname) { - isExcluded = true; + switch(typeof(exclusion[i])) { + case 'string': + isExcluded = (exclusion[i] === url); + break; + case 'object': + isExcluded = exclusion[i].test(url); break; } - } - if(rejection.status === 401 && !isExcluded) { + if(isExcluded) { + break; + } + } + if(!isExcluded && rejection.status === 401) { $window.location.href = '/'; + return; } return $q.reject(rejection); } diff --git a/static/resources/js/services/i18n/locale_messages_en-US.js b/static/resources/js/services/i18n/locale_messages_en-US.js index efed44a9e..f72d49223 100644 --- a/static/resources/js/services/i18n/locale_messages_en-US.js +++ b/static/resources/js/services/i18n/locale_messages_en-US.js @@ -79,6 +79,7 @@ var locale_messages = { 'new_project': 'New Project', 'save': 'Save', 'cancel': 'Cancel', + 'confirm': 'Confirm', 'items': 'items', 'add_member': 'Add Member', 'operation': 'Operation', @@ -188,9 +189,9 @@ var locale_messages = { 'successful_added': 'Added new user successfully.', 'copyright': 'Copyright', 'all_rights_reserved': 'All Rights Reserved.', - 'pinging_target': 'Testing connection, please wait...', + 'pinging_target': 'Testing connection, please stand by...', 'successful_ping_target': 'Test connection successfully.', - 'failed_to_ping_target': 'Faild to connect target.', + 'failed_to_ping_target': 'Cannot connect to the target.', 'policy_already_exists': 'Policy alreay exists.', 'destination_already_exists': 'Destination already exists.', 'refresh': 'Refresh', @@ -238,6 +239,8 @@ var locale_messages = { 'failed_to_delete_destination': 'Failed to delete destination.', 'failed_to_create_destination': 'Failed to create destination.', 'failed_to_update_destination': 'Failed to update destination.', + 'failed_to_toggle_publicity_insuffient_permissions': 'Failed to toggle project publicity, insuffient permissions.', + 'failed_to_toggle_publicity': 'Failed to toggle project publicity.', 'project_admin': 'Project Admin', 'developer': 'Developer', 'guest': 'Guest', @@ -247,6 +250,6 @@ var locale_messages = { 'Guest: Guest has read-only privilege for a specified project.', 'inline_help_publicity_title': 'Publicity of Project', 'inline_help_publicity': 'Setting the project as public.', - 'alert_job_contains_error': 'There contain errors in current replication jobs results, please look into it.', + 'alert_job_contains_error': 'Found errors in the current replication jobs, please look into it.', 'caution': 'Caution' }; \ No newline at end of file diff --git a/static/resources/js/services/i18n/locale_messages_zh-CN.js b/static/resources/js/services/i18n/locale_messages_zh-CN.js index 57872fbc2..895d9596e 100644 --- a/static/resources/js/services/i18n/locale_messages_zh-CN.js +++ b/static/resources/js/services/i18n/locale_messages_zh-CN.js @@ -79,6 +79,7 @@ var locale_messages = { 'new_project': '新增项目', 'save': '保存', 'cancel': '取消', + 'confirm': '确认', 'items': '条记录', 'add_member': '新增成员', 'operation': '操作', @@ -237,6 +238,8 @@ var locale_messages = { 'failed_to_delete_destination': '删除目标失败。', 'failed_to_create_destination': '创建目标失败。', 'failed_to_update_destination': '修改目标失败。', + 'failed_to_toggle_publicity_insuffient_permissions': '切换项目公开失败,权限不足。', + 'failed_to_toggle_publicity': '切换项目公开失败。', 'project_admin': '项目管理员', 'developer': '开发人员', 'guest': '来宾用户',