Class: PoolController

Inherits:
ApplicationController show all
Defined in:
app/controllers/pool_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#sort_key

Instance Method Details

#distObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/pool_controller.rb', line 25

def dist
  return unless BACUVIEW['have_gruff']
  g = Gruff::Pie.new(500)
  g.theme_37signals
  g.title = "Media Distribution"
  @pool = Pool.find(:all, 
    :select => "name, numvols", :order => sort_key(:psort, key_sql))
  for pool in @pool do
    g.data pool.name, [ pool.numvols ]
  end
  send_data(g.to_blob, :disposition => 'inline', :type => 'image/png')
end

#indexObject



11
12
13
14
15
16
17
# File 'app/controllers/pool_controller.rb', line 11

def index
  @page_title = "Pools"
  @pool = Pool.find(:all, :order => sort_key(:psort, key_sql))
  volume_counts = @pool.map{ |pool| pool.numvols }
  @max_vols = volume_counts.max
  @total_vols = volume_counts.inject(0) {|sum, i| sum + i}
end

#key_sqlObject



4
5
6
7
8
9
# File 'app/controllers/pool_controller.rb', line 4

def key_sql
  { "name"   => "name",         "name-"   => "name desc", 
    "type"   => "pooltype",     "type-"   => "pooltype desc",
    "retain" => "volretention", "retain-" => "volretention desc",
    "vols"   => "numvols",      "vols-"   => "numvols desc" }
end

#showObject



19
20
21
22
23
# File 'app/controllers/pool_controller.rb', line 19

def show
  @pool = Pool.find(params[:pid])
  @page_title = "Pool " + @pool.name
  params[:action] = params[:pid] = nil
end