Feature/multiple endpoints (#938)

* Add support for multiple endpoints for webserver
* Add support for a default endpoint (redirect) in webgui
* Always serve prod gui
* Update webgui deps
This commit is contained in:
Emil Axelsson
2019-07-19 16:49:54 +02:00
committed by GitHub
parent 134468b0d5
commit 5079f3fc60
7 changed files with 231 additions and 44 deletions
+14 -2
View File
@@ -25,7 +25,6 @@
#include <modules/cefwebgui/cefwebguimodule.h>
#include <modules/webbrowser/webbrowsermodule.h>
#include <modules/webgui/webguimodule.h>
#include <modules/cefwebgui/include/guirenderhandler.h>
#include <modules/cefwebgui/include/guikeyboardhandler.h>
#include <modules/webbrowser/include/browserinstance.h>
@@ -166,7 +165,15 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration)
} else {
WebGuiModule* webGuiModule = global::moduleEngine.module<WebGuiModule>();
_url = "http://127.0.0.1:" +
std::to_string(webGuiModule->port()) + "/#/onscreen";
std::to_string(webGuiModule->port()) + "/frontend/#/onscreen";
_endpointCallback = webGuiModule->addEndpointChangeCallback(
[this](const std::string& endpoint, bool exists) {
if (exists && endpoint == "frontend" && _instance) {
_instance->reloadBrowser();
}
}
);
}
if (configuration.hasValue<float>(GuiScaleInfo.identifier)) {
@@ -204,6 +211,11 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration)
});
global::callback::deinitializeGL.emplace_back([this]() {
if (_endpointCallback != -1) {
WebGuiModule* webGuiModule = global::moduleEngine.module<WebGuiModule>();
webGuiModule->removeEndpointChangeCallback(_endpointCallback);
_endpointCallback = -1;
}
_enabled = false;
startOrStopGui();
});
+4
View File
@@ -27,6 +27,8 @@
#include <openspace/util/openspacemodule.h>
#include <modules/webgui/webguimodule.h>
#include <openspace/properties/scalar/boolproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/properties/triggerproperty.h>
@@ -53,6 +55,8 @@ private:
properties::StringProperty _url;
properties::FloatProperty _guiScale;
std::unique_ptr<BrowserInstance> _instance;
WebGuiModule::CallbackHandle _endpointCallback = -1;
};
} // namespace openspace