Class: Legion::TTY::Screens::Dashboard
- Defined in:
- lib/legion/tty/screens/dashboard.rb
Overview
rubocop:disable Metrics/ClassLength
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #activate ⇒ Object
-
#handle_input(key) ⇒ Object
rubocop:enable Metrics/AbcSize.
-
#initialize(app) ⇒ Dashboard
constructor
A new instance of Dashboard.
- #refresh_data ⇒ Object
-
#render(width, height) ⇒ Object
rubocop:disable Metrics/AbcSize.
Methods inherited from Base
Constructor Details
#initialize(app) ⇒ Dashboard
Returns a new instance of Dashboard.
11 12 13 14 15 16 |
# File 'lib/legion/tty/screens/dashboard.rb', line 11 def initialize(app) super @last_refresh = nil @refresh_interval = 5 @cached_data = {} end |
Instance Method Details
#activate ⇒ Object
18 19 20 |
# File 'lib/legion/tty/screens/dashboard.rb', line 18 def activate refresh_data end |
#handle_input(key) ⇒ Object
rubocop:enable Metrics/AbcSize
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/legion/tty/screens/dashboard.rb', line 39 def handle_input(key) case key when 'r', :f5 refresh_data :handled when 'q', :escape :pop_screen else :pass end end |
#refresh_data ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/legion/tty/screens/dashboard.rb', line 51 def refresh_data @last_refresh = Time.now @cached_data = { services: probe_services, extensions: discover_extensions, system: system_info, activity: recent_activity } end |
#render(width, height) ⇒ Object
rubocop:disable Metrics/AbcSize
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/legion/tty/screens/dashboard.rb', line 23 def render(width, height) refresh_data if stale? rows = [] rows.concat(render_header(width)) rows.concat(render_services_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 |