commit导出方法及显示页面

This commit is contained in:
huang 2016-12-05 14:52:46 +08:00
parent 6ebaa1c90a
commit 66066e6899
6 changed files with 72 additions and 113 deletions

View File

@ -50,10 +50,10 @@ gem 'elasticsearch-model'
gem 'elasticsearch-rails' gem 'elasticsearch-rails'
#rails 3.2.22.2 bug #rails 3.2.22.2 bug
gem "test-unit", "~>3.0" # gem "test-unit", "~>3.0"
### profile ### profile
gem 'oneapm_rpm' # gem 'oneapm_rpm'
group :development do group :development do
gem 'grape-swagger' gem 'grape-swagger'

View File

@ -62,12 +62,13 @@ class IssuesController < ApplicationController
def issue_commits def issue_commits
begin begin
return render_404 if @project.gpid.nil? return render_404 if @project.gpid.nil?
limit = 20
g = Gitlab.client g = Gitlab.client
g_project = g.project(project.gpid) g_project = g.project(@project.gpid)
@rev = params[:rev].nil? ? g_project.default_branch : params[:rev] rev = params[:rev].nil? ? g_project.default_branch : params[:rev]
@commits = g.g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s, ref_name:rev) @commits = g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s, ref_name:rev)
@commits_count = params[:commit_count].to_i @commits_count = g.user_static(@project.gpid, :rev => rev).count
@commits_pages = Redmine::Pagination::Paginator.new @commits_count,limit,params[:page] @commits_pages = Redmine::Pagination::Paginator.new @commits_count, limit, params[:page]
rescue Exception => e rescue Exception => e
puts e puts e
end end

View File

@ -72,12 +72,36 @@ module ApplicationHelper
user.nil? ? User.find(2) : user user.nil? ? User.find(2) : user
end end
# 通过邮件查找用户,能查到返回用户,否则返回邮件地址
def user_by_mail mail
user = User.find_by_mail(mail)
user.nil? ? mail : user.try(:show_name)
end
def link_to_user_mail(mail, options={})
user = User.find_by_mail(mail)
user = user.nil? ? mail : user
if user.is_a?(User)
name = user.show_name
link_to name, {:controller=> 'users', :action => 'show', id: user.id}, :class => user.css_classes
else
h(user.to_s)
end
end
# 通过系统外部用户名查找用户,如果用户不存在则用邮箱替换 # 通过系统外部用户名查找用户,如果用户不存在则用邮箱替换
def get_user_by_login_and login def get_user_by_login_and login
user = User.find_by_login(login) user = User.find_by_login(login)
(user.nil? || login == "root") ? User.find(2) : user (user.nil? || login == "root") ? User.find(2) : user
end end
# 登录名来自外部系统
# 通过登录名查找用户,如果用户存在则显示用户姓名,否则显示登录名
def get_user_by_login login
user = User.find_by_login(login)
user.nil? ? login : user.show_name
end
# 重置user_path目的是将id转换成用户名 # 重置user_path目的是将id转换成用户名
def user_path(resource, parameters = {}) def user_path(resource, parameters = {})
if Fixnum === resource if Fixnum === resource

View File

