project_pack
caishi 5 years ago
commit eb71eece2d

@ -1066,12 +1066,14 @@ class AccountController < ApplicationController
# end # end
elsif !User.current.user_extensions.school.nil? elsif !User.current.user_extensions.school.nil?
@tip = "申请已提交我们将在5分钟内完成审核" @tip = "申请已提交我们将在5分钟内完成审核"
unless apply_action.present? if !apply_action.present?
ApplyAction.create(:user_id => User.current.id, :status => 0, :ip_addr => request.remote_ip, :container_type => "TrialAuthorization", :apply_reason => params[:apply_reason]) ApplyAction.create(:user_id => User.current.id, :status => 0, :ip_addr => request.remote_ip, :container_type => "TrialAuthorization", :apply_reason => params[:apply_reason])
begin if user_ex.identity == 0 || user_ex.identity == 2
status = Trustie::Sms.send(mobile:17680641960, send_type:'user_apply_auth',name:'管理员' ) begin
rescue => e status = Trustie::Sms.send(mobile:17680641960, send_type:'user_apply_auth',name:'管理员' )
Rails.logger.error "发送验证码出错: #{e}" rescue => e
Rails.logger.error "发送验证码出错: #{e}"
end
end end
end end
end end

@ -153,7 +153,7 @@ class CompetitionTeamsController < ApplicationController
# 新增加的成员 # 新增加的成员
ids = new_member_ids - team_member_ids ids = new_member_ids - team_member_ids
raise @message unless check_member_enroll_limited?(@competition, ids) # 有成员已经加入其他战队,并且只能一次报名 raise @message unless check_member_enroll_limited?(@competition, ids - [@team.user_id]) # 有成员已经加入其他战队,并且只能一次报名; 减去创建者
ids.each do |user_id| ids.each do |user_id|
next if user_id.to_i == @team.user_id next if user_id.to_i == @team.user_id
@ -170,7 +170,7 @@ class CompetitionTeamsController < ApplicationController
# 新增加的老师 # 新增加的老师
ids = new_teacher_ids - teacher_ids ids = new_teacher_ids - teacher_ids
raise @message unless check_teacher_enroll_limited?(@competition, ids) # 有老师已经加入其他战队,并且只能一次报名 raise @message unless check_teacher_enroll_limited?(@competition, ids - [@team.user_id]) # 有老师已经加入其他战队,并且只能一次报名;减去创建者
ids.each do |user_id| ids.each do |user_id|
next if user_id.to_i == @team.user_id next if user_id.to_i == @team.user_id

@ -1481,7 +1481,7 @@ end
redirect_to departments_managements_path redirect_to departments_managements_path
end end
# 改单位部门列表 # 改单位部门列表
def update_department def update_department
dep = Department.find params[:department_id] dep = Department.find params[:department_id]
@edit_id = params[:department_id] @edit_id = params[:department_id]
@ -1498,6 +1498,22 @@ end
end end
end end
# 修改部门名称
def update_depart_name
@depart = Department.find(params[:depart_id])
@depart.update_attributes(:name => params[:depart_name]) if @depart.school.departments.where(name: params[:depart_name]).count == 0
end
# 检查是否存在同名的部门
def check_depart_name
depart = Department.find(params[:depart_id])
if depart.school.departments.where(name: params[:depart_name]).count == 0
render :json => {status: 0, message: ""}
else
render :json => {status: -1, message: "该名称已存在"}
end
end
def edit_departments_school def edit_departments_school
begin begin
dep = Department.find(params[:department_id]) dep = Department.find(params[:department_id])
@ -1511,9 +1527,10 @@ end
# ApplyAddDepartment.where(:department_id =>params[:departments]).update_all(:department_id=>department_id) # ApplyAddDepartment.where(:department_id =>params[:departments]).update_all(:department_id=>department_id)
# users = UserExtensions.where("department_id = #{alt_dep.department_id}") # users = UserExtensions.where("department_id = #{alt_dep.department_id}")
# users.update_all(:department_id => department.id) # users.update_all(:department_id => department.id)
apply_dep.destroy_all; apply_dep.destroy_all
users = UserExtensions.where(:department_id => params[:alter_dep_id]) users = UserExtensions.where(:department_id => params[:alter_dep_id])
users.update_all(:department_id => dep.id) users.update_all(:department_id => dep.id)
dep.update_attributes(:identifier => alter_dep.identifier) if dep.identifier.nil? && alter_dep.identifier.present?
alter_dep.destroy alter_dep.destroy
end end
rescue Exception => e rescue Exception => e

