client_management/app/views/admin/site_panel/super_manager_management.ht...

108 lines
3.9 KiB
Plaintext

<%= form_for @site_server, :url => {:action=>"update_super_manager_management"}, :html => {:class => 'form-horizontal main-forms super_manager_form'} do |f| %>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<% end %>
<% content_for :page_specific_javascript do %>
<% end %>
<%#= f.error_messages %>
<fieldset>
<h3><%= "#{f.object.server_name} (IP: #{f.object.ip}) " %></h3>
<!-- Input Area -->
<div class="input-area">
<%= render :partial => "super_manager_form", :locals=>{:f=>f,:type=>"site_super_user"} %>
<div class="form-actions">
<%= f.submit t('submit'), class: 'btn btn-primary' %>
</div>
</div>
</fieldset>
<style type="text/css">
.remove_btn{
float: left;
color: red;
line-height: 2rem;
cursor: pointer;
font-weight: bold;
}
.remove_btn:hover{
font-size: 1.3em;
}
</style>
<script type="text/javascript">
var close_info = false;
var timeout_id;
var status_relation = {"starting":"<span style=\"color: skyblue;\">starting</span>","execing":"<span style=\"color: skyblue;\">execing</span>","detecting":"<span style=\"color: skyblue;\">detecting</span>","error":"<span style=\"color: red;\">error</span>","finish": "<span style=\"color: darkseagreen;\">finish</span>","closed":"<span style=\"color: red;\">closed</span>"};
var need_close_info = false;
function see_infos(key){
key = key || "";
if(!close_info){
var request = $.post("<%=admin_site_panel_edit_server_info_path%>",{"type":'see_infos',"key":key});
request.done(function(data){
var infos = request.responseJSON.infos;
var status = request.responseJSON.status;
if($("#info_texts").length == 0)
return infos.join("\n")
else{
if(status == "")
var status_text = "not yet create";
else
var status_text = status_relation[status];
if(!status_text){
status_text = "<span style=\"color: skyblue;\">"+status+"</span>";
}
$("#info_texts").html(status_text+"<div style='clear:both;'></div>"+infos.join("\n"));
msg_end.scrollIntoView();
if(need_close_info && status != 'execing'){
close_info = true;
window.setTimeout(function(){
window.location.reload();
},1000);
}else{
if(status == 'execing'){
need_close_info = true;
}
timeout_id = window.setTimeout(see_infos(key),1000);
}
}
})
}else{
window.clearTimeout(timeout_id);
}
};
function show_infos_dialog(key){
key = key || "";
close_info = true;
window.clearTimeout(timeout_id);
close_info = false;
if($("#dialog-confirm").length == 0){
$("#main-wrap").before("<div id='dialog-confirm' title='site infos'>"+
"<div style='clear:both;'></div><div id='info_texts'>"+see_infos(key)+"</div><div id='msg_end' style='height:0px; overflow:hidden'></div>"+
"</div>");
}else{
see_infos(key);
};
$( "#dialog-confirm" ).dialog({
resizable: true,
minHeight: 100,
maxHeight: 400,
width: '80%',
modal: true,
open: function(){
$(this).parent().css("top",$(document).height() - $(window).height() + "px");
},
close: function(){close_info = true;},
buttons: {
"<%= t('client_management.confirm') %>": function(){$( this ).dialog( "close" );close_info = true;},
"stop update": function(){close_info = true;}
}
});
}
$(document).ready(function(){
$('.apply_change_users').click(function(){
var item = $(this);
$.post("<%=admin_site_panel_edit_site_path%>",{'id': item.attr("data-id"),'type':'apply_change_users','is_server': item.data('is-server')}).done(function(){
show_infos_dialog("execing_commands");
});
});
})
</script>
<% end %>