2013-09-26 23:59:58 +00:00
|
|
|
function HeaderCtrl($scope, UserService) {
|
|
|
|
$scope.$watch( function () { return UserService.currentUser(); }, function (currentUser) {
|
|
|
|
$scope.user = currentUser;
|
|
|
|
}, true);
|
|
|
|
}
|
|
|
|
|
2013-09-24 22:21:14 +00:00
|
|
|
function RepoListCtrl($scope, Restangular) {
|
|
|
|
var repositoryFetch = Restangular.all('repository/');
|
|
|
|
repositoryFetch.getList().then(function(resp) {
|
|
|
|
$scope.repositories = resp.repositories;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function LandingCtrl($scope) {
|
|
|
|
|
|
|
|
}
|
2013-09-26 21:59:20 +00:00
|
|
|
|
|
|
|
function RepoCtrl($scope, Restangular, $routeParams, $rootScope) {
|
2013-09-27 21:01:45 +00:00
|
|
|
var tabs = ['current-image', 'image-history'];
|
|
|
|
|
2013-09-26 21:59:20 +00:00
|
|
|
$rootScope.title = 'Loading...';
|
|
|
|
|
2013-09-27 21:01:45 +00:00
|
|
|
$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();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-09-26 21:59:20 +00:00
|
|
|
$scope.editDescription = function() {
|
2013-09-26 23:07:25 +00:00
|
|
|
if (!$scope.repo.can_write) { return; }
|
|
|
|
$('#descriptionEdit')[0].value = $scope.repo.description || '';
|
|
|
|
$('#editModal').modal({});
|
2013-09-26 21:59:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.saveDescription = function() {
|
2013-09-26 23:07:25 +00:00
|
|
|
$('#editModal').modal('hide');
|
|
|
|
$scope.repo.description = $('#descriptionEdit')[0].value;
|
|
|
|
$scope.repo.put();
|
2013-09-27 19:26:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.parseDate = function(dateString) {
|
|
|
|
return Date.parse(dateString);
|
|
|
|
};
|
2013-09-27 21:01:45 +00:00
|
|
|
|
|
|
|
$scope.listImages = function() {
|
|
|
|
if ($scope.imageHistory) { return; }
|
|
|
|
|
|
|
|
var imageFetch = Restangular.one('repository/' + namespace + '/' + name + '/tag/' + $scope.currentTag.name + '/images');
|
|
|
|
imageFetch.get().then(function(resp) {
|
|
|
|
$scope.imageHistory = resp.images;
|
|
|
|
});
|
|
|
|
};
|
2013-09-26 21:59:20 +00:00
|
|
|
|
|
|
|
var namespace = $routeParams.namespace;
|
|
|
|
var name = $routeParams.name;
|
|
|
|
var tag = $routeParams.tag || 'latest';
|
|
|
|
|
|
|
|
var repositoryFetch = Restangular.one('repository/' + namespace + '/' + name);
|
|
|
|
repositoryFetch.get().then(function(repo) {
|
2013-09-26 23:07:25 +00:00
|
|
|
$rootScope.title = namespace + '/' + name;
|
|
|
|
$scope.repo = repo;
|
|
|
|
$scope.currentTag = repo.tags[tag] || repo.tags['latest'];
|
2013-09-27 20:12:51 +00:00
|
|
|
|
|
|
|
var clip = new ZeroClipboard($('#copyClipboard'), { 'moviePath': 'static/js/ZeroClipboard.swf' });
|
2013-09-27 20:28:21 +00:00
|
|
|
clip.on('complete', function() {
|
|
|
|
// Resets the animation.
|
|
|
|
var elem = $('#clipboardCopied')[0];
|
|
|
|
elem.style.display = 'none';
|
|
|
|
|
|
|
|
// Show the notification.
|
|
|
|
setTimeout(function() {
|
|
|
|
elem.style.display = 'block';
|
|
|
|
}, 1);
|
|
|
|
});
|
2013-09-26 21:59:20 +00:00
|
|
|
}, function() {
|
2013-09-26 23:07:25 +00:00
|
|
|
$scope.repo = null;
|
|
|
|
$rootScope.title = 'Unknown Repository';
|
2013-09-26 21:59:20 +00:00
|
|
|
});
|
2013-09-26 23:59:58 +00:00
|
|
|
}
|
2013-09-27 00:34:58 +00:00
|
|
|
|
2013-09-27 19:26:16 +00:00
|
|
|
function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) {
|
|
|
|
var namespace = $routeParams.namespace;
|
|
|
|
var name = $routeParams.name;
|
|
|
|
|
|
|
|
$scope.setRole = function(username, role) {
|
|
|
|
var permission = $scope.permissions[username];
|
|
|
|
permission.role = role;
|
|
|
|
|
|
|
|
var permissionPut = Restangular.one('repository/' + namespace + '/' + name + '/permissions/' + username);
|
2013-09-27 19:48:54 +00:00
|
|
|
permissionPut.customPUT(permission).then(function() {}, function(result) {
|
|
|
|
if (result.status == 409) {
|
|
|
|
$('#onlyAdminModal').modal();
|
|
|
|
} else {
|
|
|
|
$('#cannotchangeModal').modal();
|
|
|
|
}
|
|
|
|
});
|
2013-09-27 19:26:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var permissionsFetch = Restangular.one('repository/' + namespace + '/' + name + '/permissions');
|
|
|
|
permissionsFetch.get().then(function(resp) {
|
|
|
|
$rootScope.title = 'Permissions - ' + namespace + '/' + name;
|
|
|
|
$scope.repo = {
|
|
|
|
'namespace': namespace,
|
|
|
|
'name': name
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.permissions = resp.permissions;
|
|
|
|
}, function() {
|
|
|
|
$scope.repo = null;
|
|
|
|
$scope.permissions = null;
|
|
|
|
$rootScope.title = 'Unknown Repository';
|
|
|
|
});
|
2013-09-27 00:34:58 +00:00
|
|
|
}
|