@ -792,7 +792,7 @@ class ShixunsController < ApplicationController
shixun_script = modify_shixun_script @shixun, shixun_script shixun_script = modify_shixun_script @shixun, shixun_script
end end
end end
#@shixun.evaluate_script = shixun_script @shixun.evaluate_script = shixun_script
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin

@ -79,89 +79,91 @@ class StudentWorkController < ApplicationController
@shixun = Shixun.select([:id, :gpid, :name]).find(HomeworkCommonsShixuns.where(:homework_common_id => @homework.id).pluck(:shixun_id).first) @shixun = Shixun.select([:id, :gpid, :name]).find(HomeworkCommonsShixuns.where(:homework_common_id => @homework.id).pluck(:shixun_id).first)
@challenges = Challenge.select([:id]).where(:shixun_id => @shixun.id) @challenges = Challenge.select([:id]).where(:shixun_id => @shixun.id)
@myshixun = @work.myshixun @myshixun = @work.myshixun
@games = Game.where(:myshixun_id => @myshixun.id).includes(:challenge, :game_codes,:outputs).reorder("challenges.position") # 页面循环需要outputs @games = Game.where(:myshixun_id => @myshixun.id).includes(:challenge, :game_codes, :outputs).reorder("challenges.position") # 页面循环需要outputs
# 用户个人信息 # 用户个人信息
@user_name = @work.user.show_real_name @user_name = @work.user.show_real_name
@student_id = @work.user.user_extensions.try(:student_id).nil? ? '--' : @work.user.user_extensions.try(:student_id) @student_id = @work.user.user_extensions.try(:student_id).nil? ? '--' : @work.user.user_extensions.try(:student_id)
student_works_user_id = StudentWork.where(:homework_common_id => @homework.id).pluck(:user_id) # 当前用户评测最大次数
myshixuns = @shixun.myshixuns.where(:user_id => student_works_user_id).includes(games: [:outputs])
# 课堂实训中,评测次数最大值
@total_evaluate_max = 0
@user_evaluate_count = 0 @user_evaluate_count = 0
# 为了取最小efficiency。最小值是一个不确定数 if @myshixun.user_id == @work.user.id
@min_efficiency = [] @user_evaluate_count = @myshixun.games.pluck(:evaluate_count).sum.to_i
power = [] end
@game_user_query = []
myshixuns.each do |myshixun| unless params[:pdf]
# 用户个人实训总得分 student_works_user_id = StudentWork.where(:homework_common_id => @homework.id).pluck(:user_id)
user_total_score = 0 myshixuns = @shixun.myshixuns.where(:user_id => student_works_user_id).includes(:games)
# consume_time通关的关卡总耗时间all_tine实训的总耗时
pass_consume_time = 0 # 课堂实训中,评测次数最大值
all_time = 0 @total_evaluate_max = 0
# evaluate_count: 每次总评测次数eff_score用户得分/总评测次数round_sizelog(所有课堂实训最大评测次数/当前实训评测次数) # 为了取最小efficiency。最小值是一个不确定数
evaluate_count = 0 @min_efficiency = []
eff_score = 0 power = []
@game_user_query = []
myshixun.games.each do |game| myshixuns.each do |myshixun|
evaluate_count += game.outputs.first.try(:query_index).to_i # 评测次数 # 用户个人实训总得分
# y_score = (evaluate_count == 0 ? 0 : (user_total_score / evaluate_count.to_f)) user_total_score = 0
# eff_score = format("%.2f", y_score).to_f # consume_time通关的关卡总耗时间all_tine实训的总耗时
if game.status == 2 pass_consume_time = 0
pass_consume_time += (game.cost_time / 60.0).to_f all_time = 0
end # evaluate_count: 每次总评测次数eff_score用户得分/总评测次数round_sizelog(所有课堂实训最大评测次数/当前实训评测次数)
all_time += (game.cost_time / 60.0).to_f evaluate_count = 0
user_total_score += game.status == 2 ? game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i : 0 eff_score = 0
if myshixun.user_id == @work.user.id
@game_user_query << [game.id, game.outputs.first.try(:query_index).to_i] myshixun.games.each do |game|
evaluate_count += game.evaluate_count.to_i # 评测次数
# y_score = (evaluate_count == 0 ? 0 : (user_total_score / evaluate_count.to_f))
# eff_score = format("%.2f", y_score).to_f
if game.status == 2
pass_consume_time += (game.cost_time / 60.0).to_f
end
all_time += (game.cost_time / 60.0).to_f
user_total_score += game.status == 2 ? game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i : 0
if myshixun.user_id == @work.user.id
@game_user_query << [game.id, game.evaluate_count.to_i]
end
end end
end
# 当前用户评测最大次数
if myshixun.user_id == @work.user.id
@user_evaluate_count = evaluate_count
end
x_time = (all_time <= 1) ? 1 : Math.log(all_time).to_f x_time = (all_time <= 1) ? 1 : Math.log(all_time).to_f
consume_time = format("%.2f", x_time).to_f consume_time = format("%.2f", x_time).to_f
efficiency = (pass_consume_time == 0 ? 0 : Math.log((user_total_score / pass_consume_time.to_f) + 1.0)) efficiency = (pass_consume_time == 0 ? 0 : Math.log((user_total_score / pass_consume_time.to_f) + 1.0))
efficiency = format("%.2f", efficiency).to_f efficiency = format("%.2f", efficiency).to_f
@min_efficiency << efficiency @min_efficiency << efficiency
@total_evaluate_max = @total_evaluate_max > evaluate_count.to_i ? @total_evaluate_max : evaluate_count @total_evaluate_max = @total_evaluate_max > evaluate_count.to_i ? @total_evaluate_max : evaluate_count
power << {:consume_time => consume_time, :evaluate_count => evaluate_count, :user_id => myshixun.user_id, power << {:consume_time => consume_time, :evaluate_count => evaluate_count, :user_id => myshixun.user_id,
:user_total_score => user_total_score, :efficiency => efficiency} :user_total_score => user_total_score, :efficiency => efficiency}
end end
# 数据库操作改成对数组操作 # 数据库操作改成对数组操作
min_efficiency = @min_efficiency.min min_efficiency = @min_efficiency.min
result_list = [] result_list = []
power.each do |p| power.each do |p|
y_score = (p[:evaluate_count] == 0 ? 0 : (p[:user_total_score] / p[:evaluate_count].to_f)) y_score = (p[:evaluate_count] == 0 ? 0 : (p[:user_total_score] / p[:evaluate_count].to_f))
eff_score = format("%.2f", y_score).to_f eff_score = format("%.2f", y_score).to_f
user_id = p[:user_id] user_id = p[:user_id]
consume_time = p[:consume_time] consume_time = p[:consume_time]
efficiency = p[:efficiency] < 0 ? format("%.2f", p[:efficiency] - min_efficiency).to_f : p[:efficiency] efficiency = p[:efficiency] < 0 ? format("%.2f", p[:efficiency] - min_efficiency).to_f : p[:efficiency]
round_size = (p[:evaluate_count] == 0 ? 0 : Math.log(@total_evaluate_max / p[:evaluate_count].to_f)) * 3.14 round_size = (p[:evaluate_count] == 0 ? 0 : Math.log(@total_evaluate_max / p[:evaluate_count].to_f)) * 3.14
result_list << {:eff_score => eff_score, :user_id => user_id, :consume_time => consume_time, :efficiency => efficiency, :round_size => round_size} result_list << {:eff_score => eff_score, :user_id => user_id, :consume_time => consume_time, :efficiency => efficiency, :round_size => round_size}
end end
@power = [] @power = []
@efficiency = [] @efficiency = []
result_list.sort{|x, y| x[:efficiency] <=> y[:efficiency]}.each_with_index do |result, index| result_list.sort{|x, y| x[:efficiency] <=> y[:efficiency]}.each_with_index do |result, index|
@efficiency << [index+1, result[:efficiency], result[:user_id]] @efficiency << [index+1, result[:efficiency], result[:user_id]]
if result[:user_id] == @work.user.id if result[:user_id] == @work.user.id
@myself_eff = [index+1, result[:efficiency]] @myself_eff = [index+1, result[:efficiency]]
@myself_power = [result[:consume_time], result[:eff_score], result[:round_size]] @myself_power = [result[:consume_time], result[:eff_score], result[:round_size]]
end
end end
end
result_list.sort{|x, y| x[:consume_time] <=> y[:consume_time]}.each do |result| result_list.sort{|x, y| x[:consume_time] <=> y[:consume_time]}.each do |result|
@power << [result[:consume_time], result[:eff_score], result[:round_size], result[:user_id]] @power << [result[:consume_time], result[:eff_score], result[:round_size], result[:user_id]]
end
end end

