Commit a47032bc authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'gh-issue-1509' of https://github.com/koenpunt/gitlabhq into koenpunt-gh-issue-1509

Conflicts:
	vendor/assets/javascripts/branch-graph.js
parents a567d596 4b2ecbc4
...@@ -18,10 +18,3 @@ $ -> ...@@ -18,10 +18,3 @@ $ ->
# Ref switcher # Ref switcher
$('.project-refs-select').on 'change', -> $('.project-refs-select').on 'change', ->
$(@).parents('form').submit() $(@).parents('form').submit()
class @GraphNav
@init: ->
$('.graph svg').css 'position', 'relative'
$('body').bind 'keyup', (e) ->
$('.graph svg').animate(left: '+=400') if e.keyCode is 37 # left
$('.graph svg').animate(left: '-=400') if e.keyCode is 39 # right
...@@ -57,6 +57,9 @@ table a code { ...@@ -57,6 +57,9 @@ table a code {
background: url(ajax_loader.gif) no-repeat center center; background: url(ajax_loader.gif) no-repeat center center;
width: 40px; width: 40px;
height: 40px; height: 40px;
&.loading-gray {
background: url(ajax_loader_gray.gif) no-repeat center center;
}
} }
/** FLASH message **/ /** FLASH message **/
......
...@@ -87,9 +87,13 @@ class ProjectsController < ProjectResourceController ...@@ -87,9 +87,13 @@ class ProjectsController < ProjectResourceController
end end
def graph def graph
respond_to do |format|
format.html
format.json do
graph = Gitlab::Graph::JsonBuilder.new(project) graph = Gitlab::Graph::JsonBuilder.new(project)
render :json => graph.to_json
@days_json, @commits_json = graph.days_json, graph.commits_json end
end
end end
def destroy def destroy
......
...@@ -2,13 +2,15 @@ ...@@ -2,13 +2,15 @@
%br %br
.graph_holder .graph_holder
%h4 %h4
%small You can move around the graph by using arrow keys. %small You can move around the graph by using the arrow keys.
#holder.graph #holder.graph
.loading.loading-gray
:javascript :javascript
var chunk1={commits:#{@commits_json}}; var branch_graph;
var days=#{@days_json};
initGraph();
$(function(){ $(function(){
branchGraph($("#holder")[0]); branch_graph = new BranchGraph($("#holder"), {
GraphNav.init(); url: '#{url_for controller: 'projects', action: 'graph', format: :json}',
commit_url: '#{url_for controller: 'projects', action: 'show'}/commits/%s'
});
}); });
...@@ -28,7 +28,7 @@ module Gitlab ...@@ -28,7 +28,7 @@ module Gitlab
h[:refs] = refs.collect{|r|r.name}.join(" ") unless refs.nil? h[:refs] = refs.collect{|r|r.name}.join(" ") unless refs.nil?
h[:id] = sha h[:id] = sha
h[:date] = date h[:date] = date
h[:message] = escape_once(message) h[:message] = message
h[:login] = author.email h[:login] = author.email
h h
end end
......
...@@ -18,12 +18,11 @@ module Gitlab ...@@ -18,12 +18,11 @@ module Gitlab
@days = index_commits @days = index_commits
end end
def days_json def to_json(*args)
@days_json = @days.compact.map { |d| [d.day, d.strftime("%b")] }.to_json {
end days: @days.compact.map { |d| [d.day, d.strftime("%b")] },
commits: @commits.map(&:to_graph_hash)
def commits_json }.to_json(*args)
@commits_json = @commits.map(&:to_graph_hash).to_json
end end
protected protected
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment