Dashboard partial implementation
This commit is contained in:
parent
909ca19456
commit
2b03263fb7
|
@ -5,6 +5,35 @@ class Admin::DashboardsController < ApplicationController
|
|||
# before_filter :is_admin?
|
||||
|
||||
def index
|
||||
@module_app_contents, @module_app_contents_total = get_module_app_count('bulletin', 'news_bulletin', 'page_context', 'web_link')
|
||||
@recent_updated = get_recently_updated('bulletin', 'news_bulletin', 'page_context', 'web_link')
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def get_module_app_count(*args)
|
||||
a = {}
|
||||
total = 0
|
||||
args.each do |module_app|
|
||||
module_app_class = module_app.classify.constantize
|
||||
count = module_app_class.count
|
||||
a.merge!(module_app => count)
|
||||
total += count
|
||||
end
|
||||
[a.sort {|a,b| b[1]<=>a[1]}, total]
|
||||
end
|
||||
|
||||
def get_recently_updated(*args)
|
||||
a = {}
|
||||
args.each do |module_app|
|
||||
module_app_class = module_app.classify.constantize
|
||||
objects = module_app_class.order_by(:updated_at, :desc).limit(10)
|
||||
objects.each do |object|
|
||||
a.merge!(object => object.updated_at)
|
||||
end
|
||||
end
|
||||
sorted_objects = a.sort {|a,b| b[1]<=>a[1]}
|
||||
sorted_objects[0..9]
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
module Admin::DashboardHelper
|
||||
|
||||
def get_link(title)
|
||||
case title
|
||||
when 'bulletin'
|
||||
panel_announcement_back_end_bulletins_path
|
||||
when 'news_bulletin'
|
||||
panel_news_back_end_news_bulletins_path
|
||||
when'page_context'
|
||||
panel_page_content_back_end_page_contexts_path
|
||||
when'web_link'
|
||||
panel_web_resource_back_end_web_links_path
|
||||
end
|
||||
end
|
||||
|
||||
def get_link_to_object(object)
|
||||
case object._type.underscore
|
||||
when 'bulletin'
|
||||
panel_announcement_back_end_bulletin_path(object)
|
||||
when 'news_bulletin'
|
||||
panel_news_back_end_news_bulletin_path(object)
|
||||
when'page_context'
|
||||
panel_page_content_back_end_page_context_path(object)
|
||||
when'web_link'
|
||||
panel_web_resource_back_end_web_link_path(object)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,8 +1,8 @@
|
|||
<div id="isotope">
|
||||
<div class="item element">
|
||||
<h3><i class="icons-content"></i><a href=""><%= t(:content) %></a></h3>
|
||||
<div class="detail w-a h-b">
|
||||
<p class="totle"><span><%= t(:all_content) %></span>9,517</p>
|
||||
<h3><i class="icons-content"></i><%= t(:content) %></h3>
|
||||
<div class="detail w-a h-a">
|
||||
<p class="totle"><span><%= t(:all_content) %></span><%= @module_app_contents_total %></p>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -23,46 +23,12 @@
|
|||
<div class="overview">
|
||||
<table class="table table-striped">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>公告</td>
|
||||
<td class="span2">2,304</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>新聞</td>
|
||||
<td class="span2">783</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>連結</td>
|
||||
<td class="span2">45</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>連結</td>
|
||||
<td class="span2">62</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>連結</td>
|
||||
<td class="span2">52</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>新聞</td>
|
||||
<td class="span2">20</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>公告</td>
|
||||
<td class="span2">41</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>公告</td>
|
||||
<td class="span2">37</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>公告</td>
|
||||
<td class="span2">41</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>公告</td>
|
||||
<td class="span2">20</td>
|
||||
</tr>
|
||||
<% @module_app_contents.each do |module_app_content| %>
|
||||
<tr>
|
||||
<td><%= link_to t("dashboard.#{module_app_content[0]}"), get_link(module_app_content[0]) %></td>
|
||||
<td class="span2"><%= module_app_content[1] %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
@ -70,7 +36,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="item element">
|
||||
<!-- <div class="item element">
|
||||
<h3><i class="icons-member"></i><a href=""><%= t(:member) %></a></h3>
|
||||
<div class="detail w-a h-a">
|
||||
<p class="totle"><span><%= t(:all_member) %></span>2,217</p>
|
||||
|
@ -211,7 +177,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="item element">
|
||||
<h3><i class="icons-"></i><a href=""><%= t(:referral_in_links) %></a></h3>
|
||||
<div class="detail w-a h-a">
|
||||
|
@ -283,7 +249,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="item element">
|
||||
<!-- <div class="item element">
|
||||
<h3><i class="icons-"></i><a href=""><%= t(:most_visited_page) %></a></h3>
|
||||
<div class="detail noStatistics w-b h-a">
|
||||
<table class="table table-striped">
|
||||
|
@ -460,7 +426,6 @@
|
|||
<div class="item element">
|
||||
<h3><i class="icons-"></i><a href=""><%= t(:site_info) %></a></h3>
|
||||
<div class="detail noStatistics w-b h-a">
|
||||
<!--<p class="totle"><span><%= t(:statistics) %></span>9,517</p>-->
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -515,11 +480,10 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="item element">
|
||||
<h3><i class="icons-"></i><a href=""><%= t(:recent_update) %></a></h3>
|
||||
<div class="detail noStatistics w-a h-a">
|
||||
<!--<p class="totle"><span><%= t(:statistics) %></span>9,517</p>-->
|
||||
<div class="detail noStatistics w-b h-a">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -540,46 +504,12 @@
|
|||
<div class="overview">
|
||||
<table class="table table-striped">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Title1</td>
|
||||
<td class="span2">公告</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Title2</td>
|
||||
<td class="span2">頁面</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Title3</td>
|
||||
<td class="span2">頁面</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Title4</td>
|
||||
<td class="span2">公告</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Title5</td>
|
||||
<td class="span2">公告</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Title6</td>
|
||||
<td class="span2">頁面</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Title7</td>
|
||||
<td class="span2">頁面</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Title8</td>
|
||||
<td class="span2">公告</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Title9</td>
|
||||
<td class="span2">頁面</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Title10</td>
|
||||
<td class="span2">公告</td>
|
||||
</tr>
|
||||
<% @recent_updated.each do |object| %>
|
||||
<tr>
|
||||
<td><%= link_to ((object[0].title[I18n.locale] rescue nil) || (object[0].page.i18n_variable[I18n.locale] rescue nil)), get_link_to_object(object[0]) %></td>
|
||||
<td class="span2"><%= link_to t("dashboard.#{object[0]._type.underscore}"), get_link(object[0]._type.underscore) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
@ -243,6 +243,12 @@ en:
|
|||
panel: User panel
|
||||
role: User role
|
||||
|
||||
dashboard:
|
||||
bulletin: Announcement
|
||||
news_bulletin: News
|
||||
page_context: Page
|
||||
web_link: Link
|
||||
|
||||
panel:
|
||||
|
||||
modal:
|
||||
|
|
|
@ -238,6 +238,12 @@ zh_tw:
|
|||
panel: 用戶面板
|
||||
role: 用戶身份
|
||||
|
||||
dashboard:
|
||||
bulletin: 公告
|
||||
news_bulletin: 新聞
|
||||
page_context: 頁面
|
||||
web_link: 鏈接
|
||||
|
||||
panel:
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue