- Fix a bug with subscribing in the new repo view

- Have conversion to organization update its plan to a business plan
- Fix bug in the repo donut usage graph thingy where it had zero size when not in the default tab
This commit is contained in:
Joseph Schorr 2013-11-07 22:08:23 -05:00
parent 294d4849a2
commit fe69ba5ec1
9 changed files with 106 additions and 44 deletions

View file

@ -140,6 +140,23 @@ quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics',
}, function() { callback([]); });
};
planService.getMatchingBusinessPlan = function(callback) {
planService.getPlans(function() {
planService.getSubscription(null, function(sub) {
var plan = planDict[sub.plan];
if (!plan) {
planService.getMinimumPlan(0, true, callback);
return;
}
var count = Math.max(sub.usedPrivateRepos, plan.privateRepos);
planService.getMinimumPlan(count, true, callback);
}, function() {
planService.getMinimumPlan(0, true, callback);
});
});
};
planService.getPlans = function(callback) {
planService.verifyLoaded(callback);
};
@ -387,6 +404,27 @@ quayApp.directive('signinForm', function () {
});
quayApp.directive('plansTable', function () {
var directiveDefinitionObject = {
priority: 0,
templateUrl: '/static/directives/plans-table.html',
replace: false,
transclude: true,
restrict: 'C',
scope: {
'plans': '=plans',
'currentPlan': '=currentPlan'
},
controller: function($scope, $element) {
$scope.setPlan = function(plan) {
$scope.currentPlan = plan;
};
}
};
return directiveDefinitionObject;
});
quayApp.directive('organizationHeader', function () {
var directiveDefinitionObject = {
priority: 0,

View file

@ -712,11 +712,19 @@ function UserAdminCtrl($scope, $timeout, $location, Restangular, PlanService, Us
$scope.updatingUser = false;
$scope.changePasswordSuccess = false;
$scope.convertStep = 0;
$scope.org = {};
$('.form-change-pw').popover();
$scope.showConvertForm = function() {
PlanService.getMatchingBusinessPlan(function(plan) {
$scope.org.plan = plan;
});
PlanService.getPlans(function(plans) {
$scope.orgPlans = plans.business;
});
$scope.convertStep = 1;
};
@ -729,7 +737,8 @@ function UserAdminCtrl($scope, $timeout, $location, Restangular, PlanService, Us
var data = {
'adminUser': $scope.org.adminUser,
'adminPassword': $scope.org.adminPassword
'adminPassword': $scope.org.adminPassword,
'plan': $scope.org.plan.stripeId
};
var convertAccount = Restangular.one('user/convert');
@ -1017,7 +1026,7 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, Restangula
};
$scope.upgradePlan = function() {
PlanService.showSubscribeDialog($scope, $scope.planRequired.stripeId, null, function() {
PlanService.changePlan($scope, null, $scope.planRequired.stripeId, null, function() {
// Subscribing.
$scope.planChanging = true;
}, function(plan) {

View file

@ -1219,8 +1219,8 @@ RepositoryUsageChart.prototype.drawInternal_ = function() {
* Draws the chart in the given container.
*/
RepositoryUsageChart.prototype.draw = function(container) {
var cw = document.getElementById(container).clientWidth;
var ch = document.getElementById(container).clientHeight;
var cw = 200;
var ch = 200;
var radius = Math.min(cw, ch) / 2;
var pie = d3.layout.pie().sort(null);