- Add log view under repos
- Make the logs a bit nicer by adding context-sensitive icons - Fix some of the log descriptions
This commit is contained in:
parent
64c9081587
commit
782405fe65
7 changed files with 108 additions and 23 deletions
|
@ -678,7 +678,8 @@ quayApp.directive('logsView', function () {
|
|||
scope: {
|
||||
'organization': '=organization',
|
||||
'user': '=user',
|
||||
'visible': '=visible'
|
||||
'visible': '=visible',
|
||||
'repository': '=repository'
|
||||
},
|
||||
controller: function($scope, $element, $sce, Restangular) {
|
||||
$scope.loading = true;
|
||||
|
@ -696,17 +697,33 @@ quayApp.directive('logsView', function () {
|
|||
'create_repo': 'Create Repository: {repo}',
|
||||
'push_repo': 'Push to repository: {repo}',
|
||||
'pull_repo': function(metadata) {
|
||||
if (metadata.token) {
|
||||
return 'Pull repository {repo} via token {token}';
|
||||
} else if (metadata.username) {
|
||||
return 'Pull repository {repo} by {username}';
|
||||
} else {
|
||||
return 'Public pull of repository {repo} by {_ip}';
|
||||
}
|
||||
if (metadata.token) {
|
||||
return 'Pull repository {repo} via token {token}';
|
||||
} else if (metadata.username) {
|
||||
return 'Pull repository {repo} by {username}';
|
||||
} else {
|
||||
return 'Public pull of repository {repo} by {_ip}';
|
||||
}
|
||||
},
|
||||
'delete_repo': 'Delete repository: {repo}',
|
||||
'change_repo_permission': 'Change permission for user {username} in repository {repo} to {role}',
|
||||
'delete_repo_permission': 'Remove permission for user {username} from repository {repo}',
|
||||
'change_repo_permission': function(metadata) {
|
||||
if (metadata.username) {
|
||||
return 'Change permission for user {username} in repository {repo} to {role}';
|
||||
} else if (metadata.team) {
|
||||
return 'Change permission for team {team} in repository {repo} to {role}';
|
||||
} else if (metadata.token) {
|
||||
return 'Change permission for token {token} in repository {repo} to {role}';
|
||||
}
|
||||
},
|
||||
'delete_repo_permission': function(metadata) {
|
||||
if (metadata.username) {
|
||||
return 'Remove permission for user {username} from repository {repo}';
|
||||
} else if (metadata.team) {
|
||||
return 'Remove permission for team {team} from repository {repo}';
|
||||
} else if (metadata.token) {
|
||||
return 'Remove permission for token {token} from repository {repo}';
|
||||
}
|
||||
},
|
||||
'change_repo_visibility': 'Change visibility for repository {repo} to {visibility}',
|
||||
'add_repo_accesstoken': 'Create access token {token} in repository {repo}',
|
||||
'delete_repo_accesstoken': 'Delete access token {token} in repository {repo}',
|
||||
|
@ -751,14 +768,20 @@ quayApp.directive('logsView', function () {
|
|||
};
|
||||
|
||||
var update = function() {
|
||||
if (!$scope.visible || (!$scope.organization && !$scope.user)) {
|
||||
if (!$scope.visible || (!$scope.organization && !$scope.user && !$scope.repository)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.loading = true;
|
||||
|
||||
var url = $scope.organization ? getRestUrl('organization', $scope.organization.name, 'logs') :
|
||||
getRestUrl('user/logs');
|
||||
var url = getRestUrl('user/logs');
|
||||
if ($scope.organization) {
|
||||
url = getRestUrl('organization', $scope.organization.name, 'logs');
|
||||
}
|
||||
if ($scope.repository) {
|
||||
url = getRestUrl('repository', $scope.repository.namespace, $scope.repository.name, 'logs');
|
||||
}
|
||||
|
||||
var loadLogs = Restangular.one(url);
|
||||
loadLogs.customGET().then(function(resp) {
|
||||
if (!$scope.chart) {
|
||||
|
@ -788,6 +811,14 @@ quayApp.directive('logsView', function () {
|
|||
};
|
||||
|
||||
$scope.getDescription = function(log) {
|
||||
var fieldIcons = {
|
||||
'username': 'user',
|
||||
'team': 'group',
|
||||
'token': 'key',
|
||||
'repo': 'hdd',
|
||||
'robot': 'wrench'
|
||||
};
|
||||
|
||||
log.metadata['_ip'] = log.ip;
|
||||
|
||||
var description = logDescriptions[log.kind] || logTitles[log.kind] || log.kind;
|
||||
|
@ -799,6 +830,12 @@ quayApp.directive('logsView', function () {
|
|||
if (log.metadata.hasOwnProperty(key)) {
|
||||
var markedDown = getMarkedDown(log.metadata[key].toString());
|
||||
markedDown = markedDown.substr('<p>'.length, markedDown.length - '<p></p>'.length);
|
||||
|
||||
var icon = fieldIcons[key];
|
||||
if (icon) {
|
||||
markedDown = '<i class="fa fa-' + icon + '"></i>' + markedDown;
|
||||
}
|
||||
|
||||
description = description.replace('{' + key + '}', '<code>' + markedDown + '</code>');
|
||||
}
|
||||
}
|
||||
|
@ -807,6 +844,7 @@ quayApp.directive('logsView', function () {
|
|||
|
||||
$scope.$watch('organization', update);
|
||||
$scope.$watch('user', update);
|
||||
$scope.$watch('repository', update);
|
||||
$scope.$watch('visible', update);
|
||||
}
|
||||
};
|
||||
|
|
Reference in a new issue