added mechanism to construct pending sites online.
This commit is contained in:
parent
90740bb5d2
commit
07d75f8d53
|
@ -0,0 +1,18 @@
|
|||
class Admin::SitePanelController < OrbitAdminController
|
||||
def index
|
||||
@site_construct = SiteConstruct.new
|
||||
end
|
||||
|
||||
def create
|
||||
site_construct = SiteConstruct.new(site_construct_params)
|
||||
site_construct.member_id = current_user.id.to_s
|
||||
site_construct.save
|
||||
redirect_to admin_site_panel_path("msg" => "success")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def site_construct_params
|
||||
params.require(:site_construct).permit!
|
||||
end
|
||||
end
|
|
@ -0,0 +1,50 @@
|
|||
class SitePanelApiController < ApplicationController
|
||||
def index
|
||||
ip = request.remote_ip
|
||||
case ip
|
||||
when "211.72.229.126"
|
||||
type = "Pending"
|
||||
when "211.72.229.122"
|
||||
type = "Store"
|
||||
when "127.0.0.1"
|
||||
type = "Pending"
|
||||
else
|
||||
render :text => "Not a valid IP." and return
|
||||
end
|
||||
|
||||
list = SiteConstruct.where(:server_type => type, :constructed => false)
|
||||
string = ""
|
||||
list.each do |entry|
|
||||
string = string + "#{entry.server_type},#{entry.site_name},#{entry.domain_name},#{entry.port},#{entry.db_name},#{entry.path}\n"
|
||||
end
|
||||
render :text => string
|
||||
end
|
||||
|
||||
def constructed
|
||||
site_id = params[:site_id]
|
||||
ip = request.remote_ip
|
||||
case ip
|
||||
when "211.72.229.126"
|
||||
when "211.72.229.122"
|
||||
when "127.0.0.1"
|
||||
else
|
||||
render :text => "Not a valid IP." and return
|
||||
end
|
||||
site = SiteConstruct.where(:site_name => site_id, :constructed => false).first rescue nil
|
||||
if !site.nil?
|
||||
site.constructed = true
|
||||
site.save
|
||||
user = User.find(site.user_id) rescue nil
|
||||
if !user.nil?
|
||||
email = Email.new
|
||||
email.mail_to = user.member_profile.email
|
||||
email.mail_subject = "#{site.site_name} has been constructed."
|
||||
email.mail_content = "<strong>#{site.site_name}</strong> has been constructed successfully.<br />You may access the site at <a href='#{site.domain_name}'>#{site.domain_name}</a><br /><br />For any questions, please contact R&D Team.<br />Thank you."
|
||||
email.deliver
|
||||
end
|
||||
render :text => "success"
|
||||
else
|
||||
render :text => "Site not found. Either it is already constructed or not queued for construction."
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,19 @@
|
|||
class SiteConstruct
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
SERVER_TYPES = ["Pending","Store"]
|
||||
SITE_TYPES = ["School","Gravity"]
|
||||
|
||||
field :server_type
|
||||
field :site_name
|
||||
field :domain_name
|
||||
field :db_name
|
||||
field :port
|
||||
field :path
|
||||
field :site_type
|
||||
field :school_name
|
||||
field :user_id
|
||||
field :constructed, type: Boolean, :default => false
|
||||
|
||||
end
|
|
@ -0,0 +1,129 @@
|
|||
<% 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">
|
||||
<%= f.select :server_type, SiteConstruct::SERVER_TYPES %>
|
||||
</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">
|
||||
<%= f.text_field :domain_name, :id => "domain_name" %>
|
||||
<div class="hint">schoolname-deptname.pending.rulingcom.com eg: nctu-eed.pending.rulingcom.com</div>
|
||||
</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">
|
||||
$("#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 != ""){
|
||||
$("#path").val("/home/rulingcom/" + type + "/" + school + "/");
|
||||
}else{
|
||||
$("#path").val("/home/rulingcom/" + type + "/");
|
||||
}
|
||||
})
|
||||
$("#site_name").on("blur",function(){
|
||||
var val = $(this).val(),
|
||||
type = $("#site_construct_site_type").val(),
|
||||
school = $("#school_name").val();
|
||||
$("#domain_name").val(val.replace("_","-") + ".pending.rulingcom.com");
|
||||
$("#db_name").val(val);
|
||||
type = (type == "School" ? "school_sites" : "orbit_sites" );
|
||||
if(school != ""){
|
||||
$("#path").val("/home/rulingcom/" + type + "/" + school + "/")
|
||||
}else{
|
||||
$("#path").val("/home/rulingcom/" + type + "/");
|
||||
}
|
||||
})
|
||||
$("#site_construct_site_type").val("School");
|
||||
$("form#new_site_construct").on("submit",function(){
|
||||
$("#path").removeAttr("disabled");
|
||||
})
|
||||
</script>
|
|
@ -0,0 +1,6 @@
|
|||
<% if params[:msg] == "success" %>
|
||||
<div class="alert alert-success" style="width: 60%; font-size: 18px; margin: auto;"><strong>Success!</strong> Site has been queued for construction. It can take upto 5 - 10 mins. You will be notified on <strong><%= current_user.member_profile.email %></strong> once the site is ready.</div>
|
||||
<% end %>
|
||||
<%= form_for @site_construct, :url => {:action=>"create"}, :html => {:class => 'form-horizontal main-forms'} do |f| %>
|
||||
<%= render :partial => 'form', :locals => {:f => f} %>
|
||||
<% end %>
|
|
@ -52,4 +52,5 @@ en:
|
|||
amount_received: Amount Received
|
||||
amount_pending: Amount Pending
|
||||
receipt_status: Receipt Status
|
||||
loading_purchases: Loading Purchases
|
||||
loading_purchases: Loading Purchases
|
||||
create_site: Create Site
|
|
@ -52,4 +52,5 @@ zh_tw:
|
|||
amount_received: Amount Received
|
||||
amount_pending: Amount Pending
|
||||
receipt_status: Receipt Status
|
||||
loading_purchases: Loading Purchases
|
||||
loading_purchases: Loading Purchases
|
||||
create_site: Create Site
|
|
@ -36,6 +36,10 @@ Rails.application.routes.draw do
|
|||
get "contracts"
|
||||
end
|
||||
end
|
||||
|
||||
get "site_panel" => "site_panel#index"
|
||||
resources :site_panel
|
||||
|
||||
end
|
||||
|
||||
scope :cpanel do
|
||||
|
@ -86,5 +90,9 @@ Rails.application.routes.draw do
|
|||
post "loguserin" => "c_panel_sessions#loguserin"
|
||||
|
||||
end
|
||||
|
||||
get "/xhr/site_panel_api/get_list" => "site_panel_api#index"
|
||||
get "/xhr/site_panel_api/constructed/:site_id" => "site_panel_api#constructed"
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,12 +27,18 @@ module ClientManagement
|
|||
:active_for_action=>{'admin/client_managements'=>"completed_requests"},
|
||||
:available_for => 'users'
|
||||
|
||||
context_link 'client_management.contracts',
|
||||
context_link 'client_management.contracts',
|
||||
:link_path=>"contracts_admin_client_managements_path" ,
|
||||
:priority=>1,
|
||||
:active_for_action=>{'admin/client_managements'=>"contracts"},
|
||||
:available_for => 'users'
|
||||
|
||||
context_link 'client_management.create_site',
|
||||
:link_path=>"admin_site_panel_path" ,
|
||||
:priority=>1,
|
||||
:active_for_action=>{'admin/site_panel'=>"index"},
|
||||
:available_for => 'users'
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue