Class: AdminSuite::DashboardController

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

Instance Method Summary collapse

Instance Method Details

#indexObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/admin_suite/dashboard_controller.rb', line 5

def index
  # Ensure portal/resource metadata is available.
  items = navigation_items

  @health = build_root_health
  @stats = build_root_stats(items)
  @recent = build_root_recent

  @portal_cards =
    items.sort_by { |(_k, v)| (v[:order] || 100).to_i }.map do |portal_key, portal|
      color = portal[:color].presence || default_portal_color(portal_key)
      {
        key: portal_key,
        label: portal[:label] || portal_key.to_s.humanize,
        description: portal[:description],
        color: color,
        icon: portal[:icon],
        path: portal_path(portal: portal_key),
        count: portal[:sections].values.sum { |s| s[:items].size }
      }
    end

  @dashboard_sections = build_sections
end