@ -102,9 +102,10 @@ class SourcesService
# games start ############################################ # games start ############################################
def myshixuns_index params def myshixuns_index params
time = Time.parse(params[:time].to_s) endTime = Time.parse(params[:time].to_s)
beginTime = Time.parse(params[:begin_time].to_s)
offset = ((params[:page] || 1).to_i - 1) * 50 offset = ((params[:page] || 1).to_i - 1) * 50
Myshixun.select([:id, :user_id, :shixun_id]).where("created_at < ?", time).offset(offset).limit(50) Myshixun.select([:id, :user_id, :shixun_id]).where("created_at < ? and created_at > ?", endTime, beginTime).offset(offset).limit(50)
end end
def search_myshixun params def search_myshixun params

@ -4,7 +4,7 @@
<% @competition.competition_modules.where(:hidden => 0).each do |com_module| %> <% @competition.competition_modules.where(:hidden => 0).each do |com_module| %>
<% case com_module.name %> <% case com_module.name %>
<% when '首页' %> <% when '首页' %>
<% if params[:action] == 'show' %> <% if params[:controller] == 'competitions' && params[:action] == 'show' %>
<li class="<%= params[:action] == 'show' ? 'active' : '' %>"> <li class="<%= params[:action] == 'show' ? 'active' : '' %>">
<a href="javascript:void(0)" id="jump_page1" onclick="jump_to('page1')">首页</a> <a href="javascript:void(0)" id="jump_page1" onclick="jump_to('page1')">首页</a>
</li> </li>
@ -19,7 +19,7 @@
<% end %> <% end %>
<% when '赛事说明' %> <% when '赛事说明' %>
<li> <li>
<% if params[:action] == 'show' %> <% if params[:controller] == 'competitions' && params[:action] == 'show' %>
<a href="javascript:void(0)" id="jump_page3" onclick="jump_to('page3')">赛事说明</a> <a href="javascript:void(0)" id="jump_page3" onclick="jump_to('page3')">赛事说明</a>
<% else %> <% else %>
<a href="<%= competition_path(@competition, :page => 3) %>">赛事说明</a> <a href="<%= competition_path(@competition, :page => 3) %>">赛事说明</a>
@ -27,7 +27,7 @@
</li> </li>
<% when '大赛机构' %> <% when '大赛机构' %>
<li> <li>
<% if params[:action] == 'show' %> <% if params[:controller] == 'competitions' && params[:action] == 'show' %>
<a href="javascript:void(0)" id="jump_page7" onclick="jump_to('page7')">大赛机构</a> <a href="javascript:void(0)" id="jump_page7" onclick="jump_to('page7')">大赛机构</a>
<% else %> <% else %>
<a href="<%= competition_path(@competition, :page => 7) %>">大赛机构</a> <a href="<%= competition_path(@competition, :page => 7) %>">大赛机构</a>

