mirror of
https://github.com/kepler155c/opus
synced 2025-11-11 21:14:14 +00:00
friendlier networking + adding tabs
This commit is contained in:
@@ -28,10 +28,17 @@ end
|
||||
local page = UI.Page {
|
||||
menuBar = UI.MenuBar {
|
||||
buttons = {
|
||||
{ text = 'Telnet', event = 'telnet' },
|
||||
{ text = 'VNC', event = 'vnc' },
|
||||
{ text = 'Trust', event = 'trust' },
|
||||
{ text = 'Reboot', event = 'reboot' },
|
||||
{ text = 'Connect', dropdown = {
|
||||
{ text = 'Telnet t', event = 'telnet' },
|
||||
{ text = 'VNC v', event = 'vnc' },
|
||||
UI.MenuBar.spacer,
|
||||
{ text = 'Reboot r', event = 'reboot' },
|
||||
} },
|
||||
{ text = 'Trust', dropdown = {
|
||||
{ text = 'Establish', event = 'trust' },
|
||||
{ text = 'Remove', event = 'untrust' },
|
||||
} },
|
||||
{ text = 'Help', event = 'help' },
|
||||
},
|
||||
},
|
||||
grid = UI.ScrollingGrid {
|
||||
@@ -43,6 +50,9 @@ local page = UI.Page {
|
||||
},
|
||||
notification = UI.Notification { },
|
||||
accelerators = {
|
||||
t = 'telnet',
|
||||
v = 'vnc',
|
||||
r = 'reboot',
|
||||
q = 'quit',
|
||||
c = 'clear',
|
||||
},
|
||||
@@ -85,20 +95,62 @@ function page:eventHandler(event)
|
||||
args = { t.id },
|
||||
title = t.label,
|
||||
})
|
||||
elseif event.type == 'clear' then
|
||||
Util.clear(network)
|
||||
page.grid:update()
|
||||
page.grid:draw()
|
||||
|
||||
elseif event.type == 'trust' then
|
||||
shell.openForegroundTab('trust ' .. t.id)
|
||||
|
||||
elseif event.type == 'untrust' then
|
||||
local trustList = Util.readTable('usr/.known_hosts') or { }
|
||||
trustList[t.id] = nil
|
||||
Util.writeTable('usr/.known_hosts', trustList)
|
||||
|
||||
elseif event.type == 'reboot' then
|
||||
sendCommand(t.id, 'reboot')
|
||||
|
||||
elseif event.type == 'shutdown' then
|
||||
sendCommand(t.id, 'shutdown')
|
||||
end
|
||||
end
|
||||
if event.type == 'quit' then
|
||||
if event.type == 'help' then
|
||||
UI:setPage(UI.Dialog {
|
||||
title = 'Network Help',
|
||||
height = 10,
|
||||
backgroundColor = colors.white,
|
||||
text = UI.TextArea {
|
||||
x = 2, y = 2,
|
||||
backgroundColor = colors.white,
|
||||
value = [[
|
||||
In order to connect to another computer:
|
||||
|
||||
1. The target computer must have a password set (run 'password' from the shell prompt).
|
||||
2. From this computer, click trust and enter the password for that computer.
|
||||
|
||||
This only needs to be done once.
|
||||
]],
|
||||
},
|
||||
accelerators = {
|
||||
q = 'cancel',
|
||||
}
|
||||
})
|
||||
elseif event.type == 'quit' then
|
||||
Event.exitPullEvents()
|
||||
end
|
||||
UI.Page.eventHandler(self, event)
|
||||
end
|
||||
|
||||
function page.menuBar:getActive(menuItem)
|
||||
local t = page.grid:getSelected()
|
||||
if menuItem.event == 'untrust' then
|
||||
local trustList = Util.readTable('usr/.known_hosts') or { }
|
||||
return t and trustList[t.id]
|
||||
end
|
||||
return not not t
|
||||
end
|
||||
|
||||
function page.grid:getRowTextColor(row, selected)
|
||||
if not row.active then
|
||||
return colors.orange
|
||||
|
||||
Reference in New Issue
Block a user