using static resources for webui

This commit is contained in:
csoler 2019-11-24 10:50:58 +01:00
parent c2d47b01df
commit c7af86b4c1
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
2 changed files with 50 additions and 52 deletions

View file

@ -106,8 +106,10 @@ static void service_ready_handler( restbed::Service& )
std::vector<std::shared_ptr<restbed::Resource> > p3WebUI::getResources() const std::vector<std::shared_ptr<restbed::Resource> > p3WebUI::getResources() const
{ {
std::vector<std::shared_ptr<restbed::Resource> > rtab; static std::vector<std::shared_ptr<restbed::Resource> > rtab;
if(rtab.empty())
{
auto resource1 = std::make_shared< restbed::Resource >( ); auto resource1 = std::make_shared< restbed::Resource >( );
resource1->set_paths( { resource1->set_paths( {
"/{filename: index.html}", "/{filename: index.html}",
@ -156,6 +158,7 @@ std::vector<std::shared_ptr<restbed::Resource> > p3WebUI::getResources() const
rtab.push_back(resource4); rtab.push_back(resource4);
rtab.push_back(resource5); rtab.push_back(resource5);
rtab.push_back(resource6); rtab.push_back(resource6);
}
return rtab; return rtab;
} }
@ -189,17 +192,12 @@ void p3WebUI::setUserPassword(const std::string& passwd)
bool p3WebUI::restart() bool p3WebUI::restart()
{ {
rsJsonAPI->registerResourceProvider(this); rsJsonAPI->registerResourceProvider(this);
return true;
return rsJsonAPI->restart();
} }
bool p3WebUI::stop() bool p3WebUI::stop()
{ {
rsJsonAPI->unregisterResourceProvider(this); rsJsonAPI->unregisterResourceProvider(this);
if(rsJsonAPI->status()==RsJsonAPI::JSONAPI_STATUS_RUNNING)
return rsJsonAPI->restart();
else
return true; return true;
} }