Browse Source

Fix merge conflict

Gaël Métais 10 years ago
parent
commit
5a22eb9542

+ 12 - 0
front/src/css/timeline.css

@@ -52,6 +52,9 @@
   bottom: 0;
   bottom: 0;
   width: 100%;
   width: 100%;
 }
 }
+.timeline .interval .color.clickable {
+  cursor: pointer;
+}
 .timeline div.interval:hover {
 .timeline div.interval:hover {
   background: #9C4274;
   background: #9C4274;
 }
 }
@@ -184,6 +187,15 @@ input.textFilter {
 .table > div.showingDetails > div {
 .table > div.showingDetails > div {
   background: #f1c40f;
   background: #f1c40f;
 }
 }
+.table > div.highlight > div.startTime {
+  background-color: #C0F090;
+}
+.table > div.highlight-remove {
+  transition: 3s;
+}
+.table > div.highlight-remove > div.startTime {
+  transition: background-color 3s ease-in;
+}
 .table > div > .index {
 .table > div > .index {
   color: #bbb;
   color: #bbb;
   word-break: normal;
   word-break: normal;

+ 1 - 0
front/src/js/app.js

@@ -1,6 +1,7 @@
 var yltApp = angular.module('YellowLabTools', [
 var yltApp = angular.module('YellowLabTools', [
     'ngRoute',
     'ngRoute',
     'ngSanitize',
     'ngSanitize',
+    'ngAnimate',
     'indexCtrl',
     'indexCtrl',
     'dashboardCtrl',
     'dashboardCtrl',
     'queueCtrl',
     'queueCtrl',

+ 43 - 1
front/src/js/controllers/timelineCtrl.js

@@ -152,6 +152,24 @@ timelineCtrl.controller('TimelineCtrl', ['$scope', '$rootScope', '$routeParams',
         initProfiler();
         initProfiler();
     };
     };
 
 
+    $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) {
     $scope.onNodeDetailsClick = function(node) {
         var isOpen = node.showDetails;
         var isOpen = node.showDetails;
         if (!isOpen) {
         if (!isOpen) {
@@ -179,4 +197,28 @@ timelineCtrl.controller('TimelineCtrl', ['$scope', '$rootScope', '$routeParams',
 
 
     loadResults();
     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]);
+            });
+        }
+    };
+}]);

+ 17 - 0
front/src/less/timeline.less

@@ -66,6 +66,10 @@
     position: absolute;
     position: absolute;
     bottom: 0;
     bottom: 0;
     width: 100%;
     width: 100%;
+
+    &.clickable {
+        cursor: pointer;
+    }
 }
 }
 .timeline div.interval:hover {
 .timeline div.interval:hover {
     background: #9C4274;
     background: #9C4274;
@@ -206,6 +210,19 @@ input.textFilter {
     background: #f1c40f;
     background: #f1c40f;
 }
 }
 
 
+.table > div.highlight {
+    > div.startTime {
+        background-color: #C0F090;
+    }
+}
+.table > div.highlight-remove {
+    transition: 3s;
+
+    > div.startTime {
+        transition: background-color 3s ease-in;
+    }
+}
+
 .table > div > .index {
 .table > div > .index {
     color: #bbb;
     color: #bbb;
     word-break: normal;
     word-break: normal;

+ 1 - 0
front/src/main.html

@@ -23,6 +23,7 @@
     <script src="/bower_components/angular-route/angular-route.min.js"></script>
     <script src="/bower_components/angular-route/angular-route.min.js"></script>
     <script src="/bower_components/angular-resource/angular-resource.min.js"></script>
     <script src="/bower_components/angular-resource/angular-resource.min.js"></script>
     <script src="/bower_components/angular-sanitize/angular-sanitize.min.js"></script>
     <script src="/bower_components/angular-sanitize/angular-sanitize.min.js"></script>
+    <script src="/bower_components/angular-animate/angular-animate.min.js"></script>
     <script src="/js/app.js"></script>
     <script src="/js/app.js"></script>
     <script src="/js/controllers/indexCtrl.js"></script>
     <script src="/js/controllers/indexCtrl.js"></script>
     <script src="/js/controllers/dashboardCtrl.js"></script>
     <script src="/js/controllers/dashboardCtrl.js"></script>

+ 5 - 3
front/src/views/timeline.html

@@ -25,9 +25,11 @@
                             && $index * timelineIntervalDuration < result.toolsResults.phantomas.metrics.domComplete,
                             && $index * timelineIntervalDuration < result.toolsResults.phantomas.metrics.domComplete,
                         domComplete: $index * timelineIntervalDuration >= result.toolsResults.phantomas.metrics.domComplete
                         domComplete: $index * timelineIntervalDuration >= result.toolsResults.phantomas.metrics.domComplete
                      }">
                      }">
-                    <div style="height: {{100 * duration / timelineMax | number: 0}}px" class="color"></div>
+                    <div style="height: {{100 * duration / timelineMax | number: 0}}px" class="color" ng-class="{clickable: duration > 0}" scroll-on-click="{{$index * timelineIntervalDuration}}"></div>
                     <div class="tooltip detailsOverlay">
                     <div class="tooltip detailsOverlay">
-                        <div>Timestamp: {{$index * timelineIntervalDuration | number: 0}} ms</div>
+                        <div>
+                            Timestamp: {{$index * timelineIntervalDuration | number: 0}} ms
+                        </div>
                     </div>
                     </div>
                 </div>
                 </div>
             </div>
             </div>
@@ -82,7 +84,7 @@
                 showingDetails: node.showDetails,
                 showingDetails: node.showDetails,
                 jsError: node.error,
                 jsError: node.error,
                 windowPerformance: node.windowPerformance
                 windowPerformance: node.windowPerformance
-            }">
+             }" id="line_{{$index}}">
 
 
             <div class="index">{{$index + 1}}</div>
             <div class="index">{{$index + 1}}</div>
             <div class="type">
             <div class="type">