mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
Work on the rbac controller's admin panel.
This commit is contained in:
parent
68ecd088c5
commit
2c8e5e33b6
@ -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;
|
||||
|
||||
|
@ -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) {
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -30,6 +30,7 @@ public:
|
||||
protected:
|
||||
struct AdminPanelSection {
|
||||
String section_url;
|
||||
String name;
|
||||
AdminController *controller;
|
||||
};
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user