2014-08-18 21:24:00 +00:00
|
|
|
function SignInCtrl($scope, $location) {
|
2014-09-08 21:20:01 +00:00
|
|
|
$scope.redirectUrl = '/';
|
2014-08-18 21:24:00 +00:00
|
|
|
}
|
|
|
|
|
2014-02-07 02:23:27 +00:00
|
|
|
function GuideCtrl() {
|
|
|
|
}
|
|
|
|
|
|
|
|
function SecurityCtrl($scope) {
|
|
|
|
}
|
|
|
|
|
2014-10-22 18:49:33 +00:00
|
|
|
function ContactCtrl($scope, Config) {
|
|
|
|
$scope.Config = Config;
|
|
|
|
$scope.colsize = Math.floor(12 / Config.CONTACT_INFO.length);
|
|
|
|
|
|
|
|
$scope.getKind = function(contactInfo) {
|
|
|
|
var colon = contactInfo.indexOf(':');
|
|
|
|
var scheme = contactInfo.substr(0, colon);
|
|
|
|
if (scheme == 'https' || scheme == 'http') {
|
|
|
|
if (contactInfo.indexOf('//twitter.com/') > 0) {
|
|
|
|
return 'twitter';
|
|
|
|
}
|
|
|
|
|
|
|
|
return 'url';
|
|
|
|
}
|
|
|
|
|
|
|
|
return scheme;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.getTitle = function(contactInfo) {
|
|
|
|
switch ($scope.getKind(contactInfo)) {
|
|
|
|
case 'url':
|
|
|
|
return contactInfo;
|
|
|
|
|
|
|
|
case 'twitter':
|
|
|
|
var parts = contactInfo.split('/');
|
|
|
|
return '@' + parts[parts.length - 1];
|
|
|
|
|
|
|
|
case 'tel':
|
|
|
|
return contactInfo.substr('tel:'.length);
|
|
|
|
|
|
|
|
case 'irc':
|
|
|
|
// irc://chat.freenode.net:6665/quayio
|
|
|
|
var parts = contactInfo.substr('irc://'.length).split('/');
|
|
|
|
var server = parts[0];
|
|
|
|
if (server.indexOf('freenode') > 0) {
|
|
|
|
server = 'Freenode';
|
|
|
|
}
|
|
|
|
return server + ': #' + parts[parts.length - 1];
|
|
|
|
|
|
|
|
case 'mailto':
|
|
|
|
return contactInfo.substr('mailto:'.length);
|
|
|
|
}
|
|
|
|
}
|
2014-02-07 02:23:27 +00:00
|
|
|
}
|
2013-10-14 21:50:07 +00:00
|
|
|
|
2014-05-19 16:53:30 +00:00
|
|
|
function PlansCtrl($scope, $location, UserService, PlanService, $routeParams) {
|
2013-12-17 18:19:59 +00:00
|
|
|
// Monitor any user changes and place the current user into the scope.
|
|
|
|
UserService.updateUserIn($scope);
|
2013-10-02 22:14:51 +00:00
|
|
|
|
2013-12-11 22:50:48 +00:00
|
|
|
$scope.signedIn = function() {
|
|
|
|
$('#signinModal').modal('hide');
|
2014-11-24 21:07:38 +00:00
|
|
|
PlanService.handleNotedPlan();
|
2013-12-11 23:20:24 +00:00
|
|
|
};
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2013-10-02 22:14:51 +00:00
|
|
|
$scope.buyNow = function(plan) {
|
2013-12-21 02:25:06 +00:00
|
|
|
PlanService.notePlan(plan);
|
2013-10-02 22:14:51 +00:00
|
|
|
if ($scope.user && !$scope.user.anonymous) {
|
2014-11-24 21:07:38 +00:00
|
|
|
PlanService.handleNotedPlan();
|
2013-10-02 22:14:51 +00:00
|
|
|
} else {
|
2013-11-07 20:33:56 +00:00
|
|
|
$('#signinModal').modal({});
|
|
|
|
}
|
|
|
|
};
|
2014-05-19 16:53:30 +00:00
|
|
|
|
|
|
|
// Load the list of plans.
|
|
|
|
PlanService.getPlans(function(plans) {
|
|
|
|
$scope.plans = plans;
|
|
|
|
|
|
|
|
if ($scope && $routeParams['trial-plan']) {
|
|
|
|
$scope.buyNow($routeParams['trial-plan']);
|
2014-11-24 21:07:38 +00:00
|
|
|
}
|
2014-05-19 16:53:30 +00:00
|
|
|
}, /* include the personal plan */ true);
|
2013-10-02 22:14:51 +00:00
|
|
|
}
|
|
|
|
|
2014-04-09 00:33:20 +00:00
|
|
|
function TutorialCtrl($scope, AngularTour, AngularTourSignals, UserService, Config) {
|
2014-02-13 20:59:37 +00:00
|
|
|
// Default to showing sudo on all commands if on linux.
|
|
|
|
var showSudo = navigator.appVersion.indexOf("Linux") != -1;
|
|
|
|
|
2014-02-06 02:00:04 +00:00
|
|
|
$scope.tour = {
|
2014-08-08 17:50:04 +00:00
|
|
|
'title': Config.REGISTRY_TITLE_SHORT + ' Tutorial',
|
2014-02-07 01:58:26 +00:00
|
|
|
'initialScope': {
|
2014-04-09 00:33:20 +00:00
|
|
|
'showSudo': showSudo,
|
|
|
|
'domainName': Config.getDomain()
|
2014-02-07 01:58:26 +00:00
|
|
|
},
|
2014-02-06 02:00:04 +00:00
|
|
|
'steps': [
|
|
|
|
{
|
2014-08-08 17:50:04 +00:00
|
|
|
'title': 'Welcome to the ' + Config.REGISTRY_TITLE_SHORT + ' tutorial!',
|
2014-11-24 21:07:38 +00:00
|
|
|
'templateUrl': '/static/tutorial/welcome.html'
|
2014-02-06 02:00:04 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'title': 'Sign in to get started',
|
|
|
|
'templateUrl': '/static/tutorial/signup.html',
|
|
|
|
'signal': function($tourScope) {
|
2014-02-13 23:15:19 +00:00
|
|
|
var user = UserService.currentUser();
|
|
|
|
$tourScope.username = user.username;
|
|
|
|
$tourScope.email = user.email;
|
|
|
|
$tourScope.inOrganization = user.organizations && user.organizations.length > 0;
|
|
|
|
return !user.anonymous;
|
2014-02-05 01:50:13 +00:00
|
|
|
}
|
2014-02-06 02:00:04 +00:00
|
|
|
},
|
|
|
|
{
|
2014-08-08 17:50:04 +00:00
|
|
|
'title': 'Step 1: Login to ' + Config.REGISTRY_TITLE,
|
2014-02-06 02:00:04 +00:00
|
|
|
'templateUrl': '/static/tutorial/docker-login.html',
|
2014-02-07 01:58:26 +00:00
|
|
|
'signal': AngularTourSignals.serverEvent('/realtime/user/subscribe?events=docker-cli',
|
|
|
|
function(message) {
|
|
|
|
return message['data']['action'] == 'login';
|
|
|
|
}),
|
2014-02-07 17:47:53 +00:00
|
|
|
'waitMessage': "Waiting for docker login",
|
2014-02-13 22:27:50 +00:00
|
|
|
'skipTitle': "I'm already logged in",
|
|
|
|
'mixpanelEvent': 'tutorial_start'
|
2014-02-07 01:58:26 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'title': 'Step 2: Create a new container',
|
|
|
|
'templateUrl': '/static/tutorial/create-container.html'
|
2014-02-06 02:00:04 +00:00
|
|
|
},
|
|
|
|
{
|
2014-02-07 01:58:26 +00:00
|
|
|
'title': 'Step 3: Create a new image',
|
2014-02-06 02:00:04 +00:00
|
|
|
'templateUrl': '/static/tutorial/create-image.html'
|
|
|
|
},
|
|
|
|
{
|
2014-08-08 17:50:04 +00:00
|
|
|
'title': 'Step 4: Push the image to ' + Config.REGISTRY_TITLE,
|
2014-02-07 01:58:26 +00:00
|
|
|
'templateUrl': '/static/tutorial/push-image.html',
|
|
|
|
'signal': AngularTourSignals.serverEvent('/realtime/user/subscribe?events=docker-cli',
|
|
|
|
function(message, tourScope) {
|
|
|
|
var pushing = message['data']['action'] == 'push_repo';
|
|
|
|
if (pushing) {
|
|
|
|
tourScope.repoName = message['data']['repository'];
|
|
|
|
}
|
|
|
|
return pushing;
|
|
|
|
}),
|
2014-02-13 22:27:50 +00:00
|
|
|
'waitMessage': "Waiting for repository push to begin",
|
|
|
|
'mixpanelEvent': 'tutorial_wait_for_push'
|
2014-02-07 01:58:26 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'title': 'Push in progress',
|
|
|
|
'templateUrl': '/static/tutorial/pushing.html',
|
|
|
|
'signal': AngularTourSignals.serverEvent('/realtime/user/subscribe?events=docker-cli',
|
|
|
|
function(message, tourScope) {
|
|
|
|
return message['data']['action'] == 'pushed_repo';
|
|
|
|
}),
|
|
|
|
'waitMessage': "Waiting for repository push to complete"
|
2014-02-06 02:00:04 +00:00
|
|
|
},
|
|
|
|
{
|
2014-08-08 17:50:04 +00:00
|
|
|
'title': 'Step 5: View the repository on ' + Config.REGISTRY_TITLE,
|
2014-02-06 02:00:04 +00:00
|
|
|
'templateUrl': '/static/tutorial/view-repo.html',
|
|
|
|
'signal': AngularTourSignals.matchesLocation('/repository/'),
|
2014-02-13 22:27:50 +00:00
|
|
|
'overlayable': true,
|
|
|
|
'mixpanelEvent': 'tutorial_push_complete'
|
2014-02-06 02:00:04 +00:00
|
|
|
},
|
|
|
|
{
|
2014-02-13 23:15:19 +00:00
|
|
|
'templateUrl': '/static/tutorial/view-repo.html',
|
|
|
|
'signal': AngularTourSignals.matchesLocation('/repository/'),
|
|
|
|
'overlayable': true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'templateUrl': '/static/tutorial/waiting-repo-list.html',
|
2014-02-06 02:00:04 +00:00
|
|
|
'signal': AngularTourSignals.elementAvaliable('*[data-repo="{{username}}/{{repoName}}"]'),
|
|
|
|
'overlayable': true
|
|
|
|
},
|
|
|
|
{
|
2014-02-07 01:58:26 +00:00
|
|
|
'templateUrl': '/static/tutorial/repo-list.html',
|
2014-02-06 02:00:04 +00:00
|
|
|
'signal': AngularTourSignals.matchesLocation('/repository/{{username}}/{{repoName}}'),
|
|
|
|
'element': '*[data-repo="{{username}}/{{repoName}}"]',
|
|
|
|
'overlayable': true
|
|
|
|
},
|
|
|
|
{
|
2014-02-07 01:58:26 +00:00
|
|
|
'title': 'Repository View',
|
|
|
|
'content': 'This is the repository view page. It displays all the primary information about your repository.',
|
2014-02-13 22:27:50 +00:00
|
|
|
'overlayable': true,
|
|
|
|
'mixpanelEvent': 'tutorial_view_repo'
|
2014-02-07 01:58:26 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'title': 'Image History',
|
|
|
|
'content': 'The tree displays the full history of your repository, including all its tag. ' +
|
|
|
|
'You can click on a tag or image to see its information.',
|
|
|
|
'element': '#image-history-container',
|
|
|
|
'overlayable': true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'title': 'Tag/Image Information',
|
|
|
|
'content': 'This panel displays information about the currently selected tag or image',
|
|
|
|
'element': '#side-panel',
|
|
|
|
'overlayable': true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'title': 'Select tag or image',
|
|
|
|
'content': 'You can select a tag or image by clicking on this dropdown',
|
|
|
|
'element': '#side-panel-dropdown',
|
|
|
|
'overlayable': true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'content': 'To view the admin settings for the repository, click on the gear',
|
|
|
|
'element': '#admin-cog',
|
|
|
|
'signal': AngularTourSignals.matchesLocation('/repository/{{username}}/{{repoName}}/admin'),
|
|
|
|
'overlayable': true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'title': 'Repository Admin',
|
2014-07-17 17:32:39 +00:00
|
|
|
'content': "The repository admin panel allows for modification of a repository's permissions, notifications, visibility and other settings",
|
2014-02-13 22:27:50 +00:00
|
|
|
'overlayable': true,
|
|
|
|
'mixpanelEvent': 'tutorial_view_admin'
|
2014-02-07 01:58:26 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'title': 'Permissions',
|
2014-02-07 17:47:53 +00:00
|
|
|
'templateUrl': '/static/tutorial/permissions.html',
|
2014-02-07 01:58:26 +00:00
|
|
|
'overlayable': true,
|
|
|
|
'element': '#permissions'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'title': 'Adding a permission',
|
2014-02-07 17:47:53 +00:00
|
|
|
'content': 'To add an <b>additional</b> permission, enter a username or robot account name into the autocomplete ' +
|
2014-02-07 01:58:26 +00:00
|
|
|
'or hit the dropdown arrow to manage robot accounts',
|
|
|
|
'overlayable': true,
|
|
|
|
'element': '#add-entity-permission'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'templateUrl': '/static/tutorial/done.html',
|
2014-02-13 22:27:50 +00:00
|
|
|
'overlayable': true,
|
|
|
|
'mixpanelEvent': 'tutorial_complete'
|
2014-02-06 02:00:04 +00:00
|
|
|
}
|
|
|
|
]
|
2014-02-05 01:50:13 +00:00
|
|
|
};
|
2013-10-02 04:28:24 +00:00
|
|
|
}
|
|
|
|
|
2014-01-14 20:26:31 +00:00
|
|
|
function RepoListCtrl($scope, $sanitize, Restangular, UserService, ApiService) {
|
2013-11-07 02:52:31 +00:00
|
|
|
$scope.namespace = null;
|
2014-01-13 19:49:05 +00:00
|
|
|
$scope.page = 1;
|
|
|
|
$scope.publicPageCount = null;
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
// Monitor changes in the user.
|
|
|
|
UserService.updateUserIn($scope, function() {
|
|
|
|
loadMyRepos($scope.namespace);
|
|
|
|
});
|
2013-11-07 02:52:31 +00:00
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
// Monitor changes in the namespace.
|
2013-11-07 02:52:31 +00:00
|
|
|
$scope.$watch('namespace', function(namespace) {
|
|
|
|
loadMyRepos(namespace);
|
|
|
|
});
|
|
|
|
|
2014-01-13 19:49:05 +00:00
|
|
|
$scope.movePublicPage = function(increment) {
|
|
|
|
if ($scope.publicPageCount == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.page += increment;
|
|
|
|
if ($scope.page < 1) {
|
|
|
|
$scope.page = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($scope.page > $scope.publicPageCount) {
|
|
|
|
$scope.page = $scope.publicPageCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
loadPublicRepos();
|
|
|
|
};
|
|
|
|
|
2013-11-07 06:48:58 +00:00
|
|
|
var loadMyRepos = function(namespace) {
|
2013-11-07 02:52:31 +00:00
|
|
|
if (!$scope.user || $scope.user.anonymous || !namespace) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
var options = {'public': false, 'sort': true, 'namespace': namespace};
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2013-12-26 22:45:16 +00:00
|
|
|
$scope.user_repositories = ApiService.listReposAsResource().withOptions(options).get(function(resp) {
|
2013-12-17 18:19:59 +00:00
|
|
|
return resp.repositories;
|
|
|
|
});
|
|
|
|
};
|
2013-11-07 02:52:31 +00:00
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
var loadPublicRepos = function() {
|
2014-01-13 19:49:05 +00:00
|
|
|
var options = {
|
|
|
|
'public': true,
|
|
|
|
'private': false,
|
|
|
|
'sort': true,
|
|
|
|
'limit': 10,
|
|
|
|
'page': $scope.page,
|
2014-01-13 20:27:05 +00:00
|
|
|
'count': $scope.page == 1
|
2014-01-13 19:49:05 +00:00
|
|
|
};
|
|
|
|
|
2013-12-26 22:45:16 +00:00
|
|
|
$scope.public_repositories = ApiService.listReposAsResource().withOptions(options).get(function(resp) {
|
2014-01-13 20:27:05 +00:00
|
|
|
if (resp.count) {
|
|
|
|
$scope.publicPageCount = Math.ceil(resp.count / 10);
|
|
|
|
}
|
2013-12-17 18:19:59 +00:00
|
|
|
return resp.repositories;
|
2013-11-07 02:52:31 +00:00
|
|
|
});
|
|
|
|
};
|
2013-10-01 20:42:20 +00:00
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
loadPublicRepos();
|
2013-09-24 22:21:14 +00:00
|
|
|
}
|
|
|
|
|
2014-04-08 23:14:24 +00:00
|
|
|
function LandingCtrl($scope, UserService, ApiService, Features, Config) {
|
2013-11-07 02:52:31 +00:00
|
|
|
$scope.namespace = null;
|
2014-05-01 01:00:07 +00:00
|
|
|
$scope.currentScreenshot = 'repo-view';
|
2013-11-07 02:52:31 +00:00
|
|
|
|
|
|
|
$scope.$watch('namespace', function(namespace) {
|
|
|
|
loadMyRepos(namespace);
|
|
|
|
});
|
2013-10-02 04:28:24 +00:00
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
UserService.updateUserIn($scope, function() {
|
|
|
|
loadMyRepos($scope.namespace);
|
|
|
|
});
|
2013-10-01 23:37:33 +00:00
|
|
|
|
2014-05-01 01:00:07 +00:00
|
|
|
$scope.changeScreenshot = function(screenshot) {
|
|
|
|
$scope.currentScreenshot = screenshot;
|
|
|
|
};
|
|
|
|
|
2013-11-07 05:49:13 +00:00
|
|
|
$scope.canCreateRepo = function(namespace) {
|
|
|
|
if (!$scope.user) { return false; }
|
|
|
|
|
|
|
|
if (namespace == $scope.user.username) {
|
|
|
|
return true;
|
|
|
|
}
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2013-11-08 03:44:34 +00:00
|
|
|
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;
|
|
|
|
}
|
2013-11-07 05:49:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2013-11-07 02:52:31 +00:00
|
|
|
var loadMyRepos = function(namespace) {
|
|
|
|
if (!$scope.user || $scope.user.anonymous || !namespace) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
var options = {'limit': 4, 'public': false, 'sort': true, 'namespace': namespace };
|
2013-12-26 22:45:16 +00:00
|
|
|
$scope.my_repositories = ApiService.listReposAsResource().withOptions(options).get(function(resp) {
|
2013-12-17 18:19:59 +00:00
|
|
|
return resp.repositories;
|
2013-10-02 04:28:24 +00:00
|
|
|
});
|
|
|
|
};
|
2013-10-11 00:53:14 +00:00
|
|
|
|
2014-04-06 18:48:58 +00:00
|
|
|
$scope.chromify = function() {
|
|
|
|
browserchrome.update();
|
2014-04-24 05:18:47 +00:00
|
|
|
|
|
|
|
var jcarousel = $('.jcarousel');
|
|
|
|
|
|
|
|
jcarousel
|
|
|
|
.on('jcarousel:reload jcarousel:create', function () {
|
|
|
|
var width = jcarousel.innerWidth();
|
|
|
|
jcarousel.jcarousel('items').css('width', width + 'px');
|
|
|
|
})
|
|
|
|
.jcarousel({
|
|
|
|
wrap: 'circular'
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.jcarousel-control-prev')
|
|
|
|
.on('jcarouselcontrol:active', function() {
|
|
|
|
$(this).removeClass('inactive');
|
|
|
|
})
|
|
|
|
.on('jcarouselcontrol:inactive', function() {
|
|
|
|
$(this).addClass('inactive');
|
|
|
|
})
|
|
|
|
.jcarouselControl({
|
|
|
|
target: '-=1'
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.jcarousel-control-next')
|
|
|
|
.on('jcarouselcontrol:active', function() {
|
|
|
|
$(this).removeClass('inactive');
|
|
|
|
})
|
|
|
|
.on('jcarouselcontrol:inactive', function() {
|
|
|
|
$(this).addClass('inactive');
|
|
|
|
})
|
|
|
|
.jcarouselControl({
|
|
|
|
target: '+=1'
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.jcarousel-pagination')
|
|
|
|
.on('jcarouselpagination:active', 'a', function() {
|
|
|
|
$(this).addClass('active');
|
|
|
|
})
|
|
|
|
.on('jcarouselpagination:inactive', 'a', function() {
|
|
|
|
$(this).removeClass('active');
|
|
|
|
})
|
|
|
|
.jcarouselPagination({
|
|
|
|
'item': function(page, carouselItems) {
|
|
|
|
return '<a href="javascript:void(0)" class="jcarousel-page"></a>';
|
|
|
|
}
|
|
|
|
});
|
2014-04-06 18:48:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.getEnterpriseLogo = function() {
|
2014-04-08 23:14:24 +00:00
|
|
|
if (!Config.ENTERPRISE_LOGO_URL) {
|
2014-04-06 18:48:58 +00:00
|
|
|
return '/static/img/quay-logo.png';
|
|
|
|
}
|
|
|
|
|
2014-04-08 23:14:24 +00:00
|
|
|
return Config.ENTERPRISE_LOGO_URL;
|
2014-04-06 18:48:58 +00:00
|
|
|
};
|
2013-09-24 22:21:14 +00:00
|
|
|
}
|
2013-09-26 21:59:20 +00:00
|
|
|
|
2014-04-09 00:33:20 +00:00
|
|
|
function RepoCtrl($scope, $sanitize, Restangular, ImageMetadataService, ApiService, $routeParams, $rootScope, $location, $timeout, Config) {
|
|
|
|
$scope.Config = Config;
|
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
var namespace = $routeParams.namespace;
|
|
|
|
var name = $routeParams.name;
|
|
|
|
|
2014-09-18 19:56:59 +00:00
|
|
|
$scope.pullCommands = [];
|
|
|
|
$scope.currentPullCommand = null;
|
|
|
|
|
2013-09-26 21:59:20 +00:00
|
|
|
$rootScope.title = 'Loading...';
|
2013-09-27 21:01:45 +00:00
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
// Watch for the destruction of the scope.
|
2013-11-20 21:17:47 +00:00
|
|
|
$scope.$on('$destroy', function() {
|
|
|
|
if ($scope.tree) {
|
|
|
|
$scope.tree.dispose();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
// Watch for changes to the repository.
|
|
|
|
$scope.$watch('repo', function() {
|
|
|
|
if ($scope.tree) {
|
|
|
|
$timeout(function() {
|
|
|
|
$scope.tree.notifyResized();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-10-17 03:09:43 +00:00
|
|
|
// Watch for changes to the tag parameter.
|
|
|
|
$scope.$on('$routeUpdate', function(){
|
2014-01-09 23:54:59 +00:00
|
|
|
if ($location.search().tag) {
|
|
|
|
$scope.setTag($location.search().tag, false);
|
|
|
|
} else if ($location.search().image) {
|
|
|
|
$scope.setImage($location.search().image, false);
|
|
|
|
} else {
|
|
|
|
$scope.setTag($location.search().tag, false);
|
|
|
|
}
|
2013-10-17 03:09:43 +00:00
|
|
|
});
|
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
// Start scope methods //////////////////////////////////////////
|
|
|
|
|
2014-02-15 03:59:44 +00:00
|
|
|
$scope.buildDialogShowCounter = 0;
|
2014-01-14 21:01:37 +00:00
|
|
|
$scope.getFormattedCommand = ImageMetadataService.getFormattedCommand;
|
2014-01-14 20:19:47 +00:00
|
|
|
|
2014-09-18 19:56:59 +00:00
|
|
|
$scope.setCurrentPullCommand = function(pullCommand) {
|
|
|
|
$scope.currentPullCommand = pullCommand;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.updatePullCommand = function() {
|
|
|
|
$scope.pullCommands = [];
|
|
|
|
|
|
|
|
if ($scope.currentTag) {
|
|
|
|
$scope.pullCommands.push({
|
|
|
|
'title': 'docker pull (Tag ' + $scope.currentTag.name + ')',
|
|
|
|
'shortTitle': 'Pull Tag',
|
|
|
|
'icon': 'fa-tag',
|
|
|
|
'command': 'docker pull ' + Config.getDomain() + '/' + namespace + '/' + name + ':' + $scope.currentTag.name
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.pullCommands.push({
|
|
|
|
'title': 'docker pull (Full Repository)',
|
|
|
|
'shortTitle': 'Pull Repo',
|
|
|
|
'icon': 'fa-code-fork',
|
|
|
|
'command': 'docker pull ' + Config.getDomain() + '/' + namespace + '/' + name
|
|
|
|
});
|
|
|
|
|
|
|
|
if ($scope.currentTag) {
|
2014-10-14 20:46:11 +00:00
|
|
|
var squash = 'curl -L -f ' + Config.getHost('ACCOUNTNAME:PASSWORDORTOKEN');
|
2014-09-19 16:54:52 +00:00
|
|
|
squash += '/c1/squash/' + namespace + '/' + name + '/' + $scope.currentTag.name;
|
2014-09-19 16:22:54 +00:00
|
|
|
squash += ' | docker load';
|
2014-09-18 19:56:59 +00:00
|
|
|
|
|
|
|
$scope.pullCommands.push({
|
|
|
|
'title': 'Squashed image (Tag ' + $scope.currentTag.name + ')',
|
|
|
|
'shortTitle': 'Squashed',
|
|
|
|
'icon': 'fa-file-archive-o',
|
|
|
|
'command': squash,
|
|
|
|
'experimental': true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.currentPullCommand = $scope.pullCommands[0];
|
|
|
|
};
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2014-02-15 03:59:44 +00:00
|
|
|
$scope.showNewBuildDialog = function() {
|
|
|
|
$scope.buildDialogShowCounter++;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.handleBuildStarted = function(build) {
|
2014-04-16 21:50:25 +00:00
|
|
|
getBuildInfo($scope.repo);
|
2014-02-15 03:59:44 +00:00
|
|
|
startBuildInfoTimer($scope.repo);
|
|
|
|
};
|
|
|
|
|
2014-02-10 20:15:23 +00:00
|
|
|
$scope.showBuild = function(buildInfo) {
|
|
|
|
$location.path('/repository/' + namespace + '/' + name + '/build');
|
|
|
|
$location.search('current', buildInfo.id);
|
|
|
|
};
|
|
|
|
|
2014-08-13 21:54:15 +00:00
|
|
|
$scope.isPushing = function(images) {
|
|
|
|
if (!images) { return false; }
|
|
|
|
|
|
|
|
var cached = images.__isPushing;
|
|
|
|
if (cached !== undefined) {
|
|
|
|
return cached;
|
|
|
|
}
|
|
|
|
|
|
|
|
return images.__isPushing = $scope.isPushingInternal(images);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.isPushingInternal = function(images) {
|
|
|
|
if (!images) { return false; }
|
|
|
|
|
|
|
|
for (var i = 0; i < images.length; ++i) {
|
|
|
|
if (images[i].uploading) { return true; }
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2014-01-14 21:01:37 +00:00
|
|
|
$scope.getTooltipCommand = function(image) {
|
|
|
|
var sanitized = ImageMetadataService.getEscapedFormattedCommand(image);
|
2014-01-14 20:19:47 +00:00
|
|
|
return '<span class=\'codetooltip\'>' + sanitized + '</span>';
|
|
|
|
};
|
|
|
|
|
2013-11-05 00:59:28 +00:00
|
|
|
$scope.updateForDescription = function(content) {
|
|
|
|
$scope.repo.description = content;
|
2013-09-26 23:07:25 +00:00
|
|
|
$scope.repo.put();
|
2013-09-27 19:26:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.parseDate = function(dateString) {
|
|
|
|
return Date.parse(dateString);
|
|
|
|
};
|
2013-09-30 23:08:24 +00:00
|
|
|
|
2013-10-11 00:43:37 +00:00
|
|
|
$scope.getTimeSince = function(createdTime) {
|
2013-10-10 04:40:18 +00:00
|
|
|
return moment($scope.parseDate(createdTime)).fromNow();
|
|
|
|
};
|
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
$scope.loadImageChanges = function(image) {
|
2014-07-18 03:00:25 +00:00
|
|
|
if (!image) { return; }
|
|
|
|
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {'repository': namespace + '/' + name, 'image_id': image.id};
|
|
|
|
$scope.currentImageChangeResource = ApiService.getImageChangesAsResource(params).get(function(ci) {
|
2013-12-17 18:19:59 +00:00
|
|
|
$scope.currentImageChanges = ci;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.getMoreCount = function(changes) {
|
|
|
|
if (!changes) { return 0; }
|
2014-02-28 05:12:09 +00:00
|
|
|
var addedDisplayed = Math.min(2, changes.added.length);
|
|
|
|
var removedDisplayed = Math.min(2, changes.removed.length);
|
|
|
|
var changedDisplayed = Math.min(2, changes.changed.length);
|
2013-12-17 18:19:59 +00:00
|
|
|
|
|
|
|
return (changes.added.length + changes.removed.length + changes.changed.length) -
|
|
|
|
addedDisplayed - removedDisplayed - changedDisplayed;
|
|
|
|
};
|
|
|
|
|
2014-02-28 05:12:09 +00:00
|
|
|
$scope.showAddTag = function(image) {
|
|
|
|
$scope.toTagImage = image;
|
|
|
|
$('#addTagModal').modal('show');
|
2014-08-05 22:16:30 +00:00
|
|
|
setTimeout(function() {
|
|
|
|
$('#tagName').focus();
|
|
|
|
}, 500);
|
2014-02-28 05:12:09 +00:00
|
|
|
};
|
2014-01-09 22:09:54 +00:00
|
|
|
|
2014-02-28 05:12:09 +00:00
|
|
|
$scope.isOwnedTag = function(image, tagName) {
|
|
|
|
if (!image || !tagName) { return false; }
|
|
|
|
return image.tags.indexOf(tagName) >= 0;
|
|
|
|
};
|
2014-01-09 20:15:06 +00:00
|
|
|
|
2014-02-28 05:12:09 +00:00
|
|
|
$scope.isAnotherImageTag = function(image, tagName) {
|
|
|
|
if (!image || !tagName) { return false; }
|
|
|
|
return image.tags.indexOf(tagName) < 0 && $scope.repo.tags[tagName];
|
2014-01-09 20:15:06 +00:00
|
|
|
};
|
|
|
|
|
2014-01-06 20:20:58 +00:00
|
|
|
$scope.askDeleteTag = function(tagName) {
|
|
|
|
if (!$scope.repo.can_admin) { return; }
|
|
|
|
|
|
|
|
$scope.tagToDelete = tagName;
|
|
|
|
$('#confirmdeleteTagModal').modal('show');
|
|
|
|
};
|
|
|
|
|
2014-07-17 19:16:22 +00:00
|
|
|
$scope.findImageForTag = function(tag) {
|
2014-09-18 21:16:10 +00:00
|
|
|
return tag && $scope.imageByDockerId && $scope.imageByDockerId[tag.image_id];
|
2014-07-17 19:16:22 +00:00
|
|
|
};
|
|
|
|
|
2014-02-28 05:12:09 +00:00
|
|
|
$scope.createOrMoveTag = function(image, tagName, opt_invalid) {
|
|
|
|
if (opt_invalid) { return; }
|
|
|
|
|
|
|
|
$scope.creatingTag = true;
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
'repository': $scope.repo.namespace + '/' + $scope.repo.name,
|
|
|
|
'tag': tagName
|
|
|
|
};
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
'image': image.id
|
|
|
|
};
|
|
|
|
|
2014-08-18 22:21:53 +00:00
|
|
|
var errorHandler = ApiService.errorDisplay('Cannot create or move tag', function(resp) {
|
|
|
|
$('#addTagModal').modal('hide');
|
|
|
|
});
|
|
|
|
|
2014-02-28 05:12:09 +00:00
|
|
|
ApiService.changeTagImage(data, params).then(function(resp) {
|
|
|
|
$scope.creatingTag = false;
|
|
|
|
loadViewInfo();
|
|
|
|
$('#addTagModal').modal('hide');
|
2014-08-18 22:21:53 +00:00
|
|
|
}, errorHandler);
|
2014-02-28 05:12:09 +00:00
|
|
|
};
|
|
|
|
|
2014-01-06 20:20:58 +00:00
|
|
|
$scope.deleteTag = function(tagName) {
|
|
|
|
if (!$scope.repo.can_admin) { return; }
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name,
|
|
|
|
'tag': tagName
|
|
|
|
};
|
|
|
|
|
2014-08-29 17:59:54 +00:00
|
|
|
var errorHandler = ApiService.errorDisplay('Cannot delete tag', function() {
|
|
|
|
$('#confirmdeleteTagModal').modal('hide');
|
|
|
|
$scope.deletingTag = false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$scope.deletingTag = true;
|
|
|
|
|
2014-01-06 20:20:58 +00:00
|
|
|
ApiService.deleteFullTag(null, params).then(function() {
|
|
|
|
loadViewInfo();
|
2014-08-29 17:59:54 +00:00
|
|
|
$('#confirmdeleteTagModal').modal('hide');
|
|
|
|
$scope.deletingTag = false;
|
|
|
|
}, errorHandler);
|
2014-01-06 20:20:58 +00:00
|
|
|
};
|
|
|
|
|
2014-01-09 23:54:59 +00:00
|
|
|
$scope.getImagesForTagBySize = function(tag) {
|
|
|
|
var images = [];
|
|
|
|
forAllTagImages(tag, function(image) {
|
|
|
|
images.push(image);
|
|
|
|
});
|
|
|
|
|
|
|
|
images.sort(function(a, b) {
|
|
|
|
return b.size - a.size;
|
|
|
|
});
|
|
|
|
|
|
|
|
return images;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.getTotalSize = function(tag) {
|
|
|
|
var size = 0;
|
|
|
|
forAllTagImages(tag, function(image) {
|
|
|
|
size += image.size;
|
|
|
|
});
|
|
|
|
return size;
|
|
|
|
};
|
|
|
|
|
2014-07-17 19:16:22 +00:00
|
|
|
$scope.setImage = function(imageId, opt_updateURL) {
|
2014-09-23 18:13:55 +00:00
|
|
|
if (!$scope.images) { return; }
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2014-07-17 19:16:22 +00:00
|
|
|
var image = null;
|
|
|
|
for (var i = 0; i < $scope.images.length; ++i) {
|
|
|
|
var currentImage = $scope.images[i];
|
|
|
|
if (currentImage.id == imageId || currentImage.id.substr(0, 12) == imageId) {
|
|
|
|
image = currentImage;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!image) { return; }
|
|
|
|
|
|
|
|
$scope.currentTag = null;
|
|
|
|
$scope.currentImage = image;
|
|
|
|
$scope.loadImageChanges(image);
|
|
|
|
if ($scope.tree) {
|
|
|
|
$scope.tree.setImage(image.id);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opt_updateURL) {
|
|
|
|
$location.search('tag', null);
|
|
|
|
$location.search('image', imageId.substr(0, 12));
|
|
|
|
}
|
2014-09-18 19:56:59 +00:00
|
|
|
|
|
|
|
$scope.updatePullCommand();
|
2014-07-17 19:16:22 +00:00
|
|
|
};
|
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
$scope.setTag = function(tagName, opt_updateURL) {
|
|
|
|
var repo = $scope.repo;
|
2014-06-10 18:43:52 +00:00
|
|
|
if (!repo) { return; }
|
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
var proposedTag = repo.tags[tagName];
|
|
|
|
if (!proposedTag) {
|
2014-07-17 19:16:22 +00:00
|
|
|
// We must find a good default.
|
2013-12-17 18:19:59 +00:00
|
|
|
for (tagName in repo.tags) {
|
|
|
|
if (!proposedTag || tagName == 'latest') {
|
2014-11-24 21:07:38 +00:00
|
|
|
proposedTag = repo.tags[tagName];
|
2013-12-17 18:19:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (proposedTag) {
|
|
|
|
$scope.currentTag = proposedTag;
|
2014-07-17 19:16:22 +00:00
|
|
|
$scope.currentImage = null;
|
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
if ($scope.tree) {
|
2014-06-10 18:43:52 +00:00
|
|
|
$scope.tree.setTag(proposedTag.name);
|
2014-11-24 21:07:38 +00:00
|
|
|
}
|
2013-12-17 18:19:59 +00:00
|
|
|
|
|
|
|
if (opt_updateURL) {
|
2014-01-09 23:54:59 +00:00
|
|
|
$location.search('image', null);
|
2014-06-10 18:43:52 +00:00
|
|
|
$location.search('tag', proposedTag.name);
|
2013-12-17 18:19:59 +00:00
|
|
|
}
|
|
|
|
}
|
2014-01-07 20:21:24 +00:00
|
|
|
|
|
|
|
if ($scope.currentTag && !repo.tags[$scope.currentTag.name]) {
|
|
|
|
$scope.currentTag = null;
|
|
|
|
$scope.currentImage = null;
|
|
|
|
}
|
2014-09-18 19:56:59 +00:00
|
|
|
|
|
|
|
$scope.updatePullCommand();
|
2013-12-17 18:19:59 +00:00
|
|
|
};
|
|
|
|
|
2014-01-09 20:15:06 +00:00
|
|
|
$scope.getFirstTextLine = getFirstTextLine;
|
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
$scope.getTagCount = function(repo) {
|
|
|
|
if (!repo) { return 0; }
|
|
|
|
var count = 0;
|
|
|
|
for (var tag in repo.tags) {
|
|
|
|
++count;
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
};
|
|
|
|
|
2014-01-06 20:20:58 +00:00
|
|
|
$scope.hideTagMenu = function(tagName, clientX, clientY) {
|
|
|
|
$scope.currentMenuTag = null;
|
|
|
|
|
|
|
|
var tagMenu = $("#tagContextMenu");
|
|
|
|
tagMenu.hide();
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.showTagMenu = function(tagName, clientX, clientY) {
|
|
|
|
if (!$scope.repo.can_admin) { return; }
|
|
|
|
|
|
|
|
$scope.currentMenuTag = tagName;
|
|
|
|
|
|
|
|
var tagMenu = $("#tagContextMenu");
|
|
|
|
tagMenu.css({
|
|
|
|
display: "block",
|
|
|
|
left: clientX,
|
|
|
|
top: clientY
|
|
|
|
});
|
|
|
|
|
|
|
|
tagMenu.on("blur", function() {
|
|
|
|
setTimeout(function() {
|
|
|
|
tagMenu.hide();
|
|
|
|
}, 100); // Needed to allow clicking on menu items.
|
|
|
|
});
|
|
|
|
|
|
|
|
tagMenu.on("click", "a", function() {
|
|
|
|
setTimeout(function() {
|
|
|
|
tagMenu.hide();
|
|
|
|
}, 100); // Needed to allow clicking on menu items.
|
|
|
|
});
|
|
|
|
|
|
|
|
tagMenu[0].focus();
|
|
|
|
};
|
|
|
|
|
2013-10-17 02:37:29 +00:00
|
|
|
var getDefaultTag = function() {
|
|
|
|
if ($scope.repo === undefined) {
|
|
|
|
return undefined;
|
|
|
|
} else if ($scope.repo.tags.hasOwnProperty('latest')) {
|
|
|
|
return $scope.repo.tags['latest'];
|
|
|
|
} else {
|
|
|
|
for (key in $scope.repo.tags) {
|
|
|
|
return $scope.repo.tags[key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-01-09 23:54:59 +00:00
|
|
|
var forAllTagImages = function(tag, callback) {
|
2014-09-18 21:16:10 +00:00
|
|
|
if (!tag || !$scope.imageByDockerId) { return; }
|
2014-01-09 23:54:59 +00:00
|
|
|
|
2014-09-18 21:16:10 +00:00
|
|
|
var tag_image = $scope.imageByDockerId[tag.image_id];
|
2014-07-17 19:16:22 +00:00
|
|
|
if (!tag_image) { return; }
|
|
|
|
|
|
|
|
// Callback the tag's image itself.
|
|
|
|
callback(tag_image);
|
2014-01-09 23:54:59 +00:00
|
|
|
|
2014-07-17 19:16:22 +00:00
|
|
|
// Callback any parent images.
|
2014-07-18 03:02:18 +00:00
|
|
|
if (!tag_image.ancestors) { return; }
|
2014-07-17 19:16:22 +00:00
|
|
|
var ancestors = tag_image.ancestors.split('/');
|
2014-01-09 23:54:59 +00:00
|
|
|
for (var i = 0; i < ancestors.length; ++i) {
|
2014-09-18 21:16:10 +00:00
|
|
|
var image = $scope.imageByDockerId[ancestors[i]];
|
2014-01-09 23:54:59 +00:00
|
|
|
if (image) {
|
|
|
|
callback(image);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-10-30 00:54:36 +00:00
|
|
|
var fetchRepository = function() {
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {'repository': namespace + '/' + name};
|
2013-12-17 18:19:59 +00:00
|
|
|
$rootScope.title = 'Loading Repository...';
|
2013-12-26 22:45:16 +00:00
|
|
|
$scope.repository = ApiService.getRepoAsResource(params).get(function(repo) {
|
2013-12-17 18:19:59 +00:00
|
|
|
// Set the repository object.
|
2013-10-30 00:54:36 +00:00
|
|
|
$scope.repo = repo;
|
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
// Set the default tag.
|
2013-10-30 00:54:36 +00:00
|
|
|
$scope.setTag($routeParams.tag);
|
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
// Set the title of the page.
|
2014-01-13 17:57:02 +00:00
|
|
|
var qualifiedRepoName = namespace + '/' + name;
|
|
|
|
$rootScope.title = qualifiedRepoName;
|
2013-12-17 18:19:59 +00:00
|
|
|
var kind = repo.is_public ? 'public' : 'private';
|
|
|
|
$rootScope.description = jQuery(getFirstTextLine(repo.description)).text() ||
|
2014-01-13 17:57:02 +00:00
|
|
|
'Visualization of images and tags for ' + kind + ' Docker repository: ' + qualifiedRepoName;
|
2013-10-30 00:54:36 +00:00
|
|
|
|
2014-03-05 21:33:24 +00:00
|
|
|
// Load the builds for this repository. If none are active it will cancel the poll.
|
|
|
|
startBuildInfoTimer(repo);
|
2013-10-30 00:54:36 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2013-10-26 20:03:11 +00:00
|
|
|
var startBuildInfoTimer = function(repo) {
|
2013-10-29 22:56:56 +00:00
|
|
|
if ($scope.interval) { return; }
|
|
|
|
|
2013-10-28 17:09:22 +00:00
|
|
|
getBuildInfo(repo);
|
2013-10-29 22:56:56 +00:00
|
|
|
$scope.interval = setInterval(function() {
|
2013-10-30 00:54:36 +00:00
|
|
|
$scope.$apply(function() { getBuildInfo(repo); });
|
|
|
|
}, 5000);
|
2013-10-29 22:56:56 +00:00
|
|
|
|
|
|
|
$scope.$on("$destroy", function() {
|
2013-10-30 00:54:36 +00:00
|
|
|
cancelBuildInfoTimer();
|
2013-10-29 22:56:56 +00:00
|
|
|
});
|
2013-10-26 20:03:11 +00:00
|
|
|
};
|
|
|
|
|
2013-10-30 00:54:36 +00:00
|
|
|
var cancelBuildInfoTimer = function() {
|
|
|
|
if ($scope.interval) {
|
|
|
|
clearInterval($scope.interval);
|
|
|
|
}
|
|
|
|
};
|
2013-09-27 21:01:45 +00:00
|
|
|
|
2013-10-26 20:03:11 +00:00
|
|
|
var getBuildInfo = function(repo) {
|
2014-02-11 03:43:48 +00:00
|
|
|
var params = {
|
|
|
|
'repository': repo.namespace + '/' + repo.name
|
|
|
|
};
|
2013-12-17 18:19:59 +00:00
|
|
|
|
2014-02-11 03:43:48 +00:00
|
|
|
ApiService.getRepoBuilds(null, params, true).then(function(resp) {
|
2014-03-05 20:53:00 +00:00
|
|
|
// Build a filtered list of the builds that are currently running.
|
2013-10-30 00:54:36 +00:00
|
|
|
var runningBuilds = [];
|
|
|
|
for (var i = 0; i < resp.builds.length; ++i) {
|
|
|
|
var build = resp.builds[i];
|
2014-03-05 20:53:00 +00:00
|
|
|
if (build['phase'] != 'complete' && build['phase'] != 'error') {
|
2013-10-30 00:54:36 +00:00
|
|
|
runningBuilds.push(build);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-05 21:50:32 +00:00
|
|
|
var existingBuilds = $scope.runningBuilds || [];
|
2014-03-05 20:53:00 +00:00
|
|
|
$scope.runningBuilds = runningBuilds;
|
|
|
|
$scope.buildHistory = resp.builds;
|
|
|
|
|
2013-10-30 00:54:36 +00:00
|
|
|
if (!runningBuilds.length) {
|
|
|
|
// Cancel the build timer.
|
|
|
|
cancelBuildInfoTimer();
|
|
|
|
|
|
|
|
// Mark the repo as no longer building.
|
|
|
|
$scope.repo.is_building = false;
|
|
|
|
|
2014-03-05 21:50:32 +00:00
|
|
|
// Reload the repo information if all of the builds recently finished.
|
|
|
|
if (existingBuilds.length > 0) {
|
|
|
|
loadViewInfo();
|
|
|
|
}
|
2013-10-30 00:54:36 +00:00
|
|
|
}
|
2013-10-26 20:03:11 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2013-10-17 02:37:29 +00:00
|
|
|
var listImages = function() {
|
2014-11-24 21:07:38 +00:00
|
|
|
var params = {'repository': namespace + '/' + name};
|
2013-12-26 22:45:16 +00:00
|
|
|
$scope.imageHistory = ApiService.listRepositoryImagesAsResource(params).get(function(resp) {
|
2014-01-09 20:15:06 +00:00
|
|
|
$scope.images = resp.images;
|
|
|
|
$scope.specificImages = [];
|
|
|
|
|
2014-01-09 23:54:59 +00:00
|
|
|
// Build various images for quick lookup of images.
|
2014-09-18 21:16:10 +00:00
|
|
|
$scope.imageByDockerId = {};
|
2014-01-09 23:54:59 +00:00
|
|
|
for (var i = 0; i < $scope.images.length; ++i) {
|
|
|
|
var currentImage = $scope.images[i];
|
2014-09-18 21:16:10 +00:00
|
|
|
$scope.imageByDockerId[currentImage.id] = currentImage;
|
2014-01-09 23:54:59 +00:00
|
|
|
}
|
|
|
|
|
2013-10-30 17:55:44 +00:00
|
|
|
// Dispose of any existing tree.
|
|
|
|
if ($scope.tree) {
|
2013-11-20 21:17:47 +00:00
|
|
|
$scope.tree.dispose();
|
2013-10-30 17:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create the new tree.
|
2014-05-01 20:11:50 +00:00
|
|
|
var tree = new ImageHistoryTree(namespace, name, resp.images,
|
2014-01-14 21:01:37 +00:00
|
|
|
getFirstTextLine, $scope.getTimeSince, ImageMetadataService.getEscapedFormattedCommand);
|
2013-10-11 00:43:37 +00:00
|
|
|
|
2014-05-01 20:11:50 +00:00
|
|
|
$scope.tree = tree.draw('image-history-container');
|
|
|
|
if ($scope.tree) {
|
|
|
|
// If we already have a tag, use it
|
|
|
|
if ($scope.currentTag) {
|
|
|
|
$scope.tree.setTag($scope.currentTag.name);
|
|
|
|
}
|
2013-10-17 02:44:44 +00:00
|
|
|
|
2014-05-01 20:11:50 +00:00
|
|
|
// Listen for changes to the selected tag and image in the tree.
|
|
|
|
$($scope.tree).bind('tagChanged', function(e) {
|
|
|
|
$scope.$apply(function() { $scope.setTag(e.tag, true); });
|
|
|
|
});
|
2013-12-17 18:19:59 +00:00
|
|
|
|
2014-05-01 20:11:50 +00:00
|
|
|
$($scope.tree).bind('imageChanged', function(e) {
|
|
|
|
$scope.$apply(function() { $scope.setImage(e.image.id, true); });
|
|
|
|
});
|
2013-09-26 21:59:20 +00:00
|
|
|
|
2014-05-01 20:11:50 +00:00
|
|
|
$($scope.tree).bind('showTagMenu', function(e) {
|
|
|
|
$scope.$apply(function() { $scope.showTagMenu(e.tag, e.clientX, e.clientY); });
|
|
|
|
});
|
2014-01-06 20:20:58 +00:00
|
|
|
|
2014-05-01 20:11:50 +00:00
|
|
|
$($scope.tree).bind('hideTagMenu', function(e) {
|
|
|
|
$scope.$apply(function() { $scope.hideTagMenu(); });
|
|
|
|
});
|
|
|
|
}
|
2014-01-06 20:20:58 +00:00
|
|
|
|
2014-01-09 23:54:59 +00:00
|
|
|
if ($routeParams.image) {
|
|
|
|
$scope.setImage($routeParams.image);
|
|
|
|
}
|
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
return resp.images;
|
2013-10-18 21:59:26 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
var loadViewInfo = function() {
|
|
|
|
fetchRepository();
|
|
|
|
listImages();
|
2013-10-02 05:05:36 +00:00
|
|
|
};
|
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
// Fetch the repository itself as well as the image history.
|
|
|
|
loadViewInfo();
|
2013-09-26 23:59:58 +00:00
|
|
|
}
|
2013-09-27 00:34:58 +00:00
|
|
|
|
2014-04-01 04:23:53 +00:00
|
|
|
function BuildPackageCtrl($scope, Restangular, ApiService, DataFileService, $routeParams, $rootScope, $location, $timeout) {
|
2014-02-17 22:28:20 +00:00
|
|
|
var namespace = $routeParams.namespace;
|
|
|
|
var name = $routeParams.name;
|
|
|
|
var buildid = $routeParams.buildid;
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name,
|
|
|
|
'build_uuid': buildid
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.initializeTree = function() {
|
2014-02-18 02:21:55 +00:00
|
|
|
if ($scope.drawn) {
|
|
|
|
$scope.tree.notifyResized();
|
|
|
|
return;
|
|
|
|
}
|
2014-02-17 22:28:20 +00:00
|
|
|
|
|
|
|
$scope.drawn = true;
|
|
|
|
$timeout(function() {
|
|
|
|
$scope.tree.draw('file-tree-container');
|
|
|
|
}, 10);
|
|
|
|
};
|
|
|
|
|
2014-04-01 04:23:53 +00:00
|
|
|
var determineDockerfilePath = function() {
|
|
|
|
var dockerfilePath = 'Dockerfile';
|
|
|
|
if ($scope.repobuild['job_config']) {
|
|
|
|
var dockerfileFolder = ($scope.repobuild['job_config']['build_subdir'] || '');
|
|
|
|
if (dockerfileFolder[0] == '/') {
|
|
|
|
dockerfileFolder = dockerfileFolder.substr(1);
|
|
|
|
}
|
|
|
|
if (dockerfileFolder && dockerfileFolder[dockerfileFolder.length - 1] != '/') {
|
|
|
|
dockerfileFolder += '/';
|
|
|
|
}
|
|
|
|
dockerfilePath = dockerfileFolder + 'Dockerfile';
|
|
|
|
}
|
|
|
|
return dockerfilePath;
|
2014-02-17 22:36:58 +00:00
|
|
|
};
|
|
|
|
|
2014-11-24 21:07:38 +00:00
|
|
|
var processBuildPack = function(uint8array) {
|
2014-04-01 04:23:53 +00:00
|
|
|
var archiveread = function(files) {
|
|
|
|
var getpath = function(file) {
|
|
|
|
return file.path;
|
|
|
|
};
|
|
|
|
|
|
|
|
var findFile = function(path) {
|
|
|
|
for (var i = 0; i < files.length; ++i) {
|
|
|
|
var file = files[i];
|
|
|
|
if (file.path == path) {
|
|
|
|
return file;
|
|
|
|
}
|
2014-03-05 21:27:56 +00:00
|
|
|
}
|
2014-04-01 04:23:53 +00:00
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.tree = new FileTree($.map(files, getpath));
|
|
|
|
$($scope.tree).bind('fileClicked', function(e) {
|
|
|
|
var file = findFile(e.path);
|
|
|
|
if (file && file.canRead) {
|
|
|
|
saveAs(file.toBlob(), file.name);
|
2014-03-05 21:27:56 +00:00
|
|
|
}
|
2014-04-01 04:23:53 +00:00
|
|
|
});
|
2014-03-05 21:27:56 +00:00
|
|
|
|
2014-04-01 04:23:53 +00:00
|
|
|
var dockerfilePath = determineDockerfilePath();
|
|
|
|
var dockerfile = findFile(dockerfilePath);
|
|
|
|
if (dockerfile && dockerfile.canRead) {
|
|
|
|
DataFileService.blobToString(dockerfile.toBlob(), function(result) {
|
|
|
|
$scope.$apply(function() {
|
2014-05-01 05:48:39 +00:00
|
|
|
$scope.dockerFilePath = dockerfilePath || 'Dockerfile';
|
2014-04-01 04:23:53 +00:00
|
|
|
$scope.dockerFileContents = result;
|
|
|
|
});
|
|
|
|
});
|
2014-02-17 22:28:20 +00:00
|
|
|
}
|
|
|
|
|
2014-04-01 04:23:53 +00:00
|
|
|
$scope.loaded = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
var notarchive = function() {
|
2014-05-01 05:48:39 +00:00
|
|
|
DataFileService.arrayToString(uint8array, function(r) {
|
|
|
|
$scope.dockerFilePath = 'Dockerfile';
|
|
|
|
$scope.dockerFileContents = r;
|
|
|
|
$scope.loaded = true;
|
|
|
|
});
|
2014-04-01 04:23:53 +00:00
|
|
|
};
|
2014-02-17 22:28:20 +00:00
|
|
|
|
2014-07-14 20:33:00 +00:00
|
|
|
setTimeout(function() {
|
|
|
|
$scope.$apply(function() {
|
|
|
|
DataFileService.readDataArrayAsPossibleArchive(uint8array, archiveread, notarchive);
|
|
|
|
});
|
|
|
|
}, 0);
|
2014-02-17 22:28:20 +00:00
|
|
|
};
|
2014-04-01 04:23:53 +00:00
|
|
|
|
2014-03-17 18:53:05 +00:00
|
|
|
var downloadBuildPack = function(url) {
|
2014-02-17 22:28:20 +00:00
|
|
|
$scope.downloadProgress = 0;
|
|
|
|
$scope.downloading = true;
|
2014-03-17 18:53:05 +00:00
|
|
|
startDownload(url);
|
2014-02-17 22:28:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var startDownload = function(url) {
|
2014-04-01 04:23:53 +00:00
|
|
|
var onprogress = function(p) {
|
|
|
|
$scope.downloadProgress = p * 100;
|
2014-02-17 22:28:20 +00:00
|
|
|
};
|
2014-04-01 04:23:53 +00:00
|
|
|
|
|
|
|
var onerror = function() {
|
|
|
|
$scope.downloading = false;
|
|
|
|
$scope.downloadError = true;
|
2014-02-17 22:28:20 +00:00
|
|
|
};
|
2014-04-01 04:23:53 +00:00
|
|
|
|
|
|
|
var onloaded = function(uint8array) {
|
|
|
|
$scope.downloading = false;
|
|
|
|
processBuildPack(uint8array);
|
2014-02-17 22:28:20 +00:00
|
|
|
};
|
2014-04-01 04:23:53 +00:00
|
|
|
|
|
|
|
DataFileService.downloadDataFileAsArrayBuffer($scope, url,
|
|
|
|
onprogress, onerror, onloaded);
|
2014-02-17 22:28:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var getBuildInfo = function() {
|
|
|
|
$scope.repository_build = ApiService.getRepoBuildStatus(null, params, true).then(function(resp) {
|
|
|
|
if (!resp['is_writer']) {
|
|
|
|
$rootScope.title = 'Unknown build';
|
|
|
|
$scope.accessDenied = true;
|
|
|
|
return;
|
|
|
|
}
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2014-02-17 22:28:20 +00:00
|
|
|
$rootScope.title = 'Repository Build Pack - ' + resp['display_name'];
|
|
|
|
$scope.repobuild = resp;
|
|
|
|
$scope.repo = {
|
|
|
|
'namespace': namespace,
|
|
|
|
'name': name
|
|
|
|
};
|
|
|
|
|
2014-03-17 18:53:05 +00:00
|
|
|
downloadBuildPack(resp['archive_url']);
|
2014-02-17 22:28:20 +00:00
|
|
|
return resp;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
getBuildInfo();
|
|
|
|
}
|
|
|
|
|
2014-03-18 19:08:46 +00:00
|
|
|
function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope, $location, $interval, $sanitize,
|
2014-09-11 23:59:44 +00:00
|
|
|
ansi2html, AngularViewArray, AngularPollChannel) {
|
2014-02-10 20:15:23 +00:00
|
|
|
var namespace = $routeParams.namespace;
|
|
|
|
var name = $routeParams.name;
|
2014-02-11 03:43:48 +00:00
|
|
|
|
2014-02-10 20:15:23 +00:00
|
|
|
// Watch for changes to the current parameter.
|
|
|
|
$scope.$on('$routeUpdate', function(){
|
|
|
|
if ($location.search().current) {
|
|
|
|
$scope.setCurrentBuild($location.search().current, false);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-03-05 23:13:04 +00:00
|
|
|
$scope.builds = null;
|
2014-09-11 23:59:44 +00:00
|
|
|
$scope.pollChannel = null;
|
2014-02-15 03:59:44 +00:00
|
|
|
$scope.buildDialogShowCounter = 0;
|
|
|
|
|
|
|
|
$scope.showNewBuildDialog = function() {
|
|
|
|
$scope.buildDialogShowCounter++;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.handleBuildStarted = function(newBuild) {
|
2014-06-04 20:08:26 +00:00
|
|
|
if (!$scope.builds) { return; }
|
|
|
|
|
2014-03-05 22:44:02 +00:00
|
|
|
$scope.builds.unshift(newBuild);
|
2014-02-15 03:59:44 +00:00
|
|
|
$scope.setCurrentBuild(newBuild['id'], true);
|
|
|
|
};
|
|
|
|
|
2014-02-11 00:13:28 +00:00
|
|
|
$scope.adjustLogHeight = function() {
|
2014-02-20 18:27:59 +00:00
|
|
|
var triggerOffset = 0;
|
|
|
|
if ($scope.currentBuild && $scope.currentBuild.trigger) {
|
|
|
|
triggerOffset = 85;
|
|
|
|
}
|
|
|
|
$('.build-logs').height($(window).height() - 415 - triggerOffset);
|
2014-02-14 23:37:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.askRestartBuild = function(build) {
|
|
|
|
$('#confirmRestartBuildModal').modal({});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.restartBuild = function(build) {
|
|
|
|
$('#confirmRestartBuildModal').modal('hide');
|
|
|
|
|
2014-03-05 21:27:56 +00:00
|
|
|
var subdirectory = '';
|
2014-11-24 21:07:38 +00:00
|
|
|
if (build['job_config']) {
|
2014-03-05 21:27:56 +00:00
|
|
|
subdirectory = build['job_config']['build_subdir'] || '';
|
|
|
|
}
|
|
|
|
|
2014-02-14 23:37:06 +00:00
|
|
|
var data = {
|
2014-03-05 21:27:56 +00:00
|
|
|
'file_id': build['resource_key'],
|
2014-04-02 01:49:06 +00:00
|
|
|
'subdirectory': subdirectory,
|
2014-06-26 23:55:16 +00:00
|
|
|
'docker_tags': build['job_config']['docker_tags']
|
2014-02-14 23:37:06 +00:00
|
|
|
};
|
|
|
|
|
2014-04-02 01:49:06 +00:00
|
|
|
if (build['pull_robot']) {
|
|
|
|
data['pull_robot'] = build['pull_robot']['name'];
|
|
|
|
}
|
|
|
|
|
2014-02-14 23:37:06 +00:00
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.requestRepoBuild(data, params).then(function(newBuild) {
|
2014-06-04 20:08:26 +00:00
|
|
|
if (!$scope.builds) { return; }
|
|
|
|
|
2014-03-05 22:44:02 +00:00
|
|
|
$scope.builds.unshift(newBuild);
|
2014-02-14 23:37:06 +00:00
|
|
|
$scope.setCurrentBuild(newBuild['id'], true);
|
|
|
|
});
|
2014-02-11 00:13:28 +00:00
|
|
|
};
|
2014-02-10 20:15:23 +00:00
|
|
|
|
2014-02-13 02:16:11 +00:00
|
|
|
$scope.hasLogs = function(container) {
|
2014-03-18 19:08:46 +00:00
|
|
|
return container.logs.hasEntries;
|
2014-02-11 03:43:48 +00:00
|
|
|
};
|
|
|
|
|
2014-02-10 20:15:23 +00:00
|
|
|
$scope.setCurrentBuild = function(buildId, opt_updateURL) {
|
2014-03-05 23:13:04 +00:00
|
|
|
if (!$scope.builds) { return; }
|
|
|
|
|
2014-02-10 20:15:23 +00:00
|
|
|
// Find the build.
|
|
|
|
for (var i = 0; i < $scope.builds.length; ++i) {
|
|
|
|
if ($scope.builds[i].id == buildId) {
|
2014-02-14 23:46:20 +00:00
|
|
|
$scope.setCurrentBuildInternal(i, $scope.builds[i], opt_updateURL);
|
2014-02-10 20:15:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-02-14 03:01:26 +00:00
|
|
|
$scope.processANSI = function(message, container) {
|
|
|
|
var filter = container.logs._filter = (container.logs._filter || ansi2html.create());
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2014-02-14 03:01:26 +00:00
|
|
|
// Note: order is important here.
|
|
|
|
var setup = filter.getSetupHtml();
|
|
|
|
var stream = filter.addInputToStream(message);
|
|
|
|
var teardown = filter.getTeardownHtml();
|
|
|
|
return setup + stream + teardown;
|
|
|
|
};
|
|
|
|
|
2014-02-14 23:46:20 +00:00
|
|
|
$scope.setCurrentBuildInternal = function(index, build, opt_updateURL) {
|
2014-02-11 03:43:48 +00:00
|
|
|
if (build == $scope.currentBuild) { return; }
|
|
|
|
|
2014-02-13 02:16:11 +00:00
|
|
|
$scope.logEntries = null;
|
2014-02-11 21:56:39 +00:00
|
|
|
$scope.logStartIndex = null;
|
2014-02-13 02:16:11 +00:00
|
|
|
$scope.currentParentEntry = null;
|
|
|
|
|
2014-02-10 20:15:23 +00:00
|
|
|
$scope.currentBuild = build;
|
2014-02-11 03:43:48 +00:00
|
|
|
|
2014-02-10 20:15:23 +00:00
|
|
|
if (opt_updateURL) {
|
2014-02-11 00:13:28 +00:00
|
|
|
if (build) {
|
|
|
|
$location.search('current', build.id);
|
|
|
|
} else {
|
|
|
|
$location.search('current', null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Timeout needed to ensure the log element has been created
|
|
|
|
// before its height is adjusted.
|
|
|
|
setTimeout(function() {
|
|
|
|
$scope.adjustLogHeight();
|
|
|
|
}, 1);
|
|
|
|
|
2014-09-11 23:59:44 +00:00
|
|
|
// Stop any existing polling.
|
|
|
|
if ($scope.pollChannel) {
|
|
|
|
$scope.pollChannel.stop();
|
2014-02-11 00:13:28 +00:00
|
|
|
}
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2014-09-11 23:59:44 +00:00
|
|
|
// Create a new channel for polling the build status and logs.
|
|
|
|
var conductStatusAndLogRequest = function(callback) {
|
|
|
|
getBuildStatusAndLogs(build, callback);
|
|
|
|
};
|
2014-02-11 00:13:28 +00:00
|
|
|
|
2014-09-11 23:59:44 +00:00
|
|
|
$scope.pollChannel = AngularPollChannel.create($scope, conductStatusAndLogRequest, 5 * 1000 /* 5s */);
|
|
|
|
$scope.pollChannel.start();
|
2014-02-11 03:43:48 +00:00
|
|
|
};
|
|
|
|
|
2014-09-11 23:59:44 +00:00
|
|
|
var processLogs = function(logs, startIndex, endIndex) {
|
2014-02-13 02:16:11 +00:00
|
|
|
if (!$scope.logEntries) { $scope.logEntries = []; }
|
|
|
|
|
2014-09-11 23:59:44 +00:00
|
|
|
// If the start index given is less than that requested, then we've received a larger
|
|
|
|
// pool of logs, and we need to only consider the new ones.
|
|
|
|
if (startIndex < $scope.logStartIndex) {
|
|
|
|
logs = logs.slice($scope.logStartIndex - startIndex);
|
|
|
|
}
|
|
|
|
|
2014-02-11 03:43:48 +00:00
|
|
|
for (var i = 0; i < logs.length; ++i) {
|
|
|
|
var entry = logs[i];
|
2014-02-13 02:16:11 +00:00
|
|
|
var type = entry['type'] || 'entry';
|
|
|
|
if (type == 'command' || type == 'phase' || type == 'error') {
|
2014-03-18 19:08:46 +00:00
|
|
|
entry['logs'] = AngularViewArray.create();
|
2014-09-11 23:59:44 +00:00
|
|
|
entry['index'] = $scope.logStartIndex + i;
|
2014-02-13 02:16:11 +00:00
|
|
|
|
|
|
|
$scope.logEntries.push(entry);
|
2014-03-18 19:08:46 +00:00
|
|
|
$scope.currentParentEntry = entry;
|
2014-02-13 02:16:11 +00:00
|
|
|
} else if ($scope.currentParentEntry) {
|
2014-03-18 19:08:46 +00:00
|
|
|
$scope.currentParentEntry['logs'].push(entry);
|
2014-02-11 03:43:48 +00:00
|
|
|
}
|
|
|
|
}
|
2014-09-11 23:59:44 +00:00
|
|
|
|
|
|
|
return endIndex;
|
2014-02-11 03:43:48 +00:00
|
|
|
};
|
|
|
|
|
2014-11-24 21:07:38 +00:00
|
|
|
var getBuildStatusAndLogs = function(build, callback) {
|
2014-02-11 03:43:48 +00:00
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name,
|
2014-09-11 23:59:44 +00:00
|
|
|
'build_uuid': build.id
|
2014-02-11 03:43:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.getRepoBuildStatus(null, params, true).then(function(resp) {
|
2014-09-11 23:59:44 +00:00
|
|
|
if (build != $scope.currentBuild) { callback(false); return; }
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2014-02-11 00:13:28 +00:00
|
|
|
// Note: We use extend here rather than replacing as Angular is depending on the
|
|
|
|
// root build object to remain the same object.
|
2014-05-09 21:54:11 +00:00
|
|
|
var matchingBuilds = $.grep($scope.builds, function(elem) {
|
|
|
|
return elem['id'] == resp['id']
|
|
|
|
});
|
|
|
|
|
|
|
|
var currentBuild = matchingBuilds.length > 0 ? matchingBuilds[0] : null;
|
|
|
|
if (currentBuild) {
|
|
|
|
currentBuild = $.extend(true, currentBuild, resp);
|
|
|
|
} else {
|
|
|
|
currentBuild = resp;
|
|
|
|
$scope.builds.push(currentBuild);
|
|
|
|
}
|
|
|
|
|
2014-02-11 03:43:48 +00:00
|
|
|
// Load the updated logs for the build.
|
|
|
|
var options = {
|
|
|
|
'start': $scope.logStartIndex
|
|
|
|
};
|
|
|
|
|
2014-11-24 21:07:38 +00:00
|
|
|
ApiService.getRepoBuildLogsAsResource(params, true).withOptions(options).get(function(resp) {
|
2014-09-11 23:59:44 +00:00
|
|
|
if (build != $scope.currentBuild) { callback(false); return; }
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2014-09-11 23:59:44 +00:00
|
|
|
// Process the logs we've received.
|
|
|
|
$scope.logStartIndex = processLogs(resp['logs'], resp['start'], resp['total']);
|
2014-04-15 17:56:31 +00:00
|
|
|
|
|
|
|
// If the build status is an error, open the last two log entries.
|
|
|
|
if (currentBuild['phase'] == 'error' && $scope.logEntries.length > 1) {
|
|
|
|
var openLogEntries = function(entry) {
|
|
|
|
if (entry.logs) {
|
|
|
|
entry.logs.setVisible(true);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
openLogEntries($scope.logEntries[$scope.logEntries.length - 2]);
|
|
|
|
openLogEntries($scope.logEntries[$scope.logEntries.length - 1]);
|
|
|
|
}
|
2014-09-11 23:59:44 +00:00
|
|
|
|
|
|
|
// If the build phase is an error or a complete, then we mark the channel
|
|
|
|
// as closed.
|
|
|
|
callback(currentBuild['phase'] != 'error' && currentBuild['phase'] != 'complete');
|
2014-02-14 03:01:26 +00:00
|
|
|
}, function() {
|
2014-09-11 23:59:44 +00:00
|
|
|
callback(false);
|
2014-02-11 03:43:48 +00:00
|
|
|
});
|
2014-09-11 23:59:44 +00:00
|
|
|
}, function() {
|
|
|
|
callback(false);
|
2014-02-11 00:13:28 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2014-02-10 20:15:23 +00:00
|
|
|
var fetchRepository = function() {
|
|
|
|
var params = {'repository': namespace + '/' + name};
|
|
|
|
$rootScope.title = 'Loading Repository...';
|
|
|
|
$scope.repository = ApiService.getRepoAsResource(params).get(function(repo) {
|
2014-02-13 02:39:23 +00:00
|
|
|
if (!repo.can_write) {
|
|
|
|
$rootScope.title = 'Unknown builds';
|
|
|
|
$scope.accessDenied = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-11 00:13:28 +00:00
|
|
|
$rootScope.title = 'Repository Builds';
|
2014-02-10 20:15:23 +00:00
|
|
|
$scope.repo = repo;
|
2014-02-13 02:39:23 +00:00
|
|
|
|
|
|
|
getBuildInfo();
|
2014-02-10 20:15:23 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var getBuildInfo = function(repo) {
|
2014-02-11 03:43:48 +00:00
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name
|
|
|
|
};
|
2014-02-10 20:15:23 +00:00
|
|
|
|
2014-02-11 03:43:48 +00:00
|
|
|
ApiService.getRepoBuilds(null, params).then(function(resp) {
|
2014-02-10 20:15:23 +00:00
|
|
|
$scope.builds = resp.builds;
|
|
|
|
|
|
|
|
if ($location.search().current) {
|
|
|
|
$scope.setCurrentBuild($location.search().current, false);
|
2014-02-11 00:13:28 +00:00
|
|
|
} else if ($scope.builds.length > 0) {
|
2014-03-06 17:51:20 +00:00
|
|
|
$scope.setCurrentBuild($scope.builds[0].id, true);
|
2014-02-10 20:15:23 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
fetchRepository();
|
|
|
|
}
|
|
|
|
|
2014-11-24 21:07:38 +00:00
|
|
|
function RepoAdminCtrl($scope, Restangular, ApiService, KeyService, TriggerService, $routeParams,
|
2014-09-30 20:29:32 +00:00
|
|
|
$rootScope, $location, UserService, Config, Features, ExternalNotificationData) {
|
|
|
|
|
2013-09-27 19:26:16 +00:00
|
|
|
var namespace = $routeParams.namespace;
|
|
|
|
var name = $routeParams.name;
|
|
|
|
|
2014-05-30 22:28:18 +00:00
|
|
|
$scope.Features = Features;
|
2014-11-05 21:43:37 +00:00
|
|
|
$scope.TriggerService = TriggerService;
|
2014-11-26 17:54:02 +00:00
|
|
|
$scope.KeyService = KeyService;
|
2014-11-05 21:43:37 +00:00
|
|
|
|
2014-10-29 18:21:08 +00:00
|
|
|
$scope.permissions = {'team': [], 'user': [], 'loading': 2};
|
2013-12-02 19:55:04 +00:00
|
|
|
$scope.logsShown = 0;
|
2014-01-20 22:03:16 +00:00
|
|
|
$scope.deleting = false;
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2014-02-07 01:58:26 +00:00
|
|
|
$scope.permissionCache = {};
|
2014-04-03 03:33:58 +00:00
|
|
|
$scope.showTriggerSetupCounter = 0;
|
|
|
|
|
2014-02-28 21:23:36 +00:00
|
|
|
$scope.getBadgeFormat = function(format, repo) {
|
|
|
|
if (!repo) { return; }
|
|
|
|
|
2014-05-12 23:03:42 +00:00
|
|
|
var imageUrl = Config.getUrl('/repository/' + namespace + '/' + name + '/status');
|
2014-02-28 21:23:36 +00:00
|
|
|
if (!$scope.repo.is_public) {
|
|
|
|
imageUrl += '?token=' + $scope.repo.status_token;
|
|
|
|
}
|
|
|
|
|
2014-05-12 23:03:42 +00:00
|
|
|
var linkUrl = Config.getUrl('/repository/' + namespace + '/' + name);
|
2014-02-28 21:23:36 +00:00
|
|
|
|
|
|
|
switch (format) {
|
|
|
|
case 'svg':
|
|
|
|
return imageUrl;
|
|
|
|
|
|
|
|
case 'md':
|
2014-08-08 17:50:04 +00:00
|
|
|
return '[![Docker Repository on ' + Config.REGISTRY_TITLE_SHORT + '](' + imageUrl +
|
|
|
|
' "Docker Repository on ' + Config.REGISTRY_TITLE_SHORT + '")](' + linkUrl + ')';
|
2014-02-28 21:23:36 +00:00
|
|
|
|
|
|
|
case 'asciidoc':
|
2014-08-08 17:50:04 +00:00
|
|
|
return 'image:' + imageUrl + '["Docker Repository on ' + Config.REGISTRY_TITLE_SHORT + '", link="' + linkUrl + '"]';
|
2014-02-28 21:23:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
};
|
|
|
|
|
2014-01-21 21:23:00 +00:00
|
|
|
$scope.buildEntityForPermission = function(name, permission, kind) {
|
2014-02-07 01:58:26 +00:00
|
|
|
var key = name + ':' + kind;
|
|
|
|
if ($scope.permissionCache[key]) {
|
|
|
|
return $scope.permissionCache[key];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $scope.permissionCache[key] = {
|
2014-01-21 21:23:00 +00:00
|
|
|
'kind': kind,
|
|
|
|
'name': name,
|
|
|
|
'is_robot': permission.is_robot,
|
|
|
|
'is_org_member': permission.is_org_member
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2013-12-02 19:55:04 +00:00
|
|
|
$scope.loadLogs = function() {
|
|
|
|
$scope.logsShown++;
|
|
|
|
};
|
2013-09-28 05:23:00 +00:00
|
|
|
|
2013-11-02 01:48:10 +00:00
|
|
|
$scope.grantRole = function() {
|
|
|
|
$('#confirmaddoutsideModal').modal('hide');
|
|
|
|
var entity = $scope.currentAddEntity;
|
2013-11-04 23:52:38 +00:00
|
|
|
$scope.addRole(entity.name, 'read', entity.kind, entity.is_org_member)
|
2013-11-02 01:48:10 +00:00
|
|
|
$scope.currentAddEntity = null;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.addNewPermission = function(entity) {
|
2013-09-28 05:23:00 +00:00
|
|
|
// Don't allow duplicates.
|
2014-02-07 01:58:26 +00:00
|
|
|
if (!entity || !entity.kind || $scope.permissions[entity.kind][entity.name]) { return; }
|
2013-11-02 01:48:10 +00:00
|
|
|
|
2013-11-08 04:35:27 +00:00
|
|
|
if (entity.is_org_member === false) {
|
2013-11-02 01:48:10 +00:00
|
|
|
$scope.currentAddEntity = entity;
|
|
|
|
$('#confirmaddoutsideModal').modal('show');
|
|
|
|
return;
|
|
|
|
}
|
2013-09-28 05:23:00 +00:00
|
|
|
|
2013-12-10 06:38:05 +00:00
|
|
|
$scope.addRole(entity.name, 'read', entity.kind);
|
2013-09-28 05:23:00 +00:00
|
|
|
};
|
|
|
|
|
2013-11-02 01:48:10 +00:00
|
|
|
$scope.deleteRole = function(entityName, kind) {
|
2014-08-18 22:21:53 +00:00
|
|
|
var errorHandler = ApiService.errorDisplay('Cannot change permission', function(resp) {
|
2013-11-08 04:35:27 +00:00
|
|
|
if (resp.status == 409) {
|
2014-08-18 22:21:53 +00:00
|
|
|
return 'Cannot change permission as you do not have the authority';
|
2013-10-01 23:37:33 +00:00
|
|
|
}
|
2013-09-28 05:23:00 +00:00
|
|
|
});
|
2014-08-18 22:21:53 +00:00
|
|
|
|
|
|
|
var permissionDelete = Restangular.one(getRestUrl('repository', namespace, name, 'permissions', kind, entityName));
|
|
|
|
permissionDelete.customDELETE().then(function() {
|
|
|
|
delete $scope.permissions[kind][entityName];
|
|
|
|
}, errorHandler);
|
2013-09-28 05:23:00 +00:00
|
|
|
};
|
|
|
|
|
2013-11-21 00:43:19 +00:00
|
|
|
$scope.addRole = function(entityName, role, kind) {
|
2013-09-28 05:23:00 +00:00
|
|
|
var permission = {
|
2013-11-02 01:48:10 +00:00
|
|
|
'role': role,
|
2013-09-28 05:23:00 +00:00
|
|
|
};
|
|
|
|
|
2013-11-04 20:31:38 +00:00
|
|
|
var permissionPost = Restangular.one(getRestUrl('repository', namespace, name, 'permissions', kind, entityName));
|
2014-03-17 19:05:55 +00:00
|
|
|
permissionPost.customPUT(permission).then(function(result) {
|
2013-11-21 00:43:19 +00:00
|
|
|
$scope.permissions[kind][entityName] = result;
|
2014-08-18 22:21:53 +00:00
|
|
|
}, ApiService.errorDisplay('Cannot change permission'));
|
2013-09-28 05:23:00 +00:00
|
|
|
};
|
|
|
|
|
2013-11-15 22:45:37 +00:00
|
|
|
$scope.roles = [
|
2013-11-05 19:47:46 +00:00
|
|
|
{ 'id': 'read', 'title': 'Read', 'kind': 'success' },
|
|
|
|
{ 'id': 'write', 'title': 'Write', 'kind': 'success' },
|
|
|
|
{ 'id': 'admin', 'title': 'Admin', 'kind': 'primary' }
|
|
|
|
];
|
|
|
|
|
|
|
|
$scope.setRole = function(role, entityName, kind) {
|
2013-11-02 01:48:10 +00:00
|
|
|
var permission = $scope.permissions[kind][entityName];
|
2013-09-28 05:23:00 +00:00
|
|
|
var currentRole = permission.role;
|
2013-09-27 19:26:16 +00:00
|
|
|
permission.role = role;
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2013-11-04 20:31:38 +00:00
|
|
|
var permissionPut = Restangular.one(getRestUrl('repository', namespace, name, 'permissions', kind, entityName));
|
2013-11-08 04:35:27 +00:00
|
|
|
permissionPut.customPUT(permission).then(function() {}, function(resp) {
|
|
|
|
$scope.permissions[kind][entityName] = {'role': currentRole};
|
|
|
|
$scope.changePermError = null;
|
|
|
|
if (resp.status == 409 || resp.data) {
|
|
|
|
$scope.changePermError = resp.data || '';
|
|
|
|
$('#channgechangepermModal').modal({});
|
2013-10-01 23:37:33 +00:00
|
|
|
} else {
|
|
|
|
$('#cannotchangeModal').modal({});
|
|
|
|
}
|
2013-09-27 19:48:54 +00:00
|
|
|
});
|
2013-09-27 19:26:16 +00:00
|
|
|
};
|
|
|
|
|
2014-07-29 22:53:23 +00:00
|
|
|
$scope.newTokenName = null;
|
|
|
|
|
2013-10-16 18:24:10 +00:00
|
|
|
$scope.createToken = function() {
|
2014-07-29 22:53:23 +00:00
|
|
|
var data = {
|
|
|
|
'friendlyName': $scope.newTokenName
|
2013-10-16 18:24:10 +00:00
|
|
|
};
|
|
|
|
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {'repository': namespace + '/' + name};
|
2014-07-29 22:53:23 +00:00
|
|
|
ApiService.createToken(data, params).then(function(newToken) {
|
|
|
|
$scope.newTokenName = null;
|
2013-10-17 20:50:58 +00:00
|
|
|
$scope.createTokenForm.$setPristine();
|
2013-10-16 18:24:10 +00:00
|
|
|
$scope.tokens[newToken.code] = newToken;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.deleteToken = function(tokenCode) {
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name,
|
|
|
|
'code': tokenCode
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.deleteToken(null, params).then(function() {
|
2013-10-16 18:24:10 +00:00
|
|
|
delete $scope.tokens[tokenCode];
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.changeTokenAccess = function(tokenCode, newAccess) {
|
|
|
|
var role = {
|
|
|
|
'role': newAccess
|
|
|
|
};
|
|
|
|
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name,
|
|
|
|
'code': tokenCode
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.changeToken(role, params).then(function(updated) {
|
2013-10-16 18:24:10 +00:00
|
|
|
$scope.tokens[updated.code] = updated;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2013-11-23 01:14:44 +00:00
|
|
|
$scope.shownTokenCounter = 0;
|
|
|
|
|
2013-10-16 18:24:10 +00:00
|
|
|
$scope.showToken = function(tokenCode) {
|
|
|
|
$scope.shownToken = $scope.tokens[tokenCode];
|
2013-11-23 01:14:44 +00:00
|
|
|
$scope.shownTokenCounter++;
|
2013-10-16 18:24:10 +00:00
|
|
|
};
|
|
|
|
|
2013-09-28 21:11:10 +00:00
|
|
|
$scope.askChangeAccess = function(newAccess) {
|
2013-10-01 23:37:33 +00:00
|
|
|
$('#make' + newAccess + 'Modal').modal({});
|
2013-09-28 21:11:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.changeAccess = function(newAccess) {
|
2013-10-01 23:37:33 +00:00
|
|
|
$('#make' + newAccess + 'Modal').modal('hide');
|
|
|
|
|
|
|
|
var visibility = {
|
|
|
|
'visibility': newAccess
|
|
|
|
};
|
2013-12-26 22:45:16 +00:00
|
|
|
|
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.changeRepoVisibility(visibility, params).then(function() {
|
2013-10-01 23:37:33 +00:00
|
|
|
$scope.repo.is_public = newAccess == 'public';
|
|
|
|
}, function() {
|
|
|
|
$('#cannotchangeModal').modal({});
|
|
|
|
});
|
2013-09-28 21:11:10 +00:00
|
|
|
};
|
|
|
|
|
2013-10-01 18:14:30 +00:00
|
|
|
$scope.askDelete = function() {
|
2013-10-01 23:37:33 +00:00
|
|
|
$('#confirmdeleteModal').modal({});
|
2013-10-01 18:14:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.deleteRepo = function() {
|
2013-10-01 23:37:33 +00:00
|
|
|
$('#confirmdeleteModal').modal('hide');
|
|
|
|
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name
|
|
|
|
};
|
|
|
|
|
2014-01-20 22:03:16 +00:00
|
|
|
$scope.deleting = true;
|
2013-12-26 22:45:16 +00:00
|
|
|
ApiService.deleteRepository(null, params).then(function() {
|
2013-10-01 23:37:33 +00:00
|
|
|
$scope.repo = null;
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2013-10-01 23:37:33 +00:00
|
|
|
setTimeout(function() {
|
2013-10-12 17:24:55 +00:00
|
|
|
document.location = '/repository/';
|
2013-10-01 23:37:33 +00:00
|
|
|
}, 1000);
|
|
|
|
}, function() {
|
2014-01-20 22:03:16 +00:00
|
|
|
$scope.deleting = true;
|
2013-10-01 23:37:33 +00:00
|
|
|
$('#cannotchangeModal').modal({});
|
|
|
|
});
|
2013-10-01 18:14:30 +00:00
|
|
|
};
|
2013-10-02 05:05:36 +00:00
|
|
|
|
2014-07-17 17:32:39 +00:00
|
|
|
$scope.showNewNotificationCounter = 0;
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2014-07-17 17:32:39 +00:00
|
|
|
$scope.showNewNotificationDialog = function() {
|
|
|
|
$scope.showNewNotificationCounter++;
|
2013-11-15 22:45:37 +00:00
|
|
|
};
|
|
|
|
|
2014-07-17 17:32:39 +00:00
|
|
|
$scope.handleNotificationCreated = function(notification) {
|
|
|
|
$scope.notifications.push(notification);
|
|
|
|
};
|
2013-12-26 22:45:16 +00:00
|
|
|
|
2014-07-17 17:32:39 +00:00
|
|
|
$scope.handleNotificationDeleted = function(notification) {
|
|
|
|
var index = $.inArray(notification, $scope.notifications);
|
|
|
|
if (index < 0) { return; }
|
|
|
|
$scope.notifications.splice(index, 1);
|
2013-11-15 22:45:37 +00:00
|
|
|
};
|
|
|
|
|
2014-07-17 17:32:39 +00:00
|
|
|
$scope.loadNotifications = function() {
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {
|
2014-07-17 17:32:39 +00:00
|
|
|
'repository': namespace + '/' + name
|
2013-12-26 22:45:16 +00:00
|
|
|
};
|
|
|
|
|
2014-07-17 17:32:39 +00:00
|
|
|
$scope.notificationsResource = ApiService.listRepoNotificationsAsResource(params).get(
|
|
|
|
function(resp) {
|
|
|
|
$scope.notifications = resp.notifications;
|
|
|
|
return $scope.notifications;
|
|
|
|
});
|
2013-11-15 22:45:37 +00:00
|
|
|
};
|
2013-12-17 18:19:59 +00:00
|
|
|
|
2014-02-19 22:38:00 +00:00
|
|
|
$scope.showBuild = function(buildInfo) {
|
|
|
|
$location.path('/repository/' + namespace + '/' + name + '/build');
|
|
|
|
$location.search('current', buildInfo.id);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.loadTriggerBuildHistory = function(trigger) {
|
|
|
|
trigger.$loadingHistory = true;
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name,
|
|
|
|
'trigger_uuid': trigger.id,
|
|
|
|
'limit': 3
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.listTriggerRecentBuilds(null, params).then(function(resp) {
|
|
|
|
trigger.$builds = resp['builds'];
|
|
|
|
trigger.$loadingHistory = false;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2014-02-18 20:50:15 +00:00
|
|
|
$scope.loadTriggers = function() {
|
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.triggersResource = ApiService.listBuildTriggersAsResource(params).get(function(resp) {
|
|
|
|
$scope.triggers = resp.triggers;
|
2014-02-20 23:57:49 +00:00
|
|
|
|
|
|
|
// Check to see if we need to setup any trigger.
|
|
|
|
var newTriggerId = $routeParams.new_trigger;
|
|
|
|
if (newTriggerId) {
|
|
|
|
for (var i = 0; i < $scope.triggers.length; ++i) {
|
|
|
|
var trigger = $scope.triggers[i];
|
|
|
|
if (trigger['id'] == newTriggerId && !trigger['is_active']) {
|
|
|
|
$scope.setupTrigger(trigger);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-18 20:50:15 +00:00
|
|
|
return $scope.triggers;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2014-02-20 23:57:49 +00:00
|
|
|
$scope.setupTrigger = function(trigger) {
|
|
|
|
$scope.currentSetupTrigger = trigger;
|
2014-04-03 03:33:58 +00:00
|
|
|
$scope.showTriggerSetupCounter++;
|
2014-02-20 23:57:49 +00:00
|
|
|
};
|
|
|
|
|
2014-04-03 03:33:58 +00:00
|
|
|
$scope.cancelSetupTrigger = function(trigger) {
|
|
|
|
if ($scope.currentSetupTrigger != trigger) { return; }
|
2014-02-25 20:25:24 +00:00
|
|
|
|
2014-02-20 23:57:49 +00:00
|
|
|
$scope.currentSetupTrigger = null;
|
2014-04-03 03:33:58 +00:00
|
|
|
$scope.deleteTrigger(trigger);
|
2014-02-20 23:57:49 +00:00
|
|
|
};
|
|
|
|
|
2014-09-30 20:29:32 +00:00
|
|
|
$scope.showManualBuildDialog = 0;
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2014-09-30 20:29:32 +00:00
|
|
|
$scope.startTrigger = function(trigger, opt_custom) {
|
|
|
|
var parameters = TriggerService.getRunParameters(trigger.service);
|
|
|
|
if (parameters.length && !opt_custom) {
|
|
|
|
$scope.currentStartTrigger = trigger;
|
|
|
|
$scope.showManualBuildDialog++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-26 00:53:41 +00:00
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name,
|
|
|
|
'trigger_uuid': trigger.id
|
|
|
|
};
|
|
|
|
|
2014-09-30 20:29:32 +00:00
|
|
|
ApiService.manuallyStartBuildTrigger(opt_custom || {}, params).then(function(resp) {
|
2014-02-26 00:53:41 +00:00
|
|
|
var url = '/repository/' + namespace + '/' + name + '/build?current=' + resp['id'];
|
|
|
|
document.location = url;
|
2014-08-18 22:21:53 +00:00
|
|
|
}, ApiService.errorDisplay('Could not start build'));
|
2014-02-26 00:53:41 +00:00
|
|
|
};
|
|
|
|
|
2014-02-19 22:38:00 +00:00
|
|
|
$scope.deleteTrigger = function(trigger) {
|
2014-04-16 21:50:25 +00:00
|
|
|
if (!trigger) { return; }
|
|
|
|
|
2014-02-18 20:50:15 +00:00
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name,
|
|
|
|
'trigger_uuid': trigger.id
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.deleteBuildTrigger(null, params).then(function(resp) {
|
|
|
|
$scope.triggers.splice($scope.triggers.indexOf(trigger), 1);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
var fetchTokens = function() {
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.listRepoTokens(null, params).then(function(resp) {
|
2013-12-17 18:19:59 +00:00
|
|
|
$scope.tokens = resp.tokens;
|
|
|
|
}, function() {
|
|
|
|
$scope.tokens = null;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var fetchPermissions = function(kind) {
|
|
|
|
var permissionsFetch = Restangular.one('repository/' + namespace + '/' + name + '/permissions/' + kind + '/');
|
|
|
|
permissionsFetch.get().then(function(resp) {
|
|
|
|
$scope.permissions[kind] = resp.permissions;
|
2014-10-29 18:21:08 +00:00
|
|
|
$scope.permissions['loading']--;
|
2013-12-17 18:19:59 +00:00
|
|
|
}, function() {
|
|
|
|
$scope.permissions[kind] = null;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var fetchRepository = function() {
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.repository = ApiService.getRepoAsResource(params).get(function(repo) {
|
2014-02-13 02:39:23 +00:00
|
|
|
if (!repo.can_admin) {
|
|
|
|
$rootScope.title = 'Forbidden';
|
|
|
|
$scope.accessDenied = true;
|
|
|
|
return;
|
|
|
|
}
|
2013-12-17 18:19:59 +00:00
|
|
|
|
2014-02-13 02:39:23 +00:00
|
|
|
$scope.repo = repo;
|
2013-12-17 18:19:59 +00:00
|
|
|
$rootScope.title = 'Settings - ' + namespace + '/' + name;
|
|
|
|
$rootScope.description = 'Administrator settings for ' + namespace + '/' + name +
|
2014-07-17 17:32:39 +00:00
|
|
|
': Permissions, notifications and other settings';
|
2013-12-17 18:19:59 +00:00
|
|
|
|
|
|
|
// Fetch all the permissions and token info for the repository.
|
|
|
|
fetchPermissions('user');
|
|
|
|
fetchPermissions('team');
|
|
|
|
fetchTokens();
|
|
|
|
|
2013-12-27 23:05:04 +00:00
|
|
|
$('.info-icon').popover({
|
|
|
|
'trigger': 'hover',
|
|
|
|
'html': true
|
|
|
|
});
|
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
return $scope.repo;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
// Fetch the repository.
|
|
|
|
fetchRepository();
|
2013-10-02 04:48:03 +00:00
|
|
|
}
|
|
|
|
|
2014-01-16 00:15:38 +00:00
|
|
|
function UserAdminCtrl($scope, $timeout, $location, ApiService, PlanService, UserService, CookieService, KeyService,
|
2014-05-28 19:53:53 +00:00
|
|
|
$routeParams, $http, UIService, Features, Config) {
|
2014-04-06 04:36:19 +00:00
|
|
|
$scope.Features = Features;
|
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
if ($routeParams['migrate']) {
|
|
|
|
$('#migrateTab').tab('show')
|
|
|
|
}
|
|
|
|
|
|
|
|
UserService.updateUserIn($scope, function(user) {
|
2013-12-27 19:14:21 +00:00
|
|
|
$scope.cuser = jQuery.extend({}, user);
|
2014-01-14 20:23:44 +00:00
|
|
|
|
2014-08-11 22:25:01 +00:00
|
|
|
if ($scope.cuser.logins) {
|
2014-05-08 23:09:43 +00:00
|
|
|
for (var i = 0; i < $scope.cuser.logins.length; i++) {
|
2014-09-08 16:00:20 +00:00
|
|
|
var login = $scope.cuser.logins[i];
|
|
|
|
login.metadata = login.metadata || {};
|
|
|
|
|
|
|
|
if (login.service == 'github') {
|
2014-08-11 22:25:01 +00:00
|
|
|
$scope.hasGithubLogin = true;
|
2014-09-08 16:00:20 +00:00
|
|
|
$scope.githubLogin = login.metadata['service_username'];
|
2014-11-07 01:35:52 +00:00
|
|
|
$scope.githubEndpoint = KeyService['githubEndpoint'];
|
2014-05-08 23:09:43 +00:00
|
|
|
}
|
2014-08-11 19:47:44 +00:00
|
|
|
|
2014-09-08 16:00:20 +00:00
|
|
|
if (login.service == 'google') {
|
2014-08-11 19:47:44 +00:00
|
|
|
$scope.hasGoogleLogin = true;
|
2014-09-08 16:00:20 +00:00
|
|
|
$scope.googleLogin = login.metadata['service_username'];
|
2014-05-08 23:09:43 +00:00
|
|
|
}
|
2014-01-14 20:23:44 +00:00
|
|
|
}
|
|
|
|
}
|
2013-12-18 03:56:28 +00:00
|
|
|
});
|
2013-10-10 17:44:34 +00:00
|
|
|
|
2013-11-06 23:14:22 +00:00
|
|
|
$scope.readyForPlan = function() {
|
|
|
|
// Show the subscribe dialog if a plan was requested.
|
|
|
|
return $routeParams['plan'];
|
|
|
|
};
|
2013-10-10 17:44:34 +00:00
|
|
|
|
2013-11-06 22:59:16 +00:00
|
|
|
$scope.loading = true;
|
2013-10-10 17:44:34 +00:00
|
|
|
$scope.updatingUser = false;
|
|
|
|
$scope.changePasswordSuccess = false;
|
2014-01-17 22:04:05 +00:00
|
|
|
$scope.changeEmailSent = false;
|
2013-11-07 21:33:56 +00:00
|
|
|
$scope.convertStep = 0;
|
2013-11-08 03:08:23 +00:00
|
|
|
$scope.org = {};
|
2014-01-15 18:55:57 +00:00
|
|
|
$scope.githubRedirectUri = KeyService.githubRedirectUri;
|
2014-03-25 00:57:02 +00:00
|
|
|
$scope.authorizedApps = null;
|
2013-11-06 22:59:16 +00:00
|
|
|
|
2013-12-21 03:38:53 +00:00
|
|
|
$scope.logsShown = 0;
|
|
|
|
$scope.invoicesShown = 0;
|
2014-10-01 18:23:15 +00:00
|
|
|
|
|
|
|
$scope.USER_PATTERN = USER_PATTERN;
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2014-03-25 00:57:02 +00:00
|
|
|
$scope.loadAuthedApps = function() {
|
|
|
|
if ($scope.authorizedApps) { return; }
|
|
|
|
|
|
|
|
ApiService.listUserAuthorizations().then(function(resp) {
|
|
|
|
$scope.authorizedApps = resp['authorizations'];
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.deleteAccess = function(accessTokenInfo) {
|
|
|
|
var params = {
|
|
|
|
'access_token_uuid': accessTokenInfo['uuid']
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.deleteUserAuthorization(null, params).then(function(resp) {
|
|
|
|
$scope.authorizedApps.splice($scope.authorizedApps.indexOf(accessTokenInfo), 1);
|
2014-08-18 22:21:53 +00:00
|
|
|
}, ApiService.errorDisplay('Could not revoke authorization'));
|
2014-03-25 00:57:02 +00:00
|
|
|
};
|
|
|
|
|
2013-12-21 03:38:53 +00:00
|
|
|
$scope.loadLogs = function() {
|
|
|
|
if (!$scope.hasPaidBusinessPlan) { return; }
|
|
|
|
$scope.logsShown++;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.loadInvoices = function() {
|
|
|
|
$scope.invoicesShown++;
|
|
|
|
};
|
|
|
|
|
2013-11-15 23:17:12 +00:00
|
|
|
$scope.planChanged = function(plan) {
|
|
|
|
$scope.hasPaidPlan = plan && plan.price > 0;
|
2013-12-21 03:38:53 +00:00
|
|
|
$scope.hasPaidBusinessPlan = PlanService.isOrgCompatible(plan) && plan.price > 0;
|
2013-11-15 23:17:12 +00:00
|
|
|
};
|
|
|
|
|
2013-11-07 21:33:56 +00:00
|
|
|
$scope.showConvertForm = function() {
|
2014-04-06 04:36:19 +00:00
|
|
|
if (Features.BILLING) {
|
|
|
|
PlanService.getMatchingBusinessPlan(function(plan) {
|
|
|
|
$scope.org.plan = plan;
|
|
|
|
});
|
2013-11-08 03:08:23 +00:00
|
|
|
|
2014-04-06 04:36:19 +00:00
|
|
|
PlanService.getPlans(function(plans) {
|
|
|
|
$scope.orgPlans = plans;
|
|
|
|
});
|
|
|
|
}
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2013-11-07 21:33:56 +00:00
|
|
|
$scope.convertStep = 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.convertToOrg = function() {
|
|
|
|
$('#reallyconvertModal').modal({});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.reallyConvert = function() {
|
2014-05-28 19:53:53 +00:00
|
|
|
if (Config.AUTHENTICATION_TYPE != 'Database') { return; }
|
|
|
|
|
2013-11-07 21:33:56 +00:00
|
|
|
$scope.loading = true;
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
'adminUser': $scope.org.adminUser,
|
2013-11-08 03:08:23 +00:00
|
|
|
'adminPassword': $scope.org.adminPassword,
|
2014-04-06 04:36:19 +00:00
|
|
|
'plan': $scope.org.plan ? $scope.org.plan.stripeId : ''
|
2013-11-07 21:33:56 +00:00
|
|
|
};
|
|
|
|
|
2013-12-26 22:45:16 +00:00
|
|
|
ApiService.convertUserToOrganization(data).then(function(resp) {
|
2014-01-16 00:15:38 +00:00
|
|
|
CookieService.putPermanent('quay.namespace', $scope.cuser.username);
|
2013-11-07 21:33:56 +00:00
|
|
|
UserService.load();
|
|
|
|
$location.path('/');
|
|
|
|
}, function(resp) {
|
|
|
|
$scope.loading = false;
|
|
|
|
if (resp.data.reason == 'invaliduser') {
|
|
|
|
$('#invalidadminModal').modal({});
|
|
|
|
} else {
|
|
|
|
$('#cannotconvertModal').modal({});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2014-10-01 18:23:15 +00:00
|
|
|
$scope.changeUsername = function() {
|
|
|
|
UserService.load();
|
|
|
|
|
|
|
|
$scope.updatingUser = true;
|
|
|
|
|
|
|
|
ApiService.changeUserDetails($scope.cuser).then(function() {
|
|
|
|
$scope.updatingUser = false;
|
|
|
|
|
|
|
|
// Reset the form.
|
|
|
|
delete $scope.cuser['username'];
|
|
|
|
|
|
|
|
$scope.changeUsernameForm.$setPristine();
|
|
|
|
}, function(result) {
|
|
|
|
$scope.updatingUser = false;
|
|
|
|
UIService.showFormError('#changeUsernameForm', result);
|
2014-11-24 21:07:38 +00:00
|
|
|
});
|
2014-10-01 18:23:15 +00:00
|
|
|
};
|
|
|
|
|
2014-01-17 22:04:05 +00:00
|
|
|
$scope.changeEmail = function() {
|
2014-04-07 22:55:39 +00:00
|
|
|
UIService.hidePopover('#changeEmailForm');
|
|
|
|
|
2014-01-17 22:04:05 +00:00
|
|
|
$scope.updatingUser = true;
|
|
|
|
$scope.changeEmailSent = false;
|
|
|
|
|
|
|
|
ApiService.changeUserDetails($scope.cuser).then(function() {
|
|
|
|
$scope.updatingUser = false;
|
|
|
|
$scope.changeEmailSent = true;
|
|
|
|
$scope.sentEmail = $scope.cuser.email;
|
|
|
|
|
|
|
|
// Reset the form.
|
2014-10-01 18:23:15 +00:00
|
|
|
delete $scope.cuser['email'];
|
2014-03-17 18:59:40 +00:00
|
|
|
|
2014-01-17 22:04:05 +00:00
|
|
|
$scope.changeEmailForm.$setPristine();
|
|
|
|
}, function(result) {
|
|
|
|
$scope.updatingUser = false;
|
2014-09-04 18:24:20 +00:00
|
|
|
UIService.showFormError('#changeEmailForm', result);
|
2014-01-17 22:04:05 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2013-10-10 17:44:34 +00:00
|
|
|
$scope.changePassword = function() {
|
2014-04-07 22:55:39 +00:00
|
|
|
UIService.hidePopover('#changePasswordForm');
|
|
|
|
|
2013-10-10 17:44:34 +00:00
|
|
|
$scope.updatingUser = true;
|
|
|
|
$scope.changePasswordSuccess = false;
|
2013-12-26 22:45:16 +00:00
|
|
|
|
2014-09-04 18:24:20 +00:00
|
|
|
ApiService.changeUserDetails($scope.cuser).then(function(resp) {
|
|
|
|
|
2013-10-10 17:44:34 +00:00
|
|
|
$scope.updatingUser = false;
|
|
|
|
$scope.changePasswordSuccess = true;
|
|
|
|
|
2013-10-10 18:02:28 +00:00
|
|
|
// Reset the form
|
2014-03-17 18:59:40 +00:00
|
|
|
delete $scope.cuser['password']
|
|
|
|
delete $scope.cuser['repeatPassword']
|
|
|
|
|
2013-10-10 18:02:28 +00:00
|
|
|
$scope.changePasswordForm.$setPristine();
|
|
|
|
|
2013-11-06 22:59:16 +00:00
|
|
|
// Reload the user.
|
2013-10-10 17:44:34 +00:00
|
|
|
UserService.load();
|
|
|
|
}, function(result) {
|
|
|
|
$scope.updatingUser = false;
|
2014-11-24 21:07:38 +00:00
|
|
|
UIService.showFormError('#changePasswordForm', result);
|
2013-10-10 17:44:34 +00:00
|
|
|
});
|
|
|
|
};
|
2014-09-15 16:01:02 +00:00
|
|
|
|
|
|
|
$scope.detachExternalLogin = function(kind) {
|
|
|
|
var params = {
|
|
|
|
'servicename': kind
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.detachExternalLogin(null, params).then(function() {
|
|
|
|
$scope.hasGithubLogin = false;
|
|
|
|
$scope.hasGoogleLogin = false;
|
|
|
|
UserService.load();
|
|
|
|
}, ApiService.errorDisplay('Count not detach service'));
|
|
|
|
};
|
2013-10-17 21:45:08 +00:00
|
|
|
}
|
|
|
|
|
2014-11-24 21:07:38 +00:00
|
|
|
function ImageViewCtrl($scope, $routeParams, $rootScope, $timeout, ApiService, ImageMetadataService) {
|
2013-10-19 02:28:46 +00:00
|
|
|
var namespace = $routeParams.namespace;
|
|
|
|
var name = $routeParams.name;
|
|
|
|
var imageid = $routeParams.image;
|
|
|
|
|
2014-01-14 21:01:37 +00:00
|
|
|
$scope.getFormattedCommand = ImageMetadataService.getFormattedCommand;
|
2014-01-14 20:19:47 +00:00
|
|
|
|
2013-10-19 02:28:46 +00:00
|
|
|
$scope.parseDate = function(dateString) {
|
|
|
|
return Date.parse(dateString);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.getFolder = function(filepath) {
|
|
|
|
var index = filepath.lastIndexOf('/');
|
|
|
|
if (index < 0) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
return filepath.substr(0, index + 1);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.getFolders = function(filepath) {
|
|
|
|
var index = filepath.lastIndexOf('/');
|
|
|
|
if (index < 0) {
|
|
|
|
return '';
|
|
|
|
}
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2013-10-19 02:28:46 +00:00
|
|
|
return filepath.substr(0, index).split('/');
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.getFilename = function(filepath) {
|
|
|
|
var index = filepath.lastIndexOf('/');
|
|
|
|
if (index < 0) {
|
|
|
|
return filepath;
|
|
|
|
}
|
|
|
|
return filepath.substr(index + 1);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.setFolderFilter = function(folderPath, index) {
|
|
|
|
var parts = folderPath.split('/');
|
|
|
|
parts = parts.slice(0, index + 1);
|
|
|
|
$scope.setFilter(parts.join('/'));
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.setFilter = function(filter) {
|
|
|
|
$scope.search = {};
|
|
|
|
$scope.search['$'] = filter;
|
|
|
|
document.getElementById('change-filter').value = filter;
|
|
|
|
};
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2013-10-19 23:46:30 +00:00
|
|
|
$scope.initializeTree = function() {
|
|
|
|
if ($scope.tree) { return; }
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2013-10-19 23:46:30 +00:00
|
|
|
$scope.tree = new ImageFileChangeTree($scope.image, $scope.combinedChanges);
|
2013-12-18 03:56:28 +00:00
|
|
|
$timeout(function() {
|
2013-10-19 23:46:30 +00:00
|
|
|
$scope.tree.draw('changes-tree-container');
|
|
|
|
}, 10);
|
|
|
|
};
|
2013-10-19 02:28:46 +00:00
|
|
|
|
2014-03-05 22:01:04 +00:00
|
|
|
var fetchRepository = function() {
|
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.getRepoAsResource(params).get(function(repo) {
|
|
|
|
$scope.repo = repo;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2014-01-10 01:11:52 +00:00
|
|
|
var fetchImage = function() {
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name,
|
2014-11-24 21:07:38 +00:00
|
|
|
'image_id': imageid
|
2013-12-26 22:45:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.image = ApiService.getImageAsResource(params).get(function(image) {
|
2014-03-05 22:01:04 +00:00
|
|
|
if (!$scope.repo) {
|
|
|
|
$scope.repo = {
|
|
|
|
'name': name,
|
|
|
|
'namespace': namespace,
|
|
|
|
'is_public': true
|
|
|
|
};
|
|
|
|
}
|
2013-12-18 03:56:28 +00:00
|
|
|
|
|
|
|
$rootScope.title = 'View Image - ' + image.id;
|
|
|
|
$rootScope.description = 'Viewing docker image ' + image.id + ' under repository ' + namespace + '/' + name +
|
2013-11-19 00:03:35 +00:00
|
|
|
': Image changes tree and list view';
|
2013-10-19 02:28:46 +00:00
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
// Fetch the image's changes.
|
|
|
|
fetchChanges();
|
|
|
|
return image;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var fetchChanges = function() {
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name,
|
2014-11-24 21:07:38 +00:00
|
|
|
'image_id': imageid
|
2013-12-26 22:45:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.getImageChanges(null, params).then(function(changes) {
|
2013-12-18 03:56:28 +00:00
|
|
|
var combinedChanges = [];
|
|
|
|
var addCombinedChanges = function(c, kind) {
|
|
|
|
for (var i = 0; i < c.length; ++i) {
|
2014-11-24 21:07:38 +00:00
|
|
|
combinedChanges.push({
|
2013-12-18 03:56:28 +00:00
|
|
|
'kind': kind,
|
|
|
|
'file': c[i]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
addCombinedChanges(changes.added, 'added');
|
|
|
|
addCombinedChanges(changes.removed, 'removed');
|
|
|
|
addCombinedChanges(changes.changed, 'changed');
|
|
|
|
|
|
|
|
$scope.combinedChanges = combinedChanges;
|
|
|
|
$scope.imageChanges = changes;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2014-03-05 22:01:04 +00:00
|
|
|
// Fetch the repository.
|
|
|
|
fetchRepository();
|
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
// Fetch the image.
|
|
|
|
fetchImage();
|
2013-10-19 02:28:46 +00:00
|
|
|
}
|
|
|
|
|
2013-10-28 17:22:18 +00:00
|
|
|
function V1Ctrl($scope, $location, UserService) {
|
2013-12-18 03:56:28 +00:00
|
|
|
UserService.updateUserIn($scope);
|
2013-10-24 21:41:55 +00:00
|
|
|
}
|
|
|
|
|
2014-11-05 21:43:37 +00:00
|
|
|
function NewRepoCtrl($scope, $location, $http, $timeout, UserService, ApiService, PlanService, TriggerService, Features) {
|
2013-12-18 03:56:28 +00:00
|
|
|
UserService.updateUserIn($scope);
|
2013-10-30 19:44:01 +00:00
|
|
|
|
2014-05-30 22:28:18 +00:00
|
|
|
$scope.Features = Features;
|
2014-03-13 19:25:38 +00:00
|
|
|
|
2013-10-24 21:41:55 +00:00
|
|
|
$scope.repo = {
|
2014-05-16 18:19:54 +00:00
|
|
|
'is_public': 0,
|
2013-10-24 21:41:55 +00:00
|
|
|
'description': '',
|
2014-03-13 19:25:38 +00:00
|
|
|
'initialize': ''
|
2013-10-24 21:41:55 +00:00
|
|
|
};
|
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
// Watch the namespace on the repo. If it changes, we update the plan and the public/private
|
|
|
|
// accordingly.
|
|
|
|
$scope.isUserNamespace = true;
|
|
|
|
$scope.$watch('repo.namespace', function(namespace) {
|
|
|
|
// Note: Can initially be undefined.
|
|
|
|
if (!namespace) { return; }
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
var isUserNamespace = (namespace == $scope.user.username);
|
|
|
|
|
|
|
|
$scope.planRequired = null;
|
|
|
|
$scope.isUserNamespace = isUserNamespace;
|
|
|
|
|
2014-03-06 23:36:52 +00:00
|
|
|
// Determine whether private repositories are allowed for the namespace.
|
|
|
|
checkPrivateAllowed();
|
2013-12-18 03:56:28 +00:00
|
|
|
});
|
|
|
|
|
2014-01-16 00:15:38 +00:00
|
|
|
$scope.changeNamespace = function(namespace) {
|
|
|
|
$scope.repo.namespace = namespace;
|
|
|
|
};
|
|
|
|
|
2014-02-15 03:59:44 +00:00
|
|
|
$scope.handleBuildStarted = function() {
|
|
|
|
var repo = $scope.repo;
|
|
|
|
$location.path('/repository/' + repo.namespace + '/' + repo.name);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.handleBuildFailed = function(message) {
|
|
|
|
var repo = $scope.repo;
|
|
|
|
|
|
|
|
bootbox.dialog({
|
|
|
|
"message": message,
|
|
|
|
"title": "Could not start Dockerfile build",
|
|
|
|
"buttons": {
|
|
|
|
"close": {
|
|
|
|
"label": "Close",
|
|
|
|
"className": "btn-primary",
|
|
|
|
"callback": function() {
|
|
|
|
$scope.$apply(function() {
|
|
|
|
$location.path('/repository/' + repo.namespace + '/' + repo.name);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2014-02-15 03:59:44 +00:00
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
$scope.createNewRepo = function() {
|
|
|
|
$('#repoName').popover('hide');
|
|
|
|
|
|
|
|
$scope.creating = true;
|
|
|
|
var repo = $scope.repo;
|
|
|
|
var data = {
|
|
|
|
'namespace': repo.namespace,
|
|
|
|
'repository': repo.name,
|
|
|
|
'visibility': repo.is_public == '1' ? 'public' : 'private',
|
|
|
|
'description': repo.description
|
|
|
|
};
|
|
|
|
|
2013-12-26 22:45:16 +00:00
|
|
|
ApiService.createRepo(data).then(function(created) {
|
2013-12-18 03:56:28 +00:00
|
|
|
$scope.creating = false;
|
|
|
|
$scope.created = created;
|
|
|
|
|
2014-03-13 19:25:38 +00:00
|
|
|
// Start the upload process if applicable.
|
|
|
|
if ($scope.repo.initialize == 'dockerfile' || $scope.repo.initialize == 'zipfile') {
|
2014-02-15 03:59:44 +00:00
|
|
|
$scope.createdForBuild = created;
|
2013-12-18 03:56:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-13 19:25:38 +00:00
|
|
|
// Conduct the Github redirect if applicable.
|
|
|
|
if ($scope.repo.initialize == 'github') {
|
2014-11-05 21:43:37 +00:00
|
|
|
window.location = TriggerService.getRedirectUrl('github', repo.namespace, repo.name);
|
2014-03-13 19:25:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
// Otherwise, redirect to the repo page.
|
|
|
|
$location.path('/repository/' + created.namespace + '/' + created.name);
|
|
|
|
}, function(result) {
|
|
|
|
$scope.creating = false;
|
2014-01-24 19:12:04 +00:00
|
|
|
$scope.createError = result.data ? result.data.message : 'Cannot create repository';
|
2013-12-18 03:56:28 +00:00
|
|
|
$timeout(function() {
|
|
|
|
$('#repoName').popover('show');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.upgradePlan = function() {
|
|
|
|
var callbacks = {
|
|
|
|
'started': function() { $scope.planChanging = true; },
|
|
|
|
'opened': function() { $scope.planChanging = true; },
|
|
|
|
'closed': function() { $scope.planChanging = false; },
|
|
|
|
'success': subscribedToPlan,
|
|
|
|
'failure': function(resp) {
|
|
|
|
$('#couldnotsubscribeModal').modal();
|
|
|
|
$scope.planChanging = false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-03-06 23:36:52 +00:00
|
|
|
var namespace = $scope.isUserNamespace ? null : $scope.repo.namespace;
|
|
|
|
PlanService.changePlan($scope, namespace, $scope.planRequired.stripeId, callbacks);
|
|
|
|
};
|
|
|
|
|
|
|
|
var checkPrivateAllowed = function() {
|
|
|
|
if (!$scope.repo || !$scope.repo.namespace) { return; }
|
|
|
|
|
2014-04-06 04:36:19 +00:00
|
|
|
if (!Features.BILLING) {
|
|
|
|
$scope.checkingPlan = false;
|
|
|
|
$scope.planRequired = null;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-06 23:36:52 +00:00
|
|
|
$scope.checkingPlan = true;
|
|
|
|
|
|
|
|
var isUserNamespace = $scope.isUserNamespace;
|
|
|
|
ApiService.getPrivateAllowed(isUserNamespace ? null : $scope.repo.namespace).then(function(resp) {
|
|
|
|
$scope.checkingPlan = false;
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2014-04-06 04:36:19 +00:00
|
|
|
if (resp['privateAllowed']) {
|
2014-03-06 23:36:52 +00:00
|
|
|
$scope.planRequired = null;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (resp['privateCount'] == null) {
|
|
|
|
// Organization where we are not the admin.
|
|
|
|
$scope.planRequired = {};
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, lookup the matching plan.
|
|
|
|
PlanService.getMinimumPlan(resp['privateCount'] + 1, !isUserNamespace, function(minimum) {
|
|
|
|
$scope.planRequired = minimum;
|
|
|
|
});
|
|
|
|
});
|
2013-12-18 03:56:28 +00:00
|
|
|
};
|
2013-10-26 21:20:59 +00:00
|
|
|
|
2013-10-28 21:08:26 +00:00
|
|
|
var subscribedToPlan = function(sub) {
|
|
|
|
$scope.planChanging = false;
|
|
|
|
$scope.subscription = sub;
|
2013-11-01 23:13:58 +00:00
|
|
|
|
|
|
|
PlanService.getPlan(sub.plan, function(subscribedPlan) {
|
|
|
|
$scope.subscribedPlan = subscribedPlan;
|
|
|
|
$scope.planRequired = null;
|
2014-03-06 23:36:52 +00:00
|
|
|
checkPrivateAllowed();
|
2013-11-01 23:13:58 +00:00
|
|
|
});
|
2013-10-28 21:08:26 +00:00
|
|
|
};
|
2013-10-31 22:17:26 +00:00
|
|
|
}
|
|
|
|
|
2013-12-26 22:45:16 +00:00
|
|
|
function OrgViewCtrl($rootScope, $scope, ApiService, $routeParams) {
|
2013-12-18 03:56:28 +00:00
|
|
|
var orgname = $routeParams.orgname;
|
|
|
|
|
2013-12-10 06:38:05 +00:00
|
|
|
$scope.TEAM_PATTERN = TEAM_PATTERN;
|
2013-11-05 03:58:21 +00:00
|
|
|
$rootScope.title = 'Loading...';
|
|
|
|
|
2013-11-05 19:47:46 +00:00
|
|
|
$scope.teamRoles = [
|
|
|
|
{ 'id': 'member', 'title': 'Member', 'kind': 'default' },
|
|
|
|
{ 'id': 'creator', 'title': 'Creator', 'kind': 'success' },
|
|
|
|
{ 'id': 'admin', 'title': 'Admin', 'kind': 'primary' }
|
|
|
|
];
|
2014-11-24 21:07:38 +00:00
|
|
|
|
|
|
|
$scope.setRole = function(role, teamname) {
|
2013-11-08 04:35:27 +00:00
|
|
|
var previousRole = $scope.organization.teams[teamname].role;
|
2013-11-05 03:58:21 +00:00
|
|
|
$scope.organization.teams[teamname].role = role;
|
|
|
|
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {
|
|
|
|
'orgname': orgname,
|
|
|
|
'teamname': teamname
|
|
|
|
};
|
|
|
|
|
2013-11-05 03:58:21 +00:00
|
|
|
var data = $scope.organization.teams[teamname];
|
2013-11-08 04:35:27 +00:00
|
|
|
|
2013-12-26 22:45:16 +00:00
|
|
|
ApiService.updateOrganizationTeam(data, params).then(function(resp) {
|
2014-11-24 21:07:38 +00:00
|
|
|
}, function(resp) {
|
2013-11-08 04:35:27 +00:00
|
|
|
$scope.organization.teams[teamname].role = previousRole;
|
|
|
|
$scope.roleError = resp.data || '';
|
2013-11-05 03:58:21 +00:00
|
|
|
$('#cannotChangeTeamModal').modal({});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2013-11-23 01:14:44 +00:00
|
|
|
$scope.createTeam = function(teamname) {
|
2013-11-05 22:20:43 +00:00
|
|
|
if (!teamname) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($scope.organization.teams[teamname]) {
|
|
|
|
$('#team-' + teamname).removeClass('highlight');
|
|
|
|
setTimeout(function() {
|
|
|
|
$('#team-' + teamname).addClass('highlight');
|
|
|
|
}, 10);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-26 22:45:16 +00:00
|
|
|
createOrganizationTeam(ApiService, orgname, teamname, function(created) {
|
2013-12-10 06:38:05 +00:00
|
|
|
$scope.organization.teams[teamname] = created;
|
2013-11-05 22:20:43 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2013-11-05 19:47:46 +00:00
|
|
|
$scope.askDeleteTeam = function(teamname) {
|
|
|
|
$scope.currentDeleteTeam = teamname;
|
|
|
|
$('#confirmdeleteModal').modal({});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.deleteTeam = function() {
|
|
|
|
$('#confirmdeleteModal').modal('hide');
|
|
|
|
if (!$scope.currentDeleteTeam) { return; }
|
|
|
|
|
|
|
|
var teamname = $scope.currentDeleteTeam;
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {
|
|
|
|
'orgname': orgname,
|
|
|
|
'teamname': teamname
|
|
|
|
};
|
|
|
|
|
2014-08-18 22:21:53 +00:00
|
|
|
var errorHandler = ApiService.errorDisplay('Cannot delete team', function() {
|
|
|
|
$scope.currentDeleteTeam = null;
|
|
|
|
});
|
|
|
|
|
2013-12-26 22:45:16 +00:00
|
|
|
ApiService.deleteOrganizationTeam(null, params).then(function() {
|
2013-11-05 19:47:46 +00:00
|
|
|
delete $scope.organization.teams[teamname];
|
|
|
|
$scope.currentDeleteTeam = null;
|
2014-08-18 22:21:53 +00:00
|
|
|
}, errorHandler);
|
2013-11-05 19:47:46 +00:00
|
|
|
};
|
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
var loadOrganization = function() {
|
2013-12-26 22:45:16 +00:00
|
|
|
$scope.orgResource = ApiService.getOrganizationAsResource({'orgname': orgname}).get(function(org) {
|
2013-12-18 03:56:28 +00:00
|
|
|
$scope.organization = org;
|
|
|
|
$rootScope.title = orgname;
|
|
|
|
$rootScope.description = 'Viewing organization ' + orgname;
|
2013-12-21 03:38:53 +00:00
|
|
|
|
|
|
|
$('.info-icon').popover({
|
|
|
|
'trigger': 'hover',
|
|
|
|
'html': true
|
|
|
|
});
|
2013-12-18 03:56:28 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
// Load the organization.
|
2013-11-04 21:21:49 +00:00
|
|
|
loadOrganization();
|
2013-10-31 22:17:26 +00:00
|
|
|
}
|
|
|
|
|
2014-04-14 23:37:22 +00:00
|
|
|
function OrgAdminCtrl($rootScope, $scope, $timeout, Restangular, $routeParams, UserService, PlanService, ApiService, Features, UIService) {
|
2013-12-18 03:56:28 +00:00
|
|
|
var orgname = $routeParams.orgname;
|
|
|
|
|
2013-11-05 23:39:27 +00:00
|
|
|
// Load the list of plans.
|
2014-04-06 04:36:19 +00:00
|
|
|
if (Features.BILLING) {
|
|
|
|
PlanService.getPlans(function(plans) {
|
|
|
|
$scope.plans = plans;
|
|
|
|
$scope.plan_map = {};
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2014-04-06 04:36:19 +00:00
|
|
|
for (var i = 0; i < plans.length; ++i) {
|
|
|
|
$scope.plan_map[plans[i].stripeId] = plans[i];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2013-11-05 23:39:27 +00:00
|
|
|
|
2013-11-06 22:59:16 +00:00
|
|
|
$scope.orgname = orgname;
|
2013-11-07 00:06:59 +00:00
|
|
|
$scope.membersLoading = true;
|
|
|
|
$scope.membersFound = null;
|
2013-11-13 22:47:45 +00:00
|
|
|
$scope.invoiceLoading = true;
|
2013-11-27 21:56:07 +00:00
|
|
|
$scope.logsShown = 0;
|
2013-12-21 03:38:53 +00:00
|
|
|
$scope.invoicesShown = 0;
|
2014-03-20 19:46:13 +00:00
|
|
|
$scope.applicationsShown = 0;
|
2014-01-20 21:12:23 +00:00
|
|
|
$scope.changingOrganization = false;
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2013-11-27 07:29:31 +00:00
|
|
|
$scope.loadLogs = function() {
|
2013-11-27 21:56:07 +00:00
|
|
|
$scope.logsShown++;
|
2013-11-27 07:29:31 +00:00
|
|
|
};
|
|
|
|
|
2014-03-20 19:46:13 +00:00
|
|
|
$scope.loadApplications = function() {
|
|
|
|
$scope.applicationsShown++;
|
|
|
|
};
|
|
|
|
|
2013-11-13 22:47:45 +00:00
|
|
|
$scope.loadInvoices = function() {
|
2013-12-21 03:38:53 +00:00
|
|
|
$scope.invoicesShown++;
|
2013-11-13 22:47:45 +00:00
|
|
|
};
|
|
|
|
|
2013-12-21 03:38:53 +00:00
|
|
|
$scope.planChanged = function(plan) {
|
|
|
|
$scope.hasPaidPlan = plan && plan.price > 0;
|
2013-11-13 22:47:45 +00:00
|
|
|
};
|
2013-11-07 00:06:59 +00:00
|
|
|
|
2014-01-20 23:27:17 +00:00
|
|
|
$scope.$watch('organizationEmail', function(e) {
|
2014-04-07 22:55:39 +00:00
|
|
|
UIService.hidePopover('#changeEmailForm');
|
2014-01-20 23:27:17 +00:00
|
|
|
});
|
|
|
|
|
2014-01-20 21:12:23 +00:00
|
|
|
$scope.changeEmail = function() {
|
2014-04-07 22:55:39 +00:00
|
|
|
UIService.hidePopover('#changeEmailForm');
|
|
|
|
|
2014-01-20 21:12:23 +00:00
|
|
|
$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;
|
2014-01-20 23:17:03 +00:00
|
|
|
}, function(result) {
|
2014-01-20 22:03:16 +00:00
|
|
|
$scope.changingOrganization = false;
|
2014-04-07 22:55:39 +00:00
|
|
|
UIService.showFormError('#changeEmailForm', result);
|
2014-01-20 21:12:23 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2013-11-07 00:06:59 +00:00
|
|
|
$scope.loadMembers = function() {
|
|
|
|
if ($scope.membersFound) { return; }
|
|
|
|
$scope.membersLoading = true;
|
2013-12-26 22:45:16 +00:00
|
|
|
|
|
|
|
var params = {
|
|
|
|
'orgname': orgname
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.getOrganizationMembers(null, params).then(function(resp) {
|
2013-11-07 00:06:59 +00:00
|
|
|
var membersArray = [];
|
|
|
|
for (var key in resp.members) {
|
|
|
|
if (resp.members.hasOwnProperty(key)) {
|
|
|
|
membersArray.push(resp.members[key]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.membersFound = membersArray;
|
|
|
|
$scope.membersLoading = false;
|
|
|
|
});
|
|
|
|
};
|
2013-11-05 23:39:27 +00:00
|
|
|
|
|
|
|
var loadOrganization = function() {
|
2013-12-26 22:45:16 +00:00
|
|
|
$scope.orgResource = ApiService.getOrganizationAsResource({'orgname': orgname}).get(function(org) {
|
2013-12-18 03:56:28 +00:00
|
|
|
if (org && org.is_admin) {
|
|
|
|
$scope.organization = org;
|
2014-01-20 21:12:23 +00:00
|
|
|
$scope.organizationEmail = org.email;
|
2013-11-05 23:39:27 +00:00
|
|
|
$rootScope.title = orgname + ' (Admin)';
|
2013-11-19 00:03:35 +00:00
|
|
|
$rootScope.description = 'Administration page for organization ' + orgname;
|
2013-11-05 23:39:27 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
// Load the organization.
|
2013-11-05 23:39:27 +00:00
|
|
|
loadOrganization();
|
2013-10-31 22:17:26 +00:00
|
|
|
}
|
|
|
|
|
2014-09-23 15:19:50 +00:00
|
|
|
function TeamViewCtrl($rootScope, $scope, $timeout, Features, Restangular, ApiService, $routeParams) {
|
2013-10-31 22:17:26 +00:00
|
|
|
var teamname = $routeParams.teamname;
|
2013-12-18 03:56:28 +00:00
|
|
|
var orgname = $routeParams.orgname;
|
2013-11-04 19:56:54 +00:00
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
$scope.orgname = orgname;
|
2013-11-04 19:56:54 +00:00
|
|
|
$scope.teamname = teamname;
|
2014-08-16 00:51:31 +00:00
|
|
|
$scope.addingMember = false;
|
|
|
|
$scope.memberMap = null;
|
2014-09-23 15:19:50 +00:00
|
|
|
$scope.allowEmail = Features.MAILING;
|
2013-11-04 19:56:54 +00:00
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
$rootScope.title = 'Loading...';
|
|
|
|
|
2014-08-16 00:51:31 +00:00
|
|
|
$scope.filterFunction = function(invited, robots) {
|
|
|
|
return function(item) {
|
2014-08-29 03:46:27 +00:00
|
|
|
// Note: The !! is needed because is_robot will be undefined for invites.
|
|
|
|
var robot_check = (!!item.is_robot == robots);
|
|
|
|
return robot_check && item.invited == invited;
|
2014-08-16 00:51:31 +00:00
|
|
|
};
|
|
|
|
};
|
2013-11-04 20:31:38 +00:00
|
|
|
|
2014-08-29 00:49:11 +00:00
|
|
|
$scope.inviteEmail = function(email) {
|
|
|
|
if (!email || $scope.memberMap[email]) { return; }
|
|
|
|
|
|
|
|
$scope.addingMember = true;
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
'orgname': orgname,
|
|
|
|
'teamname': teamname,
|
|
|
|
'email': email
|
|
|
|
};
|
|
|
|
|
|
|
|
var errorHandler = ApiService.errorDisplay('Cannot invite team member', function() {
|
|
|
|
$scope.addingMember = false;
|
|
|
|
});
|
|
|
|
|
|
|
|
ApiService.inviteTeamMemberEmail(null, params).then(function(resp) {
|
|
|
|
$scope.members.push(resp);
|
2014-08-29 03:46:27 +00:00
|
|
|
$scope.memberMap[resp.email] = resp;
|
2014-08-29 00:49:11 +00:00
|
|
|
$scope.addingMember = false;
|
|
|
|
}, errorHandler);
|
|
|
|
};
|
|
|
|
|
2014-08-16 00:51:31 +00:00
|
|
|
$scope.addNewMember = function(member) {
|
|
|
|
if (!member || $scope.memberMap[member.name]) { return; }
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {
|
|
|
|
'orgname': orgname,
|
|
|
|
'teamname': teamname,
|
|
|
|
'membername': member.name
|
|
|
|
};
|
|
|
|
|
2014-08-29 00:49:11 +00:00
|
|
|
var errorHandler = ApiService.errorDisplay('Cannot add team member', function() {
|
|
|
|
$scope.addingMember = false;
|
|
|
|
});
|
|
|
|
|
2014-08-16 00:51:31 +00:00
|
|
|
$scope.addingMember = true;
|
2013-12-26 22:45:16 +00:00
|
|
|
ApiService.updateOrganizationTeamMember(null, params).then(function(resp) {
|
2014-08-16 00:51:31 +00:00
|
|
|
$scope.members.push(resp);
|
|
|
|
$scope.memberMap[resp.name] = resp;
|
|
|
|
$scope.addingMember = false;
|
2014-08-29 00:49:11 +00:00
|
|
|
}, errorHandler);
|
2013-11-04 20:31:38 +00:00
|
|
|
};
|
|
|
|
|
2014-09-08 21:20:01 +00:00
|
|
|
$scope.revokeInvite = function(inviteInfo) {
|
|
|
|
if (inviteInfo.kind == 'invite') {
|
|
|
|
// E-mail invite.
|
|
|
|
$scope.revokeEmailInvite(inviteInfo.email);
|
|
|
|
} else {
|
|
|
|
// User invite.
|
|
|
|
$scope.removeMember(inviteInfo.name);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.revokeEmailInvite = function(email) {
|
|
|
|
var params = {
|
|
|
|
'orgname': orgname,
|
|
|
|
'teamname': teamname,
|
|
|
|
'email': email
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.deleteTeamMemberEmailInvite(null, params).then(function(resp) {
|
|
|
|
if (!$scope.memberMap[email]) { return; }
|
|
|
|
var index = $.inArray($scope.memberMap[email], $scope.members);
|
|
|
|
$scope.members.splice(index, 1);
|
|
|
|
delete $scope.memberMap[email];
|
|
|
|
}, ApiService.errorDisplay('Cannot revoke team invite'));
|
|
|
|
};
|
|
|
|
|
2013-11-04 20:31:38 +00:00
|
|
|
$scope.removeMember = function(username) {
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {
|
|
|
|
'orgname': orgname,
|
|
|
|
'teamname': teamname,
|
|
|
|
'membername': username
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.deleteOrganizationTeamMember(null, params).then(function(resp) {
|
2014-09-08 21:20:01 +00:00
|
|
|
if (!$scope.memberMap[username]) { return; }
|
|
|
|
var index = $.inArray($scope.memberMap[username], $scope.members);
|
|
|
|
$scope.members.splice(index, 1);
|
|
|
|
delete $scope.memberMap[username];
|
|
|
|
}, ApiService.errorDisplay('Cannot remove team member'));
|
2013-11-04 20:31:38 +00:00
|
|
|
};
|
|
|
|
|
2013-11-05 01:17:58 +00:00
|
|
|
$scope.updateForDescription = function(content) {
|
|
|
|
$scope.organization.teams[teamname].description = content;
|
|
|
|
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {
|
|
|
|
'orgname': orgname,
|
|
|
|
'teamname': teamname
|
|
|
|
};
|
|
|
|
|
|
|
|
var teaminfo = $scope.organization.teams[teamname];
|
|
|
|
ApiService.updateOrganizationTeam(teaminfo, params).then(function(resp) {
|
2013-11-05 01:17:58 +00:00
|
|
|
}, function() {
|
|
|
|
$('#cannotChangeTeamModal').modal({});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2013-11-04 19:56:54 +00:00
|
|
|
var loadOrganization = function() {
|
2013-12-26 22:45:16 +00:00
|
|
|
$scope.orgResource = ApiService.getOrganizationAsResource({'orgname': orgname}).get(function(org) {
|
2013-12-18 03:56:28 +00:00
|
|
|
$scope.organization = org;
|
2013-11-05 01:17:58 +00:00
|
|
|
$scope.team = $scope.organization.teams[teamname];
|
2013-12-18 03:56:28 +00:00
|
|
|
$rootScope.title = teamname + ' (' + $scope.orgname + ')';
|
|
|
|
$rootScope.description = 'Team management page for team ' + teamname + ' under organization ' + $scope.orgname;
|
|
|
|
loadMembers();
|
|
|
|
return org;
|
2013-11-04 19:56:54 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var loadMembers = function() {
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {
|
|
|
|
'orgname': orgname,
|
2014-08-15 21:47:43 +00:00
|
|
|
'teamname': teamname,
|
|
|
|
'includePending': true
|
2013-12-26 22:45:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.membersResource = ApiService.getOrganizationTeamMembersAsResource(params).get(function(resp) {
|
2013-11-04 19:56:54 +00:00
|
|
|
$scope.members = resp.members;
|
2013-11-04 21:21:49 +00:00
|
|
|
$scope.canEditMembers = resp.can_edit;
|
2014-11-24 21:07:38 +00:00
|
|
|
|
2013-12-27 23:05:04 +00:00
|
|
|
$('.info-icon').popover({
|
|
|
|
'trigger': 'hover',
|
|
|
|
'html': true
|
|
|
|
});
|
|
|
|
|
2014-08-16 00:51:31 +00:00
|
|
|
$scope.memberMap = {};
|
|
|
|
for (var i = 0; i < $scope.members.length; ++i) {
|
|
|
|
var current = $scope.members[i];
|
2014-08-29 03:46:27 +00:00
|
|
|
$scope.memberMap[current.name || current.email] = current;
|
2014-08-16 00:51:31 +00:00
|
|
|
}
|
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
return resp.members;
|
2013-12-27 23:05:04 +00:00
|
|
|
});
|
2013-11-04 19:56:54 +00:00
|
|
|
};
|
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
// Load the organization.
|
2013-11-04 19:56:54 +00:00
|
|
|
loadOrganization();
|
2013-11-07 06:48:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function OrgsCtrl($scope, UserService) {
|
2013-12-18 03:56:28 +00:00
|
|
|
UserService.updateUserIn($scope);
|
2013-11-07 06:48:58 +00:00
|
|
|
browserchrome.update();
|
|
|
|
}
|
|
|
|
|
2014-04-06 04:36:19 +00:00
|
|
|
function NewOrgCtrl($scope, $routeParams, $timeout, $location, UserService, PlanService, ApiService, CookieService, Features) {
|
|
|
|
$scope.Features = Features;
|
|
|
|
$scope.holder = {};
|
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
UserService.updateUserIn($scope);
|
2013-11-07 20:19:52 +00:00
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
var requested = $routeParams['plan'];
|
2013-11-07 20:33:56 +00:00
|
|
|
|
2014-04-06 04:36:19 +00:00
|
|
|
if (Features.BILLING) {
|
|
|
|
// Load the list of plans.
|
|
|
|
PlanService.getPlans(function(plans) {
|
|
|
|
$scope.plans = plans;
|
2014-04-27 20:35:48 +00:00
|
|
|
$scope.holder.currentPlan = null;
|
2014-04-06 04:36:19 +00:00
|
|
|
if (requested) {
|
|
|
|
PlanService.getPlan(requested, function(plan) {
|
2014-04-27 20:35:48 +00:00
|
|
|
$scope.holder.currentPlan = plan;
|
2014-04-06 04:36:19 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2013-11-07 20:19:52 +00:00
|
|
|
|
2013-12-11 22:50:48 +00:00
|
|
|
$scope.signedIn = function() {
|
2014-04-06 04:36:19 +00:00
|
|
|
if (Features.BILLING) {
|
|
|
|
PlanService.handleNotedPlan();
|
|
|
|
}
|
2013-12-11 22:50:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.signinStarted = function() {
|
2014-04-06 04:36:19 +00:00
|
|
|
if (Features.BILLING) {
|
|
|
|
PlanService.getMinimumPlan(1, true, function(plan) {
|
|
|
|
PlanService.notePlan(plan.stripeId);
|
|
|
|
});
|
|
|
|
}
|
2013-12-11 22:50:48 +00:00
|
|
|
};
|
|
|
|
|
2013-11-07 20:19:52 +00:00
|
|
|
$scope.setPlan = function(plan) {
|
2014-04-27 20:35:48 +00:00
|
|
|
$scope.holder.currentPlan = plan;
|
2013-11-07 20:19:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.createNewOrg = function() {
|
|
|
|
$('#orgName').popover('hide');
|
|
|
|
|
|
|
|
$scope.creating = true;
|
|
|
|
var org = $scope.org;
|
|
|
|
var data = {
|
|
|
|
'name': org.name,
|
|
|
|
'email': org.email
|
|
|
|
};
|
|
|
|
|
2013-12-26 22:45:16 +00:00
|
|
|
ApiService.createOrganization(data).then(function(created) {
|
2013-11-07 20:19:52 +00:00
|
|
|
$scope.created = created;
|
|
|
|
|
|
|
|
// Reset the organizations list.
|
|
|
|
UserService.load();
|
|
|
|
|
2014-01-15 19:20:39 +00:00
|
|
|
// Set the default namesapce to the organization.
|
|
|
|
CookieService.putPermanent('quay.namespace', org.name);
|
|
|
|
|
2013-11-09 01:32:56 +00:00
|
|
|
var showOrg = function() {
|
2013-12-18 03:56:28 +00:00
|
|
|
$scope.creating = false;
|
2013-11-09 01:32:56 +00:00
|
|
|
$location.path('/organization/' + org.name + '/');
|
|
|
|
};
|
|
|
|
|
2013-11-07 20:19:52 +00:00
|
|
|
// If the selected plan is free, simply move to the org page.
|
2014-04-27 20:35:48 +00:00
|
|
|
if (!Features.BILLING || $scope.holder.currentPlan.price == 0) {
|
2013-11-09 01:32:56 +00:00
|
|
|
showOrg();
|
2013-11-07 20:19:52 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, show the subscribe for the plan.
|
2013-12-18 03:56:28 +00:00
|
|
|
$scope.creating = true;
|
2013-11-09 01:32:56 +00:00
|
|
|
var callbacks = {
|
|
|
|
'opened': function() { $scope.creating = true; },
|
|
|
|
'closed': showOrg,
|
|
|
|
'success': showOrg,
|
|
|
|
'failure': showOrg
|
|
|
|
};
|
|
|
|
|
2014-04-27 20:35:48 +00:00
|
|
|
PlanService.changePlan($scope, org.name, $scope.holder.currentPlan.stripeId, callbacks);
|
2014-08-18 22:21:53 +00:00
|
|
|
}, function(resp) {
|
2013-11-07 20:19:52 +00:00
|
|
|
$scope.creating = false;
|
2014-08-18 22:21:53 +00:00
|
|
|
$scope.createError = ApiService.getErrorMessage(resp);
|
2013-11-07 20:19:52 +00:00
|
|
|
$timeout(function() {
|
|
|
|
$('#orgName').popover('show');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
2013-12-07 00:25:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
function OrgMemberLogsCtrl($scope, $routeParams, $rootScope, $timeout, Restangular, ApiService) {
|
2013-12-07 00:25:27 +00:00
|
|
|
var orgname = $routeParams.orgname;
|
|
|
|
var membername = $routeParams.membername;
|
|
|
|
|
|
|
|
$scope.orgname = orgname;
|
|
|
|
$scope.memberInfo = null;
|
|
|
|
$scope.ready = false;
|
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
var loadOrganization = function() {
|
2013-12-26 22:45:16 +00:00
|
|
|
$scope.orgResource = ApiService.getOrganizationAsResource({'orgname': orgname}).get(function(org) {
|
2013-12-18 03:56:28 +00:00
|
|
|
$scope.organization = org;
|
|
|
|
return org;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var loadMemberInfo = function() {
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {
|
|
|
|
'orgname': orgname,
|
|
|
|
'membername': membername
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.memberResource = ApiService.getOrganizationMemberAsResource(params).get(function(resp) {
|
2013-12-18 03:56:28 +00:00
|
|
|
$scope.memberInfo = resp.member;
|
|
|
|
|
2014-09-29 18:10:11 +00:00
|
|
|
$rootScope.title = 'Logs for ' + $scope.memberInfo.name + ' (' + $scope.orgname + ')';
|
2013-12-07 00:30:55 +00:00
|
|
|
$rootScope.description = 'Shows all the actions of ' + $scope.memberInfo.username +
|
|
|
|
' under organization ' + $scope.orgname;
|
2013-12-18 03:56:28 +00:00
|
|
|
|
2013-12-07 00:25:27 +00:00
|
|
|
$timeout(function() {
|
|
|
|
$scope.ready = true;
|
|
|
|
});
|
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
return resp.member;
|
2014-11-24 21:07:38 +00:00
|
|
|
});
|
2013-12-07 00:25:27 +00:00
|
|
|
};
|
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
// Load the org info and the member info.
|
2013-12-07 00:25:27 +00:00
|
|
|
loadOrganization();
|
|
|
|
loadMemberInfo();
|
2014-03-20 19:46:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-17 19:54:07 +00:00
|
|
|
function ManageApplicationCtrl($scope, $routeParams, $rootScope, $location, $timeout, OAuthService, ApiService, UserService, Config) {
|
2014-03-20 19:46:13 +00:00
|
|
|
var orgname = $routeParams.orgname;
|
|
|
|
var clientId = $routeParams.clientid;
|
|
|
|
|
2014-11-17 19:54:07 +00:00
|
|
|
$scope.Config = Config;
|
|
|
|
$scope.OAuthService = OAuthService;
|
2014-03-20 19:46:13 +00:00
|
|
|
$scope.updating = false;
|
|
|
|
|
2014-11-17 19:54:07 +00:00
|
|
|
$scope.genScopes = {};
|
|
|
|
|
|
|
|
UserService.updateUserIn($scope);
|
|
|
|
|
|
|
|
$scope.getScopes = function(scopes) {
|
|
|
|
var checked = [];
|
|
|
|
for (var scopeName in scopes) {
|
|
|
|
if (scopes.hasOwnProperty(scopeName) && scopes[scopeName]) {
|
|
|
|
checked.push(scopeName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return checked;
|
|
|
|
};
|
|
|
|
|
2014-03-20 19:46:13 +00:00
|
|
|
$scope.askResetClientSecret = function() {
|
|
|
|
$('#resetSecretModal').modal({});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.askDelete = function() {
|
|
|
|
$('#deleteAppModal').modal({});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.deleteApplication = function() {
|
|
|
|
var params = {
|
|
|
|
'orgname': orgname,
|
|
|
|
'client_id': clientId
|
|
|
|
};
|
|
|
|
|
|
|
|
$('#deleteAppModal').modal('hide');
|
|
|
|
|
|
|
|
ApiService.deleteOrganizationApplication(null, params).then(function(resp) {
|
|
|
|
$timeout(function() {
|
|
|
|
$location.path('/organization/' + orgname + '/admin');
|
|
|
|
}, 500);
|
2014-08-18 22:21:53 +00:00
|
|
|
}, ApiService.errorDisplay('Could not delete application'));
|
2014-03-20 19:46:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.updateApplication = function() {
|
|
|
|
$scope.updating = true;
|
|
|
|
var params = {
|
|
|
|
'orgname': orgname,
|
|
|
|
'client_id': clientId
|
|
|
|
};
|
|
|
|
|
2014-03-24 22:18:35 +00:00
|
|
|
if (!$scope.application['description']) {
|
|
|
|
delete $scope.application['description'];
|
|
|
|
}
|
|
|
|
|
2014-11-25 00:25:13 +00:00
|
|
|
if (!$scope.application['avatar_email']) {
|
|
|
|
delete $scope.application['avatar_email'];
|
2014-03-24 22:18:35 +00:00
|
|
|
}
|
|
|
|
|
2014-08-18 22:21:53 +00:00
|
|
|
var errorHandler = ApiService.errorDisplay('Could not update application', function(resp) {
|
2014-03-20 19:46:13 +00:00
|
|
|
$scope.updating = false;
|
|
|
|
});
|
2014-08-18 22:21:53 +00:00
|
|
|
|
|
|
|
ApiService.updateOrganizationApplication($scope.application, params).then(function(resp) {
|
|
|
|
$scope.application = resp;
|
|
|
|
}, errorHandler);
|
2014-03-20 19:46:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.resetClientSecret = function() {
|
|
|
|
var params = {
|
|
|
|
'orgname': orgname,
|
|
|
|
'client_id': clientId
|
|
|
|
};
|
|
|
|
|
|
|
|
$('#resetSecretModal').modal('hide');
|
|
|
|
|
|
|
|
ApiService.resetOrganizationApplicationClientSecret(null, params).then(function(resp) {
|
|
|
|
$scope.application = resp;
|
2014-08-18 22:21:53 +00:00
|
|
|
}, ApiService.errorDisplay('Could not reset client secret'));
|
2014-03-20 19:46:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var loadOrganization = function() {
|
|
|
|
$scope.orgResource = ApiService.getOrganizationAsResource({'orgname': orgname}).get(function(org) {
|
|
|
|
$scope.organization = org;
|
|
|
|
return org;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var loadApplicationInfo = function() {
|
|
|
|
var params = {
|
|
|
|
'orgname': orgname,
|
|
|
|
'client_id': clientId
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.appResource = ApiService.getOrganizationApplicationAsResource(params).get(function(resp) {
|
|
|
|
$scope.application = resp;
|
|
|
|
|
|
|
|
$rootScope.title = 'Manage Application ' + $scope.application.name + ' (' + $scope.orgname + ')';
|
|
|
|
$rootScope.description = 'Manage the details of application ' + $scope.application.name +
|
|
|
|
' under organization ' + $scope.orgname;
|
|
|
|
|
|
|
|
return resp;
|
2014-11-24 21:07:38 +00:00
|
|
|
});
|
2014-03-20 19:46:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Load the organization and application info.
|
|
|
|
loadOrganization();
|
|
|
|
loadApplicationInfo();
|
2014-04-10 04:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-12-23 16:40:51 +00:00
|
|
|
function SuperUserAdminCtrl($scope, $timeout, ApiService, Features, UserService, AngularPollChannel) {
|
2014-04-10 04:26:55 +00:00
|
|
|
if (!Features.SUPER_USERS) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Monitor any user changes and place the current user into the scope.
|
|
|
|
UserService.updateUserIn($scope);
|
|
|
|
|
2015-01-04 19:38:41 +00:00
|
|
|
$scope.configStatus = null;
|
2014-10-01 17:55:09 +00:00
|
|
|
$scope.logsCounter = 0;
|
|
|
|
$scope.newUser = {};
|
2014-12-23 19:25:04 +00:00
|
|
|
$scope.createdUser = null;
|
2014-10-28 20:33:13 +00:00
|
|
|
$scope.systemUsage = null;
|
2014-12-23 16:40:51 +00:00
|
|
|
$scope.debugServices = null;
|
|
|
|
$scope.debugLogs = null;
|
|
|
|
$scope.pollChannel = null;
|
|
|
|
$scope.logsScrolled = false;
|
2014-12-23 19:01:00 +00:00
|
|
|
$scope.csrf_token = window.__token;
|
2014-12-23 16:40:51 +00:00
|
|
|
|
2014-12-23 19:25:04 +00:00
|
|
|
$scope.showCreateUser = function() {
|
|
|
|
$scope.createdUser = null;
|
|
|
|
$('#createUserModal').modal('show');
|
|
|
|
};
|
|
|
|
|
2014-12-23 16:40:51 +00:00
|
|
|
$scope.viewSystemLogs = function(service) {
|
|
|
|
if ($scope.pollChannel) {
|
|
|
|
$scope.pollChannel.stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.debugService = service;
|
|
|
|
$scope.debugLogs = null;
|
|
|
|
|
2014-12-23 19:01:00 +00:00
|
|
|
$scope.pollChannel = AngularPollChannel.create($scope, $scope.loadServiceLogs, 2 * 1000 /* 2s */);
|
2014-12-23 16:40:51 +00:00
|
|
|
$scope.pollChannel.start();
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.loadServiceLogs = function(callback) {
|
|
|
|
if (!$scope.debugService) { return; }
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
'service': $scope.debugService
|
|
|
|
};
|
|
|
|
|
|
|
|
var errorHandler = ApiService.errorDisplay('Cannot load system logs. Please contact support.',
|
|
|
|
function() {
|
|
|
|
callback(false);
|
|
|
|
})
|
|
|
|
|
|
|
|
ApiService.getSystemLogs(null, params, /* background */true).then(function(resp) {
|
|
|
|
$scope.debugLogs = resp['logs'];
|
|
|
|
callback(true);
|
|
|
|
}, errorHandler);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.loadDebugServices = function() {
|
|
|
|
if ($scope.pollChannel) {
|
|
|
|
$scope.pollChannel.stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.debugService = null;
|
|
|
|
|
|
|
|
ApiService.listSystemLogServices().then(function(resp) {
|
|
|
|
$scope.debugServices = resp['services'];
|
|
|
|
}, ApiService.errorDisplay('Cannot load system logs. Please contact support.'))
|
|
|
|
};
|
2014-10-28 20:33:13 +00:00
|
|
|
|
|
|
|
$scope.getUsage = function() {
|
|
|
|
if ($scope.systemUsage) { return; }
|
|
|
|
|
|
|
|
ApiService.getSystemUsage().then(function(resp) {
|
|
|
|
$scope.systemUsage = resp;
|
|
|
|
}, ApiService.errorDisplay('Cannot load system usage. Please contact support.'))
|
|
|
|
}
|
2014-10-01 17:55:09 +00:00
|
|
|
|
2014-12-22 20:13:23 +00:00
|
|
|
$scope.loadUsageLogs = function() {
|
2014-10-01 17:55:09 +00:00
|
|
|
$scope.logsCounter++;
|
|
|
|
};
|
|
|
|
|
2014-04-10 04:26:55 +00:00
|
|
|
$scope.loadUsers = function() {
|
|
|
|
if ($scope.users) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.loadUsersInternal();
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.loadUsersInternal = function() {
|
|
|
|
ApiService.listAllUsers().then(function(resp) {
|
|
|
|
$scope.users = resp['users'];
|
2014-10-01 17:55:09 +00:00
|
|
|
$scope.showInterface = true;
|
2014-04-10 04:26:55 +00:00
|
|
|
}, function(resp) {
|
|
|
|
$scope.users = [];
|
|
|
|
$scope.usersError = resp['data']['message'] || resp['data']['error_description'];
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.showChangePassword = function(user) {
|
|
|
|
$scope.userToChange = user;
|
|
|
|
$('#changePasswordModal').modal({});
|
|
|
|
};
|
|
|
|
|
2014-10-01 17:55:09 +00:00
|
|
|
$scope.createUser = function() {
|
|
|
|
$scope.creatingUser = true;
|
2014-12-23 19:25:04 +00:00
|
|
|
$scope.createdUser = null;
|
|
|
|
|
2014-10-01 17:55:09 +00:00
|
|
|
var errorHandler = ApiService.errorDisplay('Cannot create user', function() {
|
|
|
|
$scope.creatingUser = false;
|
2014-12-23 19:25:04 +00:00
|
|
|
$('#createUserModal').modal('hide');
|
2014-10-01 17:55:09 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
ApiService.createInstallUser($scope.newUser, null).then(function(resp) {
|
|
|
|
$scope.creatingUser = false;
|
|
|
|
$scope.newUser = {};
|
2014-12-23 19:25:04 +00:00
|
|
|
$scope.createdUser = resp;
|
|
|
|
$scope.loadUsers();
|
2014-10-01 17:55:09 +00:00
|
|
|
}, errorHandler)
|
|
|
|
};
|
|
|
|
|
2014-04-10 04:26:55 +00:00
|
|
|
$scope.showDeleteUser = function(user) {
|
|
|
|
if (user.username == UserService.currentUser().username) {
|
|
|
|
bootbox.dialog({
|
|
|
|
"message": 'Cannot delete yourself!',
|
|
|
|
"title": "Cannot delete user",
|
|
|
|
"buttons": {
|
|
|
|
"close": {
|
|
|
|
"label": "Close",
|
|
|
|
"className": "btn-primary"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.userToDelete = user;
|
|
|
|
$('#confirmDeleteUserModal').modal({});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.changeUserPassword = function(user) {
|
|
|
|
$('#changePasswordModal').modal('hide');
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
'username': user.username
|
|
|
|
};
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
'password': user.password
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.changeInstallUser(data, params).then(function(resp) {
|
|
|
|
$scope.loadUsersInternal();
|
2014-08-18 22:21:53 +00:00
|
|
|
}, ApiService.errorDisplay('Could not change user'));
|
2014-04-10 04:26:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.deleteUser = function(user) {
|
|
|
|
$('#confirmDeleteUserModal').modal('hide');
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
'username': user.username
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.deleteInstallUser(null, params).then(function(resp) {
|
|
|
|
$scope.loadUsersInternal();
|
2014-08-18 22:21:53 +00:00
|
|
|
}, ApiService.errorDisplay('Cannot delete user'));
|
2014-04-10 04:26:55 +00:00
|
|
|
};
|
|
|
|
|
2014-10-01 17:55:09 +00:00
|
|
|
$scope.sendRecoveryEmail = function(user) {
|
|
|
|
var params = {
|
|
|
|
'username': user.username
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.sendInstallUserRecoveryEmail(null, params).then(function(resp) {
|
|
|
|
bootbox.dialog({
|
|
|
|
"message": "A recovery email has been sent to " + resp['email'],
|
|
|
|
"title": "Recovery email sent",
|
|
|
|
"buttons": {
|
|
|
|
"close": {
|
|
|
|
"label": "Close",
|
|
|
|
"className": "btn-primary"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}, ApiService.errorDisplay('Cannot send recovery email'))
|
|
|
|
};
|
2015-01-04 19:38:41 +00:00
|
|
|
|
|
|
|
$scope.parseDbUri = function(value) {
|
|
|
|
if (!value) { return null; }
|
|
|
|
|
|
|
|
// Format: mysql+pymysql://<username>:<url escaped password>@<hostname>/<database_name>
|
|
|
|
var uri = URI(value);
|
|
|
|
return {
|
|
|
|
'kind': uri.protocol(),
|
|
|
|
'username': uri.username(),
|
|
|
|
'password': uri.password(),
|
|
|
|
'server': uri.host(),
|
|
|
|
'database': uri.path() ? uri.path().substr(1) : ''
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.serializeDbUri = function(fields) {
|
|
|
|
if (!fields['server']) { return '' };
|
|
|
|
|
|
|
|
try {
|
|
|
|
var uri = URI();
|
|
|
|
uri = uri && uri.host(fields['server']);
|
|
|
|
uri = uri && uri.protocol(fields['kind']);
|
|
|
|
uri = uri && uri.username(fields['username']);
|
|
|
|
uri = uri && uri.password(fields['password']);
|
|
|
|
uri = uri && uri.path('/' + (fields['database'] || ''));
|
|
|
|
uri = uri && uri.toString();
|
|
|
|
} catch (ex) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
return uri;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.createSuperUser = function() {
|
|
|
|
$scope.configStep = 'creating-superuser';
|
|
|
|
ApiService.scCreateInitialSuperuser($scope.superUser, null).then(function(resp) {
|
|
|
|
UserService.load();
|
|
|
|
$('#createSuperuserModal').modal('hide');
|
|
|
|
$scope.checkContainerStatus();
|
|
|
|
}, ApiService.errorDisplay('Could not create superuser'));
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.checkContainerStatus = function() {
|
|
|
|
var errorHandler = function(resp) {
|
|
|
|
if (resp.status == 404 && $scope.configStep == 'valid-database') {
|
|
|
|
// Container has not yet come back up, so we schedule another check.
|
|
|
|
$scope.waitForValidConfig();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ApiService.errorDisplay('Cannot load status. Please report this to support')(resp);
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.scRegistryStatus(null, null).then(function(resp) {
|
|
|
|
$scope.configStatus = resp;
|
|
|
|
|
|
|
|
// !dir_exists -> No mounted directory.
|
|
|
|
if (!$scope.configStatus.dir_exists) {
|
|
|
|
bootbox.dialog({
|
|
|
|
"message": "No volume was found mounted at path <code>/conf/stack</code>. " +
|
|
|
|
"Please rerun the container with the volume mounted and refresh this page." +
|
|
|
|
"<br><br>For more information: " +
|
|
|
|
"<a href='https://coreos.com/docs/enterprise-registry/initial-setup/'>" +
|
|
|
|
"Enterprise Registry Setup Guide</a>",
|
|
|
|
"title": "Missing mounted configuration volume",
|
|
|
|
"buttons": {},
|
|
|
|
"closeButton": false
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// is_testing = False -> valid config
|
|
|
|
// ready = False -> no valid superusers yet
|
|
|
|
if (!$scope.configStatus.is_testing && !$scope.configStatus.ready) {
|
|
|
|
$('#initializeConfigModal').modal('hide');
|
|
|
|
|
|
|
|
$scope.superUser = {};
|
|
|
|
$scope.configStep = 'create-superuser';
|
|
|
|
$('#createSuperuserModal').modal({
|
|
|
|
keyboard: false,
|
|
|
|
backdrop: 'static'
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// file_exists -> config file, but possibly invalid DB
|
|
|
|
// valid_db = False -> invalid DB
|
|
|
|
// is_testing = True -> still in testing mode
|
|
|
|
if (!$scope.configStatus.file_exists || !$scope.configStatus.valid_db ||
|
|
|
|
$scope.configStatus.is_testing) {
|
|
|
|
$('#createSuperuserModal').modal('hide');
|
|
|
|
|
|
|
|
$scope.databaseUri = '';
|
|
|
|
$scope.configStep = 'enter-database';
|
|
|
|
|
|
|
|
// Handle the case where they have entered a valid DB config, refreshed, but have not
|
|
|
|
// yet restarted the DB container.
|
|
|
|
if ($scope.configStatus.file_exists && $scope.configStatus.is_testing) {
|
|
|
|
$scope.waitForValidConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#initializeConfigModal').modal({
|
|
|
|
keyboard: false,
|
|
|
|
backdrop: 'static'
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}, errorHandler, /* background */true);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.waitForValidConfig = function() {
|
|
|
|
$scope.configStep = 'valid-database';
|
|
|
|
$timeout(function() {
|
|
|
|
$scope.checkContainerStatus();
|
|
|
|
}, 3000);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.validateDatabase = function() {
|
|
|
|
$scope.configStep = 'validating-database';
|
|
|
|
$scope.databaseInvalid = null;
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
'config': {
|
|
|
|
'DB_URI': $scope.databaseUri
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
'service': 'database'
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.scValidateConfig(data, params).then(function(resp) {
|
|
|
|
var status = resp.status;
|
|
|
|
|
|
|
|
if (status) {
|
|
|
|
$scope.configStep = 'updating-config';
|
|
|
|
ApiService.scUpdateConfig(data, null).then(function(resp) {
|
|
|
|
$scope.waitForValidConfig();
|
|
|
|
}, ApiService.errorDisplay('Cannot update config. Please report this to support'));
|
|
|
|
} else {
|
|
|
|
$scope.configStep = 'invalid-database';
|
|
|
|
$scope.databaseInvalid = resp.reason;
|
|
|
|
}
|
|
|
|
}, ApiService.errorDisplay('Cannot validate database. Please report this to support'));
|
|
|
|
};
|
|
|
|
|
|
|
|
// Load the configuration status.
|
|
|
|
$scope.checkContainerStatus();
|
2014-06-26 23:55:16 +00:00
|
|
|
}
|
2014-04-29 04:45:42 +00:00
|
|
|
|
|
|
|
function TourCtrl($scope, $location) {
|
|
|
|
$scope.kind = $location.path().substring('/tour/'.length);
|
2014-07-07 19:33:51 +00:00
|
|
|
}
|
2014-08-18 21:24:00 +00:00
|
|
|
|
|
|
|
function ConfirmInviteCtrl($scope, $location, UserService, ApiService, NotificationService) {
|
|
|
|
// Monitor any user changes and place the current user into the scope.
|
|
|
|
$scope.loading = false;
|
2014-09-11 19:45:41 +00:00
|
|
|
$scope.inviteCode = $location.search()['code'] || '';
|
2014-08-18 21:24:00 +00:00
|
|
|
|
|
|
|
UserService.updateUserIn($scope, function(user) {
|
|
|
|
if (!user.anonymous && !$scope.loading) {
|
2014-09-08 21:20:01 +00:00
|
|
|
// Make sure to not redirect now that we have logged in. We'll conduct the redirect
|
|
|
|
// manually.
|
|
|
|
$scope.redirectUrl = null;
|
2014-08-18 21:24:00 +00:00
|
|
|
$scope.loading = true;
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
'code': $location.search()['code']
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.acceptOrganizationTeamInvite(null, params).then(function(resp) {
|
|
|
|
NotificationService.update();
|
2014-11-18 19:23:53 +00:00
|
|
|
UserService.load();
|
2014-08-18 21:24:00 +00:00
|
|
|
$location.path('/organization/' + resp.org + '/teams/' + resp.team);
|
2014-09-12 18:29:01 +00:00
|
|
|
}, function(resp) {
|
2014-08-18 21:24:00 +00:00
|
|
|
$scope.loading = false;
|
2014-09-12 18:29:01 +00:00
|
|
|
$scope.invalid = ApiService.getErrorMessage(resp, 'Invalid confirmation code');
|
2014-08-18 21:24:00 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2014-09-11 19:45:41 +00:00
|
|
|
|
2014-09-08 21:20:01 +00:00
|
|
|
$scope.redirectUrl = window.location.href;
|
2014-08-29 00:50:13 +00:00
|
|
|
}
|