get date froma sonar

This commit is contained in:
Your Name 2016-06-23 11:24:58 +08:00
parent 9f15a8aa4e
commit 3fe5d9a1a3
5 changed files with 30 additions and 64 deletions

View File

@ -53,15 +53,15 @@ class QualityAnalysisController < ApplicationController
end
def index
if params[:name].nil?
if params[:resource_id].nil?
@name_flag = true
projects_date = open("http://123.59.135.93:8891/api/projects/index").read
@results = JSON.parse(projects_date)
else
@name_flag = false
project_key = params[:name]
data = open("http://123.59.135.93:8891/api/resources/index?resource=#{project_key}&depth=-1&metrics=complexity,class_complexity,lines,comment_lines,blocker_violations").read
@cc =JSON.parse(data)
resource_id = params[:resource_id]
complexity_date = open("http://123.59.135.93:8891/api/resources/index?resource=139&depth=0&metrics=complexity,function_complexity,class_complexity,file_complexity,lines,file_line,files,functions,classes,directories").read
@complexity =JSON.parse(complexity_date).first
end
end

View File

@ -1,51 +1,20 @@
<div style="min-height: 687px;" id="RSide" class="fl">
<p> lines: <%= @complexity["msr"][0]["frmt_val"] %></p>
<p> files: <%= @complexity["msr"][2]["frmt_val"] %></p>
<p> directories: <%= @complexity["msr"][3]["frmt_val"] %></p>
<p> classes: <%= @complexity["msr"][1]["frmt_val"] %></p>
<p> function: <%= @complexity["msr"][4]["frmt_val"] %></p>
<p> total Complexity: <%= @complexity["msr"][5]["frmt_val"] %></p>
<p>file_complexity: <%= @complexity["msr"][6]["frmt_val"] %></p>
<p>class_complexity: <%= @complexity["msr"][7]["frmt_val"] %></p>
<p>function_complexity: <%= @complexity["msr"][8]["frmt_val"] %></p>
<div class="project_r_h">
<h2 class="project_h2" style="width:180px;">SonarQube质量分析</h2>
</div>
<div class="repositorytitle mr15">
<form accept-charset="UTF-8" action="/projects/2/repository" class="fl c_grey02 ml5" id="revision_selector" method="get">
<!-- Branches Dropdown -->
分支:
<select id="branch" name="branch">
<option value=""></option>
<option value="Branch_szzh">Branch_szzh</option>
<option value="CourseModify">CourseModify</option>
<option value="GitlabVersion">GitlabVersion</option>
<option value="Homework">Homework</option>
<option value="Poll">Poll</option>
<option value="alan_competition">alan_competition</option>
<option value="api">api</option>
<option value="competition">competition</option>
<option value="course_group">course_group</option>
<option value="dev_chuangbin">dev_chuangbin</option>
<option value="dev_cxt2">dev_cxt2</option>
<option value="dev_dingxu">dev_dingxu</option>
<option value="dev_hjq">dev_hjq</option>
<option value="dev_repository_hjq">dev_repository_hjq</option>
<option value="dev_zanle">dev_zanle</option>
<option value="develop">develop</option>
<option value="email_verify">email_verify</option>
<option value="enterprise">enterprise</option>
<option value="exceptionHandle">exceptionHandle</option>
<option value="gitlab">gitlab</option>
<option value="gitlab_guange">gitlab_guange</option>
<option value="guange_dev">guange_dev</option>
<option value="guange_homework">guange_homework</option>
<option value="master" selected="selected">master</option>
<option value="memcached_alan">memcached_alan</option>
<option value="ouyang">ouyang</option>
<option value="ouyangxuhua">ouyangxuhua</option>
<option value="president">president</option>
<option value="redis_cache">redis_cache</option>
<option value="shapgroup">shapgroup</option>
<option value="sw_new_course">sw_new_course</option>
<option value="szzh">szzh</option>
<option value="yutao">yutao</option>
<option value="zh">zh</option>
</select>
</form>
</div>
<a href="javascript:void(0);" class="blue_btn_cir fl mt5 c_white" style="background-color:#64bdd9;">开始分析</a>
<a href="javascript:void(0);" class="blue_btn_cir fl mt5 c_white" style="background-color:#64bdd9;">branch:master</a>
<div class="cl"></div>
<div class="tac f20 fb mt35 mb30">项目代码质量分析报告</div>
<div class="analysis-tag-wrap f16"> <span class="analysis-tag fl mr15"></span> <span class="fb fl">概要信息</span></div>
@ -83,23 +52,23 @@
<div class="analysis-block mt10 mb40 flex f14">
<div class="analysis-genral">
<p class="fontGrey3">代码行数</p>
<p class="fontBlue2">9,337</p>
<p class="fontBlue2"><%= @complexity["msr"][0]["frmt_val"] %></p>
</div>
<div class="analysis-genral">
<p class="fontGrey3">文件</p>
<p class="fontBlue2">10</p>
<p class="fontBlue2"><%= @complexity["msr"][2]["frmt_val"] %></p>
</div>
<div class="analysis-genral">
<p class="fontGrey3">目录</p>
<p class="fontBlue2">6</p>
<p class="fontBlue2"><%= @complexity["msr"][3]["frmt_val"] %></p>
</div>
<div class="analysis-genral">
<p class="fontGrey3">类</p>
<p class="fontBlue2">15</p>
<p class="fontBlue2"><%= @complexity["msr"][1]["frmt_val"] %></p>
</div>
<div class="analysis-genral">
<p class="fontGrey3">方法</p>
<p class="fontBlue2">36</p>
<p class="fontBlue2"><%= @complexity["msr"][4]["frmt_val"] %></p>
</div>
</div>
<div class="analysis-tag-wrap f16"> <span class="analysis-tag fl mr15"></span> <span class="fb fl">贡献统计</span></div>
@ -145,4 +114,3 @@
<div class="cl"></div>
</ul>
</div>
</div>

