local guiCustomization = asset.require('customization/gui') -- Select which commit hashes to use for the frontend and backend local frontendHash = "32c481c9337a62745669de66d909cf15bd2bae7a" 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)