Added more helper methods to WebNode. Also a render_menu() virtual.

This commit is contained in:
Relintai 2022-01-13 22:58:59 +01:00
parent bde46b20cd
commit 127219fe34
3 changed files with 25 additions and 1 deletions

View File

@ -4,8 +4,8 @@
#include "http_enums.h"
#include "request.h"
#include "core/settings/settings.h"
#include "core/http/web_server.h"
#include "core/settings/settings.h"
#ifdef DATABASES_ENABLED
#include "core/database/database.h"
@ -85,6 +85,16 @@ void WebNode::handle_error_send_request(Request *request, const int error_code)
request->send();
}
void WebNode::render_menu(Request *request) {
WebNode *root = get_root();
if (root) {
root->_render_menu(request);
}
}
void WebNode::_render_menu(Request *request) {
}
void WebNode::create_validators() {
}
@ -105,6 +115,16 @@ WebServer *WebNode::get_server() {
return Object::cast_to<WebServer>(get_tree());
}
WebNode *WebNode::get_root() {
WebServer *s = get_server();
if (!s) {
return nullptr;
}
return s->get_web_root();
}
WebNode::WebNode() :
Node() {
// should look this up in parents when parented (and node parenting is implemented)

View File

@ -35,6 +35,8 @@ public:
virtual void handle_request_main(Request *request);
virtual void _handle_request_main(Request *request);
virtual void handle_error_send_request(Request *request, const int error_code);
virtual void render_menu(Request *request);
virtual void _render_menu(Request *request);
virtual void create_validators();
@ -44,6 +46,7 @@ public:
virtual void create_default_entries();
WebServer *get_server();
WebNode *get_root();
WebNode();
~WebNode();

View File

@ -32,6 +32,7 @@ void AdminPanel::handle_request_main(Request *request) {
return;
}
//render_menu(request);
render_headers(request);
render_segment_body_top(request);
render_controller_panel(request, c);