Side bar icons

Dashboard completed with pagination
This commit is contained in:
chris 2013-05-03 14:58:45 +08:00
parent f9fda13879
commit a4aef30a9c
10 changed files with 187 additions and 236 deletions

View File

@ -12,6 +12,27 @@ class Admin::DashboardsController < OrbitBackendController
@most_visited = get_most_visited('bulletin', 'page_context')
end
def reload_all_content
@module_app_contents, @module_app_contents_total = get_module_app_count('bulletin', 'page_context', 'web_link')
respond_to do |format|
format.js { render 'reload', locals: {div_id: 'all_content'} }
end
end
def reload_most_visited
@most_visited = get_most_visited('bulletin', 'page_context')
respond_to do |format|
format.js { render 'reload', locals: {div_id: 'most_visited'} }
end
end
def reload_recent_update
@recent_updated = get_recently_updated('bulletin', 'page_context', 'web_link')
respond_to do |format|
format.js { render 'reload', locals: {div_id: 'recent_update'} }
end
end
protected
def get_module_app_count(*args)
@ -23,7 +44,7 @@ class Admin::DashboardsController < OrbitBackendController
a.merge!(module_app => count)
total += count
end
[a.sort {|a,b| b[1]<=>a[1]}, total]
[Kaminari.paginate_array(a.sort {|a,b| b[1]<=>a[1]}).page(params[:page]).per(5), total]
end
def get_recently_updated(*args)
@ -37,20 +58,21 @@ class Admin::DashboardsController < OrbitBackendController
end
sorted_objects = a.sort {|a,b| b[1]<=>a[1]}
sorted_objects[0..19]
Kaminari.paginate_array(sorted_objects).page(params[:page_recent]).per(5)
Kaminari.paginate_array(sorted_objects).page(params[:page]).per(5)
end
def get_most_visited(*args)
a = {}
args.each do |module_app|
module_app_class = module_app.classify.constantize
objects = module_app_class.order_by(:view_count, :desc).limit(10)
objects = module_app_class.order_by(:view_count, :desc).limit(20)
objects.each do |object|
a.merge!(object => object.view_count) if object.view_count > 0 && (!object.archived rescue true)
end
end
sorted_objects = a.sort {|a,b| b[1]<=>a[1]}
sorted_objects[0..9]
sorted_objects[0..19]
Kaminari.paginate_array(sorted_objects).page(params[:page]).per(5)
end
end

View File

@ -0,0 +1,29 @@
<div class="box-header">
<h2>
<i class="icons-book-2"></i>
<span class="break"></span>
<%= t(:all_content) %>
</h2>
</div>
<div class="box-content">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th><%= t(:module) %></th>
<th class="span1"><%= t(:quantity) %></th>
</tr>
</thead>
<tbody>
<% @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><%= module_app_content[1] %></td>
</tr>
<% end %>
</tbody>
</table>
<ul class="pager">
<li><%= link_to_previous_page @module_app_contents, t(:previous), params: {controller: 'admin/dashboards', action: 'reload_all_content'}, remote: true %></li>
<li><%= link_to_next_page @module_app_contents, t(:next), params: {controller: 'admin/dashboards', action: 'reload_all_content'}, remote: true %></li>
</ul>
</div>

View File

@ -0,0 +1,31 @@
<div class="box-header">
<h2>
<i class="icons-trophy"></i>
<span class="break"></span>
<%= t(:most_visited_page) %>
</h2>
</div>
<div class="box-content">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th><%= t(:title) %></th>
<th class="span2"><%= t(:module) %></th>
<th class="span1"><%= t(:hits) %></th>
</tr>
</thead>
<tbody>
<% @most_visited.each do |object| %>
<tr>
<td><%= link_to ((object[0].title rescue nil) || (object[0].page.title rescue nil)), get_link_to_object(object[0]) %></td>
<td><%= link_to t("dashboard.#{object[0].class.to_s.underscore}"), get_link(object[0].class.to_s.underscore) %></td>
<td><%= object[1] %></td>
</tr>
<% end %>
</tbody>
</table>
<ul class="pager">
<li><%= link_to_previous_page @most_visited, t(:previous), params: {controller: 'admin/dashboards', action: 'reload_most_visited'}, remote: true %></li>
<li><%= link_to_next_page @most_visited, t(:next), params: {controller: 'admin/dashboards', action: 'reload_most_visited'}, remote: true %></li>
</ul>
</div>

