Module manager optimize for user experience and some language translation

This commit is contained in:
Manson Wang 2014-01-27 18:58:47 +08:00
parent 94eeb1c52e
commit dc9aac5785
5 changed files with 80 additions and 28 deletions

View File

@ -25,8 +25,6 @@ class Admin::ModuleStoreController < OrbitBackendController
file.puts @download_link file.puts @download_link
end end
end end
# %w(bundle install)
# site_restart
Bundler.with_clean_env { `cd #{Rails.root} && bundle install && touch tmp/restart.txt` } Bundler.with_clean_env { `cd #{Rails.root} && bundle install && touch tmp/restart.txt` }
redirect_to admin_module_store_path redirect_to admin_module_store_path
end end
@ -36,7 +34,7 @@ class Admin::ModuleStoreController < OrbitBackendController
extensions = File.new("#{Rails.root}/downloaded_extensions.rb", "r") extensions = File.new("#{Rails.root}/downloaded_extensions.rb", "r")
while (extension = extensions.gets) while (extension = extensions.gets)
if params[:module].any? { |mod| extension.include?(mod)} if params[:module].any? { |mod| extension.include?("gem '"+mod+"'")}
@mod = ModuleApp.where(:key=>extension.split("'")[1]).first @mod = ModuleApp.where(:key=>extension.split("'")[1]).first
if extension.start_with?("# ") if extension.start_with?("# ")
temp_extensions << extension.gsub("# ","") temp_extensions << extension.gsub("# ","")
@ -54,7 +52,7 @@ class Admin::ModuleStoreController < OrbitBackendController
temp_extensions.close temp_extensions.close
FileUtils.mv("#{Rails.root}/extensions.tmp.rb","#{Rails.root}/downloaded_extensions.rb") FileUtils.mv("#{Rails.root}/extensions.tmp.rb","#{Rails.root}/downloaded_extensions.rb")
Bundler.with_clean_env { `cd #{Rails.root} && bundle install && touch tmp/restart.txt` }
render :text => "true" render :text => "true"
end end
@ -63,7 +61,7 @@ class Admin::ModuleStoreController < OrbitBackendController
extensions = File.new("#{Rails.root}/downloaded_extensions.rb", "r") extensions = File.new("#{Rails.root}/downloaded_extensions.rb", "r")
while (extension = extensions.gets) while (extension = extensions.gets)
if extension.include?(params[:module]) if extension.include?("gem '"+params[:module]+"'")
@mod = ModuleApp.where(:key=>extension.split("'")[1]).first @mod = ModuleApp.where(:key=>extension.split("'")[1]).first
toggle_item(@mod , false) toggle_item(@mod , false)
temp_extensions << "" temp_extensions << ""
@ -76,12 +74,11 @@ class Admin::ModuleStoreController < OrbitBackendController
temp_extensions.close temp_extensions.close
FileUtils.mv("#{Rails.root}/extensions.tmp.rb","#{Rails.root}/downloaded_extensions.rb") FileUtils.mv("#{Rails.root}/extensions.tmp.rb","#{Rails.root}/downloaded_extensions.rb")
Bundler.with_clean_env { `cd #{Rails.root} && bundle install && touch tmp/restart.txt` }
render :text => "true" render :text => "true"
end end
def restart_server def restart_server
Bundler.with_clean_env { `cd #{Rails.root} && bundle install && touch tmp/restart.txt` }
render :text => "true" render :text => "true"
end end

View File

@ -133,8 +133,7 @@ class Admin::SitesController < OrbitBackendController
result = "failed" result = "failed"
else else
result = "success" result = "success"
%x{bundle install} Bundler.with_clean_env { `cd #{Rails.root} && bundle install && touch tmp/restart.txt` }
%x{touch tmp/restart.txt}
end end
%x(git stash pop) unless need_stash %x(git stash pop) unless need_stash

View File

