Files
OpenSpace/data/assets/util/webgui.asset
2018-11-05 21:28:57 -05:00

52 lines
2.0 KiB
Plaintext

local guiCustomization = asset.require('customization/gui')
-- Select which commit hashes to use for the frontend and backend
local frontendHash = "f6db6a5dd79df1e310a75d50f8b1f97aea8a9596"
local backendHash = "3e862a67ff2869d83187ad8bda05746b583d13d4"
local dataProvider = "data.openspaceproject.com/files/webgui"
local backend = asset.syncedResource({
Identifier = "WebGuiBackend",
Name = "Web Gui Backend",
Type = "UrlSynchronization",
Url = dataProvider .. "/backend/" .. backendHash .. "/backend.js"
})
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
-- 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.js"
)
openspace.setPropertyValueSingle(
"Modules.WebGui.ServerProcessWorkingDirectory", 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)