Merge remote-tracking branch 'origin/spartan'

Conflicts:
	test/data/test.db
This commit is contained in:
yackob03 2014-01-08 17:04:40 -05:00
commit 4234ceabe6
10 changed files with 246 additions and 10 deletions

View file

@ -194,6 +194,38 @@ function RepoCtrl($scope, Restangular, ApiService, $routeParams, $rootScope, $lo
}
};
$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"
}
}
});
});
};
$scope.setTag = function(tagName, opt_updateURL) {
var repo = $scope.repo;
var proposedTag = repo.tags[tagName];
@ -218,6 +250,11 @@ function RepoCtrl($scope, Restangular, ApiService, $routeParams, $rootScope, $lo
$location.search('tag', $scope.currentTag.name);
}
}
if ($scope.currentTag && !repo.tags[$scope.currentTag.name]) {
$scope.currentTag = null;
$scope.currentImage = null;
}
};
$scope.getTagCount = function(repo) {
@ -229,6 +266,40 @@ function RepoCtrl($scope, Restangular, ApiService, $routeParams, $rootScope, $lo
return count;
};
$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();
};
var getDefaultTag = function() {
if ($scope.repo === undefined) {
return undefined;
@ -343,6 +414,14 @@ function RepoCtrl($scope, Restangular, ApiService, $routeParams, $rootScope, $lo
$scope.$apply(function() { $scope.setImage(e.image); });
});
$($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(); });
});
return resp.images;
});
};

View file

@ -69,6 +69,25 @@ ImageHistoryTree.prototype.calculateDimensions_ = function(container) {
};
ImageHistoryTree.prototype.setupOverscroll_ = function() {
var container = this.container_;
var that = this;
var overscroll = $('#' + container).overscroll();
overscroll.on('overscroll:dragstart', function() {
$(that).trigger({
'type': 'hideTagMenu'
});
});
overscroll.on('scroll', function() {
$(that).trigger({
'type': 'hideTagMenu'
});
});
};
/**
* Updates the dimensions of the tree.
*/
@ -88,8 +107,8 @@ ImageHistoryTree.prototype.updateDimensions_ = function() {
var boundingBox = document.getElementById(container).getBoundingClientRect();
document.getElementById(container).style.maxHeight = (viewportHeight - boundingBox.top - 150) + 'px';
$('#' + container).overscroll();
this.setupOverscroll_();
// Update the tree.
var rootSvg = this.rootSvg_;
var tree = this.tree_;
@ -183,8 +202,7 @@ ImageHistoryTree.prototype.draw = function(container) {
this.root_.y0 = 0;
this.setTag_(this.currentTag_);
$('#' + container).overscroll();
this.setupOverscroll_();
};
@ -642,7 +660,7 @@ ImageHistoryTree.prototype.update_ = function(source) {
if (tag == currentTag) {
kind = 'success';
}
html += '<span class="label label-' + kind + ' tag" data-tag="' + tag + '">' + tag + '</span>';
html += '<span class="label label-' + kind + ' tag" data-tag="' + tag + '"">' + tag + '</span>';
}
return html;
});
@ -654,6 +672,19 @@ ImageHistoryTree.prototype.update_ = function(source) {
if (tag) {
that.changeTag_(tag);
}
})
.on("contextmenu", function(d, e) {
d3.event.preventDefault();
var tag = this.getAttribute('data-tag');
if (tag) {
$(that).trigger({
'type': 'showTagMenu',
'tag': tag,
'clientX': d3.event.clientX,
'clientY': d3.event.clientY
});
}
});
// Ensure the tags are visible.