1
0
mirror of https://github.com/kepler155c/opus synced 2024-11-15 13:14:49 +00:00
opus/sys/apps/system/cloud.lua

58 lines
1.3 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
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 {
2020-04-27 01:39:58 +00:00
title = 'Cloud',
2019-11-08 05:50:11 +00:00
description = 'Cloud Catcher options',
[1] = UI.Window {
x = 2, y = 2, ex = -2, ey = 4,
},
2019-06-18 19:19:24 +00:00
key = UI.TextEntry {
x = 3, ex = -3, y = 3,
2019-06-18 19:19:24 +00:00
limit = 32,
value = config.key,
shadowText = 'Cloud key',
accelerators = {
enter = 'update_key',
},
},
button = UI.Button {
x = -8, ex = -2, y = -2,
text = 'Apply',
2019-06-18 19:19:24 +00:00
event = 'update_key',
},
labelText = UI.TextArea {
x = 2, ex = -2, y = 5, ey = -4,
textColor = 'yellow',
backgroundColor = 'black',
marginLeft = 1, marginRight = 1, marginTop = 1,
2019-06-18 19:19:24 +00:00
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