@ -17,7 +17,7 @@
<% @department.each_with_index do |department,index| %> <% @department.each_with_index do |department,index| %>
<tr id="apply_add_department_<%= department.id %>"> <tr id="apply_add_department_<%= department.id %>">
<td><%= (@page -1) * @limit + index + 1 %></td> <td><%= (@page -1) * @limit + index + 1 %></td>
<td class="edu-txt-left"><%= department.name %></td> <td class="edu-txt-left" id="department_name_<%= department.id %>"><%= department.name %></td>
<td class="edu-txt-left"><%= School.where(:id => department.school_id).first %></td> <td class="edu-txt-left"><%= School.where(:id => department.school_id).first %></td>
<td><%= UserExtensions.where(:department_id => department.id, :school_id => department.school_id ).count %></td> <td><%= UserExtensions.where(:department_id => department.id, :school_id => department.school_id ).count %></td>
<td><%= User.where(:id => UserExtensions.where(:department_id => department.id, :school_id => department.school_id).map(&:user_id),:professional_certification => 1).count %></td> <td><%= User.where(:id => UserExtensions.where(:department_id => department.id, :school_id => department.school_id).map(&:user_id),:professional_certification => 1).count %></td>
@ -38,8 +38,9 @@
</td> </td>
<td><%= format_time department.created_at %></td> <td><%= format_time department.created_at %></td>
<td> <td>
<a href="javascript:void(0);" onclick="delete_confirm_box_2('<%= department_path(department) %>', '确定要删除该部门吗?')">删除&nbsp;</a> <a href="javascript:void(0);" onclick="delete_confirm_box_2('<%= department_path(department) %>', '确定要删除该部门吗?')">删除&nbsp;</a>
<%= link_to '更改', update_department_managements_path(:school_id=> department.school_id,:department_id => department.id), :remote => true, :class => "application-default-link" %> <%= link_to '更改', update_department_managements_path(:school_id=> department.school_id,:department_id => department.id), :remote => true, :class => "application-default-link" %>
<a href="javascript:void(0)" class="application-default-link" onclick="editDepartName(<%= department.id %>);">修改</a>
</td> </td>
</tr> </tr>
<% end %> <% end %>
@ -78,4 +79,11 @@
$("#update_host_count_depart_id").val(id); $("#update_host_count_depart_id").val(id);
$("input[name='host_count']").val($("#depart_host_count_"+id).html().trim()); $("input[name='host_count']").val($("#depart_host_count_"+id).html().trim());
} }
function editDepartName(id){
var htmlvalue = "<%= escape_javascript(render :partial => 'managements/edit_depart_name') %>";
pop_box_new(htmlvalue,400,204);
$("#update_depart_name_depart_id").val(id);
$("input[name='depart_name']").val($("#department_name_"+id).html().trim());
}
</script> </script>