@ -6,25 +6,25 @@
</div> </div>
<div class="muban_popup_con " > <div class="muban_popup_con " >
<div class="newupload_conbox " > <div class="newupload_conbox " >
<div class=" clear"> <% if @commits.blank? %>
<div class="cl"></div> <%= render :partial => "projects/no_data" %>
<ul class="clear lightheight28 fl"> <% else %>
<li class="mb10 clear fl"> <div class=" clear">
<span class=" fl">&nbsp;分支&nbsp;&nbsp;:&nbsp;</span> <div class="cl"></div>
<select class=" fl newupload_select" style="width:180px;"> <ul class="clear lightheight28 fl">
<option> 黄井泉</option> <li class="mb10 clear fl">
</select> <span class=" fl">&nbsp;分支&nbsp;&nbsp;:&nbsp;</span>
</li> <select class=" fl newupload_select" style="width:180px;">
</ul> <option> 黄井泉</option>
<div class="hw_search_box fr mb10" > </select>
<input class="hw_search-input" style="width:300px;" placeholder="输入描述的关键词进行搜索" type="text"> </li>
<a href="javascript:void(0);" class="hw_btn_search"></a> </ul>
</div> <div class="hw_search_box fr mb10" >
</div> <input class="hw_search-input" style="width:300px;" placeholder="输入描述的关键词进行搜索" type="text">
<div > <a href="javascript:void(0);" class="hw_btn_search"></a>
<% if @commits.blank? %> </div>
<%= render :partial => "projects/no_data" %> </div>
<% else %> <div>
<table class="newupload_table " cellspacing="0" cellpadding="0"> <table class="newupload_table " cellspacing="0" cellpadding="0">
<thead> <thead>
<tr> <tr>
@ -39,82 +39,17 @@
<% @commits.each do |commit| %> <% @commits.each do |commit| %>
<tr> <tr>
<td class="newupload_td01"><input type="checkbox"> </td> <td class="newupload_td01"><input type="checkbox"> </td>
<td class="newupload_td04"><span class="newupload_table_name">cff887</span></td> <td class="newupload_td04">
<td class="newupload_td02"><p>删除项目的实施删除版本库功能</p></td> <span class="newupload_table_name">
<td class="newupload_td04"><span class="newupload_table_name">胡莎莎</span></td> <%= link_to commit.id[0,8], {:controller => 'repositories', :action => 'commit_diff', :id => @project.id, :changeset => commit.id}, :target => "_blank" %>
<td class="newupload_td05">2016-10-26</td> </span>
</td>
<td class="newupload_td02"><p><%= commit.message %></p></td>
<td class="newupload_td04"><span class="newupload_table_name">
<%= link_to_user_mail(commit.author_email) %></span></td>
<td class="newupload_td05"><%= format_date(commit.created_at) %></td>
</tr> </tr>
<% end %> <% end %>
<tr>
<td class="newupload_td01"><input type="checkbox"> </td>
<td class="newupload_td04"><span class="newupload_table_name">cff887</span></td>
<td class="newupload_td02"><p>删除项目的实施删除版本库功能</p></td>
<td class="newupload_td04"><span class="newupload_table_name">胡莎莎</span></td>
<td class="newupload_td05">2016-10-26</td>
</tr>
<tr>
<td class="newupload_td01"><input type="checkbox"> </td>
<td class="newupload_td04"><span class="newupload_table_name">cff887ae</span></td>
<td class="newupload_td02"><p>班级作品列表的“未参与”相关优化品列表的“未参与”相关优化“未参与”相关...</p></td>
<td class="newupload_td04"><span class="newupload_table_name">胡莎莎胡莎莎胡莎莎胡莎莎</span></td>
<td class="newupload_td05">2016-10-26</td>
</tr>
<tr>
<td class="newupload_td01"><input type="checkbox"> </td>
<td class="newupload_td04"><span class="newupload_table_name">cff887</span></td>
<td class="newupload_td02"><p>删除项目的实施删除版本库功能</p></td>
<td class="newupload_td04"><span class="newupload_table_name">胡莎莎</span></td>
<td class="newupload_td05">2016-10-26</td>
</tr>
<tr>
<td class="newupload_td01"><input type="checkbox"> </td>
<td class="newupload_td04"><span class="newupload_table_name">cff887ae</span></td>
<td class="newupload_td02"><p>班级作品列表的“未参与”相关优化品列表的“未参与”相关优化“未参与”相关...</p></td>
<td class="newupload_td04"><span class="newupload_table_name">胡莎莎胡莎莎胡莎莎胡莎莎</span></td>
<td class="newupload_td05">2016-10-26</td>
</tr>
<tr>
<td class="newupload_td01"><input type="checkbox"> </td>
<td class="newupload_td04"><span class="newupload_table_name">cff887</span></td>
<td class="newupload_td02"><p>删除项目的实施删除版本库功能</p></td>
<td class="newupload_td04"><span class="newupload_table_name">胡莎莎</span></td>
<td class="newupload_td05">2016-10-26</td>
</tr>
<tr>
<td class="newupload_td01"><input type="checkbox"> </td>
<td class="newupload_td04"><span class="newupload_table_name">cff887ae</span></td>
<td class="newupload_td02"><p>班级作品列表的“未参与”相关优化品列表的“未参与”相关优化“未参与”相关...</p></td>
<td class="newupload_td04"><span class="newupload_table_name">胡莎莎胡莎莎胡莎莎胡莎莎</span></td>
<td class="newupload_td05">2016-10-26</td>
</tr>
<tr>
<td class="newupload_td01"><input type="checkbox"> </td>
<td class="newupload_td04"><span class="newupload_table_name">cff887</span></td>
<td class="newupload_td02"><p>删除项目的实施删除版本库功能</p></td>
<td class="newupload_td04"><span class="newupload_table_name">胡莎莎</span></td>
<td class="newupload_td05">2016-10-26</td>
</tr>
<tr>
<td class="newupload_td01"><input type="checkbox"> </td>
<td class="newupload_td04"><span class="newupload_table_name">cff887ae</span></td>
<td class="newupload_td02"><p>班级作品列表的“未参与”相关优化品列表的“未参与”相关优化“未参与”相关...</p></td>
<td class="newupload_td04"><span class="newupload_table_name">胡莎莎胡莎莎胡莎莎胡莎莎</span></td>
<td class="newupload_td05">2016-10-26</td>
</tr>
<tr>
<td class="newupload_td01"><input type="checkbox"> </td>
<td class="newupload_td04"><span class="newupload_table_name">cff887</span></td>
<td class="newupload_td02"><p>删除项目的实施删除版本库功能</p></td>
<td class="newupload_td04"><span class="newupload_table_name">胡莎莎</span></td>
<td class="newupload_td05">2016-10-26</td>
</tr>
<tr>
<td class="newupload_td01"><input type="checkbox"> </td>
<td class="newupload_td04"><span class="newupload_table_name">cff887ae</span></td>
<td class="newupload_td02"><p>班级作品列表的“未参与”相关优化品列表的“未参与”相关优化“未参与”相关...</p></td>
<td class="newupload_td04"><span class="newupload_table_name">胡莎莎胡莎莎胡莎莎胡莎莎</span></td>
<td class="newupload_td05">2016-10-26</td>
</tr>
</tbody> </tbody>
</table> </table>
<div class="clear"> <div class="clear">
@ -122,19 +57,18 @@
<button class=" btn btn-blue fr ">确定</button > <button class=" btn btn-blue fr ">确定</button >
<button class=" btn fr mr5">取消</button > <button class=" btn fr mr5">取消</button >
</div> </div>
<div class="fr pages_right_min mt10" > <div style="text-align:center;">
<a href="javascript:void(0);" class="pages-big">上一页</a> <div class="pages" style="width:auto; display:inline-block;">
<a href="javascript:void(0);" class="active ">1</a> <ul id="homework_pository_ref_pages">
<a href="javascript:void(0);">2</a> <%= pagination_links_full @commits_pages, @commits_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %>
<a href="javascript:void(0);">3</a> </ul>
<a href="javascript:void(0);">...</a> <div class="cl"></div>
<a href="javascript:void(0);">31</a> </div>
<a href="javascript:void(0);" class="pages-big pages-border-right">下一页</a>
<div class="cl"></div>
</div> </div>
<div class="cl"></div>
</div> </div>
<% end %> </div>
</div> <% end %>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,2 +1,2 @@
var htmlvalue = "<%= escape_javascript(render :partial => 'issues/issue_commits') %>"; var htmlvalue = "<%= escape_javascript(render :partial => 'issues/issue_commits') %>";
pop_box_new(htmlvalue,750,600); pop_box_new(htmlvalue,760,860);

View File

@ -1489,7 +1489,7 @@ function pop_up_box(value,tWidth,tTop,tLeft){
// 公共弹框样式 // 公共弹框样式
// 建议左右栏的Width460Height190 // 建议左右栏的Width460Height190
// 建议宽屏对应值Width750Height500 // 建议宽屏对应值Width760Height500
function pop_box_new(value, Width, Height){ function pop_box_new(value, Width, Height){
w = ($(window).width() - Width)/2; w = ($(window).width() - Width)/2;
h = ($(window).height() - Height)/2; h = ($(window).height() - Height)/2;