Commit fcb0b76c32b3512ead419a4451e9cc632270fc89
1 parent
9fd6c3d5
Exists in
spb-stable
and in
2 other branches
Load last commit for files per 10 items.
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
2 changed files
with
27 additions
and
3 deletions
Show diff stats
app/controllers/projects/refs_controller.rb
... | ... | @@ -31,9 +31,23 @@ class Projects::RefsController < Projects::ApplicationController |
31 | 31 | end |
32 | 32 | |
33 | 33 | def logs_tree |
34 | - contents = tree.entries | |
35 | - @logs = contents.map do |content| | |
36 | - file = params[:path] ? File.join(params[:path], content.name) : content.name | |
34 | + @offset = if params[:offset].present? | |
35 | + params[:offset].to_i | |
36 | + else | |
37 | + 0 | |
38 | + end | |
39 | + | |
40 | + @limit = 10 | |
41 | + | |
42 | + @path = params[:path] | |
43 | + | |
44 | + contents = [] | |
45 | + contents += tree.trees | |
46 | + contents += tree.blobs | |
47 | + contents += tree.submodules | |
48 | + | |
49 | + @logs = contents[@offset, @limit].to_a.map do |content| | |
50 | + file = @path ? File.join(@path, content.name) : content.name | |
37 | 51 | last_commit = @repo.last_commit_for_path(@commit.id, file) |
38 | 52 | { |
39 | 53 | file_name: content.name, | ... | ... |
app/views/projects/refs/logs_tree.js.haml
... | ... | @@ -7,3 +7,13 @@ |
7 | 7 | var row = $("table.table_#{@hex_path} tr.file_#{hexdigest(file_name)}"); |
8 | 8 | row.find("td.tree_time_ago").html('#{escape_javascript time_ago_with_tooltip(commit.committed_date)}'); |
9 | 9 | row.find("td.tree_commit").html('#{escape_javascript render("projects/tree/tree_commit_column", commit: commit)}'); |
10 | + | |
11 | +- if @logs.present? | |
12 | + :plain | |
13 | + var current_url = location.href.replace(/\/?$/, '/'); | |
14 | + var log_url = '#{project_tree_url(@project, tree_join(@ref, @path || '/'))}'.replace(/\/?$/, '/'); | |
15 | + if(current_url == log_url) { | |
16 | + // Load 10 more commit log for each file in tree | |
17 | + // if we still on the same page | |
18 | + ajaxGet('#{logs_file_project_ref_path(@project, @ref, @path || '/', offset: (@offset + @limit))}'); | |
19 | + } | ... | ... |