@ -0,0 +1,15 @@
<div class="task-popup" style="width:400px;">
<div class="task-popup-title clearfix task-popup-bggrey">修改</div>
<%= form_for '', :url => update_depart_name_managements_path,:html => {:id => 'update_depart_name_form', :remote => true, :method => :post} do |f| %>
<div class="task_popup_con edu-txt-center">
<input type="hidden" name="depart_id" id="update_depart_name_depart_id" value="">
<input type="text" name="depart_name" placeholder="输入新名称" maxlength="30" class="input-100-35"/>
<p class="color-red none edu-txt-left" id="update_depart_name_notice"></p>
<div class="inline mt20">
<a href="javascript:void(0);" class="task-btn task-btn-orange fr" onclick="submit_depart_name_form();">确定</a>
<a href="javascript:void(0);" onclick="hideModal();" class="pop_close task-btn fr mr10">取消</a>
</div>
</div>
<% end %>
</div>

@ -0,0 +1 @@
$("#department_name_<%= @depart.id %>").html("<%= params[:depart_name] %>");

@ -7,7 +7,7 @@
<!-- <span class="fl mr5 ml3">/</span>--> <!-- <span class="fl mr5 ml3">/</span>-->
<%= link_to @shixun.name, shixun_path(@shixun), :class => "edu-info-dark fl task-hide",:style=>"max-width:300px", :target => "_blank" %> <%= link_to @shixun.name, shixun_path(@shixun), :class => "edu-info-dark fl task-hide",:style=>"max-width:300px", :target => "_blank" %>
</p> </p>
<% if User.current.has_teacher_role(@homework.course) || User.current.admin? || @work.user == User.current %> <% if User.current.has_teacher_role(@homework.course) || User.current.admin? || User.current.business? || @work.user == User.current %>
<div class="fl mt5 ml10" data-tip-down="实战中获得的总经验值"> <div class="fl mt5 ml10" data-tip-down="实战中获得的总经验值">
<span class="color-green">经验值:<%= @myshixun.total_score %> </span> <span class="color-green">经验值:<%= @myshixun.total_score %> </span>
</div> </div>

