Update repo list and landing page to support choosing the list of repos to see (org or personal)
This commit is contained in:
parent
ce91190a7e
commit
4b460be4dd
4 changed files with 71 additions and 34 deletions
|
@ -143,38 +143,61 @@ function GuideCtrl($scope) {
|
|||
}
|
||||
|
||||
function RepoListCtrl($scope, Restangular, UserService) {
|
||||
$scope.namespace = null;
|
||||
|
||||
$scope.$watch( function () { return UserService.currentUser(); }, function (currentUser) {
|
||||
$scope.user = currentUser;
|
||||
}, true);
|
||||
|
||||
$scope.$watch('namespace', function(namespace) {
|
||||
loadMyRepos(namespace);
|
||||
});
|
||||
|
||||
$scope.loading = true;
|
||||
$scope.public_repositories = null;
|
||||
$scope.private_repositories = null;
|
||||
$scope.user_repositories = null;
|
||||
|
||||
// Load the list of personal repositories.
|
||||
var repositoryPrivateFetch = Restangular.all('repository/');
|
||||
repositoryPrivateFetch.getList({'public': false, 'sort': true}).then(function(resp) {
|
||||
$scope.private_repositories = resp.repositories;
|
||||
$scope.loading = !($scope.public_repositories && $scope.private_repositories);
|
||||
});
|
||||
var loadMyRepos = function(namespace) {
|
||||
if (!$scope.user || $scope.user.anonymous || !namespace) {
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.loadingmyrepos = true;
|
||||
|
||||
// Load the list of repositories.
|
||||
var params = {
|
||||
'limit': 10,
|
||||
'public': true,
|
||||
'sort': true,
|
||||
'namespace': namespace
|
||||
};
|
||||
|
||||
var repositoryFetch = Restangular.all('repository/');
|
||||
repositoryFetch.getList(params).then(function(resp) {
|
||||
$scope.user_repositories = resp.repositories;
|
||||
$scope.loading = !($scope.public_repositories && $scope.user_repositories);
|
||||
});
|
||||
};
|
||||
|
||||
// Load the list of public repositories.
|
||||
var options = {'public': true, 'private': false, 'sort': true, 'limit': 10};
|
||||
var repositoryPublicFetch = Restangular.all('repository/');
|
||||
repositoryPublicFetch.getList(options).then(function(resp) {
|
||||
$scope.public_repositories = resp.repositories;
|
||||
$scope.loading = !($scope.public_repositories && $scope.private_repositories);
|
||||
$scope.loading = !($scope.public_repositories && $scope.user_repositories);
|
||||
});
|
||||
}
|
||||
|
||||
function LandingCtrl($scope, $timeout, $location, Restangular, UserService, KeyService) {
|
||||
$('.form-signup').popover();
|
||||
|
||||
$scope.$watch( function () { return UserService.currentUser(); }, function (currentUser) {
|
||||
if (!currentUser.anonymous) {
|
||||
$scope.loadMyRepos();
|
||||
}
|
||||
$scope.namespace = null;
|
||||
|
||||
$scope.$watch('namespace', function(namespace) {
|
||||
loadMyRepos(namespace);
|
||||
});
|
||||
|
||||
$scope.$watch( function () { return UserService.currentUser(); }, function (currentUser) {
|
||||
$scope.user = currentUser;
|
||||
}, true);
|
||||
|
||||
|
@ -207,18 +230,23 @@ function LandingCtrl($scope, $timeout, $location, Restangular, UserService, KeyS
|
|||
});
|
||||
};
|
||||
|
||||
$scope.loadMyRepos = function() {
|
||||
$scope.loadingmyrepos = true;
|
||||
var loadMyRepos = function(namespace) {
|
||||
if (!$scope.user || $scope.user.anonymous || !namespace) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Load the list of repositories.
|
||||
var params = {
|
||||
'limit': 5,
|
||||
'public': false,
|
||||
'sort': true
|
||||
};
|
||||
$scope.loadingmyrepos = true;
|
||||
|
||||
var repositoryFetch = Restangular.all('repository/');
|
||||
repositoryFetch.getList(params).then(function(resp) {
|
||||
// Load the list of repositories.
|
||||
var params = {
|
||||
'limit': 4,
|
||||
'public': true,
|
||||
'sort': true,
|
||||
'namespace': namespace
|
||||
};
|
||||
|
||||
var repositoryFetch = Restangular.all('repository/');
|
||||
repositoryFetch.getList(params).then(function(resp) {
|
||||
$scope.myrepos = resp.repositories;
|
||||
$scope.loadingmyrepos = false;
|
||||
});
|
||||
|
|
Reference in a new issue