2017-11-30 09:00:26 +00:00
|
|
|
<% content_for :page_specific_css do %>
|
|
|
|
<%= stylesheet_link_tag "lib/main-forms" %>
|
|
|
|
<% end %>
|
|
|
|
<% content_for :page_specific_javascript do %>
|
|
|
|
<% end %>
|
|
|
|
<%#= f.error_messages %>
|
|
|
|
<fieldset>
|
|
|
|
<!-- Input Area -->
|
|
|
|
<div class="input-area">
|
|
|
|
|
|
|
|
<!-- Module Tabs -->
|
|
|
|
<div class="nav-name"><strong><%= t(:module) %></strong></div>
|
|
|
|
<ul class="nav nav-pills module-nav">
|
|
|
|
<li class="active">
|
|
|
|
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<!-- Module -->
|
|
|
|
<div class="tab-content module-area">
|
|
|
|
<!-- Basic Module -->
|
|
|
|
<div class="tab-pane fade in active" id="basic">
|
|
|
|
<div class="control-group">
|
|
|
|
<%= f.label :server_type ,"Server", :class => "control-label muted" %>
|
|
|
|
<div class="controls">
|
2021-01-28 03:10:41 +00:00
|
|
|
<%= f.select :server_type, SiteConstruct.server_types %>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="control-group">
|
|
|
|
<%= f.label :root_domain ,"Root Domain", :class => "control-label muted" %>
|
|
|
|
<div class="controls">
|
|
|
|
<%= select_tag :root_domain,
|
|
|
|
options_for_select(SiteServer.first.domain_names.collect{ |u| [u, u] }),
|
|
|
|
:id => "root_domain" %>
|
2017-11-30 09:00:26 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="control-group">
|
|
|
|
<%= f.label :site_type ,"Site Type", :class => "control-label muted" %>
|
|
|
|
<div class="controls">
|
|
|
|
<%= f.select :site_type, SiteConstruct::SITE_TYPES, :id => "site_type" %>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="control-group">
|
|
|
|
<%= f.label :school_name ,"School Name", :class => "control-label muted" %>
|
|
|
|
<div class="controls">
|
|
|
|
<%= f.text_field :school_name, :id => "school_name", :placeholder => "XXXX" %>
|
|
|
|
<div class="hint">Eg: NCTU</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="control-group">
|
|
|
|
<%= f.label :site_name ,"Site Name", :class => "control-label muted" %>
|
|
|
|
<div class="controls">
|
|
|
|
<%= f.text_field :site_name, :id => "site_name", :placeholder => "xxx_xxx" %>
|
|
|
|
<div class="hint">schoolname_deptname eg: nctu_eed</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="control-group">
|
|
|
|
<%= f.label :domain_name ,"Domain Name", :class => "control-label muted" %>
|
|
|
|
<div class="controls">
|
2021-01-28 03:10:41 +00:00
|
|
|
<%= f.text_field :domain_name, :id => "domain_name",:disabled => 'disabled' %>
|
|
|
|
<!--<div class="hint">schoolname-deptname.pending.rulingcom.com eg: nctu-eed.pending.rulingcom.com</div>-->
|
2017-11-30 09:00:26 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="control-group">
|
|
|
|
<%= f.label :db_name ,"Database Name", :class => "control-label muted" %>
|
|
|
|
<div class="controls">
|
|
|
|
<%= f.text_field :db_name, :id => "db_name" %>
|
|
|
|
<div class="hint">schoolname_deptname eg: nctu_eed</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="control-group">
|
|
|
|
<%= f.label :port ,"Port Number", :class => "control-label muted" %>
|
|
|
|
<div class="controls">
|
|
|
|
<%= f.number_field :port, :min => 1, :id => "port", :value => 80 %>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="control-group">
|
|
|
|
<%= f.label :path ,"Path", :class => "control-label muted" %>
|
|
|
|
<div class="controls">
|
|
|
|
<%= f.text_field :path, :disabled => true, :id => "path" %>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-actions">
|
|
|
|
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</fieldset>
|
|
|
|
<script type="text/javascript">
|
2020-04-24 14:38:28 +00:00
|
|
|
var domain_name_relations = {};
|
|
|
|
<% SiteServer.all.each do |server_server| %>
|
2021-01-28 03:10:41 +00:00
|
|
|
domain_name_relations['<%= server_server.server_name %>'] = <%= server_server.domain_names.inspect.html_safe %>;
|
2020-04-24 14:38:28 +00:00
|
|
|
<% end %>
|
|
|
|
console.log(domain_name_relations);
|
2021-01-28 03:10:41 +00:00
|
|
|
function change_domain_name(domain_name){
|
|
|
|
$("#domain_name").val($("#site_name").val().replace("_","-") + "."+domain_name);
|
|
|
|
}
|
2017-11-30 09:00:26 +00:00
|
|
|
$("#school_name").on("blur",function(){
|
|
|
|
var school = $(this).val().toLowerCase();
|
|
|
|
if($("#site_name").val() == ""){
|
|
|
|
$("#site_name").val(school + "_");
|
|
|
|
}
|
|
|
|
})
|
|
|
|
$("#site_construct_site_type").on("change",function(){
|
|
|
|
var type = $(this).val();
|
|
|
|
if(type == "School"){
|
|
|
|
$("#school_name").parents(".control-group").show();
|
|
|
|
}else{
|
|
|
|
$("#school_name").parents(".control-group").hide();
|
|
|
|
$("#school_name").val("");
|
|
|
|
}
|
|
|
|
var school = $("#school_name").val();
|
|
|
|
type = (type == "School" ? "school_sites" : "orbit_sites" );
|
|
|
|
if(school != ""){
|
2017-11-30 10:15:22 +00:00
|
|
|
$("#path").val("/home/rulingcom/" + type + "/" + school);
|
2017-11-30 09:00:26 +00:00
|
|
|
}else{
|
2017-11-30 10:15:22 +00:00
|
|
|
$("#path").val("/home/rulingcom/" + type);
|
2017-11-30 09:00:26 +00:00
|
|
|
}
|
|
|
|
})
|
2021-01-28 03:10:41 +00:00
|
|
|
$("#root_domain").change(function(){
|
|
|
|
change_domain_name($(this).val());
|
|
|
|
})
|
|
|
|
$('#site_construct_server_type').change(function(){
|
|
|
|
var domain_name = domain_name_relations[$(this).val()][0];
|
|
|
|
var domain_names = domain_name_relations[$(this).val()];
|
|
|
|
$("#root_domain").find('option').remove()
|
|
|
|
$.each(domain_names,function(i,v){
|
|
|
|
var o = new Option(v, v);
|
|
|
|
/// jquerify the DOM object 'o' so we can use the html method
|
|
|
|
$(o).html(v);
|
|
|
|
$("#root_domain").append(o);
|
|
|
|
})
|
|
|
|
if ($("#site_name").val()!=''){
|
|
|
|
change_domain_name(domain_name);
|
|
|
|
}
|
|
|
|
//$('#domain_name').siblings('.hint').html('schoolname-deptname.'+domain_name+' eg: nctu-eed.'+domain_name);
|
2020-04-24 14:38:28 +00:00
|
|
|
})
|
2017-11-30 09:00:26 +00:00
|
|
|
$("#site_name").on("blur",function(){
|
|
|
|
var val = $(this).val(),
|
|
|
|
type = $("#site_construct_site_type").val(),
|
2020-04-24 14:38:28 +00:00
|
|
|
school = $("#school_name").val(),
|
2021-01-28 03:10:41 +00:00
|
|
|
domain_name = $("#root_domain").val();
|
|
|
|
//$('#domain_name').siblings('.hint').html('schoolname-deptname.'+domain_name+' eg: nctu-eed.'+domain_name);
|
|
|
|
change_domain_name(domain_name);
|
2017-11-30 09:00:26 +00:00
|
|
|
$("#db_name").val(val);
|
|
|
|
type = (type == "School" ? "school_sites" : "orbit_sites" );
|
|
|
|
if(school != ""){
|
2017-11-30 10:15:22 +00:00
|
|
|
$("#path").val("/home/rulingcom/" + type + "/" + school);
|
2017-11-30 09:00:26 +00:00
|
|
|
}else{
|
2017-11-30 10:15:22 +00:00
|
|
|
$("#path").val("/home/rulingcom/" + type);
|
2017-11-30 09:00:26 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
$("#site_construct_site_type").val("School");
|
2021-01-19 04:48:03 +00:00
|
|
|
$("form.main-forms").submit(function(){
|
2017-11-30 09:00:26 +00:00
|
|
|
$("#path").removeAttr("disabled");
|
2021-01-19 04:48:03 +00:00
|
|
|
var type = $("#site_construct_site_type").val();
|
|
|
|
type = (type == "School" ? "school_sites" : "orbit_sites" );
|
|
|
|
var school = $("#school_name").val();
|
|
|
|
if(school != ""){
|
|
|
|
$("#path").val("/home/rulingcom/" + type + "/" + school);
|
|
|
|
}else{
|
|
|
|
$("#path").val("/home/rulingcom/" + type);
|
|
|
|
}
|
|
|
|
console.log($("#path").val());
|
2017-11-30 09:00:26 +00:00
|
|
|
})
|
|
|
|
</script>
|