(function() { /** * DEPRECATED: Organization admin/settings page. */ angular.module('quayPages').config(['pages', function(pages) { pages.create('org-admin', 'org-admin.html', OrgAdminCtrl); }]); function OrgAdminCtrl($rootScope, $scope, $timeout, Restangular, $routeParams, UserService, PlanService, ApiService, Features, UIService) { var orgname = $routeParams.orgname; // Load the list of plans. if (Features.BILLING) { PlanService.getPlans(function(plans) { $scope.plans = plans; $scope.plan_map = {}; for (var i = 0; i < plans.length; ++i) { $scope.plan_map[plans[i].stripeId] = plans[i]; } }); } $scope.orgname = orgname; $scope.membersLoading = true; $scope.membersFound = null; $scope.invoiceLoading = true; $scope.logsShown = 0; $scope.invoicesShown = 0; $scope.applicationsShown = 0; $scope.changingOrganization = false; $scope.loadLogs = function() { $scope.logsShown++; }; $scope.loadApplications = function() { $scope.applicationsShown++; }; $scope.loadInvoices = function() { $scope.invoicesShown++; }; $scope.planChanged = function(plan) { $scope.hasPaidPlan = plan && plan.price > 0; }; $scope.$watch('organizationEmail', function(e) { UIService.hidePopover('#changeEmailForm'); }); $scope.changeEmail = function() { UIService.hidePopover('#changeEmailForm'); $scope.changingOrganization = true; var params = { 'orgname': orgname }; var data = { 'email': $scope.organizationEmail }; ApiService.changeOrganizationDetails(data, params).then(function(org) { $scope.changingOrganization = false; $scope.changeEmailForm.$setPristine(); $scope.organization = org; }, function(result) { $scope.changingOrganization = false; UIService.showFormError('#changeEmailForm', result); }); }; $scope.loadMembers = function() { if ($scope.membersFound) { return; } $scope.membersLoading = true; var params = { 'orgname': orgname }; ApiService.getOrganizationMembers(null, params).then(function(resp) { var membersArray = []; for (var key in resp.members) { if (resp.members.hasOwnProperty(key)) { membersArray.push(resp.members[key]); } } $scope.membersFound = membersArray; $scope.membersLoading = false; }); }; var loadOrganization = function() { $scope.orgResource = ApiService.getOrganizationAsResource({'orgname': orgname}).get(function(org) { if (org && org.is_admin) { $scope.organization = org; $scope.organizationEmail = org.email; $rootScope.title = orgname + ' (Admin)'; $rootScope.description = 'Administration page for organization ' + orgname; } }); }; // Load the organization. loadOrganization(); } })();