opus/sys/apps/system/cloud.lua

58 lines
1.2 KiB
Lua
Raw Normal View History

local Ansi = require('opus.ansi')
local Config = require('opus.config')
local UI = require('opus.ui')
2019-03-22 05:40:29 +00:00
local colors = _G.colors
2019-03-26 13:08:39 +00:00
-- -t80x30
2019-03-23 16:20:48 +00:00
if _G.http.websocket then
2019-06-18 19:19:24 +00:00
local config = Config.load('cloud')
2019-03-22 05:40:29 +00:00
2019-06-18 19:19:24 +00:00
local tab = UI.Tab {
tabTitle = 'Cloud',
2019-11-08 05:50:11 +00:00
description = 'Cloud Catcher options',
2019-06-18 19:19:24 +00:00
key = UI.TextEntry {
x = 3, ex = -3, y = 2,
limit = 32,
value = config.key,
shadowText = 'Cloud key',
accelerators = {
enter = 'update_key',
},
},
button = UI.Button {
x = 3, y = 4,
text = 'Update',
event = 'update_key',
},
labelText = UI.TextArea {
x = 3, ex = -3, y = 6,
textColor = colors.yellow,
marginLeft = 0, marginRight = 0,
value = string.format(
[[Use a non-changing cloud key. Note that only a single computer can use this session at one time.
To obtain a key, visit:
%shttps://cloud-catcher.squiddev.cc%s then bookmark:
%shttps://cloud-catcher.squiddev.cc/?id=KEY
2019-06-18 19:19:24 +00:00
]],
Ansi.white, Ansi.reset, Ansi.white),
},
}
2019-03-22 05:40:29 +00:00
2019-06-18 19:19:24 +00:00
function tab:eventHandler(event)
if event.type == 'update_key' then
2019-12-11 16:18:02 +00:00
if self.key.value then
2019-06-18 19:19:24 +00:00
config.key = self.key.value
else
config.key = nil
end
Config.update('cloud', config)
self:emit({ type = 'success_message', message = 'Updated' })
end
end
2019-03-22 05:40:29 +00:00
2019-06-18 19:19:24 +00:00
return tab
2019-03-23 16:20:48 +00:00
end
2019-03-22 05:40:29 +00:00