2019-06-28 17:50:02 +00:00
|
|
|
local Ansi = require('opus.ansi')
|
|
|
|
local Security = require('opus.security')
|
|
|
|
local SHA = require('opus.crypto.sha2')
|
|
|
|
local UI = require('opus.ui')
|
2019-01-20 03:05:05 +00:00
|
|
|
|
|
|
|
local colors = _G.colors
|
|
|
|
local os = _G.os
|
|
|
|
local shell = _ENV.shell
|
|
|
|
|
|
|
|
local splashIntro = [[First Time Setup
|
|
|
|
|
|
|
|
%sThanks for installing Opus OS. The next screens will prompt you for basic settings for this computer.]]
|
|
|
|
local labelIntro = [[Set a friendly name for this computer.
|
|
|
|
|
|
|
|
%sNo spaces recommended.]]
|
|
|
|
local passwordIntro = [[A password is required for wireless access.
|
|
|
|
|
|
|
|
%sLeave blank to skip.]]
|
|
|
|
local packagesIntro = [[Setup Complete
|
|
|
|
|
|
|
|
%sOpen the package manager to add software to this computer.]]
|
|
|
|
|
|
|
|
local page = UI.Page {
|
|
|
|
wizard = UI.Wizard {
|
2019-06-18 19:19:24 +00:00
|
|
|
ey = -2,
|
2019-01-20 03:05:05 +00:00
|
|
|
pages = {
|
2019-02-06 04:03:57 +00:00
|
|
|
splash = UI.WizardPage {
|
2019-06-18 19:19:24 +00:00
|
|
|
index = 1,
|
|
|
|
intro = UI.TextArea {
|
|
|
|
textColor = colors.yellow,
|
|
|
|
inactive = true,
|
|
|
|
x = 3, ex = -3, y = 2, ey = -2,
|
|
|
|
value = string.format(splashIntro, Ansi.white),
|
|
|
|
},
|
|
|
|
},
|
2019-02-06 04:03:57 +00:00
|
|
|
label = UI.WizardPage {
|
2019-06-18 19:19:24 +00:00
|
|
|
index = 2,
|
|
|
|
labelText = UI.Text {
|
|
|
|
x = 3, y = 2,
|
|
|
|
value = 'Label'
|
|
|
|
},
|
|
|
|
label = UI.TextEntry {
|
|
|
|
x = 9, y = 2, ex = -3,
|
|
|
|
limit = 32,
|
|
|
|
value = os.getComputerLabel(),
|
|
|
|
},
|
|
|
|
intro = UI.TextArea {
|
|
|
|
textColor = colors.yellow,
|
|
|
|
inactive = true,
|
|
|
|
x = 3, ex = -3, y = 4, ey = -3,
|
|
|
|
value = string.format(labelIntro, Ansi.white),
|
|
|
|
},
|
|
|
|
},
|
2019-02-06 04:03:57 +00:00
|
|
|
password = UI.WizardPage {
|
2019-01-20 03:05:05 +00:00
|
|
|
index = 3,
|
2019-06-18 19:19:24 +00:00
|
|
|
passwordLabel = UI.Text {
|
|
|
|
x = 3, y = 2,
|
|
|
|
value = 'Password'
|
|
|
|
},
|
|
|
|
newPass = UI.TextEntry {
|
|
|
|
x = 12, ex = -3, y = 2,
|
|
|
|
limit = 32,
|
|
|
|
mask = true,
|
|
|
|
shadowText = 'password',
|
|
|
|
},
|
2019-04-08 13:30:47 +00:00
|
|
|
--[[
|
2019-06-18 19:19:24 +00:00
|
|
|
groupLabel = UI.Text {
|
|
|
|
x = 3, y = 3,
|
|
|
|
value = 'Group'
|
|
|
|
},
|
|
|
|
group = UI.TextEntry {
|
|
|
|
x = 12, ex = -3, y = 3,
|
|
|
|
limit = 32,
|
|
|
|
shadowText = 'network group',
|
|
|
|
},
|
2019-04-08 13:30:47 +00:00
|
|
|
]]
|
2019-06-18 19:19:24 +00:00
|
|
|
intro = UI.TextArea {
|
|
|
|
textColor = colors.yellow,
|
|
|
|
inactive = true,
|
|
|
|
x = 3, ex = -3, y = 5, ey = -3,
|
|
|
|
value = string.format(passwordIntro, Ansi.white),
|
|
|
|
},
|
2019-01-20 03:05:05 +00:00
|
|
|
},
|
2019-02-06 04:03:57 +00:00
|
|
|
packages = UI.WizardPage {
|
2019-01-20 03:05:05 +00:00
|
|
|
index = 4,
|
2019-06-18 19:19:24 +00:00
|
|
|
button = UI.Button {
|
|
|
|
x = 3, y = -3,
|
|
|
|
text = 'Open Package Manager',
|
|
|
|
event = 'packages',
|
|
|
|
},
|
|
|
|
intro = UI.TextArea {
|
|
|
|
textColor = colors.yellow,
|
|
|
|
inactive = true,
|
|
|
|
x = 3, ex = -3, y = 2, ey = -4,
|
|
|
|
value = string.format(packagesIntro, Ansi.white),
|
|
|
|
},
|
2019-01-20 03:05:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-06-18 19:19:24 +00:00
|
|
|
},
|
|
|
|
notification = UI.Notification { },
|
2019-01-20 03:05:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function page.wizard.pages.label:validate()
|
2019-06-18 19:19:24 +00:00
|
|
|
os.setComputerLabel(self.label.value)
|
|
|
|
return true
|
2019-01-20 03:05:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function page.wizard.pages.password:validate()
|
2019-06-18 19:19:24 +00:00
|
|
|
if #self.newPass.value > 0 then
|
2019-06-28 10:33:47 +00:00
|
|
|
Security.updatePassword(SHA.compute(self.newPass.value))
|
2019-06-18 19:19:24 +00:00
|
|
|
end
|
|
|
|
--[[
|
|
|
|
if #self.group.value > 0 then
|
|
|
|
local config = Config.load('os')
|
|
|
|
config.group = self.group.value
|
|
|
|
Config.update('os', config)
|
|
|
|
end
|
|
|
|
]]
|
|
|
|
return true
|
2019-01-20 03:05:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function page:eventHandler(event)
|
2019-06-18 19:19:24 +00:00
|
|
|
if event.type == 'skip' then
|
|
|
|
self.wizard:emit({ type = 'nextView' })
|
2019-01-20 03:05:05 +00:00
|
|
|
|
2019-06-18 19:19:24 +00:00
|
|
|
elseif event.type == 'view_enabled' then
|
|
|
|
event.view:focusFirst()
|
2019-01-20 03:05:05 +00:00
|
|
|
|
2019-06-18 19:19:24 +00:00
|
|
|
elseif event.type == 'packages' then
|
|
|
|
shell.openForegroundTab('PackageManager')
|
2019-01-20 03:05:05 +00:00
|
|
|
|
2019-06-18 19:19:24 +00:00
|
|
|
elseif event.type == 'wizard_complete' or event.type == 'cancel' then
|
|
|
|
UI.exitPullEvents()
|
2019-01-20 03:05:05 +00:00
|
|
|
|
|
|
|
else
|
|
|
|
return UI.Page.eventHandler(self, event)
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
UI:setPage(page)
|
|
|
|
UI:pullEvents()
|