Move all controllers into page definitions and add support for layout profiles

This commit is contained in:
Joseph Schorr 2015-02-20 18:15:48 -05:00
parent f650479266
commit d6d11644d8
34 changed files with 3744 additions and 3428 deletions

View file

@ -0,0 +1,97 @@
(function() {
/**
* Page for creating a new organization.
*/
angular.module('quayPages').config(['pages', function(pages) {
pages.create('new-organization', 'new-organization.html', NewOrgCtrl);
}]);
function NewOrgCtrl($scope, $routeParams, $timeout, $location, UserService, PlanService, ApiService, CookieService, Features) {
$scope.Features = Features;
$scope.holder = {};
UserService.updateUserIn($scope);
var requested = $routeParams['plan'];
if (Features.BILLING) {
// Load the list of plans.
PlanService.getPlans(function(plans) {
$scope.plans = plans;
$scope.holder.currentPlan = null;
if (requested) {
PlanService.getPlan(requested, function(plan) {
$scope.holder.currentPlan = plan;
});
}
});
}
$scope.signedIn = function() {
if (Features.BILLING) {
PlanService.handleNotedPlan();
}
};
$scope.signinStarted = function() {
if (Features.BILLING) {
PlanService.getMinimumPlan(1, true, function(plan) {
PlanService.notePlan(plan.stripeId);
});
}
};
$scope.setPlan = function(plan) {
$scope.holder.currentPlan = plan;
};
$scope.createNewOrg = function() {
$('#orgName').popover('hide');
$scope.creating = true;
var org = $scope.org;
var data = {
'name': org.name,
'email': org.email
};
ApiService.createOrganization(data).then(function(created) {
$scope.created = created;
// Reset the organizations list.
UserService.load();
// Set the default namesapce to the organization.
CookieService.putPermanent('quay.namespace', org.name);
var showOrg = function() {
$scope.creating = false;
$location.path('/organization/' + org.name + '/');
};
// If the selected plan is free, simply move to the org page.
if (!Features.BILLING || $scope.holder.currentPlan.price == 0) {
showOrg();
return;
}
// Otherwise, show the subscribe for the plan.
$scope.creating = true;
var callbacks = {
'opened': function() { $scope.creating = true; },
'closed': showOrg,
'success': showOrg,
'failure': showOrg
};
PlanService.changePlan($scope, org.name, $scope.holder.currentPlan.stripeId, callbacks);
}, function(resp) {
$scope.creating = false;
$scope.createError = ApiService.getErrorMessage(resp);
$timeout(function() {
$('#orgName').popover('show');
});
});
};
}
})();