new windows types
This commit is contained in:
@@ -5,54 +5,38 @@ module UI
|
||||
module_function
|
||||
|
||||
def sysop_console(app, services:)
|
||||
width = 70
|
||||
height = 18
|
||||
window = BBS::Dialogs.centred_window(app, width: width, height: height,
|
||||
title: ' Sysop Console ')
|
||||
|
||||
lines = []
|
||||
lines << " Sysop: \e[1;33m#{app.context[:username]}\e[0m"
|
||||
lines << ''
|
||||
lines << ' Stats'
|
||||
lines << " · Online users: #{services[:online].count}"
|
||||
lines << " · Total messages: #{services[:boards].total_count}"
|
||||
lines << " · Chat subscribers: #{services[:chat].subscriber_count}"
|
||||
lines << ''
|
||||
lines << ' Online users:'
|
||||
services[:online].user_list.each { |u| lines << " · #{u}" }
|
||||
lines << ''
|
||||
lines << ' Last 5 callers:'
|
||||
body = []
|
||||
body << " Sysop: \e[1;33m#{app.context[:username]}\e[0m"
|
||||
body << :spacer
|
||||
body << ' Stats'
|
||||
body << " · Online users: #{services[:online].count}"
|
||||
body << " · Total messages: #{services[:boards].total_count}"
|
||||
body << " · Chat subscribers: #{services[:chat].subscriber_count}"
|
||||
body << :spacer
|
||||
body << ' Online users:'
|
||||
services[:online].user_list.each { |u| body << " · #{u}" }
|
||||
body << :spacer
|
||||
body << ' Last 5 callers:'
|
||||
services[:last_callers].recent(5).each do |c|
|
||||
lines << " · #{c.username} #{c.timestamp[0, 16].sub('T', ' ')}"
|
||||
body << " · #{c.username} #{c.timestamp[0, 16].sub('T', ' ')}"
|
||||
end
|
||||
|
||||
view = BBS::Widgets::ScrollView.new(lines: lines)
|
||||
view.layout(window.bounds.x + 2, window.bounds.y + 1,
|
||||
width - 4, height - 4)
|
||||
window.add(view)
|
||||
|
||||
broadcast = BBS::Widgets::Button.new(
|
||||
label: '&Broadcast',
|
||||
on_click: lambda do |_|
|
||||
BBS::Dialogs.input(app, prompt: 'Sysop broadcast message:',
|
||||
title: ' Broadcast ', width: 64,
|
||||
on_submit: lambda do |text|
|
||||
next if text.strip.empty?
|
||||
services[:chat].broadcast("[SYSOP] #{app.context[:username]}", text.strip)
|
||||
end)
|
||||
end
|
||||
BBS::Windows::Info.open(app,
|
||||
title: ' Sysop Console ', width: 70, height: 18, scroll: true,
|
||||
body: body,
|
||||
buttons: [
|
||||
{ label: '&Broadcast', align: :left, on_click: ->(_window) {
|
||||
BBS::Dialogs.input(app, prompt: 'Sysop broadcast message:',
|
||||
title: ' Broadcast ', width: 64,
|
||||
on_submit: lambda do |text|
|
||||
next if text.strip.empty?
|
||||
services[:chat].broadcast("[SYSOP] #{app.context[:username]}", text.strip)
|
||||
end)
|
||||
:keep
|
||||
} },
|
||||
{ label: '&Close', cancel: true }
|
||||
]
|
||||
)
|
||||
broadcast.layout(window.bounds.x + 2, window.bounds.y + height - 2, 14, 1)
|
||||
window.add(broadcast)
|
||||
|
||||
close = BBS::Widgets::Button.new(label: '&Close',
|
||||
on_click: ->(_) { app.close_window(window) })
|
||||
close.layout(window.bounds.x + width - 11, window.bounds.y + height - 2, 9, 1)
|
||||
window.add(close)
|
||||
|
||||
window.reset_focus
|
||||
app.open_window(window)
|
||||
window
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user