@ -111,7 +111,23 @@
text-align: center; text-align: center;
z-index: 1050; z-index: 1050;
margin: 0 auto; margin: 0 auto;
padding: 10px 0; padding: 20px 0;
}
#delete_confirm_wrap{
display: none;
position: absolute;
width: 93%;
top: 30%;
z-index: 1045;
}
#delete_confirm_wrap .alert{
width: 260px;
text-align: left;
padding: 20px;
font-size: 14px;
line-height: 32px;
} }
.modal-backdrop{ .modal-backdrop{
@ -132,6 +148,20 @@
</div> </div>
</div> </div>
<div id="delete_confirm_wrap">
<div class="alert alert-error row-fluid">
<div id="module_icon" class="span3"></div>
<div class="span9">
<h4>Are you sure?</h4>
Delete module <b><span id="module_title"></span></b>
</div>
<div class="span12">
<button id="delete_module_btn" class="btn btn-danger"><i class="icon-check"></i> <%= t(:yes_) %></button>
<button id="cancel_btn" class="btn pull-right"><%= t(:cancel) %></button>
</div>
</div>
</div>
<div class="container row-fluid"> <div class="container row-fluid">
<div class="span4"> <div class="span4">
@ -144,7 +174,7 @@
</table> </table>
</div> </div>
<div class="pannel-footer"> <div class="pannel-footer">
<button id="apply_change_btn" onclick="apply_change();" class="btn btn-primary btn-small pull-right">Appy Change</button> <button id="apply_change_btn" onclick="apply_change();" class="btn btn-primary btn-small pull-right"><%= t(:apply_change) %></button>
</div> </div>
</div> </div>
</div> </div>
@ -158,7 +188,6 @@
<thead> <thead>
<tr class="sort-header"> <tr class="sort-header">
<th class="first"><a href="#">Module Title</a></th> <th class="first"><a href="#">Module Title</a></th>
<th data-hide="phone" class="active span3">Date of purchase</th>
<th data-hide="all" class="active"><a href="#">Description</a></th> <th data-hide="all" class="active"><a href="#">Description</a></th>
<th class="span2">Active</th> <th class="span2">Active</th>
</tr> </tr>
@ -173,7 +202,6 @@
<h5 class="mt_title"><span><%=link_to extension["title"], admin_module_store_show_path(extension["_slugs"][0])%></span></h5> <h5 class="mt_title"><span><%=link_to extension["title"], admin_module_store_show_path(extension["_slugs"][0])%></span></h5>
<p class="mt_dev muted"><%=extension["author"]%></p> <p class="mt_dev muted"><%=extension["author"]%></p>
</td> </td>
<td class="detail-row">2013/07/12</td>
<td> <td>
<%= extension["description"].html_safe%> <%= link_to 'Read More', admin_module_store_show_path(extension["_slugs"][0]) %> <%= extension["description"].html_safe%> <%= link_to 'Read More', admin_module_store_show_path(extension["_slugs"][0]) %>
</td> </td>
@ -181,7 +209,7 @@
<% if @module_installed.eql?(true)%> <% if @module_installed.eql?(true)%>
<td class="active">Installed</td> <td class="active">Installed</td>
<% else %> <% else %>
<td class="active"><%= link_to 'Download', admin_module_store_download_path(:id => extension["_slugs"][0]), :class=>"act btn btn-mini btn-success" %></td> <td class="active"><%= link_to t(:install), admin_module_store_download_path(:id => extension["_slugs"][0]), :class=>"act btn btn-success" %></td>
<% end %> <% end %>
</tr> </tr>
<% end %> <% end %>
@ -198,17 +226,40 @@
<script type="text/javascript"> <script type="text/javascript">
var toggle_modules = new Array(); var toggle_modules = new Array();
// var downloaded_extensions = <%= @downloaded_extensions.to_s.html_safe %>;
var extensions = <%= @extensions.to_json.to_s.html_safe %>; var extensions = <%= @extensions.to_json.to_s.html_safe %>;
var module_to_delete;
$.each(extensions,function(){ $.each(extensions,function(){
var module_key = this['key'];
var module_title = this['title'];
if(typeof this['installed']=='undefined') return; if(typeof this['installed']=='undefined') return;
if(this['updated']==false) console.log(this['key']); if(this['updated']==false) console.log(this['key']);
var checked = ""; var checked = "";
if(this['enabled']==true) checked="checked='checked'"; if(this['enabled']==true) checked="checked='checked'";
$("#extensions_table").append("<tr><td width='15%'><i class='icons-"+this['key']+" icon-3x'></i><br/>"+this['title']+"</td><td width='40%'>Version<br/>v"+this['installed_version']+"</td><td><%= t(:active) %><br/><input type='checkbox' class='toggle-check set-sidebar-state' data-disabled='true' "+checked+" onclick='toggle_module(\""+this['key']+"\");'></td><td><button onclick='remove_module(\""+this['key']+"\");' class='btn btn-small btn-danger'><i class='icon-trash'></i> <%= t(:delete_) %></button></td></tr>"); $("#extensions_table").append("<tr><td width='15%'><i class='icons-"+this['key']+" icon-3x'></i><br/>"+this['title']+"</td><td width='40%'>Version<br/>v"+this['installed_version']+"</td><td><%= t(:active) %><br/><input type='checkbox' class='toggle-check set-sidebar-state' data-disabled='true' "+checked+" onclick='toggle_module(\""+this['key']+"\");'></td><td>"+
"<button id='delete_"+this['key']+"' class='btn btn-small btn-danger'><i class='icon-trash'></i> <%= t(:delete_) %></button></td></tr>");
$("#delete_"+this['key']).click(function(){
module_to_delete = module_key;
$("#module_icon").html("<i class='icons-"+module_key+" icon-3x'></i>");
$("#module_title").html(module_title);
$(".modal-backdrop").fadeIn(300,function(){
$("#delete_confirm_wrap").fadeIn(300);
});
});
});
$("#cancel_btn").click(function(){
$("#delete_confirm_wrap").fadeOut(200,function(){
$(".modal-backdrop").fadeOut(100);
});
});
$("#delete_module_btn").click(function(){
$("#delete_confirm_wrap").fadeOut();
remove_module(module_to_delete);
}); });
function toggle_module(module){ function toggle_module(module){
@ -228,8 +279,8 @@
function apply_change(){ function apply_change(){
$(document).scrollTop(0); $(document).scrollTop(0);
$("#module_msg_title").html("Applying Change"); $("#module_msg_title").html("<%= t(:applying_change) %>");
$("#module_msg_content").html("Please wait"); $("#module_msg_content").html("<%= t(:please_wait) %>");
$(".modal-backdrop").fadeIn(300,function(){ $(".modal-backdrop").fadeIn(300,function(){
$("#alert_wrap").fadeIn(300); $("#alert_wrap").fadeIn(300);
@ -238,12 +289,10 @@
toggle_modules = new Array(); toggle_modules = new Array();
$("#apply_change_btn").hide(); $("#apply_change_btn").hide();
$("#module_msg_title").html("Change Applied"); $("#module_msg_title").html("<%= t(:change_applied) %>");
$("#module_msg_content").html("Restarting Server"); $("#module_msg_content").html("<%= t("update_manager_.restart_server") %>");
$.get("<%= admin_module_store_restart_server_path%>",function(){ $.get("<%= admin_module_store_restart_server_path%>",function(){
$("#module_msg_title").html("Change Applied");
$("#module_msg_content").html("Restarting Server");
$("#alert_wrap").delay(2000).fadeOut(300,function(){ $("#alert_wrap").delay(2000).fadeOut(300,function(){
$(".modal-backdrop").fadeOut(); $(".modal-backdrop").fadeOut();
}); });
@ -255,8 +304,8 @@
function remove_module(mod_key){ function remove_module(mod_key){
$(document).scrollTop(0); $(document).scrollTop(0);
$("#module_msg_title").html("Applying Change"); $("#module_msg_title").html("<%= t(:applying_change) %>");
$("#module_msg_content").html("Please wait"); $("#module_msg_content").html("<%= t(:please_wait) %>");
$(".modal-backdrop").fadeIn(300,function(){ $(".modal-backdrop").fadeIn(300,function(){
$("#alert_wrap").fadeIn(300); $("#alert_wrap").fadeIn(300);
@ -265,14 +314,13 @@
toggle_modules = new Array(); toggle_modules = new Array();
$("#apply_change_btn").hide(); $("#apply_change_btn").hide();
$("#module_msg_title").html("Change Applied"); $("#module_msg_title").html("<%= t(:change_applied) %>");
$("#module_msg_content").html("Restarting Server"); $("#module_msg_content").html("<%= t("update_manager_.restart_server") %>");
$.get("<%= admin_module_store_restart_server_path%>",function(){ $.get("<%= admin_module_store_restart_server_path%>",function(){
$("#module_msg_title").html("Change Applied");
$("#module_msg_content").html("Restarting Server");
$("#alert_wrap").delay(2000).fadeOut(300,function(){ $("#alert_wrap").delay(2000).fadeOut(300,function(){
$(".modal-backdrop").fadeOut(); $(".modal-backdrop").fadeOut();
location.reload();
}); });
}); });
}); });

View File

@ -61,6 +61,8 @@ en:
all_plugin_summary: All plugin summary all_plugin_summary: All plugin summary
all_plugins: All plugins all_plugins: All plugins
always_display_title: Always displayed in the title bar always_display_title: Always displayed in the title bar
apply_change: Apply Change
applying_change: Applying Change
app_auth: app_auth:
list_setting_result: Authorization List list_setting_result: Authorization List
assigning_manager: assigning_manager:
@ -111,6 +113,7 @@ en:
categories: Categories categories: Categories
category: Category category: Category
category_auth: Category Authorization category_auth: Category Authorization
change_applied: Change Applied
clear: Clear clear: Clear
close: Close close: Close
content: Content content: Content
@ -358,6 +361,7 @@ en:
phone_number: "Phone Number" phone_number: "Phone Number"
picture: Picture picture: Picture
placeholder: Field Hint placeholder: Field Hint
please_wait: Please Wait
plugins: Plugins plugins: Plugins
postdate: Postdate postdate: Postdate
posted_by: Posted by posted_by: Posted by

View File

@ -61,6 +61,8 @@ zh_tw:
all_plugin_summary: 所有學術資訊摘要 all_plugin_summary: 所有學術資訊摘要
all_plugins: 所有學術資訊 all_plugins: 所有學術資訊
always_display_title: 永遠顯示標題 always_display_title: 永遠顯示標題
apply_change: 套用變更
applying_change: 正在套用變更
app_auth: app_auth:
list_setting_result: 授權列表 list_setting_result: 授權列表
assigning_manager: assigning_manager:
@ -111,6 +113,7 @@ zh_tw:
categories: 類別 categories: 類別
category: 類別 category: 類別
category_auth: 類別授權 category_auth: 類別授權
change_applied: 變更套用完成
clear: 清除 clear: 清除
close: 關閉 close: 關閉
content: 內容 content: 內容
@ -361,6 +364,7 @@ zh_tw:
phone_number: "電話" phone_number: "電話"
picture: 圖片 picture: 圖片
placeholder: 欄位提示文字 placeholder: 欄位提示文字
please_wait: 請稍候
plugins: 學術資訊 plugins: 學術資訊
postdate: 張貼日期 postdate: 張貼日期
posted_by: 張貼人 posted_by: 張貼人