Files
bbs-server/lib/ui/windows/system_info_window.rb
2026-05-13 21:00:54 +02:00

34 lines
952 B
Ruby
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# frozen_string_literal: true
module UI
module Windows
module_function
def system_info(app, services:)
rows = [
['Online users', services[:online].count.to_s],
['Messages', services[:boards].total_count.to_s],
['Boards', services[:boards].boards.size.to_s],
['Wiki', 'https://wiki.teletypegames.org'],
['Games API', 'https://teletypegames.org'],
['Platform', RUBY_PLATFORM],
['Ruby', RUBY_VERSION],
['Uptime', format_uptime(services[:uptime])],
]
BBS::Windows::Info.open(app,
title: ' System Info ', width: 60, height: 14,
body: [{ kv: rows, label_width: 15 }]
)
end
def format_uptime(start)
return '' unless start
seconds = (Time.now - start).to_i
h = seconds / 3600
m = (seconds % 3600) / 60
s = seconds % 60
"#{h}h #{m}m #{s}s"
end
end
end