mirror of
https://github.com/kepler155c/opus
synced 2024-11-19 07:04:49 +00:00
61 lines
1.3 KiB
Lua
61 lines
1.3 KiB
Lua
local Ansi = require('ansi')
|
|
local Config = require('config')
|
|
local UI = require('ui')
|
|
|
|
local device = _G.device
|
|
|
|
local tab = UI.Tab {
|
|
tabTitle = 'Network',
|
|
description = 'Networking options',
|
|
info = UI.TextArea {
|
|
x = 3, y = 4,
|
|
value = string.format(
|
|
[[%sSet the primary modem used for wireless communications.%s
|
|
|
|
Reboot to take effect.]], Ansi.yellow, Ansi.reset)
|
|
},
|
|
label = UI.Text {
|
|
x = 3, y = 2,
|
|
value = 'Modem',
|
|
},
|
|
modem = UI.Chooser {
|
|
x = 10, ex = -3, y = 2,
|
|
nochoice = 'auto',
|
|
},
|
|
}
|
|
|
|
function tab:enable()
|
|
local width = 7
|
|
local choices = {
|
|
{ name = 'auto', value = 'auto' },
|
|
{ name = 'disable', value = 'none' },
|
|
}
|
|
|
|
for k,v in pairs(device) do
|
|
if v.isWireless and v.isWireless() and k ~= 'wireless_modem' then
|
|
table.insert(choices, { name = k, value = v.name })
|
|
width = math.max(width, #k)
|
|
end
|
|
end
|
|
|
|
self.modem.choices = choices
|
|
--self.modem.width = width + 4
|
|
|
|
local config = Config.load('os')
|
|
self.modem.value = config.wirelessModem or 'auto'
|
|
|
|
UI.Tab.enable(self)
|
|
end
|
|
|
|
function tab:eventHandler(event)
|
|
if event.type == 'choice_change' then
|
|
local config = Config.load('os')
|
|
config.wirelessModem = self.modem.value
|
|
Config.update('os', config)
|
|
self:emit({ type = 'success_message', message = 'reboot to take effect' })
|
|
return true
|
|
end
|
|
end
|
|
|
|
return tab
|