Start on org admin page
This commit is contained in:
parent
91806ee252
commit
b145f72369
3 changed files with 184 additions and 1 deletions
|
@ -1180,8 +1180,63 @@ function OrgViewCtrl($rootScope, $scope, Restangular, $routeParams) {
|
|||
loadOrganization();
|
||||
}
|
||||
|
||||
function OrgAdminCtrl($scope, Restangular, $routeParams) {
|
||||
function OrgAdminCtrl($rootScope, $scope, Restangular, $routeParams, UserService, PlanService) {
|
||||
// Load the list of plans.
|
||||
PlanService.getPlans(function(plans) {
|
||||
$scope.plans = plans.business;
|
||||
});
|
||||
|
||||
var orgname = $routeParams.orgname;
|
||||
|
||||
var loadOrganization = function() {
|
||||
var getOrganization = Restangular.one(getRestUrl('organization', orgname));
|
||||
getOrganization.get().then(function(resp) {
|
||||
if (resp && resp.is_admin) {
|
||||
$scope.organization = resp;
|
||||
$rootScope.title = orgname + ' (Admin)';
|
||||
}
|
||||
|
||||
$scope.loading = false;
|
||||
}, function() {
|
||||
$scope.loading = false;
|
||||
});
|
||||
};
|
||||
|
||||
var subscribedToPlan = function(sub) {
|
||||
$scope.subscription = sub;
|
||||
PlanService.getPlan(sub.plan, function(subscribedPlan) {
|
||||
$scope.subscribedPlan = subscribedPlan;
|
||||
$scope.planUsagePercent = sub.usedPrivateRepos * 100 / $scope.subscribedPlan.privateRepos;
|
||||
|
||||
if (sub.usedPrivateRepos > $scope.subscribedPlan.privateRepos) {
|
||||
$scope.overLimit = true;
|
||||
} else if (sub.usedPrivateRepos >= $scope.subscribedPlan.privateRepos * 0.7) {
|
||||
$scope.nearLimit = true;
|
||||
} else {
|
||||
$scope.overLimit = false;
|
||||
$scope.nearLimit = false;
|
||||
}
|
||||
|
||||
$scope.planLoading = false;
|
||||
});
|
||||
};
|
||||
|
||||
var loadSubscription = function() {
|
||||
$scope.planLoading = true;
|
||||
UserService.getCurrentSubscription(subscribedToPlan, function() {
|
||||
// Organization has no subscription.
|
||||
$scope.planLoading = false;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.getActiveSubClass = function() {
|
||||
if ($scope.overLimit) { return 'danger'; }
|
||||
if ($scope.nearLimit) { return 'warning'; }
|
||||
return 'success';
|
||||
};
|
||||
|
||||
loadSubscription();
|
||||
loadOrganization();
|
||||
}
|
||||
|
||||
function TeamViewCtrl($rootScope, $scope, Restangular, $routeParams) {
|
||||
|
|
Reference in a new issue