Files
OpenSpace/data/assets/util/webgui.asset
T
Emil Axelsson b42d4c5fb9 Update webgui
2019-06-04 17:08:31 +02:00

59 lines
2.1 KiB
Plaintext

local guiCustomization = asset.require('customization/gui')
-- Select which commit hashes to use for the frontend and backend
local frontendHash = "c603ad07d1407a7d3def43f1e203244cee1c06f6"
local backendHash = "84737f9785f12efbb12d2de9d511154c6215fe9c"
local dataProvider = "data.openspaceproject.com/files/webgui"
local backend = asset.syncedResource({
Identifier = "WebGuiBackend",
Name = "Web Gui Backend",
Type = "UrlSynchronization",
Url = dataProvider .. "/backend/" .. backendHash .. "/backend.zip"
})
local frontend = asset.syncedResource({
Identifier = "WebGuiFrontend",
Name = "Web Gui Frontend",
Type = "UrlSynchronization",
Url = dataProvider .. "/frontend/" .. frontendHash .. "/frontend.zip"
})
asset.onInitialize(function ()
-- Unzip the frontend bundle
local dest = frontend .. "/frontend"
if not openspace.directoryExists(dest) then
openspace.unzipFile(frontend .. "/frontend.zip", dest, true)
end
-- Unzip the frontend bundle
dest = backend .. "/backend"
if not openspace.directoryExists(dest) then
openspace.unzipFile(backend .. "/backend.zip", dest, true)
end
-- Do not serve the files if we are in webgui development mode.
-- In that case, you have to serve the webgui manually, using `npm start`.
if not guiCustomization.webguiDevelopmentMode then
openspace.setPropertyValueSingle(
"Modules.WebGui.ServerProcessEntryPoint", backend .. "/backend/backend.js"
)
openspace.setPropertyValueSingle(
"Modules.WebGui.WebDirectory", frontend .. "/frontend"
)
openspace.setPropertyValueSingle("Modules.WebGui.ServerProcessEnabled", true)
end
-- The GUI contains date and simulation increment,
-- so let's remove these from the dashboard.
if openspace.getPropertyValue('Modules.CefWebGui.Visible') then
openspace.setPropertyValueSingle('Dashboard.Date.Enabled', false)
openspace.setPropertyValueSingle('Dashboard.SimulationIncrement.Enabled', false)
end
end)
asset.onDeinitialize(function ()
openspace.setPropertyValueSingle("Modules.WebGui.ServerProcessEnabled", false)
end)