Add some feedback about the number of private repositories used.

This commit is contained in:
yackob03 2013-10-02 01:40:11 -04:00
parent c7e83c4d41
commit c044893ff9
4 changed files with 52 additions and 20 deletions

View file

@ -447,14 +447,18 @@ function UserAdminCtrl($scope, Restangular) {
$('.spin').spin();
$scope.loading = true;
var getSubscription = Restangular.one('user/plan');
getSubscription.get().then(function(sub) {
// User has a subscription
var subscribedToPlan = function(sub) {
$scope.subscription = sub;
$scope.loading = false;
}, function() {
$scope.loading = false;
$scope.subscribedPlan = planDict[sub.plan];
$scope.planUsagePercent = sub.usedPrivateRepos * 100 / $scope.subscribedPlan.privateRepos;
$scope.planLoading = false;
}
$scope.planLoading = true;
var getSubscription = Restangular.one('user/plan');
getSubscription.get().then(subscribedToPlan, function() {
// User has no subscription
$scope.planLoading = false;
});
$scope.subscribe = function(planId) {
@ -468,12 +472,9 @@ function UserAdminCtrl($scope, Restangular) {
console.log(subscriptionDetails);
var createSubscriptionRequest = Restangular.one('user/plan');
createSubscriptionRequest.customPUT(subscriptionDetails).then(function() {
// Success
console.log('successfully created subscription');
}, function() {
createSubscriptionRequest.customPUT(subscriptionDetails).then(subscribedToPlan, function() {
// Failure
console.log('failed to created subscription');
$scope.errorMessage = 'Unable to process subscription change.';
});
});
};