diff --git a/static/js/controllers.js b/static/js/controllers.js index 7d36ec8fb..e44e3447b 100644 --- a/static/js/controllers.js +++ b/static/js/controllers.js @@ -731,33 +731,34 @@ function RepoCtrl($scope, $sanitize, Restangular, ImageMetadataService, ApiServi } // Create the new tree. - $scope.tree = new ImageHistoryTree(namespace, name, resp.images, + var tree = new ImageHistoryTree(namespace, name, resp.images, getFirstTextLine, $scope.getTimeSince, ImageMetadataService.getEscapedFormattedCommand); - $scope.tree.draw('image-history-container'); + $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); + } - // If we already have a tag, use it - if ($scope.currentTag) { - $scope.tree.setTag($scope.currentTag.name); + // 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); }); + }); + + $($scope.tree).bind('imageChanged', function(e) { + $scope.$apply(function() { $scope.setImage(e.image.id, true); }); + }); + + $($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(); }); + }); } - // 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); }); - }); - - $($scope.tree).bind('imageChanged', function(e) { - $scope.$apply(function() { $scope.setImage(e.image.id, true); }); - }); - - $($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(); }); - }); - if ($routeParams.image) { $scope.setImage($routeParams.image); } diff --git a/static/js/graphing.js b/static/js/graphing.js index f166de025..9eeac1909 100644 --- a/static/js/graphing.js +++ b/static/js/graphing.js @@ -196,6 +196,11 @@ ImageHistoryTree.prototype.draw = function(container) { var rootSvg = d3.select("#" + container).append("svg:svg") .attr("class", "image-tree"); + if (!rootSvg) { + this.container_ = null; + return; + } + var vis = rootSvg.append("svg:g"); if (!vis) { this.container_ = null; @@ -266,6 +271,8 @@ ImageHistoryTree.prototype.draw = function(container) { this.setTag_(this.currentTag_); this.setupOverscroll_(); + + return this; };