New view repo UI
This commit is contained in:
parent
a7f5b5e033
commit
90759e0cb2
4 changed files with 207 additions and 91 deletions
|
@ -196,23 +196,7 @@ function LandingCtrl($scope, $timeout, Restangular, UserService) {
|
|||
}
|
||||
|
||||
function RepoCtrl($scope, Restangular, $routeParams, $rootScope) {
|
||||
var tabs = ['current-image', 'image-history'];
|
||||
|
||||
$rootScope.title = 'Loading...';
|
||||
|
||||
$scope.showTab = function(tabName) {
|
||||
for (var i = 0; i < tabs.length; ++i) {
|
||||
$('#' + tabs[i]).hide();
|
||||
$('#' + tabs[i] + '-tab').removeClass('active');
|
||||
}
|
||||
|
||||
$('#' + tabName).show();
|
||||
$('#' + tabName + '-tab').addClass('active');
|
||||
|
||||
if (tabName == 'image-history') {
|
||||
$scope.listImages();
|
||||
}
|
||||
};
|
||||
|
||||
$scope.editDescription = function() {
|
||||
if (!$scope.repo.can_write) { return; }
|
||||
|
@ -242,7 +226,7 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope) {
|
|||
return getMarkedDown(getFirstTextLine(commentString));
|
||||
};
|
||||
|
||||
$scope.getTimeSince= function(createdTime) {
|
||||
$scope.getTimeSince = function(createdTime) {
|
||||
return moment($scope.parseDate(createdTime)).fromNow();
|
||||
};
|
||||
|
||||
|
@ -257,12 +241,35 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope) {
|
|||
var imageFetch = Restangular.one('repository/' + namespace + '/' + name + '/image');
|
||||
imageFetch.get().then(function(resp) {
|
||||
$scope.imageHistory = resp.images;
|
||||
var tree = new ImageHistoryTree(namespace, name, resp.images, $scope.currentTag,
|
||||
$scope.getCommentFirstLine, $scope.getTimeSince);
|
||||
tree.draw('image-history-container');
|
||||
$scope.tree = new ImageHistoryTree(namespace, name, resp.images, $scope.currentTag,
|
||||
$scope.getCommentFirstLine, $scope.getTimeSince);
|
||||
|
||||
$scope.tree.draw('image-history-container');
|
||||
$($scope.tree).bind('tagChanged', function(e) {
|
||||
$scope.$apply(function() { $scope.setTag(e.tag); });
|
||||
});
|
||||
$($scope.tree).bind('imageChanged', function(e) {
|
||||
$scope.$apply(function() { $scope.setImage(e.image); });
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.setImage = function(image) {
|
||||
$scope.currentImage = image;
|
||||
if ($scope.tree) {
|
||||
$scope.tree.setImage($scope.currentImage.id);
|
||||
}
|
||||
};
|
||||
|
||||
$scope.setTag = function(tagName) {
|
||||
var repo = $scope.repo;
|
||||
$scope.currentTag = repo.tags[tagName] || repo.tags['latest'];
|
||||
$scope.currentImage = $scope.currentTag.image;
|
||||
if ($scope.tree) {
|
||||
$scope.tree.setTag($scope.currentTag.name);
|
||||
}
|
||||
};
|
||||
|
||||
$scope.getTagCount = function(repo) {
|
||||
if (!repo) { return 0; }
|
||||
var count = 0;
|
||||
|
@ -278,11 +285,13 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope) {
|
|||
|
||||
$scope.loading = true;
|
||||
|
||||
// Fetch the repo.
|
||||
var repositoryFetch = Restangular.one('repository/' + namespace + '/' + name);
|
||||
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);
|
||||
|
||||
var clip = new ZeroClipboard($('#copyClipboard'), { 'moviePath': 'static/lib/ZeroClipboard.swf' });
|
||||
clip.on('complete', function() {
|
||||
|
@ -302,6 +311,9 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope) {
|
|||
$scope.loading = false;
|
||||
$rootScope.title = 'Unknown Repository';
|
||||
});
|
||||
|
||||
// Fetch the image history.
|
||||
$scope.listImages();
|
||||
}
|
||||
|
||||
function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) {
|
||||
|
|
Reference in a new issue