Module: Pbx::Views::DisconnectedScreen

Defined in:
lib/pbx/views/disconnected_screen.rb

Constant Summary collapse

ICON_STYLE =
Lipgloss::Style.new
.foreground("#4b5563")
.bold(true)
TITLE_STYLE =
Lipgloss::Style.new
.foreground("#9ca3af")
.bold(true)
BODY_STYLE =
Lipgloss::Style.new
.foreground("#6b7280")
CODE_STYLE =
Lipgloss::Style.new
.foreground("#a78bfa")
.bold(true)
HINT_STYLE =
Lipgloss::Style.new
.foreground("#4b5563")
.italic(true)
BOX_STYLE =
Lipgloss::Style.new
.border(:rounded)
.border_foreground("#374151")
.padding(1, 3)
.margin(1, 2)

Class Method Summary collapse

Class Method Details

.call(state) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/pbx/views/disconnected_screen.rb', line 33

def self.call(state)
  missing = missing_params(state.config)

  lines = [
    ICON_STYLE.render("") + "  " + TITLE_STYLE.render("No connection configured"),
    "",
    BODY_STYLE.render("Missing parameters: ") + missing.map { |p| CODE_STYLE.render("--#{p}") }.join("  "),
    "",
    BODY_STYLE.render("Example:"),
    "  " + CODE_STYLE.render("pbx monitor --host 192.168.1.10 --user admin --secret s3cret"),
    "",
    HINT_STYLE.render("or use a config file:"),
    "  " + CODE_STYLE.render("pbx monitor --config /path/to/pbx.yml")
  ]

  BOX_STYLE.render(lines.join("\n"))
end

.missing_params(config) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/pbx/views/disconnected_screen.rb', line 51

def self.missing_params(config)
  params = []
  params << "host" if config.host == "127.0.0.1"
  params << "user" if config.user.to_s.strip.empty?
  params << "secret" if config.secret.to_s.strip.empty?
  params
end