View File

@ -0,0 +1,29 @@
<div class="box-header">
<h2>
<i class="icons-cycle"></i>
<span class="break"></span>
<%= t(:recent_update) %>
</h2>
</div>
<div class="box-content">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th><%= t(:title) %></th>
<th class="span2"><%= t(:module) %></th>
</tr>
</thead>
<tbody>
<% @recent_updated.each do |object| %>
<tr>
<td><%= link_to ((object[0].title rescue nil) || (object[0].page.title rescue nil)), get_link_to_object(object[0]) %></td>
<td><%= link_to t("dashboard.#{object[0].class.to_s.underscore}"), get_link(object[0].class.to_s.underscore) %></td>
</tr>
<% end %>
</tbody>
</table>
<ul class="pager">
<li><%= link_to_previous_page @recent_updated, t(:previous), params: {controller: 'admin/dashboards', action: 'reload_recent_update'}, remote: true %></li>
<li><%= link_to_next_page @recent_updated, t(:next), params: {controller: 'admin/dashboards', action: 'reload_recent_update'}, remote: true %></li>
</ul>
</div>

View File

@ -0,0 +1,35 @@
<div class="box-header">
<h2>
<i class="icons-book-2"></i>
<span class="break"></span>
<%= t(:traffic) %>
</h2>
</div>
<div class="box-content">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th><%= t(:total_visitors) %></th>
<th class="span1"><%= display_visitors %></th>
</tr>
</thead>
<tbody>
<tr>
<td><%= t(:visitors_today) %></td>
<td><%= display_visitors_today %></td>
</tr>
<tr>
<td><%= t(:visitors_this_week) %></td>
<td><%= display_visitors_this_week %></td>
</tr>
<tr>
<td><%= t(:visitors_this_month) %></td>
<td><%= display_visitors_this_month %></td>
</tr>
<tr>
<td><%= t(:visitors_this_year) %></td>
<td><%= display_visitors_this_year %></td>
</tr>
</tbody>
</table>
</div>

View File

