Class: IronAdmin::Dashboard
- Inherits:
-
Object
- Object
- IronAdmin::Dashboard
- Defined in:
- lib/iron_admin/dashboard.rb
Overview
Base class for defining the admin dashboard.
The dashboard is the landing page of the admin panel and typically displays key metrics, charts, and recent records. Create a subclass of Dashboard to customize what appears on your admin home page.
Only one Dashboard subclass should exist per application. When defined, it automatically registers itself as the active dashboard.
Class Method Summary collapse
-
.chart(name, type: :line, colors: nil, label: nil, live: false) { ... } ⇒ void
Defines a chart for the dashboard.
-
.inherited(subclass) ⇒ Object
private
Automatically registers subclasses as the active dashboard.
-
.layout { ... } ⇒ void
Defines a custom layout for the dashboard.
-
.metric(name, format: :number, icon: nil, live: false) { ... } ⇒ void
Defines a metric card for the dashboard.
-
.recent(resource_name, limit: 5, scope: nil) ⇒ void
Displays a list of recent records from a resource.
Class Method Details
.chart(name, type: :line, colors: nil, label: nil, live: false) { ... } ⇒ void
This method returns an undefined value.
Defines a chart for the dashboard.
Charts display time-series or categorical data visually. The block should return data in a format suitable for the chart type.
117 118 119 120 121 |
# File 'lib/iron_admin/dashboard.rb', line 117 def chart(name, type: :line, colors: nil, label: nil, live: false, &block) self.defined_charts = defined_charts + [ { name: name, type: type, colors: colors, label: label, live: live, block: block }, ] end |
.inherited(subclass) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Automatically registers subclasses as the active dashboard.
54 55 56 57 |
# File 'lib/iron_admin/dashboard.rb', line 54 def inherited(subclass) super IronAdmin.dashboard_class = subclass end |
.layout { ... } ⇒ void
This method returns an undefined value.
Defines a custom layout for the dashboard.
Use this to control the arrangement of metrics, charts, and recent record lists on the dashboard page.
159 160 161 |
# File 'lib/iron_admin/dashboard.rb', line 159 def layout(&block) self._layout_block = block end |
.metric(name, format: :number, icon: nil, live: false) { ... } ⇒ void
This method returns an undefined value.
Defines a metric card for the dashboard.
Metrics are displayed as cards showing a single value with a label. They're useful for key performance indicators and summary statistics.
84 85 86 |
# File 'lib/iron_admin/dashboard.rb', line 84 def metric(name, format: :number, icon: nil, live: false, &block) self.defined_metrics = defined_metrics + [{ name: name, format: format, icon: icon, live: live, block: block }] end |
.recent(resource_name, limit: 5, scope: nil) ⇒ void
This method returns an undefined value.
Displays a list of recent records from a resource.
Shows a table of the most recent records, with links to view each one. Useful for quick access to newly created or updated items.
142 143 144 |
# File 'lib/iron_admin/dashboard.rb', line 142 def recent(resource_name, limit: 5, scope: nil) self.defined_recents = defined_recents + [{ resource_name: resource_name, limit: limit, scope: scope }] end |