Add the command view to the tooltips in the tree, the image side bar and the image view page

This commit is contained in:
Joseph Schorr 2014-01-14 15:19:47 -05:00
parent c72cae954b
commit 6ae9485038
7 changed files with 93 additions and 8 deletions

View file

@ -1,3 +1,14 @@
function getFormattedCommand(command) {
if (!command || !command.length) { return ''; }
// Handle /bin/sh commands specially.
if (command.length > 2 && command[0] == '/bin/sh' && command[1] == '-c') {
return command[2];
}
return command.join(' ');
}
$.fn.clipboardCopy = function() {
var clip = new ZeroClipboard($(this), { 'moviePath': 'static/lib/ZeroClipboard.swf' });
@ -157,7 +168,7 @@ function LandingCtrl($scope, UserService, ApiService) {
browserchrome.update();
}
function RepoCtrl($scope, Restangular, ApiService, $routeParams, $rootScope, $location, $timeout) {
function RepoCtrl($scope, $sanitize, Restangular, ApiService, $routeParams, $rootScope, $location, $timeout) {
var namespace = $routeParams.namespace;
var name = $routeParams.name;
@ -192,6 +203,14 @@ function RepoCtrl($scope, Restangular, ApiService, $routeParams, $rootScope, $lo
// Start scope methods //////////////////////////////////////////
$scope.getFormattedCommand = getFormattedCommand;
$scope.getTooltipCommand = function(command) {
var formatted = getFormattedCommand(command);
var sanitized = $sanitize(formatted);
return '<span class=\'codetooltip\'>' + sanitized + '</span>';
};
$scope.updateForDescription = function(content) {
$scope.repo.description = content;
$scope.repo.put();
@ -563,7 +582,7 @@ function RepoCtrl($scope, Restangular, ApiService, $routeParams, $rootScope, $lo
// Create the new tree.
$scope.tree = new ImageHistoryTree(namespace, name, resp.images,
getFirstTextLine, $scope.getTimeSince);
getFirstTextLine, $scope.getTimeSince, $scope.getFormattedCommand);
$scope.tree.draw('image-history-container');
@ -979,6 +998,8 @@ function ImageViewCtrl($scope, $routeParams, $rootScope, $timeout, ApiService) {
var name = $routeParams.name;
var imageid = $routeParams.image;
$scope.getFormattedCommand = getFormattedCommand;
$scope.parseDate = function(dateString) {
return Date.parse(dateString);
};