Added System-Info page and fixed preview js issue.

This commit is contained in:
Manson Wang 2014-02-06 15:07:38 +08:00
parent 822c23e841
commit 1eaa0f1801
11 changed files with 201 additions and 61 deletions

View File

@ -2,12 +2,19 @@ $(function() {
$(".post_preview").click(function(){ $(".post_preview").click(function(){
$("#main-wrap").after("<span id='show_preview'></span>"); $("#main-wrap").after("<span id='show_preview'></span>");
$.post($(this).attr('url'), $(".previewable").serialize() ,function(data){ var preview_url = $(this).attr('url');
$('#show_preview .modal').modal();
$("form.previewable").ajaxSubmit({
beforeSubmit: function(a,f,o){
o.dataType = 'script';
o.url = preview_url;
o.type = 'post';
},success: function(msg) {
$('#show_preview .modal').modal()
$('#show_preview .modal').height(function() { $('#show_preview .modal').height(function() {
return $(window).height() * 0.7; return $(window).height() * 0.7;
}); });
},'script'); }});
}); });
$(".preview_trigger").click(function(){ $(".preview_trigger").click(function(){
$("#main-wrap").after("<span id='show_preview'></span>"); $("#main-wrap").after("<span id='show_preview'></span>");
@ -38,10 +45,10 @@ $(function() {
// o.url = url.nodeValue; // o.url = url.nodeValue;
// o.type = 'post'; // o.type = 'post';
// },success: function(msg) { // },success: function(msg) {
// $('#show_preview .modal').modal() // $('#show_preview .modal').modal()
// $('#show_preview .modal').height(function() { // $('#show_preview .modal').height(function() {
// return $(window).height() * 0.7; // return $(window).height() * 0.7;
// }); // });
// } // }
// }); // });

View File

@ -72,7 +72,10 @@ class Admin::SitesController < OrbitBackendController
end end
def system_info def system_info
@disk_free = `df -h /`.gsub("\n","<br/>").html_safe
@nginx_version = %x[/opt/nginx/sbin/nginx -v 2>&1].gsub("\n","<br/> ").html_safe
@mongo_version = `mongod --version`.split("\n")[0].html_safe
@linux_version = `lsb_release -d`.split(":")[1].html_safe
end end
def search_engine def search_engine

View File

@ -433,6 +433,10 @@ module OrbitBackendHelper
res << "<li class='active'>#{t(:search_engine)}</li>" res << "<li class='active'>#{t(:search_engine)}</li>"
when 'site_info' when 'site_info'
res << "<li class='active'>#{t(:site_info)}</li>" res << "<li class='active'>#{t(:site_info)}</li>"
when 'update_manager'
res << "<li class='active'>#{t(:update_manager)}</li>"
when 'system_info'
res << "<li class='active'>#{t("site.system_preference")}</li>"
end end
when 'items' when 'items'
res << "<li class='active'>#{t(:structure)}</li>" res << "<li class='active'>#{t(:structure)}</li>"

View File

@ -22,8 +22,8 @@
<li title="<%= t('update_manager') %>"><%= link_to admin_site_update_manager_path(@site), :class => active_for_action('sites', 'update_manager') do %><span><i class="icon-refresh"></i></span><%end%></li> <li title="<%= t('update_manager') %>"><%= link_to admin_site_update_manager_path(@site), :class => active_for_action('sites', 'update_manager') do %><span><i class="icon-refresh"></i></span><%end%></li>
<!-- <li title="System Info"><a href="/orbit_4.0.1/admin/system_info/index.shtml?sidebarNavList=8&amp;subNavBlockList=0"><span><i class="icons-info-2"></i></span></a></li> <li title="<%= t("site.system_preference") %>"><%= link_to admin_site_system_info_path(@site), :class => active_for_action('sites', 'system_info') do %><span><i class="icons-info-2"></i></span><%end%></li>
--> </ul> </ul>
</div> </div>
<div class="sub-nav-arrow"></div> <div class="sub-nav-arrow"></div>
</div> </div>

View File

@ -22,8 +22,8 @@
<li title="<%= t('update_manager') %>"><%= link_to admin_site_update_manager_path(@site), :class => active_for_action('sites', 'update_manager') do %><span><i class="icon-refresh"></i></span><%end%></li> <li title="<%= t('update_manager') %>"><%= link_to admin_site_update_manager_path(@site), :class => active_for_action('sites', 'update_manager') do %><span><i class="icon-refresh"></i></span><%end%></li>
<!-- <li title="System Info"><a href="/orbit_4.0.1/admin/system_info/index.shtml?sidebarNavList=8&amp;subNavBlockList=0"><span><i class="icons-info-2"></i></span></a></li> <li title="<%= t("site.system_preference") %>"><%= link_to admin_site_system_info_path(@site), :class => active_for_action('sites', 'system_info') do %><span><i class="icons-info-2"></i></span><%end%></li>
--> </ul> </ul>
</div> </div>
<div class="sub-nav-arrow"></div> <div class="sub-nav-arrow"></div>
</div> </div>

View File

@ -1,47 +0,0 @@
<h1><%= I18n.t("site.system_preference") %></h1>
<ul class="nav nav-tabs" id="myTab">
<li class="active"><a href="#summary" data-toggle="tab"><%= I18n.t("site.system_preference_.tab_summary") %></a></li>
<li><a href="#commits" data-toggle="tab"><%= I18n.t("site.system_preference_.tab_commits") %></a></li>
<li><a href="#backups" data-toggle="tab"><%= I18n.t("site.system_preference_.tab_backups") %></a></li>
<li><a href="#resque_logs" data-toggle="tab"><%= I18n.t("site.system_preference_.tab_logs") %></a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active in" id="summary">
<h2><%= I18n.t("site.system_preference_.summary.disk_space") %>:</h2>
<%= content_tag :p,@site.disk_space.gsub(/\n/,"<br />").html_safe if @site.disk_space %>
<h2><%= I18n.t("site.system_preference_.summary.code_update_at") %>: </h2>
<% @site.system_package_info.each do |index,value| %>
<h2><%= index.titleize %> <%= I18n.t("site.system_preference_.summary.version") %>:</h2>
<%= content_tag :p,value %>
<% end %>
<h2><%= I18n.t("site.system_preference_.summary.weekness_report") %>:<%= '' %></h2>
</div>
<div class="tab-pane" id="commits">
<% if @git_commit_list_file %>
<% @git_commit_list_file.lines do |line|%>
<%= line %><br/>
<% end%>
<% else %>
<div class="well"><%= I18n.t("site.system_preference_.summary.no_data") %></div>
<% end %>
</div>
<div class="tab-pane" id="backups">
<%if @db_backup_list_file %>
<% @db_backup_list_file.lines do |line|%>
<%=line %><br/>
<% end %>
<% else %>
<div class="well"><%= I18n.t("site.system_preference_.summary.no_data") %></div>
<% end %>
</div>
<div class="tab-pane" id="resque_logs">
<%if @db_backup_list_file %>
<% @resque_logs_file.lines do |line|%>
<%=line %><br/>
<% end if @resque_logs_file%>
<%else %>
<div class="well"><%= I18n.t("site.system_preference_.summary.no_data") %></div>
<% end %>
</div>
</div>

View File

@ -1,5 +1,159 @@
<%= stylesheet_link_tag "lib/wrap-nav" %>
<%= stylesheet_link_tag "lib/main-list" %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload.css" %>
<%= stylesheet_link_tag "lib/togglebox.css" %>
<%= stylesheet_link_tag "lib/list-check.css" %>
<%= javascript_include_tag "lib/site_set" %>
<%= javascript_include_tag "lib/list-check" %>
<% content_for :side_bar do %> <% content_for :side_bar do %>
<%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('site.settings'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-cog', :side_bar_content => 'admin/sites/side_bar'} %> <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('site.settings'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-cog', :side_bar_content => 'admin/sites/side_bar'} %>
<% end %> <% end %>
system_info.html.erb <form class="form-horizontal main-forms">
<fieldset>
<div class="input-area">
<div class="nav-name"><strong><%= t("preferences.classification") %></strong></div>
<ul class="nav nav-pills language-nav">
<li class="active"><a href="#overview" data-toggle="tab"><%= t("site.system_preference_.tab_summary") %></a></li>
<li><a href="#mail-cron-logs" data-toggle="tab"><%= t("site.system_preference_.tab_send_reminders_log") %></a></li>
</ul>
<div class="tab-content">
<!-- Overview -->
<div id="overview" class="tab-pane fade in active">
<h3 class="muted"><%= t("site.system_preference_.summary.disk_space") %></h3>
<blockquote>
<p>
<%= @disk_free %>
</p>
</blockquote>
<h3 class="muted">Nginx <%= t("site.system_preference_.summary.version") %></h3>
<blockquote>
<p>
<%= @nginx_version %>
</p>
</blockquote>
</span>
<h3 class="muted">MongoDB <%= t("site.system_preference_.summary.version") %></h3>
<blockquote>
<p>
<%= @mongo_version %>
</p>
</blockquote>
<h3 class="muted">Linux <%= t("site.system_preference_.summary.version") %></h3>
<blockquote>
<p>
<%= @linux_version %>
</p>
</blockquote>
</span>
</div>
<!-- Email Log -->
<div id="mail-cron-logs" class="tab-pane fade">
<ul class="nav nav-pills">
<li class="active">
<a href="#send-log" data-toggle="tab"><%= t(:email_log) %></a>
</li>
<li>
<a href="#waiting-sent" data-toggle="tab"><%= t(:email_queue) %></a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane fade in active" id="send-log">
<p class="">
<a href="#" class="btn list-active-btn disabled" data-check-action="list-be-remove" rel="/panel/announcement/back_end/bulletins/delete"><i class="icons-trash"></i></a>
</p>
<table class="table main-list table-striped">
<thead>
<tr>
<th>
<input type="checkbox" class="list-check" name="to_delete[]" value="b" />
</th>
<th><%= t(:sent_date) %></th>
<th><%= t(:subject) %></th>
<th><%= t(:mail_to) %></th>
<th><%= t(:mail_user) %></th>
<th><%= t(:mail_from_app) %></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input type="checkbox" class="list-check" name="to_delete[]" value="b" />
</td>
<td>2014-01-16 17:57</td>
<td>【轉知】國家教育研究院辦理普通高級中學語文及社會領域課綱微調分區公聽會
<div class="quick-edit">
<ul class="nav nav-pills">
<li><a href="#" class="text-error"><%= t(:delete_) %></a></li>
</ul>
</div>
</td>
<td>alluser@tea.ntue.edu.tw</td>
<td>蔣 欣潔</td>
<td>er_email</td>
</tr>
</tbody>
</table>
</div>
<div class="tab-pane fade in" id="waiting-sent">
<p class="">
<a href="#" class="btn list-active-btn disabled" data-check-action="list-be-remove" rel="/panel/announcement/back_end/bulletins/delete"><i class="icons-trash"></i></a>
</p>
<table class="table main-list table-striped">
<thead>
<tr>
<th>
<input type="checkbox" class="list-check" name="to_delete[]" value="b" />
</th>
<th>Sentdate</th>
<th>Subject</th>
<th>Mail To</th>
<th>Mail User</th>
<th>Mail From App</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input type="checkbox" class="list-check" name="to_delete[]" value="b" />
</td>
<td>2014-01-16 17:57</td>
<td>【轉知】國家教育研究院辦理普通高級中學語文及社會領域課綱微調分區公聽會
<div class="quick-edit">
<ul class="nav nav-pills">
<li><a href="#" class="text-error"><%= t(:delete_) %></a></li>
</ul>
</div>
</td>
<td>alluser@tea.ntue.edu.tw</td>
<td>蔣 欣潔</td>
<td>er_email</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</fieldset>
</form>
<div id="dialog" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="Delete item" aria-hidden="true">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><%= t(:sure?) %></h3>
</div>
<div class="modal-body">
<span class="text-warning text-center"><%= t(:this_action_can_not_be_restore) %></span>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true"><%= t(:close) %></button>
<button class="delete-item btn btn-danger"><%= t(:delete_) %></button>
</div>
</div>

View File

@ -41,7 +41,7 @@
function InsertPreviewImage(){ function InsertPreviewImage(){
if($("iframe").contents().find('.news_image').length){ if($("iframe").contents().find('.news_image').length){
$("iframe").contents().find('.news_image').append("<a href='' target='_blank'><img src='"+preview_img+"' width='320' height='240' /></a>"); $("iframe").contents().find('.news_image').append("<a href='' target='_blank'><img src='"+preview_img+"' width='320' /></a>");
}else{ }else{
setTimeout(InsertPreviewImage,1000); setTimeout(InsertPreviewImage,1000);
} }

View File

@ -192,6 +192,8 @@ en:
link: Editing link link: Editing link
page: Editing page page: Editing page
email: Email email: Email
email_log: Email Log
email_queue: Waiting to be sent
enable: Enable enable: Enable
enabled_for: Enabled for enabled_for: Enabled for
end: End end: End
@ -274,6 +276,9 @@ en:
setting: Mail settings setting: Mail settings
tls: TLS tls: TLS
user_name: User Name user_name: User Name
mail_from_app: Mail From App
mail_to: Mail To
mail_user: Mail User
manager: Manager manager: Manager
markup: Markup markup: Markup
markup_options: Markup options markup_options: Markup options
@ -424,6 +429,7 @@ en:
index: Index index: Index
summary: Summary summary: Summary
thumbnail: Thumbnail thumbnail: Thumbnail
sent_date: Sent Date
settings: Site Setting settings: Site Setting
site: site:
backend_openness_on: Backend Openness backend_openness_on: Backend Openness
@ -454,6 +460,7 @@ en:
tab_commits: Commits tab_commits: Commits
tab_summary: Summary tab_summary: Summary
tab_logs: Logs tab_logs: Logs
tab_send_reminders_log: Send reminders log
summary: summary:
code_update_at: Code Update histroy code_update_at: Code Update histroy
disk_space: Disk Free disk_space: Disk Free
@ -483,6 +490,7 @@ en:
sub_role: Sub Role sub_role: Sub Role
sub_role_field: Sub Role Field sub_role_field: Sub Role Field
sub_role_info: " Sub Role Info." sub_role_info: " Sub Role Info."
subject: Subject
subtitle: Subtitle subtitle: Subtitle
submit: Submit submit: Submit
submit_approval: Submit approval submit_approval: Submit approval
@ -506,6 +514,7 @@ en:
text: Text text: Text
theme: Theme theme: Theme
themes: Themes themes: Themes
this_action_can_not_be_restore: This action can not be restored, are you sure you want to delete?
title: Title title: Title
to_search: Set as Search Key to_search: Set as Search Key
to_show: Display in frontend to_show: Display in frontend

View File

@ -192,6 +192,8 @@ zh_tw:
link: 編輯連結 link: 編輯連結
page: 編輯頁面 page: 編輯頁面
email: 電子郵件 email: 電子郵件
email_log: 寄送紀錄
email_queue: 待寄送郵件
enable: 開啟 enable: 開啟
enabled_for: 啟用 enabled_for: 啟用
end: 結束 end: 結束
@ -276,6 +278,9 @@ zh_tw:
setting: 電子郵件設定 setting: 電子郵件設定
tls: 電子郵件TLS tls: 電子郵件TLS
user_name: 電子郵件帳號 user_name: 電子郵件帳號
mail_from_app: 寄送模組
mail_to: 收件者
mail_user: 寄件者
manager: 管理者 manager: 管理者
markup: 輸入模式 markup: 輸入模式
markup_options: 標註選項 markup_options: 標註選項
@ -426,6 +431,7 @@ zh_tw:
index: 檢索 index: 檢索
summary: 摘要 summary: 摘要
thumbnail: 縮圖 thumbnail: 縮圖
sent_date: 寄送日期
settings: 基本設定 settings: 基本設定
site: site:
frontend_closed: 前台關閉? frontend_closed: 前台關閉?
@ -456,6 +462,7 @@ zh_tw:
tab_commits: 程式版本 tab_commits: 程式版本
tab_summary: 總覽 tab_summary: 總覽
tab_logs: 排程工作日誌 tab_logs: 排程工作日誌
tab_send_reminders_log: 寄送提醒紀錄
summary: summary:
code_update_at: 程式更新紀錄 code_update_at: 程式更新紀錄
disk_space: 硬碟空間 disk_space: 硬碟空間
@ -485,6 +492,7 @@ zh_tw:
sub_role: 子身份 sub_role: 子身份
sub_role_field: 子身份欄位 sub_role_field: 子身份欄位
sub_role_info: 子身份資料 sub_role_info: 子身份資料
subject: 主題
subtitle: 副標題 subtitle: 副標題
submit: 送出 submit: 送出
submit_approval: 送出已核准 submit_approval: 送出已核准
@ -508,6 +516,7 @@ zh_tw:
text: 內文 text: 內文
theme: 套用頁面樣式 theme: 套用頁面樣式
themes: 主題 themes: 主題
this_action_can_not_be_restore: 刪除後將無法還原,您確定要刪除嗎?
title: 標題 title: 標題
to_search: 加入搜尋條件 to_search: 加入搜尋條件
to_show: 是否顯示於前台 to_show: 是否顯示於前台

View File

@ -10,6 +10,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
end end
def preview def preview
params['bulletin']['image'] = nil
bulletin = Bulletin.new params bulletin = Bulletin.new params
@preview_obj = bulletin.to_preview @preview_obj = bulletin.to_preview
@preview_obj.save @preview_obj.save