From: Michal Fojtik <[email protected]>
---
src/app/controllers/dashboard_controller.rb | 24 +----
src/app/helpers/dashboard_helper.rb | 40 +++++++
src/app/views/dashboard/monitor.haml | 157 +++++++++++++++++++++++++++
src/app/views/layouts/aggregator.haml | 2 +-
4 files changed, 202 insertions(+), 21 deletions(-)
create mode 100644 src/app/views/dashboard/monitor.haml
diff --git a/src/app/controllers/dashboard_controller.rb
b/src/app/controllers/dashboard_controller.rb
index 5a83efb..94c0713 100644
--- a/src/app/controllers/dashboard_controller.rb
+++ b/src/app/controllers/dashboard_controller.rb
@@ -20,14 +20,9 @@
# Likewise, all the methods added will be available for all controllers.
class DashboardController < ApplicationController
- layout :layout
before_filter :require_user
before_filter :get_nav_items, :only => [:index]
- def layout
- return "dashboard" unless ajax?
- end
-
def ajax?
return params[:ajax] == "true"
end
@@ -63,22 +58,11 @@ class DashboardController < ApplicationController
end
end
- def index
- # FIXME filter to just those that the user has access to
- @cloud_accounts = CloudAccount.find(:all)
-
- # FIXME remove general role based permission check, replace w/
- # more granular / per-permission-object permission checks on the
- # dashboard in the future (here and in dashboard views)
- @is_admin = @current_user.permissions.collect { |p| p.role }.
- find { |r| r.name == "Administrator" }
+ def monitor
+ end
- @hide_getting_started = true
- #...@hide_getting_started =
cookies["#...@current_user.login}_hide_getting_started"]
- @current_users_pool = Pool.find(:first, :conditions => ['name = ?',
@current_user.login])
- @cloud_accounts = CloudAccount.list_for_user(@current_user,
Privilege::ACCOUNT_VIEW)
- @stats = Instance.get_user_instances_stats(@current_user)
- render :action => :summary
+ def index
+ render :action => 'monitor'
end
def hide_getting_started
diff --git a/src/app/helpers/dashboard_helper.rb
b/src/app/helpers/dashboard_helper.rb
index a56bad4..8980396 100644
--- a/src/app/helpers/dashboard_helper.rb
+++ b/src/app/helpers/dashboard_helper.rb
@@ -19,4 +19,44 @@
# Likewise, all the methods added will be available for all controllers.
module DashboardHelper
+
+ def monitor_quota_value(name, value, unit)
+ name=content_tag 'td', :class => 'first nowrap' do
+ name
+ end
+ value=content_tag 'td' do
+ content_tag 'div', :class => 'percentBlock' do
+ value
+ end
+ end
+ unit=content_tag 'td' do
+ unit
+ end
+ "#{name}#{value}#{unit}"
+ end
+
+ def monitor_bar_value(value, opts={})
+ bar=content_tag 'td' do
+ percent_block=content_tag 'div', :class => 'percentBlock' do
+ # TODO: Count text-indent value correctly here
+ bar_style = "width:#{value}%;text-indent:14%"
+ content_tag 'div', :class => 'percentBlockInner gradGreen', :style =>
bar_style do
+ "#{value}%"
+ end
+ end
+ if opts[:min] and opts[:max]
+ min=content_tag 'div', :class => 'min' do "#{opts[:min]}% Min" ; end
+ max=content_tag 'div', :class => 'min' do "#{opts[:max]}% Max" ; end
+ "#{percent_block}#{min}#{max}"
+ else
+ percent_block
+ end
+ end
+ total=content_tag 'td' do
+ "#{opts[:total]}"
+ end
+ "#{bar}#{total}"
+ end
+
+
end
diff --git a/src/app/views/dashboard/monitor.haml
b/src/app/views/dashboard/monitor.haml
new file mode 100644
index 0000000..b8a574c
--- /dev/null
+++ b/src/app/views/dashboard/monitor.haml
@@ -0,0 +1,157 @@
+%h2 Key Metrics
+%table{ :class => 'noborder' }
+ %thead
+ %tr
+ %th
+ %th{ :colspan => 2 } Aggregate quota
+ %th{ :colspan => 2 } Current usage
+ %th{ :colspan => 2 } Avg: Last 24 hours
+ %th{ :colspan => 2 } Avg: Last month
+ %th{ :colspan => 2 } Avg: Calendar year
+ %tbody
+ %tr
+ =monitor_quota_value "Number of Instances", '2.500', 'Instances'
+ =monitor_bar_value '32', :total => '2351'
+ =monitor_bar_value '32', :total => '2351', :min => 13, :max => 83
+ =monitor_bar_value '32', :total => '2351', :min => 13, :max => 83
+ %tr
+ =monitor_quota_value "System Storage", '1.200', 'Templates'
+ =monitor_bar_value '32', :total => '2351', :min => 13, :max => 83
+ =monitor_bar_value '32', :total => '2351', :min => 13, :max => 83
+ =monitor_bar_value '32', :total => '2351', :min => 13, :max => 83
+ %tr
+ =monitor_quota_value "Operational Storage", '512', 'TB'
+ =monitor_bar_value '32', :total => '2351'
+ =monitor_bar_value '32', :total => '2351', :min => 13, :max => 83
+ =monitor_bar_value '32', :total => '2351', :min => 13, :max => 83
+ %tr
+ =monitor_quota_value "Customed Network Traffic", '824', 'GB'
+ =monitor_bar_value '32', :total => '2351'
+ =monitor_bar_value '32', :total => '2351', :min => 13, :max => 83
+ =monitor_bar_value '32', :total => '2351', :min => 13, :max => 83
+ %tr
+ =monitor_quota_value "Cost per hour", '824', '??'
+ =monitor_bar_value '32', :total => '102'
+ =monitor_bar_value '32', :total => '2351', :min => 13, :max => 83
+ =monitor_bar_value '32', :total => '2351', :min => 13, :max => 83
+
+%h2 Aggregate quality of service
+%img{ :src => '/dev/null', :width => '943', :height => '381'}
+%div{ :class => 'grid_4' }
+ %h4 Show:
+ %ul
+ %li
+ %input{ :type => 'checkbox', :checked => 'checked', :name => 'instances'
}
+ %label{ :for => 'instances' } Instances
+ %li
+ %input{ :type => 'checkbox', :checked => 'checked', :name => 'time_to' }
+ %label{ :for => 'time_to' } Time to
+ %li
+ %input{ :type => 'checkbox', :checked => 'checked', :name =>
'launch_failures' }
+ %label{ :for => 'launch_failures' } Launch failures
+ %li
+ %input{ :type => 'checkbox', :checked => 'checked', :name => 'requests' }
+ %label{ :for => 'requests' } Requests
+ %li
+ %input{ :type => 'checkbox', :checked => 'checked', :name => 'retries' }
+ %label{ :for => 'retries' } Retries
+
+%div{ :class => 'grid_4' }
+ %h4 Set time scale:
+ %ul
+ %li
+ %input{ :type => 'radio', :checked => 'checked', :name => '1' }
+ %label{ :for => '1' } 30 minutes
+ %li
+ %input{ :type => 'radio', :checked => 'checked', :name => '2' }
+ %label{ :for => '2' } 2 hours
+ %li
+ %input{ :type => 'radio', :checked => 'checked', :name => '3' }
+ %label{ :for => '3' } 2 days
+ %li
+ %input{ :type => 'radio', :checked => 'checked', :name => '4' }
+ %label{ :for => '4' } 1 week
+ %li
+ %input{ :type => 'radio', :checked => 'checked', :name => '5' }
+ %label{ :for => '5' } 1 month
+
+%div{ :class => 'grid_8' }
+ %h4 Graph key:
+ %ul
+ %li
+ %img{:src => '/dev/null', :width => '80', :height => '20'}
+ INSTANCES
+ %li
+ %img{:src => '/dev/null', :width => '80', :height => '20'}
+ REQUESTS
+ %li
+ %img{:src => '/dev/null', :width => '80', :height => '20'}
+ TIME TO LAUNCH
+ %li
+ %img{:src => '/dev/null', :width => '80', :height => '20'}
+ FAILURES
+ %li
+ %img{:src => '/dev/null', :width => '80', :height => '20'}
+ RETRIES
+
+%h2 Statistics
+
+%h2 Quality of service provider
+%img{ :src => '/dev/null', :width => '943', :height => '381'}
+%div{ :class => 'grid_4' }
+ %h4 Show:
+ %ul
+ %li
+ %input{ :type => 'checkbox', :checked => 'checked', :name => 'instances'
}
+ %label{ :for => 'instances' } Instances
+ %li
+ %input{ :type => 'checkbox', :checked => 'checked', :name => 'time_to' }
+ %label{ :for => 'time_to' } Time to
+ %li
+ %input{ :type => 'checkbox', :checked => 'checked', :name =>
'launch_failures' }
+ %label{ :for => 'launch_failures' } Launch failures
+ %li
+ %input{ :type => 'checkbox', :checked => 'checked', :name => 'requests' }
+ %label{ :for => 'requests' } Requests
+ %li
+ %input{ :type => 'checkbox', :checked => 'checked', :name => 'retries' }
+ %label{ :for => 'retries' } Retries
+
+%div{ :class => 'grid_4' }
+ %h4 Set time scale:
+ %ul
+ %li
+ %input{ :type => 'radio', :checked => 'checked', :name => '1' }
+ %label{ :for => '1' } 30 minutes
+ %li
+ %input{ :type => 'radio', :checked => 'checked', :name => '2' }
+ %label{ :for => '2' } 2 hours
+ %li
+ %input{ :type => 'radio', :checked => 'checked', :name => '3' }
+ %label{ :for => '3' } 2 days
+ %li
+ %input{ :type => 'radio', :checked => 'checked', :name => '4' }
+ %label{ :for => '4' } 1 week
+ %li
+ %input{ :type => 'radio', :checked => 'checked', :name => '5' }
+ %label{ :for => '5' } 1 month
+
+%div{ :class => 'grid_8' }
+ %h4 Graph key:
+ %ul
+ %li
+ %img{:src => '/dev/null', :width => '80', :height => '20'}
+ INSTANCES
+ %li
+ %img{:src => '/dev/null', :width => '80', :height => '20'}
+ REQUESTS
+ %li
+ %img{:src => '/dev/null', :width => '80', :height => '20'}
+ TIME TO LAUNCH
+ %li
+ %img{:src => '/dev/null', :width => '80', :height => '20'}
+ FAILURES
+ %li
+ %img{:src => '/dev/null', :width => '80', :height => '20'}
+ RETRIES
+
diff --git a/src/app/views/layouts/aggregator.haml
b/src/app/views/layouts/aggregator.haml
index 8430b0a..25ccc11 100644
--- a/src/app/views/layouts/aggregator.haml
+++ b/src/app/views/layouts/aggregator.haml
@@ -49,6 +49,6 @@
= render_navigation(:expand_all => true, :level => 3)
#content.container_16
= render :partial => '/layouts/notification'
- = (yield(:content) or yield) # content is set if we're using a sub
template
+ = yield
%footer
= render :partial => "layouts/footer"
--
1.7.2.3
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel