Files
OpenSpace/data/assets/util/webgui.asset
Emil Axelsson 0c6b5e95c6 Introduce ability to configure ports etc for external applications. (#785)
Introduce ability to configure ports etc for external applications, including webgui
2019-01-04 10:23:28 +01: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 = "abf5fe23ef29af408d6c071057f1cc706c9b09a3"
local backendHash = "6e773425b3e90ba93f0090e44427e474fe5c633f"
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)