diff --git a/app/controllers/admin/dashboards_controller.rb b/app/controllers/admin/dashboards_controller.rb index e874b6638..8ecb8952d 100644 --- a/app/controllers/admin/dashboards_controller.rb +++ b/app/controllers/admin/dashboards_controller.rb @@ -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 diff --git a/app/views/admin/dashboards/_all_content.html.erb b/app/views/admin/dashboards/_all_content.html.erb new file mode 100644 index 000000000..c0ad1a6af --- /dev/null +++ b/app/views/admin/dashboards/_all_content.html.erb @@ -0,0 +1,29 @@ +
+

+ + + <%= t(:all_content) %> +

+
+
+ + + + + + + + + <% @module_app_contents.each do |module_app_content| %> + + + + + <% end %> + +
<%= t(:module) %><%= t(:quantity) %>
<%= link_to t("dashboard.#{module_app_content[0]}"), get_link(module_app_content[0]) %><%= module_app_content[1] %>
+ +
\ No newline at end of file diff --git a/app/views/admin/dashboards/_most_visited.html.erb b/app/views/admin/dashboards/_most_visited.html.erb new file mode 100644 index 000000000..c5c435f70 --- /dev/null +++ b/app/views/admin/dashboards/_most_visited.html.erb @@ -0,0 +1,31 @@ +
+

+ + + <%= t(:most_visited_page) %> +

+
+
+ + + + + + + + + + <% @most_visited.each do |object| %> + + + + + + <% end %> + +
<%= t(:title) %><%= t(:module) %><%= t(:hits) %>
<%= link_to ((object[0].title rescue nil) || (object[0].page.title rescue nil)), get_link_to_object(object[0]) %><%= link_to t("dashboard.#{object[0].class.to_s.underscore}"), get_link(object[0].class.to_s.underscore) %><%= object[1] %>
+ +
\ No newline at end of file diff --git a/app/views/admin/dashboards/_recent_update.html.erb b/app/views/admin/dashboards/_recent_update.html.erb new file mode 100644 index 000000000..6e282cefc --- /dev/null +++ b/app/views/admin/dashboards/_recent_update.html.erb @@ -0,0 +1,29 @@ +
+

+ + + <%= t(:recent_update) %> +

+
+
+ + + + + + + + + <% @recent_updated.each do |object| %> + + + + + <% end %> + +
<%= t(:title) %><%= t(:module) %>
<%= link_to ((object[0].title rescue nil) || (object[0].page.title rescue nil)), get_link_to_object(object[0]) %><%= link_to t("dashboard.#{object[0].class.to_s.underscore}"), get_link(object[0].class.to_s.underscore) %>
+ +
\ No newline at end of file diff --git a/app/views/admin/dashboards/_traffic.html.erb b/app/views/admin/dashboards/_traffic.html.erb new file mode 100644 index 000000000..8667a6eed --- /dev/null +++ b/app/views/admin/dashboards/_traffic.html.erb @@ -0,0 +1,35 @@ +
+

+ + + <%= t(:traffic) %> +

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
<%= t(:total_visitors) %><%= display_visitors %>
<%= t(:visitors_today) %><%= display_visitors_today %>
<%= t(:visitors_this_week) %><%= display_visitors_this_week %>
<%= t(:visitors_this_month) %><%= display_visitors_this_month %>
<%= t(:visitors_this_year) %><%= display_visitors_this_year %>
+
\ No newline at end of file diff --git a/app/views/admin/dashboards/index.html.erb b/app/views/admin/dashboards/index.html.erb index beaf9fe60..b526b941c 100644 --- a/app/views/admin/dashboards/index.html.erb +++ b/app/views/admin/dashboards/index.html.erb @@ -1,233 +1,29 @@ - - - - - -
-
-
-
-
-

- - - <%= t(:recent_update) %> -

-
-
- - - - - - - - - <% @recent_updated.each do |object| %> - - - - - <% end %> - -
<%= t(:title) %><%= t(:module) %>
<%= link_to ((object[0].title rescue nil) || (object[0].page.title rescue nil)), get_link_to_object(object[0]) %><%= link_to t("dashboard.#{object[0].class.to_s.underscore}"), get_link(object[0].class.to_s.underscore) %>
- -
-
-
-
-

- - - <%= t(:all_content) %> -

-
-
- - - - - - - - - <% @module_app_contents.each do |module_app_content| %> - - - - - <% end %> - -
<%= t(:module) %><%= t(:quantity) %>
<%= link_to t("dashboard.#{module_app_content[0]}"), get_link(module_app_content[0]) %><%= module_app_content[1] %>
- -
-
-
-
-
-
-
-

- - - Event -

-
-
- 23/12/2012 -

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore.

- 23/02/2012 -

Lorem ipsum dolor sit amet dolore.

- 13/02/2012 -

Lorem ipsum dolor sit amet dolore.

- 13/02/2012 -

Lorem ipsum dolor sit amet dolore.

- 13/02/2012 -

Lorem ipsum dolor sit amet dolore.

-
-
-
-
-

- - - Most Visited Page -

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ModuleQuantity
Page215
Announcement145
Link73
431
565
- -
-
+
+
+
+
+ <%= render 'recent_update' %>
-
\ No newline at end of file +
+
+ <%= render 'all_content' %> +
+
+ +
+
+
+
+ <%= render 'traffic' %> +
+
+
+
+ <%= render 'most_visited' %> +
+
+
+ + \ No newline at end of file diff --git a/app/views/admin/dashboards/reload.js.erb b/app/views/admin/dashboards/reload.js.erb new file mode 100644 index 000000000..ded160b32 --- /dev/null +++ b/app/views/admin/dashboards/reload.js.erb @@ -0,0 +1 @@ +$("#<%= div_id %>").html("<%= j render div_id %>") \ No newline at end of file diff --git a/config/locales/new_ui.en.yml b/config/locales/new_ui.en.yml index 279be7fa8..24c843dc6 100644 --- a/config/locales/new_ui.en.yml +++ b/config/locales/new_ui.en.yml @@ -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: diff --git a/config/routes.rb b/config/routes.rb index c7dfbab9a..8052d7af6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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' diff --git a/lib/orbit_app/helper/side_bar_renderer.rb b/lib/orbit_app/helper/side_bar_renderer.rb index e58af3994..9fbbb78fc 100644 --- a/lib/orbit_app/helper/side_bar_renderer.rb +++ b/lib/orbit_app/helper/side_bar_renderer.rb @@ -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|