|
@@ -1,6 +1,6 @@
|
|
|
var timelineCtrl = angular.module('timelineCtrl', []);
|
|
|
|
|
|
-timelineCtrl.controller('TimelineCtrl', ['$scope', '$rootScope', '$routeParams', '$location', '$timeout', 'Menu', 'Results', 'API', function($scope, $rootScope, $routeParams, $location, $timeout, Menu, Results, API) {
|
|
|
+timelineCtrl.controller('TimelineCtrl', ['$scope', '$rootScope', '$routeParams', '$location', '$anchorScroll', '$timeout', 'Menu', 'Results', 'API', function($scope, $rootScope, $routeParams, $location, $anchorScroll, $timeout, Menu, Results, API) {
|
|
|
$scope.runId = $routeParams.runId;
|
|
|
$scope.Menu = Menu.setCurrentPage('timeline', $scope.runId);
|
|
|
|
|
@@ -106,8 +106,22 @@ timelineCtrl.controller('TimelineCtrl', ['$scope', '$rootScope', '$routeParams',
|
|
|
return out;
|
|
|
}
|
|
|
|
|
|
- $scope.filter = function(textFilter, scriptName) {
|
|
|
+ $scope.findLineIndexByTimestamp = function(timestamp) {
|
|
|
+ var lineIndex = 0;
|
|
|
|
|
|
+ for (var i = 0; i < $scope.executionTree.length; i ++) {
|
|
|
+ var delta = $scope.executionTree[i].data.timestamp - timestamp;
|
|
|
+
|
|
|
+ if (delta < $scope.timelineIntervalDuration) {
|
|
|
+ lineIndex = i;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (delta > 0) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return lineIndex;
|
|
|
};
|
|
|
|
|
|
$scope.onNodeDetailsClick = function(node) {
|
|
@@ -137,4 +151,28 @@ timelineCtrl.controller('TimelineCtrl', ['$scope', '$rootScope', '$routeParams',
|
|
|
|
|
|
loadResults();
|
|
|
|
|
|
-}]);
|
|
|
+}]);
|
|
|
+
|
|
|
+timelineCtrl.directive('scrollOnClick', ['$animate', '$timeout', function($animate, $timeout) {
|
|
|
+ return {
|
|
|
+ restrict: 'A',
|
|
|
+ link: function (scope, element, attributes) {
|
|
|
+ // When the user clicks on the timeline, find the right profiler line and scroll to it
|
|
|
+ element.on('click', function() {
|
|
|
+ var lineIndex = scope.findLineIndexByTimestamp(attributes.scrollOnClick);
|
|
|
+ var lineElement = angular.element(document.getElementById('line_' + lineIndex));
|
|
|
+
|
|
|
+ // Animate the background color to "flash" the row
|
|
|
+ lineElement.addClass('highlight');
|
|
|
+ $timeout(function() {
|
|
|
+ $animate.removeClass(lineElement, 'highlight');
|
|
|
+ scope.$digest();
|
|
|
+ }, 50);
|
|
|
+
|
|
|
+
|
|
|
+ window.scrollTo(0, lineElement[0].offsetTop);
|
|
|
+ console.log(lineElement[0]);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+}]);
|