2013-10-17 18:46:23 +00:00
|
|
|
$.fn.clipboardCopy = function() {
|
2013-11-19 00:03:35 +00:00
|
|
|
var clip = new ZeroClipboard($(this), { 'moviePath': 'static/lib/ZeroClipboard.swf' });
|
|
|
|
|
2013-10-17 18:46:23 +00:00
|
|
|
clip.on('complete', function() {
|
|
|
|
// Resets the animation.
|
|
|
|
var elem = $('#clipboardCopied')[0];
|
|
|
|
elem.style.display = 'none';
|
2013-10-22 04:40:33 +00:00
|
|
|
elem.classList.remove('animated');
|
|
|
|
|
2013-10-17 18:46:23 +00:00
|
|
|
// Show the notification.
|
|
|
|
setTimeout(function() {
|
|
|
|
elem.style.display = 'inline-block';
|
2013-10-22 04:40:33 +00:00
|
|
|
elem.classList.add('animated');
|
|
|
|
}, 10);
|
2013-10-17 18:46:23 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
function SigninCtrl($scope) {
|
2013-10-14 21:50:07 +00:00
|
|
|
};
|
|
|
|
|
2013-11-07 20:33:56 +00:00
|
|
|
function PlansCtrl($scope, $location, UserService, PlanService) {
|
2013-11-01 23:13:58 +00:00
|
|
|
// Load the list of plans.
|
2013-11-05 19:40:45 +00:00
|
|
|
PlanService.getPlans(function(plans) {
|
2013-11-01 23:13:58 +00:00
|
|
|
$scope.plans = plans;
|
2013-12-20 02:51:46 +00:00
|
|
|
}, /* include the personal plan */ true);
|
2013-10-04 18:35:51 +00:00
|
|
|
|
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');
|
2013-12-11 23:20:24 +00:00
|
|
|
PlanService.handleNotedPlan();
|
|
|
|
};
|
2013-12-11 22:50:48 +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) {
|
2013-12-21 02:25:06 +00:00
|
|
|
PlanService.handleNotedPlan();
|
2013-10-02 22:14:51 +00:00
|
|
|
} else {
|
2013-11-07 20:33:56 +00:00
|
|
|
$('#signinModal').modal({});
|
|
|
|
}
|
|
|
|
};
|
2013-10-02 22:14:51 +00:00
|
|
|
}
|
|
|
|
|
2013-10-11 00:53:14 +00:00
|
|
|
function GuideCtrl($scope) {
|
2013-10-02 04:28:24 +00:00
|
|
|
}
|
|
|
|
|
2013-11-22 20:54:23 +00:00
|
|
|
function SecurityCtrl($scope) {
|
2013-10-02 04:28:24 +00:00
|
|
|
}
|
|
|
|
|
2013-12-17 22:02:37 +00:00
|
|
|
function ContactCtrl($scope) {
|
|
|
|
}
|
|
|
|
|
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;
|
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};
|
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
|
|
|
}
|
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
function LandingCtrl($scope, UserService, ApiService) {
|
2013-11-07 02:52:31 +00:00
|
|
|
$scope.namespace = null;
|
|
|
|
|
|
|
|
$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
|
|
|
|
2013-11-07 05:49:13 +00:00
|
|
|
$scope.canCreateRepo = function(namespace) {
|
|
|
|
if (!$scope.user) { return false; }
|
|
|
|
|
|
|
|
if (namespace == $scope.user.username) {
|
|
|
|
return true;
|
|
|
|
}
|
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
|
|
|
|
2013-10-12 01:28:02 +00:00
|
|
|
browserchrome.update();
|
2013-09-24 22:21:14 +00:00
|
|
|
}
|
2013-09-26 21:59:20 +00:00
|
|
|
|
2014-01-14 21:01:37 +00:00
|
|
|
function RepoCtrl($scope, $sanitize, Restangular, ImageMetadataService, ApiService, $routeParams, $rootScope, $location, $timeout) {
|
2013-12-17 18:19:59 +00:00
|
|
|
var namespace = $routeParams.namespace;
|
|
|
|
var name = $routeParams.name;
|
|
|
|
|
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-01-14 21:01:37 +00:00
|
|
|
$scope.getFormattedCommand = ImageMetadataService.getFormattedCommand;
|
2014-01-14 20:19:47 +00:00
|
|
|
|
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) {
|
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; }
|
|
|
|
var addedDisplayed = Math.min(5, changes.added.length);
|
|
|
|
var removedDisplayed = Math.min(5, changes.removed.length);
|
|
|
|
var changedDisplayed = Math.min(5, changes.changed.length);
|
|
|
|
|
|
|
|
return (changes.added.length + changes.removed.length + changes.changed.length) -
|
|
|
|
addedDisplayed - removedDisplayed - changedDisplayed;
|
|
|
|
};
|
|
|
|
|
2014-01-09 23:54:59 +00:00
|
|
|
$scope.setImage = function(imageId, opt_updateURL) {
|
|
|
|
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;
|
2013-12-17 18:19:59 +00:00
|
|
|
$scope.currentImage = image;
|
|
|
|
$scope.loadImageChanges(image);
|
|
|
|
if ($scope.tree) {
|
2014-01-09 23:54:59 +00:00
|
|
|
$scope.tree.setImage(image.id);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opt_updateURL) {
|
|
|
|
$location.search('tag', null);
|
|
|
|
$location.search('image', imageId.substr(0, 12));
|
2013-12-17 18:19:59 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-01-09 20:15:06 +00:00
|
|
|
$scope.tagSpecificImages = function(tagName) {
|
|
|
|
if (!tagName) { return []; }
|
|
|
|
|
|
|
|
var tag = $scope.repo.tags[tagName];
|
|
|
|
if (!tag) { return []; }
|
|
|
|
|
|
|
|
if ($scope.specificImages && $scope.specificImages[tagName]) {
|
|
|
|
return $scope.specificImages[tagName];
|
|
|
|
}
|
|
|
|
|
|
|
|
var getIdsForTag = function(currentTag) {
|
|
|
|
var ids = {};
|
2014-01-09 23:54:59 +00:00
|
|
|
forAllTagImages(currentTag, function(image) {
|
|
|
|
ids[image.dbid] = true;
|
|
|
|
});
|
2014-01-09 20:15:06 +00:00
|
|
|
return ids;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Remove any IDs that match other tags.
|
|
|
|
var toDelete = getIdsForTag(tag);
|
|
|
|
for (var currentTagName in $scope.repo.tags) {
|
|
|
|
var currentTag = $scope.repo.tags[currentTagName];
|
|
|
|
if (currentTag != tag) {
|
|
|
|
for (var dbid in getIdsForTag(currentTag)) {
|
|
|
|
delete toDelete[dbid];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return the matching list of images.
|
|
|
|
var images = [];
|
|
|
|
for (var i = 0; i < $scope.images.length; ++i) {
|
|
|
|
var image = $scope.images[i];
|
|
|
|
if (toDelete[image.dbid]) {
|
|
|
|
images.push(image);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
images.sort(function(a, b) {
|
2014-01-09 22:09:54 +00:00
|
|
|
var result = new Date(b.created) - new Date(a.created);
|
|
|
|
if (result != 0) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-01-09 20:15:06 +00:00
|
|
|
return b.dbid - a.dbid;
|
|
|
|
});
|
|
|
|
|
|
|
|
$scope.specificImages[tagName] = images;
|
|
|
|
return images;
|
|
|
|
};
|
|
|
|
|
2014-01-06 20:20:58 +00:00
|
|
|
$scope.askDeleteTag = function(tagName) {
|
|
|
|
if (!$scope.repo.can_admin) { return; }
|
|
|
|
|
|
|
|
$scope.tagToDelete = tagName;
|
|
|
|
$('#confirmdeleteTagModal').modal('show');
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.deleteTag = function(tagName) {
|
|
|
|
if (!$scope.repo.can_admin) { return; }
|
|
|
|
$('#confirmdeleteTagModal').modal('hide');
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name,
|
|
|
|
'tag': tagName
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.deleteFullTag(null, params).then(function() {
|
|
|
|
loadViewInfo();
|
|
|
|
}, function(resp) {
|
|
|
|
bootbox.dialog({
|
|
|
|
"message": resp.data ? resp.data : 'Could not delete tag',
|
|
|
|
"title": "Cannot delete tag",
|
|
|
|
"buttons": {
|
|
|
|
"close": {
|
|
|
|
"label": "Close",
|
|
|
|
"className": "btn-primary"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
$scope.setTag = function(tagName, opt_updateURL) {
|
|
|
|
var repo = $scope.repo;
|
|
|
|
var proposedTag = repo.tags[tagName];
|
|
|
|
if (!proposedTag) {
|
|
|
|
// We must find a good default
|
|
|
|
for (tagName in repo.tags) {
|
|
|
|
if (!proposedTag || tagName == 'latest') {
|
|
|
|
proposedTag = repo.tags[tagName];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (proposedTag) {
|
|
|
|
$scope.currentTag = proposedTag;
|
|
|
|
$scope.currentImage = $scope.currentTag.image;
|
|
|
|
$scope.loadImageChanges($scope.currentImage);
|
|
|
|
if ($scope.tree) {
|
|
|
|
$scope.tree.setTag($scope.currentTag.name);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opt_updateURL) {
|
2014-01-09 23:54:59 +00:00
|
|
|
$location.search('image', null);
|
2013-12-17 18:19:59 +00:00
|
|
|
$location.search('tag', $scope.currentTag.name);
|
|
|
|
}
|
|
|
|
}
|
2014-01-07 20:21:24 +00:00
|
|
|
|
|
|
|
if ($scope.currentTag && !repo.tags[$scope.currentTag.name]) {
|
|
|
|
$scope.currentTag = null;
|
|
|
|
$scope.currentImage = null;
|
|
|
|
}
|
2013-12-17 18:19:59 +00:00
|
|
|
};
|
|
|
|
|
2014-01-09 20:15:06 +00:00
|
|
|
$scope.getFirstTextLine = getFirstTextLine;
|
|
|
|
|
|
|
|
$scope.getImageListingClasses = function(image, tagName) {
|
|
|
|
var classes = '';
|
|
|
|
if (image.ancestors.length > 1) {
|
|
|
|
classes += 'child ';
|
|
|
|
}
|
|
|
|
|
|
|
|
var currentTag = $scope.repo.tags[tagName];
|
|
|
|
if (image.dbid == currentTag.image.dbid) {
|
|
|
|
classes += 'tag-image ';
|
|
|
|
}
|
|
|
|
|
|
|
|
return classes;
|
|
|
|
};
|
|
|
|
|
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) {
|
|
|
|
if (!tag || !$scope.imageByDBID) { return; }
|
|
|
|
|
|
|
|
callback(tag.image);
|
|
|
|
|
|
|
|
var ancestors = tag.image.ancestors.split('/');
|
|
|
|
for (var i = 0; i < ancestors.length; ++i) {
|
|
|
|
var image = $scope.imageByDBID[ancestors[i]];
|
|
|
|
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
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
// If the repository is marked as building, start monitoring it for changes.
|
2013-10-30 00:54:36 +00:00
|
|
|
if (repo.is_building) {
|
|
|
|
startBuildInfoTimer(repo);
|
2013-12-17 18:19:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$('#copyClipboard').clipboardCopy();
|
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) {
|
2013-12-26 22:45:16 +00:00
|
|
|
// Note: We use restangular manually here because we need to turn off the loading bar.
|
2013-10-26 20:03:11 +00:00
|
|
|
var buildInfo = Restangular.one('repository/' + repo.namespace + '/' + repo.name + '/build/');
|
2013-12-17 18:19:59 +00:00
|
|
|
buildInfo.withHttpConfig({
|
|
|
|
'ignoreLoadingBar': true
|
|
|
|
});
|
|
|
|
|
2013-10-26 20:03:11 +00:00
|
|
|
buildInfo.get().then(function(resp) {
|
2013-10-30 00:54:36 +00:00
|
|
|
var runningBuilds = [];
|
|
|
|
for (var i = 0; i < resp.builds.length; ++i) {
|
|
|
|
var build = resp.builds[i];
|
|
|
|
if (build.status != 'complete') {
|
|
|
|
runningBuilds.push(build);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.buildsInfo = runningBuilds;
|
|
|
|
if (!runningBuilds.length) {
|
|
|
|
// Cancel the build timer.
|
|
|
|
cancelBuildInfoTimer();
|
|
|
|
|
|
|
|
// Mark the repo as no longer building.
|
|
|
|
$scope.repo.is_building = false;
|
|
|
|
|
|
|
|
// Reload the repo information.
|
2013-12-17 18:19:59 +00:00
|
|
|
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() {
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {'repository': namespace + '/' + name};
|
|
|
|
$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.
|
|
|
|
$scope.imageByDBID = {};
|
|
|
|
for (var i = 0; i < $scope.images.length; ++i) {
|
|
|
|
var currentImage = $scope.images[i];
|
|
|
|
$scope.imageByDBID[currentImage.dbid] = currentImage;
|
|
|
|
}
|
|
|
|
|
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.
|
2013-10-17 02:33:35 +00:00
|
|
|
$scope.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
|
|
|
|
|
|
|
$scope.tree.draw('image-history-container');
|
2013-10-17 02:49:37 +00:00
|
|
|
|
2013-10-17 02:44:44 +00:00
|
|
|
// If we already have a tag, use it
|
|
|
|
if ($scope.currentTag) {
|
|
|
|
$scope.tree.setTag($scope.currentTag.name);
|
|
|
|
}
|
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
// Listen for changes to the selected tag and image in the tree.
|
2013-10-11 00:43:37 +00:00
|
|
|
$($scope.tree).bind('tagChanged', function(e) {
|
2013-10-30 17:55:44 +00:00
|
|
|
$scope.$apply(function() { $scope.setTag(e.tag, true); });
|
2013-10-11 00:43:37 +00:00
|
|
|
});
|
2013-12-17 18:19:59 +00:00
|
|
|
|
2013-10-11 00:43:37 +00:00
|
|
|
$($scope.tree).bind('imageChanged', function(e) {
|
2014-01-09 23:54:59 +00:00
|
|
|
$scope.$apply(function() { $scope.setImage(e.image.id, true); });
|
2013-10-11 00:43:37 +00:00
|
|
|
});
|
2013-09-26 21:59:20 +00:00
|
|
|
|
2014-01-06 20:20:58 +00:00
|
|
|
$($scope.tree).bind('showTagMenu', function(e) {
|
|
|
|
$scope.$apply(function() { $scope.showTagMenu(e.tag, e.clientX, e.clientY); });
|
|
|
|
});
|
|
|
|
|
|
|
|
$($scope.tree).bind('hideTagMenu', function(e) {
|
|
|
|
$scope.$apply(function() { $scope.hideTagMenu(); });
|
|
|
|
});
|
|
|
|
|
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
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope) {
|
2013-09-27 19:26:16 +00:00
|
|
|
var namespace = $routeParams.namespace;
|
|
|
|
var name = $routeParams.name;
|
|
|
|
|
2013-11-02 01:48:10 +00:00
|
|
|
$scope.permissions = {'team': [], 'user': []};
|
2013-12-02 19:55:04 +00:00
|
|
|
$scope.logsShown = 0;
|
2014-01-20 22:03:16 +00:00
|
|
|
$scope.deleting = false;
|
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.
|
2013-11-02 01:48:10 +00:00
|
|
|
if ($scope.permissions[entity.kind][entity.name]) { return; }
|
|
|
|
|
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) {
|
2013-11-04 20:31:38 +00:00
|
|
|
var permissionDelete = Restangular.one(getRestUrl('repository', namespace, name, 'permissions', kind, entityName));
|
2013-09-28 05:23:00 +00:00
|
|
|
permissionDelete.customDELETE().then(function() {
|
2013-11-02 01:48:10 +00:00
|
|
|
delete $scope.permissions[kind][entityName];
|
2013-11-08 04:35:27 +00:00
|
|
|
}, function(resp) {
|
|
|
|
if (resp.status == 409) {
|
|
|
|
$scope.changePermError = resp.data || '';
|
|
|
|
$('#channgechangepermModal').modal({});
|
2013-10-01 23:37:33 +00:00
|
|
|
} else {
|
|
|
|
$('#cannotchangeModal').modal({});
|
|
|
|
}
|
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));
|
2013-11-21 00:43:19 +00:00
|
|
|
permissionPost.customPOST(permission).then(function(result) {
|
|
|
|
$scope.permissions[kind][entityName] = result;
|
2013-09-28 05:23:00 +00:00
|
|
|
}, function(result) {
|
2013-10-01 23:37:33 +00:00
|
|
|
$('#cannotchangeModal').modal({});
|
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;
|
2013-09-28 05:23:00 +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
|
|
|
};
|
|
|
|
|
2013-10-16 18:24:10 +00:00
|
|
|
$scope.createToken = function() {
|
|
|
|
var friendlyName = {
|
|
|
|
'friendlyName': $scope.newToken.friendlyName
|
|
|
|
};
|
|
|
|
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {'repository': namespace + '/' + name};
|
|
|
|
ApiService.createToken(friendlyName, params).then(function(newToken) {
|
2013-10-17 20:50:58 +00:00
|
|
|
$scope.newToken.friendlyName = '';
|
|
|
|
$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;
|
|
|
|
|
|
|
|
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
|
|
|
|
2013-11-15 22:45:37 +00:00
|
|
|
$scope.loadWebhooks = function() {
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name
|
|
|
|
};
|
|
|
|
|
2013-12-17 18:19:59 +00:00
|
|
|
$scope.newWebhook = {};
|
2013-12-26 22:45:16 +00:00
|
|
|
$scope.webhooksResource = ApiService.listWebhooksAsResource(params).get(function(resp) {
|
2013-11-15 22:45:37 +00:00
|
|
|
$scope.webhooks = resp.webhooks;
|
2013-12-17 18:19:59 +00:00
|
|
|
return $scope.webhooks;
|
2013-11-15 22:45:37 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.createWebhook = function() {
|
2013-12-17 18:19:59 +00:00
|
|
|
if (!$scope.newWebhook.url) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.createWebhook($scope.newWebhook, params).then(function(resp) {
|
2013-11-15 22:45:37 +00:00
|
|
|
$scope.webhooks.push(resp);
|
|
|
|
$scope.newWebhook.url = '';
|
2013-12-18 03:56:28 +00:00
|
|
|
$scope.createWebhookForm.$setPristine();
|
2013-11-15 22:45:37 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.deleteWebhook = function(webhook) {
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name,
|
|
|
|
'public_id': webhook.public_id
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.deleteWebhook(null, params).then(function(resp) {
|
2013-11-15 22:45:37 +00:00
|
|
|
$scope.webhooks.splice($scope.webhooks.indexOf(webhook), 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;
|
|
|
|
}, 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) {
|
2013-12-17 18:19:59 +00:00
|
|
|
$scope.repo = repo;
|
|
|
|
|
|
|
|
$rootScope.title = 'Settings - ' + namespace + '/' + name;
|
|
|
|
$rootScope.description = 'Administrator settings for ' + namespace + '/' + name +
|
|
|
|
': Permissions, webhooks and other settings';
|
|
|
|
|
|
|
|
// 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,
|
|
|
|
$routeParams, $http) {
|
2013-12-18 03:56:28 +00:00
|
|
|
if ($routeParams['migrate']) {
|
|
|
|
$('#migrateTab').tab('show')
|
|
|
|
}
|
|
|
|
|
|
|
|
UserService.updateUserIn($scope, function(user) {
|
2013-12-18 22:04:07 +00:00
|
|
|
$scope.askForPassword = user.askForPassword;
|
2013-12-27 19:14:21 +00:00
|
|
|
$scope.cuser = jQuery.extend({}, user);
|
2014-01-14 20:23:44 +00:00
|
|
|
|
|
|
|
for (var i = 0; i < $scope.cuser.logins.length; i++) {
|
|
|
|
if ($scope.cuser.logins[i].service == 'github') {
|
|
|
|
var githubId = $scope.cuser.logins[i].service_identifier;
|
|
|
|
$http.get('https://api.github.com/user/' + githubId).success(function(resp) {
|
|
|
|
$scope.githubLogin = resp.login;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
$scope.githubClientId = KeyService.githubClientId;
|
2013-11-06 22:59:16 +00:00
|
|
|
|
2014-01-17 22:04:05 +00:00
|
|
|
$('.form-change').popover();
|
2013-10-10 17:44:34 +00:00
|
|
|
|
2013-12-21 03:38:53 +00:00
|
|
|
$scope.logsShown = 0;
|
|
|
|
$scope.invoicesShown = 0;
|
|
|
|
|
|
|
|
$scope.loadLogs = function() {
|
|
|
|
if (!$scope.hasPaidBusinessPlan) { return; }
|
|
|
|
$scope.logsShown++;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.loadInvoices = function() {
|
|
|
|
if (!$scope.hasPaidBusinessPlan) { return; }
|
|
|
|
$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() {
|
2013-11-08 03:08:23 +00:00
|
|
|
PlanService.getMatchingBusinessPlan(function(plan) {
|
|
|
|
$scope.org.plan = plan;
|
|
|
|
});
|
|
|
|
|
|
|
|
PlanService.getPlans(function(plans) {
|
2013-12-20 02:51:46 +00:00
|
|
|
$scope.orgPlans = plans;
|
2013-11-08 03:08:23 +00:00
|
|
|
});
|
|
|
|
|
2013-11-07 21:33:56 +00:00
|
|
|
$scope.convertStep = 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.convertToOrg = function() {
|
|
|
|
$('#reallyconvertModal').modal({});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.reallyConvert = function() {
|
|
|
|
$scope.loading = true;
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
'adminUser': $scope.org.adminUser,
|
2013-11-08 03:08:23 +00:00
|
|
|
'adminPassword': $scope.org.adminPassword,
|
|
|
|
'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-01-17 22:04:05 +00:00
|
|
|
$scope.changeEmail = function() {
|
|
|
|
$('#changeEmailForm').popover('hide');
|
|
|
|
$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.
|
|
|
|
$scope.cuser.repeatEmail = '';
|
|
|
|
$scope.changeEmailForm.$setPristine();
|
|
|
|
}, function(result) {
|
|
|
|
$scope.updatingUser = false;
|
|
|
|
|
|
|
|
$scope.changeEmailError = result.data.message;
|
|
|
|
$timeout(function() {
|
|
|
|
$('#changeEmailForm').popover('show');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2013-10-10 17:44:34 +00:00
|
|
|
$scope.changePassword = function() {
|
2014-01-17 22:04:05 +00:00
|
|
|
$('#changePasswordForm').popover('hide');
|
2013-10-10 17:44:34 +00:00
|
|
|
$scope.updatingUser = true;
|
|
|
|
$scope.changePasswordSuccess = false;
|
2013-12-26 22:45:16 +00:00
|
|
|
|
2013-12-27 19:14:21 +00:00
|
|
|
ApiService.changeUserDetails($scope.cuser).then(function() {
|
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
|
2013-12-27 19:14:21 +00:00
|
|
|
$scope.cuser.password = '';
|
|
|
|
$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;
|
|
|
|
|
|
|
|
$scope.changePasswordError = result.data.message;
|
|
|
|
$timeout(function() {
|
2014-01-17 22:04:05 +00:00
|
|
|
$('#changePasswordForm').popover('show');
|
2013-10-10 17:44:34 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
2013-10-17 21:45:08 +00:00
|
|
|
}
|
|
|
|
|
2014-01-14 21:01:37 +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 '';
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
2013-10-19 23:46:30 +00:00
|
|
|
|
|
|
|
$scope.initializeTree = function() {
|
|
|
|
if ($scope.tree) { return; }
|
|
|
|
|
|
|
|
$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-01-10 01:11:52 +00:00
|
|
|
var fetchImage = function() {
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name,
|
|
|
|
'image_id': imageid
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.image = ApiService.getImageAsResource(params).get(function(image) {
|
2013-12-18 03:56:28 +00:00
|
|
|
$scope.repo = {
|
|
|
|
'name': name,
|
|
|
|
'namespace': namespace
|
|
|
|
};
|
|
|
|
|
|
|
|
$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();
|
2013-10-19 02:28:46 +00:00
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
$('#copyClipboard').clipboardCopy();
|
2013-10-19 02:28:46 +00:00
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
return image;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var fetchChanges = function() {
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {
|
|
|
|
'repository': namespace + '/' + name,
|
|
|
|
'image_id': imageid
|
|
|
|
};
|
|
|
|
|
|
|
|
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) {
|
|
|
|
combinedChanges.push({
|
|
|
|
'kind': kind,
|
|
|
|
'file': c[i]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
addCombinedChanges(changes.added, 'added');
|
|
|
|
addCombinedChanges(changes.removed, 'removed');
|
|
|
|
addCombinedChanges(changes.changed, 'changed');
|
|
|
|
|
|
|
|
$scope.combinedChanges = combinedChanges;
|
|
|
|
$scope.imageChanges = changes;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
// 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
|
|
|
}
|
|
|
|
|
2013-12-26 22:45:16 +00:00
|
|
|
function NewRepoCtrl($scope, $location, $http, $timeout, UserService, ApiService, PlanService) {
|
2013-12-18 03:56:28 +00:00
|
|
|
UserService.updateUserIn($scope);
|
2013-10-30 19:44:01 +00:00
|
|
|
|
2013-10-24 21:41:55 +00:00
|
|
|
$scope.repo = {
|
|
|
|
'is_public': 1,
|
|
|
|
'description': '',
|
|
|
|
'initialize': false
|
|
|
|
};
|
|
|
|
|
2013-10-28 17:09:22 +00:00
|
|
|
$('#couldnotbuildModal').on('hidden.bs.modal', function() {
|
|
|
|
$scope.$apply(function() {
|
|
|
|
$location.path('/repository/' + $scope.created.namespace + '/' + $scope.created.name);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
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; }
|
|
|
|
|
|
|
|
var isUserNamespace = (namespace == $scope.user.username);
|
|
|
|
|
2013-12-19 04:03:19 +00:00
|
|
|
$scope.checkingPlan = true;
|
2013-12-18 03:56:28 +00:00
|
|
|
$scope.planRequired = null;
|
|
|
|
$scope.isUserNamespace = isUserNamespace;
|
|
|
|
|
|
|
|
if (isUserNamespace) {
|
|
|
|
// Load the user's subscription information in case they want to create a private
|
|
|
|
// repository.
|
2013-12-26 22:45:16 +00:00
|
|
|
ApiService.getUserPrivateCount().then(function(resp) {
|
2013-12-19 04:03:19 +00:00
|
|
|
if (resp.privateCount + 1 > resp.reposAllowed) {
|
|
|
|
PlanService.getMinimumPlan(resp.privateCount + 1, false, function(minimum) {
|
|
|
|
$scope.planRequired = minimum;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.checkingPlan = false;
|
|
|
|
}, function() {
|
|
|
|
$scope.planRequired = {};
|
|
|
|
$scope.checkingPlan = false;
|
2013-12-18 03:56:28 +00:00
|
|
|
});
|
|
|
|
} else {
|
2013-12-26 22:45:16 +00:00
|
|
|
ApiService.getOrganizationPrivateAllowed(null, {'orgname': namespace}).then(function(resp) {
|
2013-12-18 03:56:28 +00:00
|
|
|
$scope.planRequired = resp.privateAllowed ? null : {};
|
2013-12-19 04:03:19 +00:00
|
|
|
$scope.checkingPlan = false;
|
2013-12-18 03:56:28 +00:00
|
|
|
}, function() {
|
|
|
|
$scope.planRequired = {};
|
2013-12-19 04:03:19 +00:00
|
|
|
$scope.checkingPlan = false;
|
2013-12-18 03:56:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Auto-set to private repo.
|
|
|
|
$scope.repo.is_public = '0';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-01-16 00:15:38 +00:00
|
|
|
$scope.changeNamespace = function(namespace) {
|
|
|
|
$scope.repo.namespace = namespace;
|
|
|
|
};
|
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
$scope.createNewRepo = function() {
|
|
|
|
$('#repoName').popover('hide');
|
|
|
|
|
|
|
|
var uploader = $('#file-drop')[0];
|
|
|
|
if ($scope.repo.initialize && uploader.files.length < 1) {
|
|
|
|
$('#missingfileModal').modal();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$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;
|
|
|
|
|
|
|
|
// Repository created. Start the upload process if applicable.
|
|
|
|
if ($scope.repo.initialize) {
|
|
|
|
startFileUpload(created);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, redirect to the repo page.
|
|
|
|
$location.path('/repository/' + created.namespace + '/' + created.name);
|
|
|
|
}, function(result) {
|
|
|
|
$scope.creating = false;
|
|
|
|
$scope.createError = result.data;
|
|
|
|
$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;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
PlanService.changePlan($scope, null, $scope.planRequired.stripeId, callbacks);
|
|
|
|
};
|
|
|
|
|
2013-10-26 21:20:59 +00:00
|
|
|
var startBuild = function(repo, fileId) {
|
|
|
|
$scope.building = true;
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
'file_id': fileId
|
|
|
|
};
|
|
|
|
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {
|
|
|
|
'repository': repo.namespace + '/' + repo.name
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.requestRepoBuild(data, params).then(function(resp) {
|
|
|
|
$location.path('/repository/' + params.repository);
|
2013-10-26 21:20:59 +00:00
|
|
|
}, function() {
|
|
|
|
$('#couldnotbuildModal').modal();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var conductUpload = function(repo, file, url, fileId, mimeType) {
|
|
|
|
var request = new XMLHttpRequest();
|
|
|
|
request.open('PUT', url, true);
|
2013-10-26 22:37:53 +00:00
|
|
|
request.setRequestHeader('Content-Type', mimeType);
|
2013-10-26 21:20:59 +00:00
|
|
|
request.onprogress = function(e) {
|
2013-10-28 17:09:22 +00:00
|
|
|
$scope.$apply(function() {
|
2013-10-26 22:37:53 +00:00
|
|
|
var percentLoaded;
|
|
|
|
if (e.lengthComputable) {
|
|
|
|
$scope.upload_progress = (e.loaded / e.total) * 100;
|
|
|
|
}
|
|
|
|
});
|
2013-10-26 21:20:59 +00:00
|
|
|
};
|
|
|
|
request.onerror = function() {
|
2013-10-28 17:09:22 +00:00
|
|
|
$scope.$apply(function() {
|
2013-10-26 22:37:53 +00:00
|
|
|
$('#couldnotbuildModal').modal();
|
|
|
|
});
|
2013-10-26 21:20:59 +00:00
|
|
|
};
|
|
|
|
request.onreadystatechange = function() {
|
|
|
|
var state = request.readyState;
|
|
|
|
if (state == 4) {
|
|
|
|
$scope.$apply(function() {
|
|
|
|
$scope.uploading = false;
|
|
|
|
startBuild(repo, fileId);
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
request.send(file);
|
|
|
|
};
|
|
|
|
|
|
|
|
var startFileUpload = function(repo) {
|
|
|
|
$scope.uploading = true;
|
|
|
|
$scope.uploading_progress = 0;
|
|
|
|
|
|
|
|
var uploader = $('#file-drop')[0];
|
|
|
|
var file = uploader.files[0];
|
|
|
|
$scope.upload_file = file.name;
|
|
|
|
|
|
|
|
var mimeType = file.type || 'application/octet-stream';
|
|
|
|
var data = {
|
|
|
|
'mimeType': mimeType
|
|
|
|
};
|
2013-10-17 21:45:08 +00:00
|
|
|
|
2013-12-26 22:45:16 +00:00
|
|
|
var getUploadUrl = ApiService.getFiledropUrl(data).then(function(resp) {
|
2013-10-26 21:20:59 +00:00
|
|
|
conductUpload(repo, file, resp.url, resp.file_id, mimeType);
|
|
|
|
}, function() {
|
|
|
|
$('#couldnotbuildModal').modal();
|
|
|
|
});
|
2013-10-17 21:45:08 +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;
|
|
|
|
|
|
|
|
// Check to see if the current plan allows for an additional private repository to
|
|
|
|
// be created.
|
|
|
|
var privateAllowed = $scope.subscription.usedPrivateRepos < $scope.subscribedPlan.privateRepos;
|
|
|
|
if (!privateAllowed) {
|
|
|
|
// If not, find the minimum repository that does.
|
2013-11-05 19:47:48 +00:00
|
|
|
PlanService.getMinimumPlan($scope.subscription.usedPrivateRepos + 1, !$scope.isUserNamespace, function(minimum) {
|
2013-11-01 23:13:58 +00:00
|
|
|
$scope.planRequired = minimum;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
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' }
|
|
|
|
];
|
|
|
|
|
2013-11-08 04:35:27 +00:00
|
|
|
$scope.setRole = function(role, teamname) {
|
|
|
|
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) {
|
2013-11-08 04:35:27 +00:00
|
|
|
}, function(resp) {
|
|
|
|
$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
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.deleteOrganizationTeam(null, params).then(function() {
|
2013-11-05 19:47:46 +00:00
|
|
|
delete $scope.organization.teams[teamname];
|
|
|
|
$scope.currentDeleteTeam = null;
|
|
|
|
}, function() {
|
|
|
|
$('#cannotchangeModal').modal({});
|
|
|
|
$scope.currentDeleteTeam = null;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
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-01-20 23:17:03 +00:00
|
|
|
function OrgAdminCtrl($rootScope, $scope, $timeout, Restangular, $routeParams, UserService, PlanService, ApiService) {
|
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.
|
|
|
|
PlanService.getPlans(function(plans) {
|
2013-12-20 02:51:46 +00:00
|
|
|
$scope.plans = plans;
|
2013-11-13 22:47:45 +00:00
|
|
|
$scope.plan_map = {};
|
2013-11-13 23:00:51 +00:00
|
|
|
|
2013-12-20 02:51:46 +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-01-20 21:12:23 +00:00
|
|
|
$scope.changingOrganization = false;
|
2013-11-13 22:47:45 +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
|
|
|
};
|
|
|
|
|
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-01-20 23:23:15 +00:00
|
|
|
$('#changeEmailForm').popover('hide');
|
2014-01-20 23:27:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
$scope.changeEmail = function() {
|
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-01-20 21:12:23 +00:00
|
|
|
$scope.changeEmailError = result.data.message;
|
|
|
|
$timeout(function() {
|
|
|
|
$('#changeEmailForm').popover('show');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
function TeamViewCtrl($rootScope, $scope, 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;
|
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
$rootScope.title = 'Loading...';
|
|
|
|
|
2013-11-04 20:31:38 +00:00
|
|
|
$scope.addNewMember = function(member) {
|
|
|
|
if ($scope.members[member.name]) { return; }
|
|
|
|
|
2013-12-26 22:45:16 +00:00
|
|
|
var params = {
|
|
|
|
'orgname': orgname,
|
|
|
|
'teamname': teamname,
|
|
|
|
'membername': member.name
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.updateOrganizationTeamMember(null, params).then(function(resp) {
|
2013-12-10 06:38:05 +00:00
|
|
|
$scope.members[member.name] = resp;
|
|
|
|
}, function() {
|
|
|
|
$('#cannotChangeMembersModal').modal({});
|
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) {
|
2013-11-04 20:31:38 +00:00
|
|
|
delete $scope.members[username];
|
|
|
|
}, function() {
|
|
|
|
$('#cannotChangeMembersModal').modal({});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
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,
|
|
|
|
'teamname': teamname
|
|
|
|
};
|
|
|
|
|
|
|
|
$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;
|
2013-12-27 23:05:04 +00:00
|
|
|
|
|
|
|
$('.info-icon').popover({
|
|
|
|
'trigger': 'hover',
|
|
|
|
'html': true
|
|
|
|
});
|
|
|
|
|
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-01-15 19:20:39 +00:00
|
|
|
function NewOrgCtrl($scope, $routeParams, $timeout, $location, UserService, PlanService, ApiService, CookieService) {
|
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
|
|
|
|
2013-11-07 20:19:52 +00:00
|
|
|
// Load the list of plans.
|
|
|
|
PlanService.getPlans(function(plans) {
|
2013-12-20 02:51:46 +00:00
|
|
|
$scope.plans = plans;
|
2013-11-07 20:19:52 +00:00
|
|
|
$scope.currentPlan = null;
|
2013-11-07 20:33:56 +00:00
|
|
|
if (requested) {
|
|
|
|
PlanService.getPlan(requested, function(plan) {
|
|
|
|
$scope.currentPlan = plan;
|
|
|
|
});
|
|
|
|
}
|
2013-11-07 20:19:52 +00:00
|
|
|
});
|
|
|
|
|
2013-12-11 22:50:48 +00:00
|
|
|
$scope.signedIn = function() {
|
|
|
|
PlanService.handleNotedPlan();
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.signinStarted = function() {
|
|
|
|
PlanService.getMinimumPlan(1, true, function(plan) {
|
|
|
|
PlanService.notePlan(plan.stripeId);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2013-11-07 20:19:52 +00:00
|
|
|
$scope.setPlan = function(plan) {
|
|
|
|
$scope.currentPlan = plan;
|
|
|
|
};
|
|
|
|
|
|
|
|
$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.
|
|
|
|
if ($scope.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
|
|
|
|
};
|
|
|
|
|
2013-12-18 03:56:28 +00:00
|
|
|
PlanService.changePlan($scope, org.name, $scope.currentPlan.stripeId, callbacks);
|
2013-11-07 20:19:52 +00:00
|
|
|
}, function(result) {
|
|
|
|
$scope.creating = false;
|
|
|
|
$scope.createError = result.data.message || result.data;
|
|
|
|
$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;
|
|
|
|
|
2013-12-07 00:30:55 +00:00
|
|
|
$rootScope.title = 'Logs for ' + $scope.memberInfo.username + ' (' + $scope.orgname + ')';
|
|
|
|
$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;
|
|
|
|
});
|
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();
|
2013-09-27 00:34:58 +00:00
|
|
|
}
|