Merge branch 'orgs' of ssh://bitbucket.org/yackob03/quay into orgs
Conflicts: static/partials/new-organization.html
This commit is contained in:
commit
9f1bf1499d
9 changed files with 123 additions and 50 deletions
|
@ -55,6 +55,7 @@ quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics',
|
|||
username: null,
|
||||
email: null,
|
||||
askForPassword: false,
|
||||
organizations: []
|
||||
}
|
||||
|
||||
var userService = {}
|
||||
|
@ -140,6 +141,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 +405,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,
|
||||
|
|
|
@ -15,8 +15,11 @@ $.fn.clipboardCopy = function() {
|
|||
};
|
||||
|
||||
function HeaderCtrl($scope, $location, UserService, Restangular) {
|
||||
$scope.$watch( function () { return UserService.currentUser(); }, function (currentUser) {
|
||||
var searchToken = 0;
|
||||
|
||||
$scope.$watch( function () { return UserService.currentUser(); }, function (currentUser) {
|
||||
$scope.user = currentUser;
|
||||
++searchToken;
|
||||
}, true);
|
||||
|
||||
$scope.signout = function() {
|
||||
|
@ -40,6 +43,11 @@ function HeaderCtrl($scope, $location, UserService, Restangular) {
|
|||
name: 'repositories',
|
||||
remote: {
|
||||
url: '/api/find/repository?query=%QUERY',
|
||||
replace: function (url, uriEncodedQuery) {
|
||||
url = url.replace('%QUERY', uriEncodedQuery);
|
||||
url += '&cb=' + searchToken;
|
||||
return url;
|
||||
},
|
||||
filter: function(data) {
|
||||
var datums = [];
|
||||
for (var i = 0; i < data.repositories.length; ++i) {
|
||||
|
@ -214,11 +222,13 @@ function LandingCtrl($scope, $timeout, $location, Restangular, UserService, KeyS
|
|||
if (namespace == $scope.user.username) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (var i = 0; i < $scope.user.organizations.length; ++i) {
|
||||
var org = $scope.user.organizations[i];
|
||||
if (org.name == namespace) {
|
||||
return org.can_create_repo;
|
||||
|
||||
if ($scope.user.organizations) {
|
||||
for (var i = 0; i < $scope.user.organizations.length; ++i) {
|
||||
var org = $scope.user.organizations[i];
|
||||
if (org.name == namespace) {
|
||||
return org.can_create_repo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -711,11 +721,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;
|
||||
};
|
||||
|
||||
|
@ -728,7 +746,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');
|
||||
|
@ -1016,7 +1035,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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Reference in a new issue