Work on the rbac controller's admin panel.

This commit is contained in:
Relintai 2021-11-01 21:21:03 +01:00
parent 68ecd088c5
commit 2c8e5e33b6
7 changed files with 66 additions and 1 deletions

View File

@ -69,6 +69,9 @@ public:
std::string to_string() const;
void print() const;
//todo
static String num(const int num) { return "1"; }
char *c_str();
const char *c_str() const;

View File

@ -11,6 +11,10 @@ void AdminController::admin_handle_request_main(Request *request) {
}
String AdminController::admin_get_section_name() {
return "";
}
void AdminController::admin_add_section_links(Vector<AdminSectionLinkInfo> *links) {
}

View File

@ -27,6 +27,7 @@ class AdminController : public Controller {
public:
virtual void admin_handle_request_main(Request *request);
virtual String admin_get_section_name();
virtual void admin_add_section_links(Vector<AdminSectionLinkInfo> *links);
virtual bool admin_full_render();

View File

@ -59,6 +59,10 @@ void AdminPanel::render_admin_panel_list(Request *request) {
AdminPanelSection &s = _controllers[i];
b.div()->cls("section_header");
b.w(s.controller->admin_get_section_name());
b.cdiv();
s.controller->admin_add_section_links(&links);
for (int j = 0; j < links.size(); ++j) {

View File

@ -30,6 +30,7 @@ public:
protected:
struct AdminPanelSection {
String section_url;
String name;
AdminController *controller;
};

View File

@ -15,11 +15,59 @@ void RBACController::create_validators() {
}
void RBACController::admin_handle_request_main(Request *request) {
String seg = request->get_current_path_segment();
if (seg == "") {
admin_render_rank_list(request);
return;
}
}
void RBACController::admin_render_rank_list(Request *request) {
HTMLBuilder b;
b.h3()->f()->w("RBAC Editor")->ch3();
b.h4()->f()->a()->href(request->get_url_root_parent())->f()->w("<- Back")->ca()->ch4();
for (std::map<int, Ref<RBACRank> >::iterator p = _permissions.begin(); p != _permissions.end(); p++) {
Ref<RBACRank> r = p->second;
if (!r.is_valid()) {
continue;
}
b.div()->cls("row");
{
b.a()->href(request->get_url_root("edit_permissions/") + String::num(r->id));
b.w("Id: ")->w(String::num(r->id))->w(", Name: ")->w(r->name)->w(", Name Internal: ")->w(r->name_internal);
b.ca();
b.a()->href(request->get_url_root("edit_rank/") + String::num(r->id));
b.w("Edit Names");
b.ca();
}
b.cdiv();
}
b.a()->href(request->get_url_root("new_rank"));
b.w("New Rank");
b.ca();
request->body += b.result;
}
void RBACController::admin_render_rank_editor(Request *request) {
}
String RBACController::admin_get_section_name() {
return "Role Based Access Control";
}
void RBACController::admin_add_section_links(Vector<AdminSectionLinkInfo> *links) {
links->push_back(AdminSectionLinkInfo("Test", "test"));
links->push_back(AdminSectionLinkInfo("Editor", ""));
}
void RBACController::initialize() {

View File

@ -22,8 +22,12 @@ public:
void create_validators();
void admin_handle_request_main(Request *request);
String admin_get_section_name();
void admin_add_section_links(Vector<AdminSectionLinkInfo> *links);
void admin_render_rank_list(Request *request);
void admin_render_rank_editor(Request *request);
void initialize();
static RBACController *get_singleton();