@ -77,8 +77,8 @@
<% end %> <% end %>
</td> </td>
<td><%= game.try(:open_time).nil? || game.status == 3 ? "--" : format_time(game.open_time) %></td> <td><%= game.try(:open_time).nil? || game.status == 3 ? "--" : format_time(game.open_time) %></td>
<% user_query = @game_user_query.select{|user_query| user_query[0] == game.id} %> <%# user_query = @game_user_query.select{|user_query| user_query[0] == game.id} %>
<td><%= user_query.blank? ? "--" : user_query.first[1] %></td> <td><%= game.evaluate_count.to_i == 0 ? "--" : game.evaluate_count.to_i %></td>
<td><%= game.try(:end_time).nil? ? "--" : format_time(game.end_time) %></td> <td><%= game.try(:end_time).nil? ? "--" : format_time(game.end_time) %></td>
<td><%= game.consumes_time %></td> <td><%= game.consumes_time %></td>
<td><%= game.status == 2 ? (game.final_score.to_i < 0 ? 0 : game.challenge.choose_score.to_i) : 0 %> / <%= game.challenge.choose_score %></td> <td><%= game.status == 2 ? (game.final_score.to_i < 0 ? 0 : game.challenge.choose_score.to_i) : 0 %> / <%= game.challenge.choose_score %></td>

@ -629,6 +629,8 @@ RedmineApp::Application.routes.draw do ## oauth相关
match 'new_major', :via => [:get, :post] match 'new_major', :via => [:get, :post]
post 'insert_major' post 'insert_major'
match 'update_department',:via => [:get, :post] match 'update_department',:via => [:get, :post]
post 'update_depart_name'
get 'check_depart_name'
post 'edit_departments_school' post 'edit_departments_school'
get 'create_departments' get 'create_departments'
post 'add_department' post 'add_department'

