Class: Legion::TTY::Screens::Dashboard
- Defined in:
- lib/legion/tty/screens/dashboard.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- PANELS =
%i[services llm extensions system activity].freeze
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #activate ⇒ Object
-
#handle_input(key) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity.
-
#initialize(app) ⇒ Dashboard
constructor
A new instance of Dashboard.
- #refresh_data ⇒ Object
-
#render(width, height) ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#selected_panel ⇒ Object
rubocop:enable Metrics/CyclomaticComplexity.
Methods inherited from Base
Constructor Details
#initialize(app) ⇒ Dashboard
Returns a new instance of Dashboard.
13 14 15 16 17 18 19 |
# File 'lib/legion/tty/screens/dashboard.rb', line 13 def initialize(app) super @last_refresh = nil @refresh_interval = 5 @cached_data = {} @selected_panel = 0 end |
Instance Method Details
#activate ⇒ Object
21 22 23 |
# File 'lib/legion/tty/screens/dashboard.rb', line 21 def activate refresh_data end |
#handle_input(key) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/legion/tty/screens/dashboard.rb', line 44 def handle_input(key) case key when 'r', :f5 refresh_data :handled when 'q', :escape :pop_screen when 'j', :down @selected_panel = (@selected_panel + 1) % PANELS.size :handled when 'k', :up @selected_panel = (@selected_panel - 1) % PANELS.size :handled when '1' then navigate_to_panel(0) when '2' then navigate_to_panel(1) when '3' then navigate_to_panel(2) when '4' then navigate_to_panel(3) when '5' then navigate_to_panel(4) when 'e' extensions_shortcut else :pass end end |
#refresh_data ⇒ Object
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/legion/tty/screens/dashboard.rb', line 75 def refresh_data @last_refresh = Time.now @cached_data = { services: probe_services, llm: llm_info, extensions: discover_extensions, system: system_info, activity: recent_activity } end |
#render(width, height) ⇒ Object
rubocop:disable Metrics/AbcSize
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/legion/tty/screens/dashboard.rb', line 26 def render(width, height) refresh_data if stale? rows = [] rows.concat(render_header(width)) rows.concat(render_services_panel(width)) rows.concat(render_llm_panel(width)) rows.concat(render_extensions_panel(width)) rows.concat(render_system_panel(width)) rows.concat(render_activity_panel(width, remaining_height(height, rows.size))) rows.concat((width)) pad_to_height(rows, height) end |
#selected_panel ⇒ Object
rubocop:enable Metrics/CyclomaticComplexity
71 72 73 |
# File 'lib/legion/tty/screens/dashboard.rb', line 71 def selected_panel PANELS[@selected_panel] end |