mirror of
https://github.com/kepler155c/opus
synced 2025-10-20 18:27:40 +00:00
simplify ui
This commit is contained in:
@@ -204,7 +204,7 @@ function page:setResult(result)
|
||||
if Util.size(v) == 0 then
|
||||
entry.value = 'table: (empty)'
|
||||
else
|
||||
entry.value = 'table'
|
||||
entry.value = tostring(v)
|
||||
end
|
||||
end
|
||||
table.insert(t, entry)
|
||||
|
@@ -34,6 +34,7 @@ local page = UI.Page {
|
||||
UI.MenuBar.spacer,
|
||||
{ text = 'Reboot r', event = 'reboot' },
|
||||
} },
|
||||
{ text = 'Chat', event = 'chat' },
|
||||
{ text = 'Trust', dropdown = {
|
||||
{ text = 'Establish', event = 'trust' },
|
||||
{ text = 'Remove', event = 'untrust' },
|
||||
@@ -81,7 +82,7 @@ end
|
||||
function page:eventHandler(event)
|
||||
local t = self.grid:getSelected()
|
||||
if t then
|
||||
if event.type == 'telnet' or event.type == 'grid_select' then
|
||||
if event.type == 'telnet' then
|
||||
multishell.openTab({
|
||||
path = 'sys/apps/telnet.lua',
|
||||
focused = true,
|
||||
@@ -108,6 +109,13 @@ function page:eventHandler(event)
|
||||
trustList[t.id] = nil
|
||||
Util.writeTable('usr/.known_hosts', trustList)
|
||||
|
||||
elseif event.type == 'chat' then
|
||||
multishell.openTab({
|
||||
path = 'sys/apps/shell',
|
||||
args = { 'chat join opusChat-' .. t.id .. ' guest'},
|
||||
title = 'Chatroom',
|
||||
focused = true,
|
||||
})
|
||||
elseif event.type == 'reboot' then
|
||||
sendCommand(t.id, 'reboot')
|
||||
|
||||
|
@@ -118,12 +118,12 @@ local function parseIcon(iconText)
|
||||
end
|
||||
|
||||
UI.VerticalTabBar = class(UI.TabBar)
|
||||
function UI.VerticalTabBar:init(args)
|
||||
UI.TabBar.init(self, args)
|
||||
function UI.VerticalTabBar:setParent()
|
||||
self.x = 1
|
||||
self.width = 8
|
||||
self.height = nil
|
||||
self.ey = -1
|
||||
UI.TabBar.setParent(self)
|
||||
for k,c in pairs(self.children) do
|
||||
c.x = 1
|
||||
c.y = k + 1
|
||||
@@ -160,16 +160,11 @@ local page = UI.Page {
|
||||
}
|
||||
|
||||
UI.Icon = class(UI.Window)
|
||||
function UI.Icon:init(args)
|
||||
local defaults = {
|
||||
UIElement = 'Icon',
|
||||
width = 14,
|
||||
height = 4,
|
||||
}
|
||||
UI:setProperties(defaults, args)
|
||||
UI.Window.init(self, defaults)
|
||||
end
|
||||
|
||||
UI.Icon.defaults = {
|
||||
UIElement = 'Icon',
|
||||
width = 14,
|
||||
height = 4,
|
||||
}
|
||||
function UI.Icon:eventHandler(event)
|
||||
if event.type == 'mouse_click' then
|
||||
self:setFocus(self.button)
|
||||
@@ -498,7 +493,6 @@ function editor:eventHandler(event)
|
||||
width = self.width,
|
||||
height = self.height,
|
||||
})
|
||||
--fileui:setTransition(UI.effect.explode)
|
||||
UI:setPage(fileui, fs.getDir(self.iconFile), function(fileName)
|
||||
if fileName then
|
||||
self.iconFile = fileName
|
||||
|
@@ -1,8 +1,10 @@
|
||||
_G.requireInjector()
|
||||
|
||||
local Config = require('config')
|
||||
local UI = require('ui')
|
||||
local Util = require('util')
|
||||
local Config = require('config')
|
||||
local Security = require('security')
|
||||
local SHA1 = require('sha1')
|
||||
local UI = require('ui')
|
||||
local Util = require('util')
|
||||
|
||||
local fs = _G.fs
|
||||
local multishell = _ENV.multishell
|
||||
@@ -24,7 +26,7 @@ end
|
||||
local env = {
|
||||
path = shell.path(),
|
||||
aliases = shell.aliases(),
|
||||
lua_path = LUA_PATH,
|
||||
lua_path = _ENV.LUA_PATH,
|
||||
}
|
||||
Config.load('shell', env)
|
||||
|
||||
@@ -77,6 +79,36 @@ local systemPage = UI.Page {
|
||||
},
|
||||
},
|
||||
|
||||
passwordTab = UI.Window {
|
||||
tabTitle = 'Password',
|
||||
oldPass = UI.TextEntry {
|
||||
x = 2, y = 2, ex = -2,
|
||||
limit = 32,
|
||||
mask = true,
|
||||
shadowText = 'old password',
|
||||
inactive = not Security.getPassword(),
|
||||
},
|
||||
newPass = UI.TextEntry {
|
||||
y = 3, x = 2, ex = -2,
|
||||
limit = 32,
|
||||
mask = true,
|
||||
shadowText = 'new password',
|
||||
accelerators = {
|
||||
enter = 'new_password',
|
||||
},
|
||||
},
|
||||
button = UI.Button {
|
||||
x = 2, y = 5,
|
||||
text = 'Update',
|
||||
event = 'update_password',
|
||||
},
|
||||
info = UI.TextArea {
|
||||
x = 2, ex = -2,
|
||||
y = 7,
|
||||
value = 'Add a password to enable other computers to connect to this one.',
|
||||
}
|
||||
},
|
||||
|
||||
infoTab = UI.Window {
|
||||
tabTitle = 'Info',
|
||||
labelText = UI.Text {
|
||||
@@ -205,6 +237,22 @@ function systemPage.tabs.aliasTab:eventHandler(event)
|
||||
end
|
||||
end
|
||||
|
||||
function systemPage.tabs.passwordTab:eventHandler(event)
|
||||
if event.type == 'update_password' then
|
||||
if #self.newPass.value == 0 then
|
||||
systemPage.notification:error('Invalid password')
|
||||
elseif Security.getPassword() and not Security.verifyPassword(SHA1.sha1(self.oldPass.value)) then
|
||||
systemPage.notification:error('Passwords do not match')
|
||||
else
|
||||
Security.updatePassword(SHA1.sha1(self.newPass.value))
|
||||
self.oldPass.inactive = false
|
||||
systemPage.notification:success('Password updated')
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function systemPage.tabs.infoTab:eventHandler(event)
|
||||
if event.type == 'update_label' then
|
||||
os.setComputerLabel(self.label.value)
|
||||
|
@@ -395,6 +395,13 @@ function multishell.hideTab(tabId)
|
||||
local tab = tabs[tabId]
|
||||
if tab then
|
||||
tab.hidden = true
|
||||
if currentTab.tabId == tabId then
|
||||
if tabs[currentTab.previousTabId] then
|
||||
multishell.setFocus(currentTab.previousTabId)
|
||||
else
|
||||
multishell.setFocus(overviewTab.tabId)
|
||||
end
|
||||
end
|
||||
redrawMenu()
|
||||
end
|
||||
end
|
||||
|
@@ -29,10 +29,10 @@ if not password then
|
||||
end
|
||||
|
||||
print('connecting...')
|
||||
local socket = Socket.connect(remoteId, 19)
|
||||
local socket, msg = Socket.connect(remoteId, 19)
|
||||
|
||||
if not socket then
|
||||
error('Unable to connect to ' .. remoteId .. ' on port 19')
|
||||
error(msg)
|
||||
end
|
||||
|
||||
local publicKey = Security.getPublicKey()
|
||||
|
Reference in New Issue
Block a user