add limit feature
This commit is contained in:
parent
05a359e0fa
commit
999d08434c
|
@ -1,4 +1,5 @@
|
||||||
class Admin::SitePanelController < OrbitAdminController
|
class Admin::SitePanelController < OrbitAdminController
|
||||||
|
before_action :check_server_ability, only: [:index]
|
||||||
def initialize
|
def initialize
|
||||||
super
|
super
|
||||||
@app_title = "client_management"
|
@app_title = "client_management"
|
||||||
|
@ -134,6 +135,8 @@ class Admin::SitePanelController < OrbitAdminController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def create
|
def create
|
||||||
|
server_abiliy = ServerAbility.first
|
||||||
|
if server_ability.available
|
||||||
site_construct = SiteConstruct.new(site_construct_params)
|
site_construct = SiteConstruct.new(site_construct_params)
|
||||||
site_construct.user_id = current_user.id.to_s
|
site_construct.user_id = current_user.id.to_s
|
||||||
site_construct.status = "creating"
|
site_construct.status = "creating"
|
||||||
|
@ -161,6 +164,9 @@ class Admin::SitePanelController < OrbitAdminController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
redirect_to "#{admin_site_panel_sites_list_path}?id=#{site_construct_id}"
|
redirect_to "#{admin_site_panel_sites_list_path}?id=#{site_construct_id}"
|
||||||
|
else
|
||||||
|
render :text => I18n.t('client_management.over_the_limit')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
def create_site
|
def create_site
|
||||||
site_construct = SiteConstruct.find(params[:id])
|
site_construct = SiteConstruct.find(params[:id])
|
||||||
|
@ -275,4 +281,22 @@ class Admin::SitePanelController < OrbitAdminController
|
||||||
def site_server_params
|
def site_server_params
|
||||||
params.require(:site_server).permit! rescue {}
|
params.require(:site_server).permit! rescue {}
|
||||||
end
|
end
|
||||||
|
def check_server_ability
|
||||||
|
store_token = current_site.store_token
|
||||||
|
network = ONetwork.new(OrbitStore::URL,"post")
|
||||||
|
site_num = SiteConstruct.where(hidden: false,:status.ne => 'closed').count
|
||||||
|
response = network.request("/xhr/check_server_ability",
|
||||||
|
{"store_token" => store_token,
|
||||||
|
"site_num" => site_num,
|
||||||
|
"site_name" => current_site.title,
|
||||||
|
"site_url" => current_site.root_url})
|
||||||
|
data = JSON.parse(response.body) rescue {}
|
||||||
|
puts data
|
||||||
|
@server_ability = ServerAbility.first
|
||||||
|
if data.keys.length>0 && !data['ability'].blank?
|
||||||
|
@server_ability.update_attributes(ability: data['ability'], site_num: site_num)
|
||||||
|
else
|
||||||
|
@server_ability.update_attributes(site_num: site_num)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -0,0 +1,9 @@
|
||||||
|
class ServerAbility
|
||||||
|
include Mongoid::Document
|
||||||
|
include Mongoid::Timestamps
|
||||||
|
field :ability, type: Integer, default: 0
|
||||||
|
field :site_num, type: Integer, default: 0
|
||||||
|
def available
|
||||||
|
self.ability==0 || self.site_num<self.ability
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,6 +1,8 @@
|
||||||
<% if params[:msg] == "success" %>
|
<% 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>
|
<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 %>
|
<% end %>
|
||||||
|
<% if @server_ability.available %>
|
||||||
<%= form_for @site_construct, :url => {:action=>"create"}, :html => {:class => 'form-horizontal main-forms'} do |f| %>
|
<%= form_for @site_construct, :url => {:action=>"create"}, :html => {:class => 'form-horizontal main-forms'} do |f| %>
|
||||||
<%= render :partial => 'form', :locals => {:f => f} %>
|
<%= render :partial => 'form', :locals => {:f => f} %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% end %>
|
|
@ -7,6 +7,7 @@ en:
|
||||||
upload_cert: Upload Cert
|
upload_cert: Upload Cert
|
||||||
cert_management: Cert Management
|
cert_management: Cert Management
|
||||||
client_management:
|
client_management:
|
||||||
|
over_the_limit: Please Contact us (RulingCare) to add the limit of Site number.
|
||||||
redirect_to_https: Redirect to https
|
redirect_to_https: Redirect to https
|
||||||
start_date: Start Date
|
start_date: Start Date
|
||||||
end_date: End Date
|
end_date: End Date
|
||||||
|
|
|
@ -7,6 +7,7 @@ zh_tw:
|
||||||
upload_cert: 上傳憑證
|
upload_cert: 上傳憑證
|
||||||
cert_management: 憑證管理
|
cert_management: 憑證管理
|
||||||
client_management:
|
client_management:
|
||||||
|
over_the_limit: 請您聯絡客服以增加可以新增的網站數量上限。
|
||||||
redirect_to_https: 跳轉到https
|
redirect_to_https: 跳轉到https
|
||||||
start_date: 開始日期
|
start_date: 開始日期
|
||||||
end_date: 結束日期
|
end_date: 結束日期
|
||||||
|
|
|
@ -9,6 +9,10 @@ module ClientManagement
|
||||||
taggable "SiteServer"
|
taggable "SiteServer"
|
||||||
# frontend_enabled
|
# frontend_enabled
|
||||||
# data_count 1..30
|
# data_count 1..30
|
||||||
|
require File.expand_path('../../../app/models/server_ability', __FILE__)
|
||||||
|
if ServerAbility.count==0
|
||||||
|
ServerAbility.create()
|
||||||
|
end
|
||||||
set_keyword_contstraints ["/cpanel/"]
|
set_keyword_contstraints ["/cpanel/"]
|
||||||
side_bar do
|
side_bar do
|
||||||
head_label_i18n 'client_management.client_management', icon_class: "icons-users"
|
head_label_i18n 'client_management.client_management', icon_class: "icons-users"
|
||||||
|
|
Loading…
Reference in New Issue