Class: RubyUIAdmin::Views::Dashboard

Inherits:
Base
  • Object
show all
Defined in:
app/components/ruby_ui_admin/views/dashboard.rb

Instance Method Summary collapse

Methods inherited from Base

#authorized_to?, #view_template

Methods included from Translation

#rua_t

Methods included from PathHelpers

#attachment_url, #resource_edit_path, #resource_index_path, #resource_new_path, #resource_show_path

Constructor Details

#initialize(dashboard:) ⇒ Dashboard

Returns a new instance of Dashboard.



6
7
8
# File 'app/components/ruby_ui_admin/views/dashboard.rb', line 6

def initialize(dashboard:)
  @dashboard = dashboard
end

Instance Method Details

#contentObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/components/ruby_ui_admin/views/dashboard.rb', line 14

def content
  div(class: "mb-6") do
    h1(class: "text-2xl font-semibold tracking-tight") { @dashboard.class.title }
    if (description = @dashboard.class.description)
      p(class: "text-sm text-muted-foreground mt-1") { description }
    end
  end

  cards = @dashboard.get_cards
  if cards.empty?
    p(class: "text-muted-foreground") { "No cards defined yet." }
  else
    div(class: grid_class) do
      cards.each { |card| render RubyUIAdmin::Views::CardComponent.new(card: card) }
    end
  end
end

#page_titleObject



10
11
12
# File 'app/components/ruby_ui_admin/views/dashboard.rb', line 10

def page_title
  "#{@dashboard.class.title} ยท #{RubyUIAdmin.configuration.app_name}"
end