@ -26,6 +26,27 @@ function submit_depart_host_count(){
} }
} }
function submit_depart_name_form(){
if($("input[name='depart_name']").val().trim() == ""){
$("#update_depart_name_notice").html("名称不能为空").show();
} else {
$.ajax({
type: "GET",
url: '/managements/check_depart_name',
data: {depart_id: $("#update_depart_name_depart_id").val(), depart_name: $("input[name='depart_name']").val().trim()},
success: function (data) {
if(data.status == 0){
$("#update_depart_name_notice").hide();
$('#update_depart_name_form').submit();
hideModal();
} else{
$("#update_depart_name_notice").html("该名称已存在").show();
}
}
});
}
}
/*--------------------------- 用户授权全选 -------------------------------*/ /*--------------------------- 用户授权全选 -------------------------------*/
$("#all_member_select").live('click', function(){ $("#all_member_select").live('click', function(){
if($("#all_member_select").is(':checked')){ if($("#all_member_select").is(':checked')){

@ -206,6 +206,7 @@ $(function(){
// window resize // window resize
$(window).on('resize', function() { $(window).on('resize', function() {
// _resizeVNC_if_needed()
$('.CodeMirror.cm-s-railscasts').css("height", $("#games_repository_contents").height() - repositoryTabHeight); $('.CodeMirror.cm-s-railscasts').css("height", $("#games_repository_contents").height() - repositoryTabHeight);
}) })
@ -1182,6 +1183,7 @@ $(function(){ // 这里重新加一次事件监听,不在原有事件的基
dragging = true; dragging = true;
dragDom = lab; dragDom = lab;
$('#htmlIframe').css('pointer-events', 'none') $('#htmlIframe').css('pointer-events', 'none')
$('#can-drag').show()
return false; return false;
} }
); );
@ -1202,7 +1204,10 @@ $(function(){ // 这里重新加一次事件监听,不在原有事件的基
doc.live("mouseup", function(e) { doc.live("mouseup", function(e) {
// 在大窗口将下边测试集滚动条拖上去后,将窗口缩小,再拖下来就有这种情况 https://www.trustie.net/issues/16326 // 在大窗口将下边测试集滚动条拖上去后,将窗口缩小,再拖下来就有这种情况 https://www.trustie.net/issues/16326
$('#can-drag').hide()
if (dragging === true) { if (dragging === true) {
// _resizeVNC_if_needed()
window.editor_CodeMirror && window.editor_CodeMirror.refresh() window.editor_CodeMirror && window.editor_CodeMirror.refresh()
// 使得iframe可以继续捕获事件 // 使得iframe可以继续捕获事件
$('#htmlIframe').css('pointer-events', 'inherit') $('#htmlIframe').css('pointer-events', 'inherit')
@ -1210,6 +1215,27 @@ $(function(){ // 这里重新加一次事件监听,不在原有事件的基
dragging = false; dragging = false;
}); });
}) })
function _resizeVNC_if_needed() {
return;
if (window.__isVNC) {
// $('#screen>div').width('1024px').height('768px')
var trueHeight = $('#game_right_contents').height();
var width = $('#game_right_contents').width()
// __rfb && __rfb.get_display().autoscale(width, trueHeight)
return;
if (trueHeight < 768) {
var width = $('#game_right_contents').width()
var _left = width - $('#screen').width() / 2
var scale = (trueHeight / 768).toFixed(5)
// _left
$('#screen').css('transform', 'scale(' + scale + ', ' + scale +')').css('transform-origin', 0 + 'px 0px')
} else {
$('#screen').css('transform', 'scale(' + 1 + ', ' + 1 +')')
}
}
}
// --------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------
/** /**

File diff suppressed because one or more lines are too long

@ -46,7 +46,8 @@ class MainContent extends Component {
} else { } else {
games_repository_contents_style = {overflow: 'hidden', height: '445px'} games_repository_contents_style = {overflow: 'hidden', height: '445px'}
} }
const showIframeContent = shixun && shixun.vnc == true const showIframeContent = shixun && shixun.vnc == true
// window.__isVNC = showIframeContent && !!vnc_url
return ( return (
<div className="page--body -margin-t-64 -flex"> <div className="page--body -margin-t-64 -flex">
<div className="-layout -stretch -fit labelN" id="game_show_content"> <div className="-layout -stretch -fit labelN" id="game_show_content">
@ -55,6 +56,18 @@ class MainContent extends Component {
{/* 左侧任务说明等功能的区域 */} {/* 左侧任务说明等功能的区域 */}
<LeftViewContainer {...this.props}></LeftViewContainer> <LeftViewContainer {...this.props}></LeftViewContainer>
</div> </div>
<style>{`
.can-drag {
width: 100%;
height: 100%;
z-index: 100;
position: fixed;
cursor: col-resize;
top: 0px;
}
`}</style>
{showIframeContent && vnc_url && <div id="can-drag" className="can-drag" style={{display: 'none'}}></div>}
<div className="b-label -layout" style={{left: '687px'}}> <div className="b-label -layout" style={{left: '687px'}}>
<div className="resize-helper "> <div className="resize-helper ">

@ -13,6 +13,7 @@ class VNCDisplay extends Component {
// When this function is called we have // When this function is called we have
// successfully connected to a server // successfully connected to a server
function connectedToServer(e) { function connectedToServer(e) {
$('#top_bar').hide()
status("Connected to " + desktopName); status("Connected to " + desktopName);
} }
// This function is called when we are disconnected // This function is called when we are disconnected
@ -109,6 +110,8 @@ class VNCDisplay extends Component {
// Set parameters that can be changed on an active connection // Set parameters that can be changed on an active connection
rfb.viewOnly = readQueryVariable('view_only', false); rfb.viewOnly = readQueryVariable('view_only', false);
rfb.scaleViewport = readQueryVariable('scale', false); rfb.scaleViewport = readQueryVariable('scale', false);
rfb.resizeSession = true
window.__rfb = rfb;
} }
render() { render() {
@ -116,7 +119,7 @@ class VNCDisplay extends Component {
return ( return (
<div className=""> <div className="" style={{height: '100%'}}>
<style>{` <style>{`
#top_bar { #top_bar {
background-color: #6e84a3; background-color: #6e84a3;
@ -137,6 +140,7 @@ class VNCDisplay extends Component {
cursor: pointer; cursor: pointer;
} }
#screen { #screen {
height: 100%;
flex: 1; /* fill remaining space */ flex: 1; /* fill remaining space */
overflow: hidden; overflow: hidden;
} }

@ -25,7 +25,14 @@ const styles = theme => ({
color: '#4CACFF', color: '#4CACFF',
border: '1px solid #4CACFF' border: '1px solid #4CACFF'
} }
},
hoverButton: {
margin: theme.spacing.unit,
height: '30px',
padding: '0 16px',
color: '#4CACFF',
border: '1px solid #4CACFF'
}, },
buttonText: { buttonText: {
color: '#1B4061 !important', color: '#1B4061 !important',
@ -64,10 +71,12 @@ class ActionView extends Component {
</span> </span>
{/*将第一个按钮改为visibility方式隐藏不然加载时测评按钮会出现没有垂直居中的情况*/} {/*将第一个按钮改为visibility方式隐藏不然加载时测评按钮会出现没有垂直居中的情况*/}
<Button size="small" className={classes.button + ' actionViewfirstButton'} onClick={()=>this.showWebDisplay(challenge)} <Tooltip title={ "倒计时为0时服务将被关闭" }>
style={{ visibility: challenge.showWebDisplayButton ? '': 'hidden'}}> <Button size="small" className={classes.hoverButton + ' actionViewfirstButton'} onClick={()=>this.showWebDisplay(challenge)}
查看效果 style={{ visibility: challenge.showWebDisplayButton ? '': 'hidden'}} id="showWebDisplayButton">
</Button> 查看效果
</Button>
</Tooltip>
{ {

Loading…
Cancel
Save