2015-02-20 23:15:48 +00:00
|
|
|
(function() {
|
|
|
|
/**
|
|
|
|
* Page that displays details about an organization, such as its teams.
|
|
|
|
*/
|
|
|
|
angular.module('quayPages').config(['pages', function(pages) {
|
2015-03-25 19:31:05 +00:00
|
|
|
pages.create('org-view', 'org-view.html', OrgViewCtrl, {
|
|
|
|
'newLayout': true,
|
|
|
|
'title': 'Organization {{ organization.name }}',
|
|
|
|
'description': 'Organization {{ organization.name }}'
|
2015-06-29 09:33:00 +00:00
|
|
|
})
|
2015-02-20 23:15:48 +00:00
|
|
|
}]);
|
|
|
|
|
2015-03-30 22:44:23 +00:00
|
|
|
function OrgViewCtrl($scope, $routeParams, $timeout, ApiService, UIService, AvatarService) {
|
2015-03-25 19:31:05 +00:00
|
|
|
var orgname = $routeParams.orgname;
|
|
|
|
|
|
|
|
$scope.showLogsCounter = 0;
|
|
|
|
$scope.showApplicationsCounter = 0;
|
|
|
|
$scope.showInvoicesCounter = 0;
|
2015-04-21 20:07:24 +00:00
|
|
|
$scope.showRobotsCounter = 0;
|
|
|
|
$scope.showTeamsCounter = 0;
|
2015-03-25 19:31:05 +00:00
|
|
|
|
2015-03-30 22:44:23 +00:00
|
|
|
$scope.orgScope = {
|
|
|
|
'changingOrganization': false,
|
|
|
|
'organizationEmail': ''
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.$watch('orgScope.organizationEmail', function(e) {
|
|
|
|
UIService.hidePopover('#changeEmailForm input');
|
2015-03-25 19:31:05 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
var loadRepositories = function() {
|
|
|
|
var options = {
|
|
|
|
'namespace': orgname,
|
2015-08-13 16:19:18 +00:00
|
|
|
'public': true
|
2015-03-25 19:31:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.repositoriesResource = ApiService.listReposAsResource().withOptions(options).get(function(resp) {
|
|
|
|
return resp.repositories;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var loadOrganization = function() {
|
|
|
|
$scope.orgResource = ApiService.getOrganizationAsResource({'orgname': orgname}).get(function(org) {
|
|
|
|
$scope.organization = org;
|
2015-03-30 22:44:23 +00:00
|
|
|
$scope.orgScope.organizationEmail = org.email;
|
2015-03-25 19:31:05 +00:00
|
|
|
$scope.isAdmin = org.is_admin;
|
|
|
|
$scope.isMember = org.is_member;
|
|
|
|
|
|
|
|
// Load the repositories.
|
|
|
|
$timeout(function() {
|
|
|
|
loadRepositories();
|
|
|
|
}, 10);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
// Load the organization.
|
|
|
|
loadOrganization();
|
|
|
|
|
2015-04-21 20:07:24 +00:00
|
|
|
$scope.showRobots = function() {
|
|
|
|
$scope.showRobotsCounter++;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.showTeams = function() {
|
|
|
|
$scope.showTeamsCounter++;
|
|
|
|
};
|
|
|
|
|
2015-03-25 19:31:05 +00:00
|
|
|
$scope.showInvoices = function() {
|
|
|
|
$scope.showInvoicesCounter++;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.showApplications = function() {
|
|
|
|
$scope.showApplicationsCounter++;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.showLogs = function() {
|
|
|
|
$scope.showLogsCounter++;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.changeEmail = function() {
|
2015-03-30 22:44:23 +00:00
|
|
|
UIService.hidePopover('#changeEmailForm input');
|
2015-03-25 19:31:05 +00:00
|
|
|
|
2015-03-30 22:44:23 +00:00
|
|
|
$scope.orgScope.changingOrganization = true;
|
2015-03-25 19:31:05 +00:00
|
|
|
var params = {
|
|
|
|
'orgname': orgname
|
|
|
|
};
|
|
|
|
|
|
|
|
var data = {
|
2015-03-30 22:44:23 +00:00
|
|
|
'email': $scope.orgScope.organizationEmail
|
2015-03-25 19:31:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.changeOrganizationDetails(data, params).then(function(org) {
|
2015-03-30 22:44:23 +00:00
|
|
|
$scope.orgScope.changingOrganization = false;
|
2015-03-25 19:31:05 +00:00
|
|
|
$scope.organization = org;
|
|
|
|
}, function(result) {
|
2015-03-30 22:44:23 +00:00
|
|
|
$scope.orgScope.changingOrganization = false;
|
|
|
|
UIService.showFormError('#changeEmailForm input', result, 'right');
|
2015-03-25 19:31:05 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
2015-02-20 23:15:48 +00:00
|
|
|
})();
|