dashboards.rb 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. ActiveAdmin::Dashboards.build do
  2. # Define your dashboard sections here. Each block will be
  3. # rendered on the dashboard in the context of the view. So just
  4. # return the content which you would like to display.
  5. # == Simple Dashboard Section
  6. # Here is an example of a simple dashboard section
  7. #
  8. section "Bots and Channels" do
  9. @bots = Bot.all
  10. @bots.each do |bot|
  11. panel "Botnick: " + bot.botnick do
  12. span link_to("view this bot", "/admin/bots/" + bot.id.to_s)
  13. span "|"
  14. span link_to("edit this bot", "/admin/bots/" + bot.id.to_s + "/edit")
  15. span "|"
  16. span link_to("add a channel to this bot", "/admin/channels/new?bot_id=" + bot.id.to_s + "&botnick=" + bot.botnick.to_s)
  17. table do
  18. @channels = Channel.find_all_by_bot_id(bot.id)
  19. th :Name
  20. th :Activate
  21. th :Actions
  22. @channels.each do |c|
  23. tr do
  24. td c.name
  25. td c.activate
  26. td do
  27. span link_to("view", "/admin/channels/" + c.id.to_s)
  28. span link_to("edit", "/admin/channels/" + c.id.to_s + "/edit")
  29. span link_to("delete", "/admin/channels/" + c.id.to_s, :method => 'delete', :confirm => "You sure?")
  30. end
  31. end
  32. end
  33. end
  34. end
  35. end
  36. span link_to("add a new bot", "admin/bots/new")
  37. end
  38. section "Frequencies and Bans" do
  39. ul do
  40. @frequencies = Frequency.all
  41. @frequencies.each do |f|
  42. li "Freq: " + f.name + " on prefix: " + f.prefix + " (" + f.delay.to_s + " seconds delay)"
  43. ul do
  44. @bans = Ban.find_all_by_frequency_id(f.id)
  45. @bans.each do |b|
  46. li "Hostmask: " + b.hostmask + " Reason: " + b.reason + " (from " + b.valid_from.to_s + " to " + b.valid_to.to_s + ")"
  47. end
  48. end
  49. end
  50. end
  51. end
  52. # == Render Partial Section
  53. # The block is rendered within the context of the view, so you can
  54. # easily render a partial rather than build content in ruby.
  55. #
  56. # section "Recent Posts" do
  57. # div do
  58. # render 'recent_posts' # => this will render /app/views/admin/dashboard/_recent_posts.html.erb
  59. # end
  60. # end
  61. # == Section Ordering
  62. # The dashboard sections are ordered by a given priority from top left to
  63. # bottom right. The default priority is 10. By giving a section numerically lower
  64. # priority it will be sorted higher. For example:
  65. #
  66. # section "Recent Posts", :priority => 10
  67. # section "Recent User", :priority => 1
  68. #
  69. # Will render the "Recent Users" then the "Recent Posts" sections on the dashboard.
  70. # == Conditionally Display
  71. # Provide a method name or Proc object to conditionally render a section at run time.
  72. #
  73. # section "Membership Summary", :if => :memberships_enabled?
  74. # section "Membership Summary", :if => Proc.new { current_admin_user.account.memberships.any? }
  75. end