remove public repo code;redirect to signin instead
This commit is contained in:
parent
9384133897
commit
0aae47fa7c
1 changed files with 7 additions and 49 deletions
|
@ -231,7 +231,7 @@ function TutorialCtrl($scope, AngularTour, AngularTourSignals, UserService, Conf
|
|||
};
|
||||
}
|
||||
|
||||
function RepoListCtrl($scope, $sanitize, Restangular, UserService, ApiService) {
|
||||
function RepoListCtrl($scope, $location, $sanitize, Restangular, UserService, ApiService) {
|
||||
$scope.namespace = null;
|
||||
$scope.page = 1;
|
||||
$scope.publicPageCount = null;
|
||||
|
@ -246,16 +246,11 @@ function RepoListCtrl($scope, $sanitize, Restangular, UserService, ApiService) {
|
|||
}
|
||||
loadStarredRepos();
|
||||
loadRepos();
|
||||
} else {
|
||||
$location.path('signin');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Monitor changes in the namespace.
|
||||
//$scope.$watch('namespace', function(namespace) {
|
||||
// loadStarredRepos($scope.namespace)
|
||||
// loadRepos();
|
||||
//});
|
||||
|
||||
$scope.toggleStar = function(repo) {
|
||||
if (repo.is_starred) {
|
||||
unstarRepo(repo);
|
||||
|
@ -270,7 +265,7 @@ function RepoListCtrl($scope, $sanitize, Restangular, UserService, ApiService) {
|
|||
'repository': repo.name
|
||||
};
|
||||
ApiService.createStar(data).then(function(result) {
|
||||
addToStarred(repo);
|
||||
updateReposAfterStar(repo);
|
||||
}, function(result) {
|
||||
// TODO(jzelinskie): have some kind of pop-up for star failure
|
||||
});
|
||||
|
@ -281,7 +276,7 @@ function RepoListCtrl($scope, $sanitize, Restangular, UserService, ApiService) {
|
|||
'repository': repo.namespace + '/' + repo.name
|
||||
};
|
||||
ApiService.deleteStar(null, data).then(function(result) {
|
||||
removeFromStarred(repo);
|
||||
updateReposAfterUnstar(repo);
|
||||
}, function(result) {
|
||||
// TODO(jzelinskie): have some kind of pop-up for star failure
|
||||
});
|
||||
|
@ -301,7 +296,7 @@ function RepoListCtrl($scope, $sanitize, Restangular, UserService, ApiService) {
|
|||
return repoIndex != -1 ? namespace.repositories.value[repoIndex] : null;
|
||||
}
|
||||
|
||||
var addToStarred = function(repository) {
|
||||
var updateReposAfterStar = function(repository) {
|
||||
$scope.starred_repositories.value.push(repository);
|
||||
|
||||
var repo = findRepoInList(repository.namespace, repository.name);
|
||||
|
@ -310,7 +305,7 @@ function RepoListCtrl($scope, $sanitize, Restangular, UserService, ApiService) {
|
|||
}
|
||||
}
|
||||
|
||||
var removeFromStarred = function(repository) {
|
||||
var updateReposAfterUnstar = function(repository) {
|
||||
// Remove from the starred listings
|
||||
var index = $scope.starred_repositories.value.map(function (r) {
|
||||
return r.namespace + '/' + r.name;
|
||||
|
@ -324,23 +319,6 @@ function RepoListCtrl($scope, $sanitize, Restangular, UserService, ApiService) {
|
|||
}
|
||||
};
|
||||
|
||||
$scope.movePublicPage = function(increment) {
|
||||
if ($scope.publicPageCount == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.page += increment;
|
||||
if ($scope.page < 1) {
|
||||
$scope.page = 1;
|
||||
}
|
||||
|
||||
if ($scope.page > $scope.publicPageCount) {
|
||||
$scope.page = $scope.publicPageCount;
|
||||
}
|
||||
|
||||
loadPublicRepos();
|
||||
};
|
||||
|
||||
var loadStarredRepos = function() {
|
||||
if (!$scope.user || $scope.user.anonymous) {
|
||||
return;
|
||||
|
@ -372,26 +350,6 @@ function RepoListCtrl($scope, $sanitize, Restangular, UserService, ApiService) {
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
var loadPublicRepos = function() {
|
||||
var options = {
|
||||
'public': true,
|
||||
'private': false,
|
||||
'sort': true,
|
||||
'limit': 10,
|
||||
'page': $scope.page,
|
||||
'count': $scope.page == 1
|
||||
};
|
||||
|
||||
$scope.public_repositories = ApiService.listReposAsResource().withOptions(options).get(function(resp) {
|
||||
if (resp.count) {
|
||||
$scope.publicPageCount = Math.ceil(resp.count / 10);
|
||||
}
|
||||
return resp.repositories;
|
||||
});
|
||||
};
|
||||
|
||||
//loadPublicRepos();
|
||||
}
|
||||
|
||||
function LandingCtrl($scope, UserService, ApiService, Features, Config) {
|
||||
|
|
Reference in a new issue