Fix bug.
This commit is contained in:
parent
c4be16f884
commit
e94b273e90
|
@ -450,7 +450,7 @@ class Admin::SitePanelController < OrbitAdminController
|
|||
member_data.created_at = time;
|
||||
member_data.updated_at = time;
|
||||
if (member){
|
||||
member_data._id = member._id;
|
||||
delete member_data[\"uid\"];
|
||||
member = db.member_profiles.update(member_query, {$set: member_data});
|
||||
}else{
|
||||
member = db.member_profiles.insertOne(member_data);
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
<div class="controls" id="root_domain_group">
|
||||
<div class="root_domain_group">
|
||||
<%= select_tag :root_domain,
|
||||
options_for_select(SiteServer.first.domain_names.collect{ |u| [u, u] }),
|
||||
options_for_select((SiteServer.first.domain_names.collect{ |u| [u, u] } rescue [])),
|
||||
:class => "root_domain" %>
|
||||
</div>
|
||||
<%= button_tag 'add root domain',:type => 'button', :id => 'add_root_domain',class: 'btn btn-info',:style => 'margin-top: 1em;' %>
|
||||
|
@ -84,7 +84,7 @@
|
|||
<div class="controls">
|
||||
<div class="domain_group">
|
||||
<input type="text" onchange="change_domain_input(this)" oninput="replace_domain_input(this)">
|
||||
<span class="root_domain_text"><%= SiteServer.first.domain_names[0] %></span>
|
||||
<span class="root_domain_text"><%= SiteServer.first.domain_names[0] rescue nil %></span>
|
||||
<%= hidden_field_tag nil,nil, :class => "domain_name",:id=>nil %>
|
||||
</div>
|
||||
<%= f.hidden_field :domain_name %>
|
||||
|
|
|
@ -63,12 +63,13 @@
|
|||
</td>
|
||||
<td>
|
||||
<% if site_server.need_update_site_ids.count != 0 %>
|
||||
<a class="btn btn-primary update_nginx_settings" href="#" data-key="<%=site_server.server_name%>" style="background: blueviolet;"><%=t("client_management.update_nginx_settings")%></a>
|
||||
<a class="btn btn-primary update_nginx_settings" href="javascript:void(0)" data-key="<%=site_server.server_name%>" style="background: blueviolet;"><%=t("client_management.update_nginx_settings")%></a>
|
||||
<% end %>
|
||||
<a class="btn btn-primary" href = "<%= admin_site_panel_edit_server_info_path+"?id=#{site_server.id.to_s}" %>"><%=t(:edit)%></a>
|
||||
<a class="btn btn-info" href = "<%= admin_site_panel_edit_server_info_path+"?id=#{site_server.id.to_s}" %>"><%=t(:edit)%></a>
|
||||
<a class="btn btn-danger" href = "#" onclick="if(window.confirm('Do you really want to delete <%=site_server.server_name%>?')) { window.location.href = '<%= admin_site_panel_edit_server_info_path+"?id=#{site_server.id.to_s}&type=delete" %>';}"><%=t(:remove)%></a>
|
||||
<a class="btn btn-primary" href = "<%= admin_site_panel_sites_list_path+"?server_name=#{site_server.server_name}" %>"><%= t('client_management.see_sites') %></a>
|
||||
<a class="btn btn-primary detect_sites" href="#" data-key="<%=site_server.server_name%>">Detect sites</a>
|
||||
<a class="btn btn-success" href = "<%= backup_setting_admin_site_panel_path(site_server) %>"><%= t('client_management.backup_setting') %></a>
|
||||
<a class="btn btn-dark btn-inverse detect_sites" href="javascript:void(0)" data-key="<%=site_server.server_name%>">Detect sites</a>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
@ -76,11 +77,11 @@
|
|||
</table>
|
||||
<div class="bottomnav clearfix">
|
||||
<div class="pagination pagination-centered"><%=paginate(@site_servers)%></div>
|
||||
<a class="btn btn-primary pull-right see_infos" href="#" data-key="detect_sites">See detect infos</a>
|
||||
<a class="btn btn-primary pull-right see_infos" href="#" data-key="execing_commands">See exec infos</a>
|
||||
<a class="btn btn-dark btn-inverse pull-right see_infos" href="javascript:void(0)" data-key="detect_sites">See detect infos</a>
|
||||
<a class="btn btn-primary pull-right see_infos" href="javascript:void(0)" data-key="execing_commands">See exec infos</a>
|
||||
<a class="btn btn-primary pull-right" href="<%=admin_site_panel_edit_server_info_path+"?type=create"%>"><%=t(:add)%></a>
|
||||
<a class="btn btn-primary pull-right detect_sites" href="#">Detect sites</a>
|
||||
<a id="exec_commands" class="btn btn-primary pull-right" href="#">Exec commands</a>
|
||||
<a class="btn btn-dark btn-inverse pull-right detect_sites" href="javascript:void(0)">Detect sites</a>
|
||||
<a id="exec_commands" class="btn btn-primary pull-right" href="javascript:void(0)">Exec commands</a>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).on("change", "input[data-key=\"{{create_super_manager}}\"]", function() {
|
||||
|
@ -91,87 +92,97 @@
|
|||
}
|
||||
});
|
||||
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>"};
|
||||
function show_exec_commands_block(server_names){
|
||||
if($("#exec-commands-dialog-confirm").length == 0){
|
||||
var built_in_commands = "<hr style='clear: both;'/><div><ul class='no_list_style'>"
|
||||
<% render :partial => "get_commands_list" %>
|
||||
var command_trans = <%= @command_trans.to_json.html_safe %>;
|
||||
Object.keys(command_trans).forEach(function(k){
|
||||
built_in_commands += "<li><label><input class='built_in_commands' type='checkbox' data-key='{{"+ k +"}}'>" + command_trans[k] + "</label></li>"
|
||||
})
|
||||
built_in_commands += "</ul></div>"
|
||||
$("#main-wrap").before("<div id='exec-commands-dialog-confirm' title='Commands to Exec'>"+
|
||||
"<div style='clear:both;'></div><div id='server_names_block'></div>"+
|
||||
built_in_commands+
|
||||
"<div style=\"display: none;\" id=\"super_manager_div\"><input type=\"text\" placeholder=\"account\" name=\"account\"><br><input type=\"password\" placeholder=\"password\" name=\"password\"></div>"+"<textarea style='height: 200px;width: 100%;' id='commands_area'></textarea>"+
|
||||
"</div>");
|
||||
};
|
||||
$( "#exec-commands-dialog-confirm" ).dialog({
|
||||
resizable: true,
|
||||
minHeight: 300,
|
||||
maxHeight: 400,
|
||||
modal: true,
|
||||
width: '80%',
|
||||
open: function(){
|
||||
$(this).parent().css("top",$(document).height() - $(window).height() + "px");
|
||||
},
|
||||
close: function(){$( this ).dialog( "close" );},
|
||||
buttons: {
|
||||
"<%= t(:submit) %>": function(){$( this ).dialog( "close" );exec_commands()},
|
||||
}
|
||||
});
|
||||
$("#server_names_block").html($.map(server_names,function(server_name){
|
||||
return "<input style='float: left;' class='server_name_checkbox' type='checkbox' id='server_name_"+server_name+"'><label style='float: left;' for='server_name_"+server_name+"'>"+server_name+"</label>"
|
||||
}))
|
||||
}
|
||||
function exec_commands(){
|
||||
var commands = "";
|
||||
var built_in_commands_selected = [];
|
||||
$("input.built_in_commands:checked").each(function(i,v){
|
||||
built_in_commands_selected.push($(v).data("key"));
|
||||
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 show_exec_commands_block(server_names){
|
||||
if($("#exec-commands-dialog-confirm").length == 0){
|
||||
var built_in_commands = "<hr style='clear: both;'/><div><ul class='no_list_style'>"
|
||||
<% render :partial => "get_commands_list" %>
|
||||
var command_trans = <%= @command_trans.to_json.html_safe %>;
|
||||
Object.keys(command_trans).forEach(function(k){
|
||||
built_in_commands += "<li><label><input class='built_in_commands' type='checkbox' data-key='{{"+ k +"}}'>" + command_trans[k] + "</label></li>"
|
||||
})
|
||||
commands += built_in_commands_selected.join("////");
|
||||
commands += $('#commands_area').val().replace(/(\r\n|\n)/g,"////");
|
||||
var server_names = [];
|
||||
var $els = $(".server_name_checkbox");
|
||||
for(var i = 0; i < $els.length; i++){
|
||||
if($els.eq(i).prop("checked")){
|
||||
console.log($els.eq(i));
|
||||
server_names.push($("label[for='"+$els.eq(i).attr('id')+"']").text().trim());
|
||||
}
|
||||
built_in_commands += "</ul></div>"
|
||||
$("#main-wrap").before("<div id='exec-commands-dialog-confirm' title='Commands to Exec'>"+
|
||||
"<div style='clear:both;'></div><div id='server_names_block'></div>"+
|
||||
built_in_commands+
|
||||
"<div style=\"display: none;\" id=\"super_manager_div\"><input type=\"text\" placeholder=\"account\" name=\"account\"><br><input type=\"password\" placeholder=\"password\" name=\"password\" minlength=\"8\"></div>"+"<textarea style='height: 200px;width: 100%;' id='commands_area'></textarea>"+
|
||||
"</div>");
|
||||
};
|
||||
$( "#exec-commands-dialog-confirm" ).dialog({
|
||||
resizable: true,
|
||||
minHeight: 300,
|
||||
maxHeight: 400,
|
||||
modal: true,
|
||||
width: '80%',
|
||||
open: function(){
|
||||
$(this).parent().css("top",$(document).height() - $(window).height() + "px");
|
||||
},
|
||||
close: function(){$( this ).dialog( "close" );},
|
||||
buttons: {
|
||||
"<%= t(:submit) %>": function(){$( this ).dialog( "close" );exec_commands()},
|
||||
}
|
||||
});
|
||||
$("#server_names_block").html($.map(server_names,function(server_name){
|
||||
return "<input style='float: left;' class='server_name_checkbox' type='checkbox' id='server_name_"+server_name+"'><label style='float: left;' for='server_name_"+server_name+"'>"+server_name+"</label>"
|
||||
}))
|
||||
}
|
||||
function exec_commands(){
|
||||
var commands = "";
|
||||
var built_in_commands_selected = [];
|
||||
$("input.built_in_commands:checked").each(function(i,v){
|
||||
built_in_commands_selected.push($(v).data("key"));
|
||||
})
|
||||
commands += built_in_commands_selected.join("////");
|
||||
commands += $('#commands_area').val().replace(/(\r\n|\n)/g,"////");
|
||||
var server_names = [];
|
||||
var $els = $(".server_name_checkbox");
|
||||
for(var i = 0; i < $els.length; i++){
|
||||
if($els.eq(i).prop("checked")){
|
||||
server_names.push($("label[for='"+$els.eq(i).attr('id')+"']").text().trim());
|
||||
}
|
||||
$.post("<%=admin_site_panel_edit_site_path%>",{'server_names':server_names,'commands':commands,'account': $('input[name="account"]').val(),'password': $('input[name="password"]').val()}).done(function(){
|
||||
show_infos_dialog("execing_commands");
|
||||
});
|
||||
}
|
||||
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>";
|
||||
$.post("<%=admin_site_panel_edit_site_path%>",{'server_names':server_names,'commands':commands,'account': $('input[name="account"]').val(),'password': $('input[name="password"]').val()}).done(function(){
|
||||
show_infos_dialog("execing_commands");
|
||||
});
|
||||
}
|
||||
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;
|
||||
}
|
||||
$("#info_texts").html(status_text+"<div style='clear:both;'></div>"+infos.join("\n"));
|
||||
msg_end.scrollIntoView();
|
||||
timeout_id = window.setTimeout(see_infos(key),1000);
|
||||
}
|
||||
})
|
||||
}else{
|
||||
window.clearTimeout(timeout_id);
|
||||
}
|
||||
};
|
||||
}
|
||||
})
|
||||
}else{
|
||||
window.clearTimeout(timeout_id);
|
||||
}
|
||||
};
|
||||
function show_infos_dialog(key){
|
||||
key = key || "";
|
||||
close_info = true;
|
||||
|
|
|
@ -38,28 +38,30 @@
|
|||
<td><%=site.display_port%></td>
|
||||
<td class="site_status"><%= (site.status.blank? ? "not yet create" : status_relation[site.status]) %></td>
|
||||
<td>
|
||||
<a href="#" title="<%=t("client_management.see_logs_for_site",{:site=>site.domain_name})%>" class="btn btn-primary see_infos" data-id="<%=site.id.to_s%>"><%=t('client_management.see_logs')%></a>
|
||||
<a href="javascript:void(0)" title="<%=t("client_management.see_logs_for_site",{:site=>site.domain_name})%>" class="btn btn-primary see_infos" data-id="<%=site.id.to_s%>"><%=t('client_management.see_logs')%></a>
|
||||
<% if site.status.blank? || (site.status == 'creating' && (time_now - site.updated_at > 60)) %>
|
||||
<a href="#" title="create <%=site.domain_name%>" class="btn btn-primary create_site" data-id="<%=site.id.to_s%>"><%=t('client_management.create_site')%></a>
|
||||
<a href="javascript:void(0)" title="create <%=site.domain_name%>" class="btn btn-primary create_site" data-id="<%=site.id.to_s%>"><%=t('client_management.create_site')%></a>
|
||||
<% elsif site.status == "error" || site.status == "finish" %>
|
||||
<a href="#" title="recreate <%=site.domain_name%>" class="btn btn-primary recreate_site" data-id="<%=site.id.to_s%>"><%=t('client_management.recreate_site')%></a>
|
||||
<a href="#" title="<%=t("client_management.delete_site_for_site",{:site=>site.domain_name})%>" class="btn btn-primary delete_site" data-id="<%=site.id.to_s%>"><%=t('client_management.delete_site')%></a>
|
||||
<a href="#" title="<%=t("client_management.close_site_for_site",{:site=>site.domain_name})%>" class="btn btn-primary close_site" data-id="<%=site.id.to_s%>"><%=t('client_management.close_site')%></a>
|
||||
<a href="#" title="Restart <%=site.domain_name%>" class="btn btn-primary open_site" data-id="<%=site.id.to_s%>"><%=t('client_management.restart_site')%></a>
|
||||
<% if site.created_at > Time.now - 3.day %>
|
||||
<a href="javascript:void(0)" title="recreate <%=site.domain_name%>" class="btn btn-primary recreate_site" data-id="<%=site.id.to_s%>"><%=t('client_management.recreate_site')%></a>
|
||||
<% end %>
|
||||
<a href="javascript:void(0)" title="<%=t("client_management.delete_site_for_site",{:site=>site.domain_name})%>" class="btn btn-primary delete_site" data-id="<%=site.id.to_s%>"><%=t('client_management.delete_site')%></a>
|
||||
<a href="javascript:void(0)" title="<%=t("client_management.close_site_for_site",{:site=>site.domain_name})%>" class="btn btn-danger close_site" data-id="<%=site.id.to_s%>"><%=t('client_management.close_site')%></a>
|
||||
<a href="javascript:void(0)" title="Restart <%=site.domain_name%>" class="btn btn-primary open_site btn-success" data-id="<%=site.id.to_s%>"><%=t('client_management.restart_site')%></a>
|
||||
<% elsif site.status == "closed" %>
|
||||
<a href="#" title="<%=t("client_management.delete_site_for_site",{:site=>site.domain_name})%>" class="btn btn-primary delete_site" data-id="<%=site.id.to_s%>"><%=t('client_management.delete_site')%></a>
|
||||
<a href="#" title="<%=t("client_management.start_site_for_site",{:site=>site.domain_name})%>" class="btn btn-primary open_site" data-id="<%=site.id.to_s%>"><%=t('client_management.start_site')%></a>
|
||||
<a href="javascript:void(0)" title="<%=t("client_management.delete_site_for_site",{:site=>site.domain_name})%>" class="btn btn-primary delete_site" data-id="<%=site.id.to_s%>"><%=t('client_management.delete_site')%></a>
|
||||
<a href="javascript:void(0)" title="<%=t("client_management.start_site_for_site",{:site=>site.domain_name})%>" class="btn btn-success open_site" data-id="<%=site.id.to_s%>"><%=t('client_management.start_site')%></a>
|
||||
<% end%>
|
||||
<% if site.status.present? %>
|
||||
<% if site.rails_env == "production" %>
|
||||
<a href="#" title="<%=t("client_management.switch_to_development")%>" class="btn btn-primary open_site" data-id="<%=site.id.to_s%>" data-env="development"><%=t('client_management.switch_to_development')%></a>
|
||||
<a href="javascript:void(0)" title="<%=t("client_management.switch_to_development")%>" class="btn btn-primary open_site btn-success" data-id="<%=site.id.to_s%>" data-env="development"><%=t('client_management.switch_to_development')%></a>
|
||||
<% else %>
|
||||
<a href="#" title="<%=t("client_management.switch_to_production")%>" class="btn btn-primary open_site" data-id="<%=site.id.to_s%>" data-env="production"><%=t('client_management.switch_to_production')%></a>
|
||||
<a href="javascript:void(0)" title="<%=t("client_management.switch_to_production")%>" class="btn btn-primary open_site btn-success" data-id="<%=site.id.to_s%>" data-env="production"><%=t('client_management.switch_to_production')%></a>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<a href="#" title="<%=t("client_management.exec_commands_on_site",{:site=>site.domain_name})%>" class="btn btn-primary exec_commands" data-id="<%=site.id.to_s%>"><%=t('client_management.exec_commands')%></a>
|
||||
<a href="<%=admin_site_panel_edit_site_path+"?id=#{site.id}&type=detail"%>" title="<%=t("client_management.see_detail_for_site",{:site=>site.domain_name})%>" class="btn btn-primary see_detail" data-id="<%=site.id.to_s%>"><%=t('client_management.detail')%></a>
|
||||
<a href="<%=admin_site_panel_edit_site_path+"?id=#{site.id}&type=delete_from_list"%>" title="<%=t("client_management.delete_from_list_for_site",{:site=>site.domain_name})%>" class="btn btn-primary" data-id="<%=site.id.to_s%>"><%=t('client_management.delete_from_list')%></a>
|
||||
<a href="javascript:void(0)" title="<%=t("client_management.exec_commands_on_site",{:site=>site.domain_name})%>" class="btn btn-primary exec_commands" data-id="<%=site.id.to_s%>"><%=t('client_management.exec_commands')%></a>
|
||||
<a href="<%=admin_site_panel_edit_site_path+"?id=#{site.id}&type=detail"%>" title="<%=t("client_management.see_detail_for_site",{:site=>site.domain_name})%>" class="btn btn-info see_detail" data-id="<%=site.id.to_s%>"><%=t('client_management.detail')%></a>
|
||||
<a href="<%=admin_site_panel_edit_site_path+"?id=#{site.id}&type=delete_from_list"%>" title="<%=t("client_management.delete_from_list_for_site",{:site=>site.domain_name})%>" class="btn btn-danger" data-id="<%=site.id.to_s%>"><%=t('client_management.delete_from_list')%></a>
|
||||
<% if site.status == "finish" || site.status == "closed" %>
|
||||
<a href="<%=admin_site_panel_path+"?copy_id=#{site.id}"%>" title="<%=t('client_management.copy_site_hint')%>" class="btn btn-primary"><%=t('client_management.copy_site')%></a>
|
||||
<a data-id="<%= site.id %>" title="<%=t('client_management.edit_cert_setting')%>" class="btn btn-primary open-cert-form"><%=t('client_management.edit_cert_setting')%></a>
|
||||
|
@ -80,6 +82,7 @@
|
|||
<% end %>
|
||||
<% if site.status != "" %>
|
||||
<a data-id="<%= site.id %>" title="<%=t('client_management.https_setting')%>" class="btn btn-primary https_setting"><%=t('client_management.https_setting')%></a>
|
||||
<a title="<%=t('client_management.super_manager_management')%>" class="btn btn-primary super_manager_management" href="<%=super_manager_management_for_site_admin_site_panel_path(:id=>site.id) %>"><%=t('client_management.super_manager_management')%></a>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -91,6 +94,10 @@
|
|||
<a class="btn btn-primary pull-right" href="<%=admin_site_panel_path%>" title="Create new web"><%=t(:add)%></a>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var close_info = false;
|
||||
var timeout_id;
|
||||
var status_relation = {"creating":"<span style=\"color: skyblue;\">creating</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;
|
||||
$(document).on("change", "input[data-key=\"{{create_super_manager}}\"]", function() {
|
||||
if ($(this).prop('checked')){
|
||||
$('#super_manager_div').show()
|
||||
|
@ -99,9 +106,6 @@
|
|||
}
|
||||
});
|
||||
$(document).ready(function(){
|
||||
var close_info = false;
|
||||
var timeout_id;
|
||||
var status_relation = {"creating":"<span style=\"color: skyblue;\">creating</span>","error":"<span style=\"color: red;\">error</span>","finish": "<span style=\"color: darkseagreen;\">finish</span>","closed":"<span style=\"color: red;\">closed</span>"};
|
||||
function see_infos(id){
|
||||
if(!close_info){
|
||||
var request = $.post("<%=admin_site_panel_site_infos_path%>",{"id":id});
|
||||
|
@ -135,14 +139,24 @@
|
|||
});
|
||||
if(new_params_text[new_params_text.length -1] == "&")
|
||||
new_params_text = new_params_text.substr(0,new_params_text.length - 1)
|
||||
if(params["id"] == id || window.refresh_flag){
|
||||
if(params["id"] == id || window.refresh_flag || need_close_info){
|
||||
close_info = true;
|
||||
console.log(new_params_text);
|
||||
console.log(window.location.href)
|
||||
window.location.search = new_params_text;
|
||||
window.setTimeout(function(){
|
||||
var current_location_search = window.location.search;
|
||||
if(current_location_search == ''){
|
||||
current_location_search = '?';
|
||||
}
|
||||
if(new_params_text == current_location_search){
|
||||
window.location.reload();
|
||||
}else{
|
||||
window.location.search = new_params_text;
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
}else if(status == "changing"){
|
||||
window.refresh_flag = true
|
||||
}else{
|
||||
need_close_info = true;
|
||||
}
|
||||
$(".see_infos[data-id="+id+"]").parent().siblings(".site_status").html(status_text);
|
||||
//msg_end.scrollIntoView();
|
||||
|
@ -159,7 +173,7 @@
|
|||
close_info = true;
|
||||
window.clearTimeout(timeout_id);
|
||||
close_info = false;
|
||||
var id = $(item).data("id");
|
||||
var id = item.data("id");
|
||||
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(id)+"</div><div id='msg_end' style='height:0px; overflow:hidden'></div>"+
|
||||
|
@ -180,13 +194,13 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
$('.see_infos').click(function(){show_infos_dialog(this);});
|
||||
$('.see_infos').click(function(){show_infos_dialog($(this));});
|
||||
$('.create_site').click(function(){
|
||||
close_info = true;
|
||||
window.clearTimeout(timeout_id);
|
||||
close_info = false;
|
||||
var id = $(this).attr("data-id");
|
||||
var item = this;
|
||||
var item = $(this);
|
||||
var id = item.attr("data-id");
|
||||
$.post("<%= admin_site_panel_create_site_path %>",{'id': id}).done(function(){
|
||||
show_infos_dialog(item);
|
||||
}).fail(function() {
|
||||
|
@ -196,31 +210,19 @@
|
|||
$('.recreate_site').click(function(){
|
||||
if(window.confirm("Do you really want to recreate this site?")){
|
||||
if(window.confirm("Do you really want to recreate this site?")){
|
||||
close_info = true;
|
||||
window.clearTimeout(timeout_id);
|
||||
close_info = false;
|
||||
var id = $(this).attr("data-id");
|
||||
var item = this;
|
||||
$.post("<%= admin_site_panel_create_site_path %>",{'id': id}).done(function(){
|
||||
show_infos_dialog(item);
|
||||
}).fail(function() {
|
||||
window.location.reload();
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
$('.delete_site').click(function(){
|
||||
var item = this;
|
||||
if(window.confirm("Do you really want to delete this site?")){
|
||||
if(window.confirm("Do you really want to delete this site?")){
|
||||
var _this = $(this);
|
||||
if($("#dialog-confirm").length == 0){
|
||||
$("#main-wrap").before("<div id='dialog-confirm' title='site infos'>"+
|
||||
"<div style='clear:both;'></div><div id='info_texts'>"+"Do you really want to "+$(this).attr('title')+"?</div>"+"<input id=\"confirm_input\"/ placeholder=\"<%= t('client_management.please_input_confirm_delete') %>\" style=\"width: 17em;\">"+"<div id='msg_end' style='height:0px; overflow:hidden'></div>"+
|
||||
"<div style='clear:both;'></div><div id='info_texts'>"+"Do you really want to "+$(this).attr('title')+"?</div>"+"<input id=\"confirm_input\"/ placeholder=\"<%= t('client_management.please_input_confirm_recreate') %>\" style=\"width: 17em;\">"+"<div id='msg_end' style='height:0px; overflow:hidden'></div>"+
|
||||
"</div>");
|
||||
}else{
|
||||
$("#info_texts").html("Do you really want to "+$(this).attr('title')+".");
|
||||
$('#confirm_input').css('display','block');
|
||||
$('#confirm_input').val('');
|
||||
$("#info_texts").html("Do you really want to "+_this.attr('title')+".");
|
||||
if($('#confirm_input').length == 0){
|
||||
$('#info_texts').after("<input id=\"confirm_input\"/ placeholder=\"<%= t('client_management.please_input_confirm_recreate') %>\" style=\"width: 17em;\">");
|
||||
}else{
|
||||
$('#confirm_input').css('display','block');
|
||||
$('#confirm_input').val('');
|
||||
}
|
||||
}
|
||||
$( "#dialog-confirm" ).dialog({
|
||||
resizable: true,
|
||||
|
@ -236,30 +238,90 @@
|
|||
$( this ).dialog( "close" );
|
||||
},
|
||||
buttons: {
|
||||
"<%= t('client_management.confirm') %>": function(){
|
||||
if($('#confirm_input').val().match(/<%= t('client_management.confirm_delete') %>/gi)){
|
||||
$('#confirm_input').css('display','none');
|
||||
$.post("<%=admin_site_panel_edit_site_path%>",{'id':$(item).attr("data-id"),'type':'delete'}).done(function(data){
|
||||
"<%= t('client_management.confirm') %>": function(){
|
||||
if($('#confirm_input').val().match(/<%= t('client_management.confirm_recreate') %>/gi)){
|
||||
$('#confirm_input').val('');
|
||||
$('#confirm_input').css('display','none');
|
||||
close_info = true;
|
||||
window.clearTimeout(timeout_id);
|
||||
close_info = false;
|
||||
var id =_this.attr("data-id");
|
||||
var item = _this;
|
||||
$.post("<%= admin_site_panel_create_site_path %>",{'id': id}).done(function(){
|
||||
show_infos_dialog(item);
|
||||
item.remove();
|
||||
});
|
||||
}else{
|
||||
alert("<%= t('client_management.please_input_confirm_delete').html_safe %>");
|
||||
$('#confirm_input').focus();
|
||||
}
|
||||
}).fail(function() {
|
||||
window.location.reload();
|
||||
})
|
||||
}else{
|
||||
alert("<%= t('client_management.please_input_confirm_recreate').html_safe %>");
|
||||
$('#confirm_input').focus();
|
||||
}
|
||||
},
|
||||
"<%= t('client_management.cancel') %>": function(){
|
||||
"<%= t('client_management.cancel') %>": function(){
|
||||
$('#confirm_input').css('display','none');
|
||||
$( this ).dialog( "close" );
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
$('.delete_site').click(function(){
|
||||
var item = $(this);
|
||||
if(window.confirm("Do you really want to delete this site?")){
|
||||
if(window.confirm("Do you really want to delete this site?")){
|
||||
if($("#dialog-confirm").length == 0){
|
||||
$("#main-wrap").before("<div id='dialog-confirm' title='site infos'>"+
|
||||
"<div style='clear:both;'></div><div id='info_texts'>"+"Do you really want to "+$(this).attr('title')+"?</div>"+"<input id=\"confirm_input\"/ placeholder=\"<%= t('client_management.please_input_confirm_delete') %>\" style=\"width: 17em;\">"+"<div id='msg_end' style='height:0px; overflow:hidden'></div>"+
|
||||
"</div>");
|
||||
}else{
|
||||
$("#info_texts").html("Do you really want to "+$(this).attr('title')+".");
|
||||
if($('#confirm_input').length == 0){
|
||||
$('#info_texts').after("<input id=\"confirm_input\"/ placeholder=\"<%= t('client_management.please_input_confirm_recreate') %>\" style=\"width: 17em;\">");
|
||||
}else{
|
||||
$('#confirm_input').css('display','block');
|
||||
$('#confirm_input').val('');
|
||||
}
|
||||
}
|
||||
$( "#dialog-confirm" ).dialog({
|
||||
resizable: true,
|
||||
minHeight: 200,
|
||||
maxHeight: 400,
|
||||
modal: true,
|
||||
width: '80%',
|
||||
open: function(){
|
||||
$('#confirm_input').blur();
|
||||
},
|
||||
close: function(){
|
||||
$('#confirm_input').css('display','none');
|
||||
$( this ).dialog( "close" );
|
||||
}
|
||||
},
|
||||
buttons: {
|
||||
"<%= t('client_management.confirm') %>": function(){
|
||||
if($('#confirm_input').val().match(/<%= t('client_management.confirm_delete') %>/gi)){
|
||||
$('#confirm_input').val('');
|
||||
$('#confirm_input').css('display','none');
|
||||
$.post("<%=admin_site_panel_edit_site_path%>",{'id':item.attr("data-id"),'type':'delete'}).done(function(data){
|
||||
show_infos_dialog(item);
|
||||
item.remove();
|
||||
});
|
||||
}else{
|
||||
alert("<%= t('client_management.please_input_confirm_delete').html_safe %>");
|
||||
$('#confirm_input').focus();
|
||||
}
|
||||
},
|
||||
"<%= t('client_management.cancel') %>": function(){
|
||||
$('#confirm_input').css('display','none');
|
||||
$( this ).dialog( "close" );
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
$(".https_setting").click(function(){
|
||||
var id = $(this).data("id");
|
||||
var item = this;
|
||||
var item = $(this);
|
||||
var id = item.data("id");
|
||||
if($("#https_setting-dialog-confirm").length == 0){
|
||||
$("#main-wrap").before("<div id='https_setting-dialog-confirm' title='<%=t("client_management.https_setting")%>'>"
|
||||
+"<div id='https_setting_area'></div>"+
|
||||
|
@ -291,15 +353,15 @@
|
|||
})
|
||||
})
|
||||
$('.close_site').click(function(){
|
||||
var item = this;
|
||||
var item = $(this);
|
||||
$.post("<%=admin_site_panel_edit_site_path%>",{'id':$(this).attr("data-id"),'type':'close'}).done(function(){
|
||||
show_infos_dialog(item);
|
||||
item.remove();
|
||||
});
|
||||
});
|
||||
$('.open_site').click(function(){
|
||||
var item = this;
|
||||
var env = $(this).data("env");
|
||||
var item = $(this);
|
||||
var env = item.data("env");
|
||||
if( env == undefined )
|
||||
env = "";
|
||||
$.post("<%=admin_site_panel_edit_site_path%>",{'id':$(this).attr("data-id"),'type':'open','env': env}).done(function(){
|
||||
|
@ -322,7 +384,7 @@
|
|||
$("#main-wrap").before("<div id='exec-commands-dialog-confirm' title='Commands to Exec'>" +
|
||||
"<div style='clear:both;'></div>"+
|
||||
built_in_commands+
|
||||
"<div style=\"display: none;\" id=\"super_manager_div\"><input type=\"text\" placeholder=\"account\" name=\"account\"><br><input type=\"password\" placeholder=\"password\" name=\"password\"></div>"+
|
||||
"<div style=\"display: none;\" id=\"super_manager_div\"><input type=\"text\" placeholder=\"account\" name=\"account\"><br><input type=\"password\" placeholder=\"password\" name=\"password\" minlength=\"8\"></div>"+
|
||||
"<textarea style='height: 200px;width: 100%;' id='commands_area' data-id='"+id+"'></textarea>"+
|
||||
"</div>");
|
||||
}else{
|
||||
|
@ -349,8 +411,6 @@
|
|||
commands += built_in_commands_selected.join("////");
|
||||
commands += $('#commands_area').val().replace(/(\r\n|\n)/g,"////");
|
||||
var id = $('#commands_area').attr('data-id');
|
||||
console.log(id);
|
||||
console.log(commands);
|
||||
$.post("<%=admin_site_panel_edit_site_path%>",{'id':id,'commands':commands,'account': $('input[name="account"]').val(),'password': $('input[name="password"]').val()}).done(function(){
|
||||
show_infos_dialog($('.see_infos[data-id="'+id+'"]').eq(0));
|
||||
});
|
||||
|
@ -386,7 +446,10 @@
|
|||
})
|
||||
</script>
|
||||
<style type="text/css">
|
||||
.delete_site{
|
||||
.delete_site, .recreate_site{
|
||||
background: #7d1a23;
|
||||
}
|
||||
.delete_site:hover, .delete_site:focus, .recreate_site:hover, .recreate_site:focus{
|
||||
background: #eb1d30;
|
||||
}
|
||||
</style>
|
|
@ -61,7 +61,7 @@
|
|||
<div class="control-group">
|
||||
<label class="control-label muted" for="active_server"><%= t("client_management.active") %></label>
|
||||
<div class="controls">
|
||||
<%= f.check_box :active,:id=>"active_server" %>
|
||||
<%= f.check_box :active,:id=>"active_server",:title=>t("client_management.active") %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -108,8 +108,10 @@ en:
|
|||
server_manager: Server Manager
|
||||
confirm: Confirm
|
||||
cancel: Cancel
|
||||
please_input_confirm_delete: "Please input 'Confirm delete' to here."
|
||||
confirm_delete: Confirm delete
|
||||
please_input_confirm_recreate: "Please input 'Confirm Recreate' to here."
|
||||
please_input_confirm_delete: "Please input 'Confirm Delete' to here."
|
||||
confirm_recreate: Confirm Recreate
|
||||
confirm_delete: Confirm Delete
|
||||
action: Action
|
||||
see_logs: See logs
|
||||
see_logs_for_site: "see infos for %{site}"
|
||||
|
@ -126,7 +128,7 @@ en:
|
|||
exec_commands_on_site: "Exec commands on %{site}"
|
||||
copy_site: Copy site
|
||||
copy_site_hint: Copy site to another site.
|
||||
edit_cert_setting: Edit cert Setting
|
||||
edit_cert_setting: Edit Cert CSR Setting
|
||||
delete_from_list: Delete from list
|
||||
delete_from_list_for_site: "Delete %{site} from list"
|
||||
detail: See details
|
||||
|
|
|
@ -21,12 +21,12 @@ zh_tw:
|
|||
domain_hint: "*僅能匹配一層的網址"
|
||||
redirect_to_default_domain_name: 跳轉到預設的domain name
|
||||
default_domain_names: 預設的domain names
|
||||
disable: 關閉
|
||||
enable: 開啟
|
||||
disable: 停用
|
||||
enable: 啟用
|
||||
option:
|
||||
'0': 預設
|
||||
'1': 關閉
|
||||
'2': 開啟
|
||||
'1': 停用
|
||||
'2': 啟用
|
||||
alreay_install: 已安裝
|
||||
not_install: 未安裝
|
||||
active: 啟用
|
||||
|
@ -108,7 +108,9 @@ zh_tw:
|
|||
server_manager: 伺服器管理
|
||||
confirm: Confirm
|
||||
cancel: Cancel
|
||||
please_input_confirm_recreate: "請輸入'確認重新架站'。"
|
||||
please_input_confirm_delete: "請輸入'確認刪除'。"
|
||||
confirm_recreate: 確認重新架站
|
||||
confirm_delete: 確認刪除
|
||||
action: 動作
|
||||
see_logs: 查看log
|
||||
|
@ -126,7 +128,7 @@ zh_tw:
|
|||
exec_commands_on_site: "在%{site}上執行指令"
|
||||
copy_site: 複製網站
|
||||
copy_site_hint: 將該網站的資料複製到新的網站
|
||||
edit_cert_setting: 更改憑證設定
|
||||
edit_cert_setting: 更改憑證CSR設定
|
||||
delete_from_list: 從列表上刪除
|
||||
delete_from_list_for_site: "將%{site}從列表上移除(暫時隱藏)"
|
||||
detail: 查看設定
|
||||
|
|
|
@ -4,22 +4,29 @@ require 'json'
|
|||
require 'base64'
|
||||
namespace :exec_commands do
|
||||
desc "Exec commands Script"
|
||||
task :exec_commands,[:base64_args,:site_construct_id,:commands,:type,:server_name,:rails_env] => :environment do |task,args|
|
||||
task :exec_commands,[:base64_args,:site_construct_id,:commands,:type,:server_name,:rails_env,:commands_i18n] => :environment do |task,args|
|
||||
if args.base64_args.present?
|
||||
tmp = JSON.parse(Base64.decode64(args.base64_args)) rescue {}
|
||||
args = Rake::TaskArguments.new(tmp.keys, tmp.values)
|
||||
end
|
||||
@type = args.type
|
||||
if !args.site_construct_id.blank?
|
||||
if args.site_construct_id.present?
|
||||
@site_construct = SiteConstruct.find(args.site_construct_id)
|
||||
site_server = SiteServer.where(:server_name=>@site_construct.server_type).first
|
||||
site_servers = [site_server]
|
||||
@site_construct.update(:status=>"execing",:infos=>[""])
|
||||
else
|
||||
@site_construct = nil
|
||||
site_servers = SiteServer.where(:server_name.in=>args.server_name.split("////")).to_a
|
||||
end
|
||||
if args.type == "exec_all"
|
||||
Multithread.where(:key=>'execing_commands').each{|thread| thread.destroy if (thread.status["status"] == "error" || thread.status["status"] == "finish")}
|
||||
Multithread.where(:key=>'execing_commands').each do |thread|
|
||||
if thread.status["status"] == "error" || thread.status["status"] == "finish"
|
||||
thread.destroy
|
||||
elsif thread.updated_at < (Time.now - 5.minute)
|
||||
thread.destroy
|
||||
end
|
||||
end
|
||||
@thread = Multithread.where(:key=>'execing_commands').first
|
||||
else
|
||||
@thread = nil
|
||||
|
@ -38,8 +45,12 @@ namespace :exec_commands do
|
|||
@command_trans["start_site_in_env,#{env}"] = I18n.t("client_management.start_site_in_env",{:env=>env})
|
||||
end
|
||||
begin
|
||||
if @thread.nil? && args.type == "exec_all"
|
||||
@thread = Multithread.create(:key=>'execing_commands',:status=>{"infos"=>[],"status"=>"execing"})
|
||||
if args.type == "exec_all"
|
||||
if @thread.nil?
|
||||
@thread = Multithread.create(:key=>'execing_commands',:status=>{"infos"=>[],"status"=>"execing"})
|
||||
else
|
||||
@thread.update(:status=>{"infos"=>[],"status"=>"execing"})
|
||||
end
|
||||
end
|
||||
site_servers.each do |site_server|
|
||||
ip = site_server.ip
|
||||
|
@ -102,21 +113,26 @@ namespace :exec_commands do
|
|||
else
|
||||
sites = [@site_construct]
|
||||
end
|
||||
if args.commands.include?("{{create_users}}")
|
||||
commands = args.commands
|
||||
if commands.class == String
|
||||
commands = commands.split("////").select{|c| c != ""}
|
||||
elsif commands.nil?
|
||||
commands = []
|
||||
end
|
||||
if commands.include?("{{create_users}}")
|
||||
commands = ['sudo -p "sudo password:" chmod 777 {{full_site_path}} -R',
|
||||
'sudo -p "sudo password:" chmod 777 {{full_site_path}}/public -R',
|
||||
'sudo -p "sudo password:" chmod 777 {{full_site_path}}/app/templates -R',
|
||||
'sudo -p "sudo password:" useradd --home-dir {{full_site_path}}/app/templates {{site_name}} --no-create-home --badnames',
|
||||
'sudo -p "sudo password:" bash -l -c \'echo -e "{{site_name}}\n{{site_name}}"|passwd {{site_name}}\'']
|
||||
else
|
||||
commands = args.commands.split("////").select{|c| c != ""} rescue [args.commands]
|
||||
end
|
||||
@commands_i18n = args.commands_i18n # command 客製化翻譯
|
||||
sites.each do |site_construct|
|
||||
@site_construct = site_construct
|
||||
@site_construct.update!(:infos=>[])
|
||||
exec_ssh_command_by_sudo(ssh,"chmod 777 #{@site_construct.path}/#{@site_construct.site_name} -R")
|
||||
rails_env = @site_construct.rails_env.blank? ? "development" : @site_construct.rails_env
|
||||
commands.each do |command|
|
||||
commands.each_with_index do |command, idx|
|
||||
@command_i18n = command
|
||||
update_flag = 1
|
||||
@command_relations.each do |k,v|
|
||||
|
@ -126,8 +142,9 @@ namespace :exec_commands do
|
|||
command = command.gsub("{{#{k}}}",v)
|
||||
@command_i18n = @command_i18n.gsub("{{#{k}}}",@command_trans[k])
|
||||
end
|
||||
if command.include?('{{db_name}}')
|
||||
@command_i18n = "create super manager"
|
||||
if @commands_i18n
|
||||
tmp = @commands_i18n[idx]
|
||||
@command_i18n = tmp if tmp
|
||||
end
|
||||
command = command.gsub("{{rails_env}}",rails_env)
|
||||
command = command.gsub("{{full_site_path}}",@site_construct.full_site_path)
|
||||
|
@ -136,8 +153,7 @@ namespace :exec_commands do
|
|||
@command_i18n = @command_i18n.gsub("{{rails_env}}",rails_env)
|
||||
@command_i18n = @command_i18n.gsub("{{full_site_path}}",@site_construct.full_site_path)
|
||||
@command_i18n = @command_i18n.gsub("{{site_name}}",@site_construct.site_name)
|
||||
command = command.gsub(/'{1,3}/,"'\"'\"'")
|
||||
puts ['command',command,"bash -l -c 'cd #{@site_construct.path}/#{@site_construct.site_name};#{command}'"]
|
||||
command = command.gsub("'","'\"'\"'")
|
||||
exec_ssh_command_by_sudo_and_see_output(ssh,"bash -l -c 'cd #{@site_construct.path}/#{@site_construct.site_name};#{command}'", update_flag)
|
||||
@command_i18n = nil
|
||||
end
|
||||
|
@ -147,6 +163,8 @@ namespace :exec_commands do
|
|||
end
|
||||
if !@thread.nil?
|
||||
@thread.update(:status=>@thread.status.merge({"status"=>"finish"}))
|
||||
elsif @site_construct
|
||||
@site_construct.update(:status =>"finish")
|
||||
end
|
||||
rescue => e
|
||||
if !@thread.nil?
|
||||
|
|
Loading…
Reference in New Issue