Class: StompBase::Pages::DashboardComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/stomp_base/pages/dashboard_component.rb

Instance Method Summary collapse

Methods inherited from BaseComponent

#call, #render?

Constructor Details

#initialize(title: nil) ⇒ DashboardComponent

Returns a new instance of DashboardComponent.



6
7
8
9
# File 'app/components/stomp_base/pages/dashboard_component.rb', line 6

def initialize(title: nil)
  super()
  @title = title || t("stomp_base.dashboard.title")
end

Instance Method Details

#environment_badge_colorObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/components/stomp_base/pages/dashboard_component.rb', line 19

def environment_badge_color
  case system_info[:environment]
  when "production"
    "bg-red-100 text-red-800 border-red-200"
  when "staging"
    "bg-yellow-100 text-yellow-800 border-yellow-200"
  when "development"
    "bg-green-100 text-green-800 border-green-200"
  else
    "bg-gray-100 text-gray-800 border-gray-200"
  end
end

#memory_percentageObject



32
33
34
35
# File 'app/components/stomp_base/pages/dashboard_component.rb', line 32

def memory_percentage
  total_memory_mb = 8192 # Default assumption, could be made configurable
  ((performance_info[:memory] / total_memory_mb) * 100).round(1)
end

#performance_infoObject



15
16
17
# File 'app/components/stomp_base/pages/dashboard_component.rb', line 15

def performance_info
  @performance_info ||= build_performance_info
end

#system_infoObject



11
12
13
# File 'app/components/stomp_base/pages/dashboard_component.rb', line 11

def system_info
  @system_info ||= build_system_info
end