output局部刷新

权限显示控制
This commit is contained in:
huang 2017-03-15 17:57:10 +08:00
parent 91e043cc16
commit 28cf382576
8 changed files with 59 additions and 45 deletions

View File

@ -1,7 +1,7 @@
class GamesController < ApplicationController
layout "base_myshixun"
before_filter :find_myshixun, :only => [:index]
before_filter :find_game, :only => [:show, :game_build, :entry,:next_step]
before_filter :find_game, :only => [:show, :game_build, :entry,:next_step, :output_show]
before_filter :find_repository, :only => [:show, :entry]
before_filter :allowd_manager, :only => [:game_build]
include ApplicationHelper
@ -14,7 +14,7 @@ class GamesController < ApplicationController
def show
@git_url = git_repository_url(@myshixun, "Myshixun")
@entries = @repository.entries(@path, @rev)
@outputs =
@outputs = @game.game_outputses
respond_to do |format|
format.html
format.js
@ -30,6 +30,12 @@ class GamesController < ApplicationController
end
end
# json调用显示左边的隐藏具体详情@game 字段 msg
# 刷新右边的输出结果 @game out_put
def output_show
@game = GameOutputs.find(params[:game_output_id])
end
# status 0: 未提交测评或者提交测评失败后报错1中间状态还没返回值2返回值并成功
def game_build
gitUrl = git_repository_url(@myshixun, "Myshixun")

View File

@ -0,0 +1,15 @@
<div class=" col-width-2 fl content-submit ml15 mt15">
<div class="panel-header ">
<h3 >操作</h3>
</div>
<div class="content-submitbox">
<a href="#" class="task-btn mb10 ">保存修改</a>
<% if @game.status == 0 %>
<%= link_to "提交评测", {:controller => 'games', :action => "game_build", :id => @game, :myshixun_id => @myshixun}, :class => "task-btn task-btn-green", :onclick => "training_task_submmit();", :remote => true %>
<% elsif @game.status == 2 %>
<a class="task-btn mb10">评测中..</a>
<% elsif @game.status == 1 %>
<%= link_to "下 一 步 ", {:controller => 'games', :action => "next_step", :id => @game, :myshixun_id => @myshixun}, :class => "task-btn task-btn-green", :onclick => "training_task_submmit();", :remote => true %>
<% end %>
</div>
</div>

View File

@ -0,0 +1,9 @@
<div class=" col-width-4 fl content-output ml15 mt15">
<div class="panel-header ">
<h3 >测试输出</h3>
</div>
<div class="content-history-inner">
Thor position=(32,4).Light position={32,4}<br/>
Engryg=74
</div>
</div>

View File

@ -0,0 +1,18 @@
<div class=" col-width-5 fl content-history mt15" >
<div class="panel-header clearfix">
<h3 class="fl">测评历史</h3>
<div class="fr mt5">
<a href="#"><i class="fa fa-minus font-14 mr10 fl color-grey"></i></a>
<a href="#"><i class="fa fa-minus-square font-14 fl color-grey"></i></a>
</div>
</div>
<div class="content-history-inner">
<% @outputs.each do |output| %>
<div class="<% output.code == 0 ? 'clearfix history-success mb10' : 'clearfix history-fail mb10' %>">
<span class="<% output.code == 0 ? 'icon-success fl mr5' : 'icon-fail fl mr5' %>">2</span>
<p class="fl">恭喜,您已经完成了本任务!</p>
<%= link_to "详情", outputs_show_myshixun_game_path(@game, :myshixun_id => @myshixun, :game_output_id => output.id), :class => "fr mr10" %>
</div>
<% end %>
</div>
</div>

View File

@ -1,41 +0,0 @@
<div class=" col-width-5 fl content-history mt15" >
<div class="panel-header clearfix">
<h3 class="fl">测评历史</h3>
<div class="fr mt5">
<a href="#"><i class="fa fa-minus font-14 mr10 fl color-grey"></i></a>
<a href="#"><i class="fa fa-minus-square font-14 fl color-grey"></i></a>
</div>
</div>
<div class="content-history-inner">
<div class="clearfix history-success mb10">
<span class="icon-success fl mr5">2</span>
<p class="fl">恭喜,您已经完成了本任务!</p>
<a href="#" class="fr mr10">详情</a>
</div>
<div class="clearfix history-fail mb10">
<span class="icon-fail fl mr5">1</span>
<p class="fl">错误结果!</p>
<a href="#" class="fr mr10">详情</a>
</div>
</div>
</div>
<div class=" col-width-4 fl content-output ml15 mt15">
<div class="panel-header ">
<h3 >测试输出</h3>
</div>
<div class="content-history-inner">
Thor position=(32,4).Light position={32,4}<br/>
Engryg=74
</div>
</div>
<div class=" col-width-2 fl content-submit ml15 mt15">
<div class="panel-header ">
<h3 >操作</h3>
</div>
<div class="content-submitbox">
<a href="#" class="task-btn mb10 ">保存修改</a>
<% %>
<%= link_to "提交评测", {:controller => 'games', :action => "game_build", :id => @game, :myshixun_id => @myshixun}, :class => "task-btn task-btn-green", :onclick => "training_task_submmit();", :remote => true %>
<%= link_to "下一步 ", {:controller => 'games', :action => "next_step", :id => @game, :myshixun_id => @myshixun}, :class => "task-btn task-btn-green", :onclick => "training_task_submmit();", :remote => true %>
</div>
</div>

View File

View File

@ -83,8 +83,14 @@
<div id="code_content">
<%= render :partial => 'repository' %>
</div>
<div id="code_outputs">
<%= render :partial => 'outputs' %>
<div id="code_results">
<%= render :partial => 'exec_results' %>
</div>
<div id="code_outpus">
<%= render :partial => 'code_outputs' %>
</div>
<div id="code_actions">
<%= render :partial => 'code_actions' %>
</div>
<div id="outputs"></div>
</div>

View File

@ -67,6 +67,7 @@ RedmineApp::Application.routes.draw do
match 'game_build', :via => [:get, :post]
match 'next_step', :via => [:get, :post]
get 'entry'
get 'outputs_show'
end
end
end