@ -1,233 +1,29 @@
<!-- <div id="isotope">
<div class="item element">
<h3><i class="icons-airplane"></i><%= t(:traffic) %></h3>
<div class="detail w-a h-a">
<p class="totle"><span><%= t(:total_visitors) %></span><%= display_visitors %></p>
<table class="table table-striped">
<thead>
<tr>
<th><%= t(:item) %></th>
<th class="span2"><%= t(:data) %></th>
</tr>
</thead>
</table>
<div class="detal-list my_scroll">
<div class="scrollbar">
<div class="track">
<div class="thumb">
<div class="end"></div>
</div>
</div>
</div>
<div class="viewport">
<div class="overview">
<table class="table table-striped">
<tbody>
<tr>
<td><%= t(:visitors_today) %></td>
<td><%= display_visitors_today %></td>
</tr>
<tr>
<td><%= t(:visitors_this_week) %></td>
<td><%= display_visitors_this_week %></td>
</tr>
<tr>
<td><%= t(:visitors_this_month) %></td>
<td><%= display_visitors_this_month %></td>
</tr>
<tr>
<td><%= t(:visitors_this_year) %></td>
<td><%= display_visitors_this_year %></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="item element">
<h3><i class="icons-trophy"></i><%= t(:most_visited_page) %></h3>
<div class="detail noStatistics w-b h-a">
<table class="table table-striped">
<thead>
<tr>
<th><%= t(:title) %></th>
<th class="span2"><%= t(:module) %></th>
<th class="span2"><%= t(:hits) %></th>
</tr>
</thead>
</table>
<div class="detal-list my_scroll">
<div class="scrollbar">
<div class="track">
<div class="thumb">
<div class="end"></div>
</div>
</div>
</div>
<div class="viewport">
<div class="overview">
<table class="table table-striped">
<tbody>
<% @most_visited.each do |object| %>
<tr>
<td><%= link_to ((object[0].title rescue nil) || (object[0].page.title rescue nil)), get_link_to_object(object[0]) %></td>
<td class="span2"><%= link_to t("dashboard.#{object[0].class.to_s.underscore}"), get_link(object[0].class.to_s.underscore) %></td>
<td class="span2"><%= object[1] %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div> -->
<section id="main-wrap">
<div class="wrap-inner initial">
<div class="row-fluid">
<div class="box span8">
<div class="box-header">
<h2>
<i class="icons-cycle"></i>
<span class="break"></span>
<%= t(:recent_update) %>
</h2>
</div>
<div class="box-content">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th><%= t(:title) %></th>
<th class="span2"><%= t(:module) %></th>
</tr>
</thead>
<tbody>
<% @recent_updated.each do |object| %>
<tr>
<td><%= link_to ((object[0].title rescue nil) || (object[0].page.title rescue nil)), get_link_to_object(object[0]) %></td>
<td><%= link_to t("dashboard.#{object[0].class.to_s.underscore}"), get_link(object[0].class.to_s.underscore) %></td>
</tr>
<% end %>
</tbody>
</table>
<ul class="pager">
<li><a href="#">Previous</a></li>
<li><a href="#">Next</a></li>
</ul>
<div id='recent_update'>
<%= render 'recent_update' %>
</div>
</div>
<div class="box span4">
<div class="box-header">
<h2>
<i class="icons-book-2"></i>
<span class="break"></span>
<%= t(:all_content) %>
</h2>
</div>
<div class="box-content">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th><%= t(:module) %></th>
<th class="span1"><%= t(:quantity) %></th>
</tr>
</thead>
<tbody>
<% @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><%= module_app_content[1] %></td>
</tr>
<% end %>
</tbody>
</table>
<ul class="pager">
<li><a href="#">Previous</a></li>
<li><a href="#">Next</a></li>
</ul>
<div id='all_content'>
<%= render 'all_content' %>
</div>
</div>
</div>
<hr>
<div class="row-fluid">
<div class="box span5">
<div class="box-header">
<h2>
<i class="icons-star"></i>
<span class="break"></span>
Event
</h2>
</div>
<div class="box-content">
<span class="label label-info">23/12/2012</span>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore.</p>
<span class="label label-info">23/02/2012</span>
<p>Lorem ipsum dolor sit amet dolore.</p>
<span class="label label-info">13/02/2012</span>
<p>Lorem ipsum dolor sit amet dolore.</p>
<span class="label label-info">13/02/2012</span>
<p>Lorem ipsum dolor sit amet dolore.</p>
<span class="label label-info">13/02/2012</span>
<p>Lorem ipsum dolor sit amet dolore.</p>
<div class="box span4">
<div id='traffic'>
<%= render 'traffic' %>
</div>
</div>
<div class="box span7">
<div class="box-header">
<h2>
<i class="icons-trophy"></i>
<span class="break"></span>
Most Visited Page
</h2>
</div>
<div class="box-content">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th>Module</th>
<th class="span1">Quantity</th>
</tr>
</thead>
<tbody>
<tr>
<td>Page</td>
<td>215</td>
</tr>
<tr>
<td>Announcement</td>
<td>145</td>
</tr>
<tr>
<td>Link</td>
<td>73</td>
</tr>
<tr>
<td>4</td>
<td>31</td>
</tr>
<tr>
<td>5</td>
<td>65</td>
</tr>
</tbody>
</table>
<ul class="pager">
<li><a href="#">Previous</a></li>
<li><a href="#">Next</a></li>
</ul>
<div class="box span8">
<div id='most_visited'>
<%= render 'most_visited' %>
</div>
</div>
</div>
</div>
</section>
</section>

View File

@ -0,0 +1 @@
$("#<%= div_id %>").html("<%= j render div_id %>")

View File

@ -12,7 +12,9 @@ en:
merge: Merge
new:
tag: New tag
next: Next
no_app: No module
previous: Previous
remove_default: Remove default
select_all: Select all
tag:

View File

@ -53,7 +53,13 @@ Orbit::Application.routes.draw do
resources :ad_images ,:except => [:show,:index]
end
resources :dashboards
resources :dashboards do
collection do
get 'reload_all_content'
get 'reload_most_visited'
get 'reload_recent_update'
end
end
resources :designs do
collection do
get 'upload_package'

View File

@ -10,7 +10,7 @@ module SideBarRenderer
@params = params
@current_user = user
if display?
content_tag :div, class: "sub-nav-block" do
content_tag :div, class: "sub-nav-block #{@icon_class}" do
concat content_tag :h4, I18n.t(@head_label)
concat (content_tag :ul, class: "nav nav-list" do
@context_links.sort_by {| obj | obj.priority}.map{ |link|