Allow a user to register from the landing page. Fix spacing issues.
This commit is contained in:
parent
70685e2aa8
commit
0d6d463fc1
5 changed files with 205 additions and 137 deletions
|
@ -2,17 +2,17 @@ function getFirstTextLine(commentString) {
|
|||
if (!commentString) { return; }
|
||||
|
||||
var lines = commentString.split('\n');
|
||||
var MARKDOWN_CHARS = {
|
||||
'#': true,
|
||||
'-': true,
|
||||
'>': true,
|
||||
'`': true
|
||||
};
|
||||
var MARKDOWN_CHARS = {
|
||||
'#': true,
|
||||
'-': true,
|
||||
'>': true,
|
||||
'`': true
|
||||
};
|
||||
|
||||
for (var i = 0; i < lines.length; ++i) {
|
||||
// Skip code lines.
|
||||
if (lines[i].indexOf(' ') == 0) {
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip empty lines.
|
||||
|
@ -22,7 +22,7 @@ function getFirstTextLine(commentString) {
|
|||
|
||||
// Skip control lines.
|
||||
if (MARKDOWN_CHARS[$.trim(lines[i])[0]]) {
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
return getMarkedDown(lines[i]);
|
||||
|
@ -43,30 +43,30 @@ function HeaderCtrl($scope, UserService) {
|
|||
$('#repoSearch').typeahead({
|
||||
name: 'repositories',
|
||||
remote: {
|
||||
url: '/api/repository/find/%QUERY',
|
||||
filter: function(data) {
|
||||
var datums = [];
|
||||
for (var i = 0; i < data.repositories.length; ++i) {
|
||||
var repo = data.repositories[i];
|
||||
datums.push({
|
||||
'value': repo.name,
|
||||
'tokens': [repo.name, repo.namespace],
|
||||
'repo': repo
|
||||
});
|
||||
}
|
||||
return datums;
|
||||
}
|
||||
url: '/api/repository/find/%QUERY',
|
||||
filter: function(data) {
|
||||
var datums = [];
|
||||
for (var i = 0; i < data.repositories.length; ++i) {
|
||||
var repo = data.repositories[i];
|
||||
datums.push({
|
||||
'value': repo.name,
|
||||
'tokens': [repo.name, repo.namespace],
|
||||
'repo': repo
|
||||
});
|
||||
}
|
||||
return datums;
|
||||
}
|
||||
},
|
||||
template: function (datum) {
|
||||
template = '<div class="repo-mini-listing">';
|
||||
template += '<i class="icon-hdd icon-large"></i>'
|
||||
template += '<span class="name">' + datum.repo.namespace +'/' + datum.repo.name + '</span>'
|
||||
if (datum.repo.description) {
|
||||
template += '<span class="description">' + getFirstTextLine(datum.repo.description) + '</span>'
|
||||
}
|
||||
template = '<div class="repo-mini-listing">';
|
||||
template += '<i class="icon-hdd icon-large"></i>'
|
||||
template += '<span class="name">' + datum.repo.namespace +'/' + datum.repo.name + '</span>'
|
||||
if (datum.repo.description) {
|
||||
template += '<span class="description">' + getFirstTextLine(datum.repo.description) + '</span>'
|
||||
}
|
||||
|
||||
template += '</div>'
|
||||
return template;
|
||||
template += '</div>'
|
||||
return template;
|
||||
},
|
||||
|
||||
});
|
||||
|
@ -98,8 +98,26 @@ function RepoListCtrl($scope, Restangular) {
|
|||
});
|
||||
}
|
||||
|
||||
function LandingCtrl($scope) {
|
||||
function LandingCtrl($scope, $timeout, Restangular, UserService) {
|
||||
$('.form-signup').popover();
|
||||
|
||||
$scope.$watch( function () { return UserService.currentUser(); }, function (currentUser) {
|
||||
$scope.user = currentUser;
|
||||
}, true);
|
||||
|
||||
$scope.awaitingConfirmation = false;
|
||||
$scope.register = function() {
|
||||
var newUserPost = Restangular.one('user/');
|
||||
newUserPost.customPOST($scope.newUser).then(function() {
|
||||
$scope.awaitingConfirmation = true;
|
||||
}, function(result) {
|
||||
console.log("Displaying error message.");
|
||||
$scope.registerError = result.data.message;
|
||||
$timeout(function() {
|
||||
$('.form-signup').popover('show');
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function RepoCtrl($scope, Restangular, $routeParams, $rootScope) {
|
||||
|
@ -108,27 +126,27 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope) {
|
|||
$rootScope.title = 'Loading...';
|
||||
|
||||
$scope.showTab = function(tabName) {
|
||||
for (var i = 0; i < tabs.length; ++i) {
|
||||
$('#' + tabs[i]).hide();
|
||||
$('#' + tabs[i] + '-tab').removeClass('active');
|
||||
}
|
||||
for (var i = 0; i < tabs.length; ++i) {
|
||||
$('#' + tabs[i]).hide();
|
||||
$('#' + tabs[i] + '-tab').removeClass('active');
|
||||
}
|
||||
|
||||
$('#' + tabName).show();
|
||||
$('#' + tabName + '-tab').addClass('active');
|
||||
$('#' + tabName).show();
|
||||
$('#' + tabName + '-tab').addClass('active');
|
||||
|
||||
if (tabName == 'image-history') {
|
||||
$scope.listImages();
|
||||
}
|
||||
if (tabName == 'image-history') {
|
||||
$scope.listImages();
|
||||
}
|
||||
};
|
||||
|
||||
$scope.editDescription = function() {
|
||||
if (!$scope.repo.can_write) { return; }
|
||||
|
||||
if (!$scope.markdownDescriptionEditor) {
|
||||
var converter = Markdown.getSanitizingConverter();
|
||||
var editor = new Markdown.Editor(converter, '-description');
|
||||
editor.run();
|
||||
$scope.markdownDescriptionEditor = editor;
|
||||
var converter = Markdown.getSanitizingConverter();
|
||||
var editor = new Markdown.Editor(converter, '-description');
|
||||
editor.run();
|
||||
$scope.markdownDescriptionEditor = editor;
|
||||
}
|
||||
|
||||
$('#wmd-input-description')[0].value = $scope.repo.description;
|
||||
|
@ -155,12 +173,12 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope) {
|
|||
};
|
||||
|
||||
$scope.listImages = function() {
|
||||
if ($scope.imageHistory) { return; }
|
||||
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;
|
||||
});
|
||||
var imageFetch = Restangular.one('repository/' + namespace + '/' + name + '/tag/' + $scope.currentTag.name + '/images');
|
||||
imageFetch.get().then(function(resp) {
|
||||
$scope.imageHistory = resp.images;
|
||||
});
|
||||
};
|
||||
|
||||
var namespace = $routeParams.namespace;
|
||||
|
@ -178,14 +196,14 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope) {
|
|||
|
||||
var clip = new ZeroClipboard($('#copyClipboard'), { 'moviePath': 'static/lib/ZeroClipboard.swf' });
|
||||
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);
|
||||
// Resets the animation.
|
||||
var elem = $('#clipboardCopied')[0];
|
||||
elem.style.display = 'none';
|
||||
|
||||
// Show the notification.
|
||||
setTimeout(function() {
|
||||
elem.style.display = 'block';
|
||||
}, 1);
|
||||
});
|
||||
|
||||
$scope.loading = false;
|
||||
|
@ -201,35 +219,34 @@ function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) {
|
|||
var name = $routeParams.name;
|
||||
|
||||
$('#userSearch').typeahead({
|
||||
name: 'users',
|
||||
remote: {
|
||||
url: '/api/users/%QUERY',
|
||||
filter: function(data) {
|
||||
var datums = [];
|
||||
for (var i = 0; i < data.users.length; ++i) {
|
||||
var user = data.users[i];
|
||||
datums.push({
|
||||
'value': user,
|
||||
'tokens': [user],
|
||||
'username': user
|
||||
});
|
||||
}
|
||||
return datums;
|
||||
}
|
||||
},
|
||||
template: function (datum) {
|
||||
template = '<div class="user-mini-listing">';
|
||||
template += '<i class="icon-user icon-large"></i>'
|
||||
template += '<span class="name">' + datum.username + '</span>'
|
||||
template += '</div>'
|
||||
return template;
|
||||
},
|
||||
|
||||
name: 'users',
|
||||
remote: {
|
||||
url: '/api/users/%QUERY',
|
||||
filter: function(data) {
|
||||
var datums = [];
|
||||
for (var i = 0; i < data.users.length; ++i) {
|
||||
var user = data.users[i];
|
||||
datums.push({
|
||||
'value': user,
|
||||
'tokens': [user],
|
||||
'username': user
|
||||
});
|
||||
}
|
||||
return datums;
|
||||
}
|
||||
},
|
||||
template: function (datum) {
|
||||
template = '<div class="user-mini-listing">';
|
||||
template += '<i class="icon-user icon-large"></i>'
|
||||
template += '<span class="name">' + datum.username + '</span>'
|
||||
template += '</div>'
|
||||
return template;
|
||||
},
|
||||
});
|
||||
|
||||
$('#userSearch').on('typeahead:selected', function(e, datum) {
|
||||
$('#userSearch').typeahead('setQuery', '');
|
||||
$scope.addNewPermission(datum.username);
|
||||
$('#userSearch').typeahead('setQuery', '');
|
||||
$scope.addNewPermission(datum.username);
|
||||
});
|
||||
|
||||
$scope.addNewPermission = function(username) {
|
||||
|
@ -239,34 +256,34 @@ function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) {
|
|||
// Need the $scope.apply for both the permission stuff to change and for
|
||||
// the XHR call to be made.
|
||||
$scope.$apply(function() {
|
||||
$scope.addRole(username, 'read')
|
||||
$scope.addRole(username, 'read')
|
||||
});
|
||||
};
|
||||
|
||||
$scope.deleteRole = function(username) {
|
||||
var permissionDelete = Restangular.one('repository/' + namespace + '/' + name + '/permissions/' + username);
|
||||
permissionDelete.customDELETE().then(function() {
|
||||
delete $scope.permissions[username];
|
||||
delete $scope.permissions[username];
|
||||
}, function(result) {
|
||||
if (result.status == 409) {
|
||||
$('#onlyadminModal').modal({});
|
||||
} else {
|
||||
$('#cannotchangeModal').modal({});
|
||||
}
|
||||
if (result.status == 409) {
|
||||
$('#onlyadminModal').modal({});
|
||||
} else {
|
||||
$('#cannotchangeModal').modal({});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.addRole = function(username, role) {
|
||||
var permission = {
|
||||
'role': role
|
||||
'role': role
|
||||
};
|
||||
|
||||
var permissionPost = Restangular.one('repository/' + namespace + '/' + name + '/permissions/' + username);
|
||||
permissionPost.customPOST(permission).then(function() {
|
||||
$scope.permissions[username] = permission;
|
||||
$scope.permissions = $scope.permissions;
|
||||
$scope.permissions[username] = permission;
|
||||
$scope.permissions = $scope.permissions;
|
||||
}, function(result) {
|
||||
$('#cannotchangeModal').modal({});
|
||||
$('#cannotchangeModal').modal({});
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -277,50 +294,50 @@ function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) {
|
|||
|
||||
var permissionPut = Restangular.one('repository/' + namespace + '/' + name + '/permissions/' + username);
|
||||
permissionPut.customPUT(permission).then(function() {}, function(result) {
|
||||
if (result.status == 409) {
|
||||
permission.role = currentRole;
|
||||
$('#onlyadminModal').modal({});
|
||||
} else {
|
||||
$('#cannotchangeModal').modal({});
|
||||
}
|
||||
if (result.status == 409) {
|
||||
permission.role = currentRole;
|
||||
$('#onlyadminModal').modal({});
|
||||
} else {
|
||||
$('#cannotchangeModal').modal({});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.askChangeAccess = function(newAccess) {
|
||||
$('#make' + newAccess + 'Modal').modal({});
|
||||
$('#make' + newAccess + 'Modal').modal({});
|
||||
};
|
||||
|
||||
$scope.changeAccess = function(newAccess) {
|
||||
$('#make' + newAccess + 'Modal').modal('hide');
|
||||
$('#make' + newAccess + 'Modal').modal('hide');
|
||||
|
||||
var visibility = {
|
||||
'visibility': newAccess
|
||||
};
|
||||
var visibilityPost = Restangular.one('repository/' + namespace + '/' + name + '/changevisibility');
|
||||
visibilityPost.customPOST(visibility).then(function() {
|
||||
$scope.repo.is_public = newAccess == 'public';
|
||||
}, function() {
|
||||
$('#cannotchangeModal').modal({});
|
||||
});
|
||||
var visibility = {
|
||||
'visibility': newAccess
|
||||
};
|
||||
var visibilityPost = Restangular.one('repository/' + namespace + '/' + name + '/changevisibility');
|
||||
visibilityPost.customPOST(visibility).then(function() {
|
||||
$scope.repo.is_public = newAccess == 'public';
|
||||
}, function() {
|
||||
$('#cannotchangeModal').modal({});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.askDelete = function() {
|
||||
$('#confirmdeleteModal').modal({});
|
||||
$('#confirmdeleteModal').modal({});
|
||||
};
|
||||
|
||||
$scope.deleteRepo = function() {
|
||||
$('#confirmdeleteModal').modal('hide');
|
||||
$('#confirmdeleteModal').modal('hide');
|
||||
|
||||
var deleteAction = Restangular.one('repository/' + namespace + '/' + name);
|
||||
deleteAction.customDELETE().then(function() {
|
||||
$scope.repo = null;
|
||||
|
||||
setTimeout(function() {
|
||||
document.location = '/#/repository';
|
||||
}, 1000);
|
||||
}, function() {
|
||||
$('#cannotchangeModal').modal({});
|
||||
});
|
||||
var deleteAction = Restangular.one('repository/' + namespace + '/' + name);
|
||||
deleteAction.customDELETE().then(function() {
|
||||
$scope.repo = null;
|
||||
|
||||
setTimeout(function() {
|
||||
document.location = '/#/repository';
|
||||
}, 1000);
|
||||
}, function() {
|
||||
$('#cannotchangeModal').modal({});
|
||||
});
|
||||
};
|
||||
|
||||
$('.spin').spin();
|
||||
|
|
Reference in a new issue