From f744bf266c7ee66ae6382ce9245c8e576f1cc672 Mon Sep 17 00:00:00 2001 From: Manson Wang Date: Fri, 1 Nov 2013 18:45:12 +0800 Subject: [PATCH] Working on dashboard --- .../admin/dashboards_controller.rb | 10 - app/helpers/application_helper.rb | 11 + .../admin/dashboards/_server_loading.erb | 728 +++++++++--------- .../admin/dashboards/_traffic_loading.erb | 101 ++- app/views/admin/dashboards/index.html.erb | 18 +- config/routes.rb | 2 +- 6 files changed, 431 insertions(+), 439 deletions(-) diff --git a/app/controllers/admin/dashboards_controller.rb b/app/controllers/admin/dashboards_controller.rb index e7fd745e8..282d48e15 100644 --- a/app/controllers/admin/dashboards_controller.rb +++ b/app/controllers/admin/dashboards_controller.rb @@ -50,16 +50,6 @@ class Admin::DashboardsController < OrbitBackendController render :json => @usw.uw_diskused_perc.to_s end - def get_month_traffic - result = [] - (0..31).each do |i| - the_day = i.day.ago - visits = Impression.where( created_at: {'$gte' => the_day.beginning_of_day, '$lte' => the_day.end_of_day}).count - result.push({the_day.strftime("%b-%d")=>visits}) - end - render :js => result.to_json - end - protected def get_module_app_count(*args) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f28f15a67..63fd06574 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -242,6 +242,17 @@ module ApplicationHelper display_visitors(created_at: {'$gte' => Date.today.beginning_of_year, '$lte' => Date.today.end_of_year}) end + def get_month_traffic + result = [['Date','Visits']] + (0..30).each do |i| + the_day = i.day.ago + visits = Impression.where( created_at: {'$gte' => the_day.beginning_of_day, '$lte' => the_day.end_of_day}).count + result.push([ the_day.strftime("%b-%d"), visits]) + # result.push({'x'=> i, 'y'=> visits}) + end + result.to_json + end + def display_date_time(object) object.strftime("%Y-%m-%d %H:%M") end diff --git a/app/views/admin/dashboards/_server_loading.erb b/app/views/admin/dashboards/_server_loading.erb index 6ff3fa003..18493cb68 100644 --- a/app/views/admin/dashboards/_server_loading.erb +++ b/app/views/admin/dashboards/_server_loading.erb @@ -2,399 +2,399 @@

- Server Loading + Server Status

-
-
-
+ + +
\ No newline at end of file diff --git a/app/views/admin/dashboards/_traffic_loading.erb b/app/views/admin/dashboards/_traffic_loading.erb index 0dee91c68..204eec484 100644 --- a/app/views/admin/dashboards/_traffic_loading.erb +++ b/app/views/admin/dashboards/_traffic_loading.erb @@ -2,61 +2,58 @@

- Traffic Loading + Monthly Traffic

-
+
\ 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 1d7007916..d05145d93 100644 --- a/app/views/admin/dashboards/index.html.erb +++ b/app/views/admin/dashboards/index.html.erb @@ -1,10 +1,4 @@ - - - - - - - +
@@ -14,11 +8,6 @@ <%= render 'server_loading' %>
-
-
- <%= render 'traffic' %> -
-
@@ -47,6 +36,11 @@ <%= render 'most_visited' %>
+
+
+ <%= render 'traffic' %> +
+
\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index f15898c7a..139bdce66 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -70,7 +70,7 @@ Orbit::Application.routes.draw do get 'get_cpu_usage' get 'get_mem_usage' get 'get_disk_usage' - get 'get_month_traffic' + # get 'get_month_traffic' end end resources :designs do