incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [2/2] git commit: [#7128] Added support for paging to commit_browser
Date Tue, 18 Feb 2014 21:39:20 GMT
[#7128] Added support for paging to commit_browser

Signed-off-by: Cory Johns <cjohns@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/33fa7560
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/33fa7560
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/33fa7560

Branch: refs/heads/cj/7128
Commit: 33fa756089923cff6775074077770527cbd46751
Parents: 0b099be
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Tue Feb 18 19:54:22 2014 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Tue Feb 18 19:54:22 2014 +0000

----------------------------------------------------------------------
 .../lib/widgets/resources/js/commit_browser.js  | 79 +++++++++++++-------
 1 file changed, 53 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/33fa7560/Allura/allura/lib/widgets/resources/js/commit_browser.js
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/resources/js/commit_browser.js b/Allura/allura/lib/widgets/resources/js/commit_browser.js
index 37c4408..e288800 100644
--- a/Allura/allura/lib/widgets/resources/js/commit_browser.js
+++ b/Allura/allura/lib/widgets/resources/js/commit_browser.js
@@ -65,11 +65,11 @@ if($('#commit_graph')){
     var point_size = 10;
     var page_size = 15;
 
-    var data;
+    var data = {'commits': [], 'built_tree': {}};
     var offset = 1;
     var selected_commit = -1;
     var y_offset = offset * y_space;
-    var tree, next_column, max_x_pos, max_row;
+    var tree, next_column, max_x_pos, max_row = 0, last_row = 0;
 
     var $graph_holder = $('#graph_holder');
     var $scroll_placeholder = $('#graph_scroll_placeholder');
@@ -100,36 +100,55 @@ if($('#commit_graph')){
       $scroll_placeholder.height(graph_height);
     }
 
-    $.getJSON(document.location.href+'_data', function(data) {
-        data = data;
-        tree = data['built_tree'];
-        next_column = data['next_column'];
-        max_x_pos = x_space*next_column;
-        max_row = data['max_row']
-        setHeight(max_row);
+    function get_data(select_first) {
+        var params = {'limit': 25};
+        if (data['next_commit']) {
+            params['start'] = data['next_commit'];
+        }
+        $.getJSON(document.location.href+'_data', params, function(new_data) {
+            $.extend(true, data, new_data);
+            tree = data['built_tree'];
+            next_column = data['next_column'];
+            max_x_pos = x_space*next_column;
+            max_row += data['max_row']
+            for (var c in new_data['built_tree']) {
+                tree[c].row += last_row;
+            }
+            last_row = max_row;
+            setHeight(max_row);
 
-        // Calculate the (x,y) positions of all the commits
-        for(var c in tree){
-            var commit = tree[c];
-            var x_pos = x_space+(commit.column*x_space);
-            var y_pos = y_space+((commit.row)*y_space);
-            if (!taken_coords[x_pos]){
-                taken_coords[x_pos] = [y_pos]
+            // Calculate the (x,y) positions of all the commits
+            for(var c in tree){
+                var commit = tree[c];
+                var x_pos = x_space+(commit.column*x_space);
+                var y_pos = y_space+((commit.row)*y_space);
+                if (!taken_coords[x_pos]){
+                    taken_coords[x_pos] = [y_pos]
+                }
+                else if(taken_coords[x_pos].indexOf(y_pos) == -1){
+                    taken_coords[x_pos].push(y_pos);
+                }
+                commit_rows[commit.row] = {
+                    url: commit.url,
+                    x_pos: x_pos,
+                    y_pos: y_pos }
             }
-            else if(taken_coords[x_pos].indexOf(y_pos) == -1){
-                taken_coords[x_pos].push(y_pos);
+            drawGraph(offset);
+            if (select_first) {
+                selectCommit(0);
             }
-            commit_rows[commit.row] = {
-                url: commit.url,
-                x_pos: x_pos,
-                y_pos: y_pos }
-        }
-        drawGraph(offset);
-        selectCommit(0);
-    });
+        });
+    }
+    get_data(true);
 
     function selectCommit(index) {
       if (index < 0 || index > max_row) return;
+      if (index == max_row) {
+          if (data['next_commit']) {
+              get_data();
+          }
+          return;
+      }
       var commit = commit_rows[index];
       highlighter_ctx.clearRect(0, 0, canvas.width, canvas.height);
       highlighter_ctx.fillRect(
@@ -179,6 +198,9 @@ if($('#commit_graph')){
 
             for(var i=0,len=commit.parents.length;i<len;i++){
                 var parent = tree[commit.parents[i]];
+                if (!parent) {
+                    continue;
+                }
                 var parent_x = x_space+parent.column*x_space
                 var parent_y = y_space+(parent.row-offset)*y_space;
 
@@ -212,6 +234,11 @@ if($('#commit_graph')){
             canvas_ctx.fillStyle = "#000";
             canvas_ctx.fillText(commit.short_id + " " + commit.message, (1+next_column) *
x_space, y_pos);
         }
+        if (data['next_commit']) {
+            var y_pos = y_space+((max_row-offset)*y_space);
+            canvas_ctx.fillStyle = 'rgb(0,0,256)';
+            canvas_ctx.fillText('Show more', (1+next_column) * x_space, y_pos);
+        }
     }
 
     function setOffset(x) {


Mime
View raw message