From 645d945ccb1a70d2279c073d917c7e644c03c06a Mon Sep 17 00:00:00 2001 From: bohung Date: Wed, 17 Mar 2021 19:19:18 +0800 Subject: [PATCH] Add lots of chinese translations. Add switch to development and production mode button. --- .../admin/site_panel_controller.rb | 2 +- .../site_panel/_sites_list_table.html.erb | 48 ++++++++++++------- config/locales/en.yml | 28 ++++++++++- config/locales/zh_tw.yml | 36 ++++++++++++-- lib/client_management/engine.rb | 4 +- lib/tasks/exec_command.rake | 5 +- 6 files changed, 95 insertions(+), 28 deletions(-) diff --git a/app/controllers/admin/site_panel_controller.rb b/app/controllers/admin/site_panel_controller.rb index c8f7eea..f9f80e9 100644 --- a/app/controllers/admin/site_panel_controller.rb +++ b/app/controllers/admin/site_panel_controller.rb @@ -148,7 +148,7 @@ class Admin::SitePanelController < OrbitAdminController end elsif params[:type] == 'open' Thread.new do - system("bundle exec rake exec_commands:exec_commands[#{params[:id]},,open_site]") + system("bundle exec rake exec_commands:exec_commands[#{params[:id]},,open_site,,#{params[:env]}]") end elsif params[:type] == 'detail' @site = SiteConstruct.find(params[:id]) diff --git a/app/views/admin/site_panel/_sites_list_table.html.erb b/app/views/admin/site_panel/_sites_list_table.html.erb index 238e0da..916b505 100644 --- a/app/views/admin/site_panel/_sites_list_table.html.erb +++ b/app/views/admin/site_panel/_sites_list_table.html.erb @@ -1,11 +1,11 @@ - - + + - - + + @@ -26,23 +26,27 @@
Server nameDomain name<%=t('client_management.server_name')%><%=t('client_management.domain_name')%> PortStatusAction<%=t('client_management.status')%><%=t('client_management.action')%>
<%=site.port%> <%= (site.status.blank? ? "not yet create" : status_relation[site.status]) %> - See infos + site.domain_name})%>" class="btn btn-primary see_infos" data-id="<%=site.id.to_s%>"><%=t('client_management.see_logs')%> <% if site.status.blank? %> - Create site + <%=t('client_management.create_site')%> <% elsif site.status == "error" || site.status == "finish" %> - Recreate site - Delete site - Close site - Restart site + <%=t('client_management.recreate_site')%> + site.domain_name})%>" class="btn btn-primary delete_site" data-id="<%=site.id.to_s%>"><%=t('client_management.delete_site')%> + site.domain_name})%>" class="btn btn-primary close_site" data-id="<%=site.id.to_s%>"><%=t('client_management.close_site')%> + <%=t('client_management.restart_site')%> <% elsif site.status == "closed" %> - Start site + site.domain_name})%>" class="btn btn-primary open_site" data-id="<%=site.id.to_s%>"><%=t('client_management.start_site')%> <% end%> - Exec commands - " title="See <%=site.domain_name%> detail" class="btn btn-primary see_detail" data-id="<%=site.id.to_s%>">Detail - " title="Delete <%=site.domain_name%> from list" class="btn btn-primary" data-id="<%=site.id.to_s%>">Delete from list + <% if site.status.present? %> + " class="btn btn-primary open_site" data-id="<%=site.id.to_s%>" data-env="development"><%=t('client_management.switch_to_development')%> + " class="btn btn-primary open_site" data-id="<%=site.id.to_s%>" data-env="production"><%=t('client_management.switch_to_production')%> + <% end %> + site.domain_name})%>" class="btn btn-primary exec_commands" data-id="<%=site.id.to_s%>"><%=t('client_management.exec_commands')%> + " 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')%> + " 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')%> <% if site.status == "finish" || site.status == "closed" %> - " title="Copy site to another site." class="btn btn-primary">Copy site - Edit cert Setting + " title="<%=t('client_management.copy_site_hint')%>" class="btn btn-primary"><%=t('client_management.copy_site')%> + <%=t('client_management.edit_cert_setting')%>
" class="cert-form" style="display: none;"> <%= form_for site, as: 'site', url: "/#{I18n.locale}/admin/site_panel/update_cert_setting",method: "post" do |f| %>
@@ -212,7 +216,10 @@ }); $('.open_site').click(function(){ var item = this; - $.post("<%=admin_site_panel_edit_site_path%>",{'id':$(this).attr("data-id"),'type':'open'}).done(function(){ + var env = $(this).data("env"); + if( env == undefined ) + env = ""; + $.post("<%=admin_site_panel_edit_site_path%>",{'id':$(this).attr("data-id"),'type':'open','env': env}).done(function(){ show_infos_dialog(item); item.remove(); }); @@ -278,4 +285,9 @@ $('#cert-form-'+$(this).data('id')).dialog('open') }) }) - \ No newline at end of file + + \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 653fd8a..04b4ae0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -61,4 +61,30 @@ en: confirm: Confirm cancel: Cancel please_input_confirm_delete: "Please input 'Confirm delete' to here." - confirm_delete: Confirm delete \ No newline at end of file + confirm_delete: Confirm delete + action: Action + see_logs: See logs + see_logs_for_site: "see infos for %{site}" + start_site: Start site + start_site_for_site: "Start %{site}" + restart_site: Restart site + create_site: Create site + recreate_site: Recreate site + close_site: Close site + close_site_for_site: "Close %{site}" + delete_site: Delete site + delete_site_for_site: "Delete %{site}" + exec_commands: Exec commands + 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 + delete_from_list: Delete from list + delete_from_list_for_site: "Delete %{site} from list" + detail: See details + see_detail_for_site: "See details for %{site}" + status: Status + server_name: Server name + domain_name: Domain name + switch_to_development: Switch to development + switch_to_production: Switch to production \ No newline at end of file diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index db96df6..338cd46 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -2,11 +2,11 @@ zh_tw: client_management: copy_source: 複製來源 see_sites: 查看主機上的網站 - client_management: Client Management + client_management: 網站管理系統 my_sites: My Sites help_and_faq: Help and FAQ get_in_contact: Contact CS - site_list: Site List + site_list: 網站列表 add_site: Add Site please_wait: Please wait while we gather your sites. tickets: Tickets @@ -56,9 +56,35 @@ zh_tw: receipt_status: Receipt Status loading_purchases: Loading Purchases create_site: Create Site - sites_list: Site list - server_manager: Server Manager + sites_list: 網站列表 + server_manager: 伺服器管理 confirm: Confirm cancel: Cancel please_input_confirm_delete: "請輸入'確認刪除'。" - confirm_delete: 確認刪除 \ No newline at end of file + confirm_delete: 確認刪除 + action: 動作 + see_logs: 查看log + see_logs_for_site: "查看%{site}的log" + start_site: 啟動網站 + start_site_for_site: "啟動%{site}" + restart_site: 重啟網站 + create_site: 架站 + recreate_site: 重新架站 + close_site: 關閉網站 + close_site_for_site: "關閉%{site}" + delete_site: 永久刪除網站 + delete_site_for_site: "永久刪除%{site}" + exec_commands: 執行指令 + exec_commands_on_site: "在%{site}上執行指令" + copy_site: 複製網站 + copy_site_hint: 將該網站的資料複製到新的網站 + edit_cert_setting: 更改憑證設定 + delete_from_list: 從列表上刪除 + delete_from_list_for_site: "將%{site}從列表上移除(暫時隱藏)" + detail: 查看設定 + see_detail_for_site: "查看%{site}的設定" + status: 狀態 + server_name: 伺服器名稱 + domain_name: 網域名稱 + switch_to_development: 切換到development模式 + switch_to_production: 切換到production模式 \ No newline at end of file diff --git a/lib/client_management/engine.rb b/lib/client_management/engine.rb index 53aab69..2cb09dc 100644 --- a/lib/client_management/engine.rb +++ b/lib/client_management/engine.rb @@ -13,8 +13,8 @@ module ClientManagement side_bar do head_label_i18n 'client_management.client_management', icon_class: "icons-users" available_for "users" - active_for_controllers (['admin/client_managements']) - head_link_path "admin_client_managements_path" + active_for_controllers (['admin/site_panels']) + head_link_path "admin_site_panel_server_manager_path" context_link 'client_management.new_requests', :link_path=>"admin_client_managements_path" , diff --git a/lib/tasks/exec_command.rake b/lib/tasks/exec_command.rake index 38db070..7243d67 100644 --- a/lib/tasks/exec_command.rake +++ b/lib/tasks/exec_command.rake @@ -2,7 +2,7 @@ require 'net/ssh' require 'pathname' namespace :exec_commands do desc "Exec commands Script" - task :exec_commands,[:site_construct_id,:commands,:type,:server_name] => :environment do |task,args| + task :exec_commands,[:site_construct_id,:commands,:type,:server_name,:rails_env] => :environment do |task,args| @type = args.type if !args.site_construct_id.blank? @site_construct = SiteConstruct.find(args.site_construct_id) @@ -54,6 +54,9 @@ namespace :exec_commands do break end end + if args.rails_env.present? + rails_env = args.rails_env + end update_infos_for_exec("starting site to #{rails_env}") outputs = exec_ssh_command_by_sudo_and_see_output(ssh,"sudo -p 'sudo password:' chmod 777 #{@site_construct.path}/#{@site_construct.site_name} -R",false) output = exec_ssh_command_by_sudo_and_see_output(ssh,"bash -l -c 'cd #{@site_construct.path}/#{@site_construct.site_name}\nkill -s TERM `fuser tmp/unicorn.sock`\nsudo -p \"sudo password:\" kill -s TERM `sudo -p \"sudo password:\" fuser tmp/unicorn.sock`\nsudo -p \"sudo password:\" rm -f tmp/pids/unicorn.pid\nbundle exec unicorn_rails -c config/unicorn.rb -D -E #{rails_env}\n'",false)