Class: AdminSuite::UI::RowDSL
- Inherits:
-
Object
- Object
- AdminSuite::UI::RowDSL
- Defined in:
- lib/admin_suite/ui/dashboard_definition.rb
Overview
DSL used inside row do ... end.
Instance Method Summary collapse
- #cards_panel(title, resources: nil, span: nil, **options, &block) ⇒ Object
-
#chart_panel(title, data: nil, span: nil, **options, &block) ⇒ Object
type:selects the Chart.js chart type::bar(default),:line,:area(a line chart rendered with fill), or:doughnut. - #health_panel(title, status: nil, metrics: nil, span: nil, **options, &block) ⇒ Object
-
#initialize(row) ⇒ RowDSL
constructor
A new instance of RowDSL.
- #panel(type, title = nil, span: nil, **options, &block) ⇒ Object
- #recent_panel(title, scope: nil, link: nil, span: nil, **options, &block) ⇒ Object
- #stat_panel(title, value = nil, span: nil, **options, &block) ⇒ Object
- #table_panel(title, rows: nil, columns: nil, span: nil, **options, &block) ⇒ Object
Constructor Details
#initialize(row) ⇒ RowDSL
Returns a new instance of RowDSL.
32 33 34 |
# File 'lib/admin_suite/ui/dashboard_definition.rb', line 32 def initialize(row) @row = row end |
Instance Method Details
#cards_panel(title, resources: nil, span: nil, **options, &block) ⇒ Object
62 63 64 |
# File 'lib/admin_suite/ui/dashboard_definition.rb', line 62 def cards_panel(title, resources: nil, span: nil, **, &block) panel(:cards, title, span: span, **.merge(resources: resources, block: block)) end |
#chart_panel(title, data: nil, span: nil, **options, &block) ⇒ Object
type: selects the Chart.js chart type: :bar (default), :line,
:area (a line chart rendered with fill), or :doughnut. It flows
through **options untouched by this method -- the _chart.html.erb
partial is what validates it, falling back to :bar with a logged
warning for anything else, so a host typo degrades rather than
breaking the dashboard.
57 58 59 60 |
# File 'lib/admin_suite/ui/dashboard_definition.rb', line 57 def chart_panel(title, data: nil, span: nil, **, &block) data_proc = data.is_a?(Proc) ? data : (block_given? ? block : nil) panel(:chart, title, span: span, **.merge(data: data_proc || data)) end |
#health_panel(title, status: nil, metrics: nil, span: nil, **options, &block) ⇒ Object
47 48 49 |
# File 'lib/admin_suite/ui/dashboard_definition.rb', line 47 def health_panel(title, status: nil, metrics: nil, span: nil, **, &block) panel(:health, title, span: span, **.merge(status: status, metrics: metrics, block: block)) end |
#panel(type, title = nil, span: nil, **options, &block) ⇒ Object
36 37 38 39 40 |
# File 'lib/admin_suite/ui/dashboard_definition.rb', line 36 def panel(type, title = nil, span: nil, **, &block) [:span] = span if span [:block] = block if block_given? @row.panels << PanelDefinition.new(type: type.to_sym, title: title, options: ) end |
#recent_panel(title, scope: nil, link: nil, span: nil, **options, &block) ⇒ Object
66 67 68 |
# File 'lib/admin_suite/ui/dashboard_definition.rb', line 66 def recent_panel(title, scope: nil, link: nil, span: nil, **, &block) panel(:recent, title, span: span, **.merge(scope: scope, link: link, block: block)) end |
#stat_panel(title, value = nil, span: nil, **options, &block) ⇒ Object
42 43 44 45 |
# File 'lib/admin_suite/ui/dashboard_definition.rb', line 42 def stat_panel(title, value = nil, span: nil, **, &block) value_proc = value.is_a?(Proc) ? value : (block_given? ? block : nil) panel(:stat, title, span: span, **.merge(value: value_proc || value)) end |
#table_panel(title, rows: nil, columns: nil, span: nil, **options, &block) ⇒ Object
70 71 72 |
# File 'lib/admin_suite/ui/dashboard_definition.rb', line 70 def table_panel(title, rows: nil, columns: nil, span: nil, **, &block) panel(:table, title, span: span, **.merge(rows: rows, columns: columns, block: block)) end |