This commit is contained in:
Joseph Schorr 2013-10-16 23:12:00 -04:00
commit 58aaf41430
4 changed files with 53 additions and 21 deletions

View file

@ -52,7 +52,8 @@ def create_subtree(repo, structure, parent):
create_subtree(repo, subtree, new_image)
def __generate_repository(user, name, description, is_public, permissions, structure):
def __generate_repository(user, name, description, is_public, permissions,
structure):
repo = model.create_repository(user.username, name, user)
if is_public:
@ -92,7 +93,7 @@ if __name__ == '__main__':
'Complex repository with many branches and tags.',
False, [(new_user_2, 'read')],
(2, [(3, [], 'v2.0'),
(1, [(1, [(1, [], ['latest', 'prod'])],
(1, [(1, [(1, [], ['prod'])],
'staging'),
(1, [], None)], None)], None))
@ -113,3 +114,7 @@ if __name__ == '__main__':
__generate_repository(new_user_1, 'shared',
'Shared repository, another user can write.', False,
[(new_user_2, 'write')], (5, [], 'latest'))
__generate_repository(new_user_1, 'empty',
'Empty repository with no images or tags.', False,
[], (0, [], None))

View file

@ -300,17 +300,35 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope, $location) {
if (!string) { return ''; }
return getMarkedDown(string);
};
$scope.listImages = function() {
var getDefaultTag = function() {
if ($scope.repo === undefined) {
return undefined;
} else if ($scope.repo.tags.hasOwnProperty('latest')) {
return $scope.repo.tags['latest'];
} else {
for (key in $scope.repo.tags) {
return $scope.repo.tags[key];
}
}
};
var listImages = function() {
if ($scope.imageHistory) { return; }
var imageFetch = Restangular.one('repository/' + namespace + '/' + name + '/image');
var imageFetch = Restangular.one('repository/' + namespace + '/' + name + '/image/');
imageFetch.get().then(function(resp) {
$scope.imageHistory = resp.images;
$scope.tree = new ImageHistoryTree(namespace, name, resp.images,
$scope.getCommentFirstLine, $scope.getTimeSince);
$scope.tree.draw('image-history-container');
// If we already have a tag, use it
if ($scope.currentTag) {
$scope.tree.setTag($scope.currentTag.name);
}
$($scope.tree).bind('tagChanged', function(e) {
$scope.$apply(function() { $scope.setTag(e.tag, true); });
});
@ -329,16 +347,26 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope, $location) {
$scope.setTag = function(tagName, opt_updateURL) {
var repo = $scope.repo;
$scope.currentTag = repo.tags[tagName] || repo.tags['latest'];
$scope.currentImage = $scope.currentTag.image;
currentTagName = $scope.currentTag.name;
if ($scope.tree) {
$scope.tree.setTag(currentTagName);
var proposedTag = repo.tags[tagName];
if (!proposedTag) {
// We must find a good default
for (tagName in repo.tags) {
if (!proposedTag || tagName == 'latest') {
proposedTag = repo.tags[tagName];
}
}
}
if (opt_updateURL) {
$location.search('tag', currentTagName);
if (proposedTag) {
$scope.currentTag = proposedTag;
$scope.currentImage = $scope.currentTag.image;
if ($scope.tree) {
$scope.tree.setTag($scope.currentTag.name);
}
if (opt_updateURL) {
$location.search('tag', $scope.currentTag.name);
}
}
};
@ -353,7 +381,6 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope, $location) {
var namespace = $routeParams.namespace;
var name = $routeParams.name;
var tag = $routeParams.tag || 'latest';
$scope.loading = true;
@ -362,8 +389,8 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope, $location) {
repositoryFetch.get().then(function(repo) {
$rootScope.title = namespace + '/' + name;
$scope.repo = repo;
$scope.currentTag = repo.tags[tag] || repo.tags['latest'];
$scope.setImage($scope.currentTag.image);
$scope.setTag($routeParams.tag);
var clip = new ZeroClipboard($('#copyClipboard'), { 'moviePath': 'static/lib/ZeroClipboard.swf' });
clip.on('complete', function() {
@ -385,7 +412,7 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope, $location) {
});
// Fetch the image history.
$scope.listImages();
listImages();
}
function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) {

View file

@ -374,8 +374,8 @@ ImageHistoryTree.prototype.setTag_ = function(tagName) {
// Update the state of each existing node to no longer be highlighted.
if (this.currentImage_) {
var currentNode = imageByDBID[this.currentImage_.dbid];
this.markPath_(currentNode, false);
var currentNode = imageByDBID[this.currentImage_.dbid];
this.markPath_(currentNode, false);
}
// Find the new current image (if any).
@ -385,8 +385,8 @@ ImageHistoryTree.prototype.setTag_ = function(tagName) {
// Update the state of the new node path.
if (this.currentImage_) {
var currentNode = imageByDBID[this.currentImage_.dbid];
this.markPath_(currentNode, true);
var currentNode = imageByDBID[this.currentImage_.dbid];
this.markPath_(currentNode, true);
}
// Ensure that the children are in the correct order.

BIN
test.db

Binary file not shown.