View File

@ -1,7 +1,7 @@
<% if @name_flag %>
<%= @results.each do |result| %>
<p>
<%=link_to result["k"], project_quality_analysis_path(:name => result["k"]) %>
<%=link_to result["k"], project_quality_analysis_path(:resource_id => result["id"]) %>
</p>
<% end %>
<% else %>

View File

@ -1,7 +1,6 @@
<div class="popupWrap w800"> <a href="javascript:void(0);" class="popupClose"></a>
<div class="f16 fb fontBlue mb10">代码质量分析</div>
<div>
<%= form_tag( url_for(:controller => 'quality_analysis', :action => 'create', :project_id => @project.id, :user_id => User.current.id, :identifier => @repository.identifier), :remote => true, :id => 'quality_analyses_form') do %>
<div class="f16 fb fontBlue mb10">代码质量分析</div>
<div>
<%= form_tag( url_for(:controller => 'quality_analysis', :action => 'create', :project_id => @project.id, :user_id => User.current.id, :identifier => @repository.identifier), :remote => true, :id => 'quality_analyses_form') do %>
<div class="ui form">
<div class="mb10" style="margin-right:13px;">
<textarea id="path_description" name="path" rows="8" placeholder="目录相对于根目录,用半角逗号隔开。如:src/main/java,libs,res/script" style="height: 87px; resize:vertical;" class="analysis-option-box"></textarea>
@ -20,6 +19,5 @@
<div class="courseSendCancel"><a href="javascript:void(0);" class="sendSourceText" onclick="hideModal()">取消</a></div>
<div class="cl"></div>
</div>
<% end %>
</div>
</div>
<% end %>
</div>

View File

@ -2,7 +2,7 @@ $('#ajax-modal').html('<%= escape_javascript( render :partial => 'repositories/q
showModal('ajax-modal', '615px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal()' style='margin-left: 580px;'><img src='/images/bid/close.png' width='26px' height='26px' /></a>");
$('#ajax-modal').parent().css("top","20%").css("left","42%").css("border","3px solid #269ac9");
$('#ajax-modal').parent().css("top","20%").css("left","30%").css("border","3px solid #269ac9");
$('#ajax-modal').parent().addClass("popbox_polls");