ajax相关路由
This commit is contained in:
parent
662d90b431
commit
a5d6ca7cad
|
@ -62,7 +62,7 @@ class GamesController < ApplicationController
|
|||
params = {:jobName => "#{jobName}", :taskId => "#{taskId}", :step => "#{step}", :gitUrl => "#{gitUrl}", :input => input, :output => output }
|
||||
uri = URI.parse("http://123.59.135.74:9999/jenkins-exec/api/buildJob")
|
||||
res = uri_exec uri, params
|
||||
# @game.update_attribute(:status, 1)
|
||||
@game.update_attribute(:status, 1)
|
||||
|
||||
@outputs = @game.outputs
|
||||
end
|
||||
|
@ -73,8 +73,7 @@ class GamesController < ApplicationController
|
|||
|
||||
|
||||
def game_status
|
||||
new_game = Game.where(:id => @game.id).first
|
||||
render :json => {status: new_game.status}
|
||||
render :json => {status: @game.status}
|
||||
end
|
||||
|
||||
# 自动推送下一个任务
|
||||
|
|
|
@ -34,11 +34,38 @@
|
|||
<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 %>
|
||||
<div id="game_commit">
|
||||
<%= link_to "提交评测", {:controller => 'games', :action => "game_build", :id => @game, :myshixun_id => @myshixun}, :class => "task-btn task-btn-green", :onclick => "training_task_submmit();", :remote => true %>
|
||||
</div>
|
||||
<% elsif @game.status == 1 %>
|
||||
<a class="task-btn mb10">评测中..</a>
|
||||
<% elsif @game.status == 2 %>
|
||||
<%= 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>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
function training_task_submmit(){
|
||||
|
||||
$.ajax('game_build', function(){
|
||||
$("#game_commit").html("<span class='task-btn task-btn-green'>当前任务正在后台测评中,稍后将显示您的任务完成情况......</span>");
|
||||
|
||||
//循环等1分钟
|
||||
var intId = setInterval(function(){
|
||||
$.ajax('game_status', function(data){
|
||||
//如果查到了,就退出
|
||||
clearInterval(intId);
|
||||
|
||||
$("#code_results").html(data);
|
||||
|
||||
});
|
||||
}, 2000);
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
|
@ -19,7 +19,6 @@
|
|||
$.ajax('game_build', function(){
|
||||
$("#training_tasl_commit").html("<span class='task-display-span alert-blue mt10'>当前任务正在后台测评中,稍后将显示您的任务完成情况......</span>");
|
||||
|
||||
|
||||
//循环等1分钟
|
||||
var intId = setInterval(function(){
|
||||
$.ajax('game_status', function(data){
|
||||
|
|
|
@ -70,6 +70,7 @@ RedmineApp::Application.routes.draw do
|
|||
match 'next_step', :via => [:get, :post]
|
||||
get 'entry'
|
||||
get 'outputs_show'
|
||||
get 'game_status'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue