mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-17 04:11:24 +01:00
update for fine-grained 401 filtering and other refinements.
This commit is contained in:
parent
a502635de1
commit
be3110634a
@ -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) {
|
||||
|
@ -1,5 +1,3 @@
|
||||
<a href="javascript:void(0)" role="button" tab-index="0"
|
||||
data-trigger="focus" data-toggle="popover" data-placement="right"
|
||||
data-title="//vm.helpTitle//">
|
||||
<a role="button" tab-index="0" data-trigger="focus" data-toggle="popover" data-placement="right" data-title="//vm.helpTitle//">
|
||||
<span class="glyphicon glyphicon-info-sign"></span>
|
||||
</a>
|
@ -2,7 +2,7 @@
|
||||
<td width="45%"><switch-role roles="vm.roles" edit-mode="vm.editMode" user-id="vm.userId" role-name="vm.roleName"></switch-role></td>
|
||||
<td width="25%">
|
||||
<a ng-show="vm.userId != vm.currentUserId" href="javascript:void(0);" ng-click="vm.updateProjectMember({projectId: vm.projectId, userId: vm.userId, roleId: vm.roleId})">
|
||||
<span ng-if="!vm.editMode" class="glyphicon glyphicon-pencil" title="// 'edit' | tr //"></span><span ng-if="vm.editMode" class="glyphicon glyphicon-ok" title="Confirm">
|
||||
<span ng-if="!vm.editMode" class="glyphicon glyphicon-pencil" title="// 'edit' | tr //"></span><span ng-if="vm.editMode" class="glyphicon glyphicon-ok" title="// 'confirm' | tr //">
|
||||
</a>
|
||||
<a ng-show="vm.userId != vm.currentUserId" href="javascript:void(0);" ng-click="vm.cancelUpdate()" title="// 'cancel' | tr //">
|
||||
<span ng-if="vm.editMode" class="glyphicon glyphicon-remove"></span>
|
||||
|
@ -14,7 +14,7 @@
|
||||
</div>
|
||||
<div class="form-group" style="margin-top: 5px;">
|
||||
<input type="checkbox" ng-model="vm.isPublic"> // 'public' | tr //
|
||||
<inline-help help-title="// 'inline_help_publicity_title' | tr //" content="// 'inline_help_publicity' | tr //"></inline-help>
|
||||
<inline-help help-title="//'inline_help_publicity_title' | tr//" content="//'inline_help_publicity' | tr//"></inline-help>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-2 col-md-2">
|
||||
|
@ -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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -49,7 +49,7 @@
|
||||
<div class="form-group col-md-12 form-group-custom">
|
||||
<div class="col-md-3"></div>
|
||||
<div class="col-md-9">
|
||||
<button type="submit" class="btn btn-default" ng-disabled="vm.notAvailable || !vm.pingAvailable" ng-click="form.$valid && vm.pingDestination()" loading-progress hide-target="false" toggle-in-progress="vm.pingTIP">// 'test_connection' | tr //</button>
|
||||
<button type="button" class="btn btn-default" ng-disabled="vm.notAvailable || !vm.pingAvailable" ng-click="vm.pingDestination()" loading-progress hide-target="false" toggle-in-progress="vm.pingTIP">// 'test_connection' | tr //</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-12 form-group-custom">
|
||||
|
@ -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;
|
||||
|
@ -33,9 +33,9 @@
|
||||
<td width="30%">//r.endpoint//</td>
|
||||
<td width="35%">//r.creation_time | dateL : 'YYYY-MM-DD HH:mm:ss'//</td>
|
||||
<td width="15%">
|
||||
<a href="javascript:void(0);" data-toggle="modal" data-target="#createDestinationModal" ng-click="vm.editDestination(r.id)"><span class="glyphicon glyphicon-pencil"></span></a>
|
||||
<a href="javascript:void(0);" data-toggle="modal" data-target="#createDestinationModal" ng-click="vm.editDestination(r.id)" title="// 'edit' | tr //" ><span class="glyphicon glyphicon-pencil"></span></a>
|
||||
|
||||
<a href="javascript:void(0);" ng-click="vm.confirmToDelete(r.id)"><span class="glyphicon glyphicon-trash"></span></a>
|
||||
<a href="javascript:void(0);" ng-click="vm.confirmToDelete(r.id)" title="// 'delete' | tr //"><span class="glyphicon glyphicon-trash"></span></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
@ -42,11 +42,11 @@
|
||||
</td>
|
||||
<td width="12%">
|
||||
<div class="display-inline-block" ng-switch on="//r.enabled//">
|
||||
<a href="javascript:void(0);" ng-click="vm.togglePolicy(r.id, 0)"><span ng-switch-when="1" class="glyphicon glyphicon-stop color-danger"></span></a>
|
||||
<a href="javascript:void(0);" ng-click="vm.togglePolicy(r.id, 1)"><span ng-switch-when="0" class="glyphicon glyphicon-play color-success"></span></a>
|
||||
<a href="javascript:void(0);" ng-click="vm.togglePolicy(r.id, 0)" title="// 'disable' | tr //"><span ng-switch-when="1" class="glyphicon glyphicon-stop color-danger"></span></a>
|
||||
<a href="javascript:void(0);" ng-click="vm.togglePolicy(r.id, 1)" title="// 'enable' | tr //"><span ng-switch-when="0" class="glyphicon glyphicon-play color-success"></span></a>
|
||||
</div>
|
||||
|
||||
<a href="javascript:void(0);" data-toggle="modal" data-target="#createPolicyModal" ng-click="vm.editReplication(r.id)"><span class="glyphicon glyphicon-pencil"></span></a>
|
||||
<a href="javascript:void(0);" data-toggle="modal" data-target="#createPolicyModal" ng-click="vm.editReplication(r.id)" title="// 'edit_policy' | tr //"><span class="glyphicon glyphicon-pencil"></span></a>
|
||||
|
||||
<!--a href="javascript:void(0);"><span class="glyphicon glyphicon-trash"></span></a-->
|
||||
</td>
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 = {
|
||||
'<strong>Guest</strong>: Guest has read-only privilege for a specified project.',
|
||||
'inline_help_publicity_title': '<strong>Publicity of Project</strong>',
|
||||
'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'
|
||||
};
|
@ -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': '来宾用户',
|
||||
|
Loading…
Reference in New Issue
Block a user