pub struct Admin { /* private fields */ }Expand description
The admin panel module: its address, its title, who may use it and its resources.
Implementations§
Source§impl Admin
impl Admin
Sourcepub fn new() -> Self
pub fn new() -> Self
A panel at /admin, titled “Admin”, with no resources yet, that
nobody may open until authorize says who may.
Sourcepub fn named(self, name: &str) -> Self
pub fn named(self, name: &str) -> Self
Names the panel, so it takes the AdminEntrys aimed at that name
(AdminEntry::panel) instead of the unnamed ones. A named panel has
its own route names, admin.<name>.* (admin.staff.dashboard), and
module name admin.<name>, so several panels can run in one app.
Sourcepub fn only_own_resources(self) -> Self
pub fn only_own_resources(self) -> Self
Ignores what modules contribute: only the resources added here.
Sourcepub fn title(self, title: &str) -> Self
pub fn title(self, title: &str) -> Self
The panel’s name, at the top of its navigation and in page titles.
Who may open the panel at all: logged-in users for whom allows
says yes (others get 403, guests go to log in). Without it, nobody
may.
Sourcepub fn gate(self, name: &str) -> Self
pub fn gate(self, name: &str) -> Self
Lets in the users the gate name lets through (App::gate, or a
permission of that name with the Permissions module, after
App::gate_before).
Sourcepub fn slot(self, slot: Slot, template: &str) -> Self
pub fn slot(self, slot: Slot, template: &str) -> Self
Adds template (MiniJinja source) to a place in every page’s
layout, without replacing the layout. Several for one slot are drawn
in the order added. A file of the slot’s name under the app’s views
(Slot::template) replaces them.
use renox_admin::{Admin, Slot};
let admin = Admin::new().slot(
Slot::AfterContent,
r#"<aside class="about"><h2>About this page</h2><p>{{ request.route }}</p></aside>"#,
);Sourcepub fn resource<R: AdminResource>(self, resource: R) -> Self
pub fn resource<R: AdminResource>(self, resource: R) -> Self
Adds a resource, after the ones before it in the navigation.
§Panics
If its slug isn’t letters, digits, _ and -, or another resource
has it.
Sourcepub fn settings<S: AdminSettings>(self, label: &str) -> Self
pub fn settings<S: AdminSettings>(self, label: &str) -> Self
Adds a page that edits a group of settings kept in the database
(renox::settings), at /admin/settings/<key> under a “Settings”
heading of the navigation. The form comes from
AdminSettings::fields; saving runs the group’s rules and
AppState::save_settings, so it is audited and emits
SettingsChanged. The app needs the renox::settings::Settings
module (the group is declared for you).
A group marked ENCRYPTED never prints its values: its fields start
empty with a note saying whether they are set and when they changed,
and a field left empty keeps its stored value.
§Panics
If another page has the same group.
Trait Implementations§
Source§impl Module for Admin
impl Module for Admin
Source§fn routes_with(&self, contributions: &Contributions) -> Routes
fn routes_with(&self, contributions: &Contributions) -> Routes
register (see Registry::contribute). Every register has run
by then, so module order does not matter. Calls Module::routes
by default. Read moreSource§fn register(&self, app: &mut Registry)
fn register(&self, app: &mut Registry)
Source§fn migrations(&self) -> &'static [Migration]
fn migrations(&self) -> &'static [Migration]
renox::migrations!("src/app/products/migrations").Auto Trait Implementations§
impl !RefUnwindSafe for Admin
impl !UnwindSafe for Admin
impl Freeze for Admin
impl Send for Admin
impl Sync for Admin
impl Unpin for Admin
impl UnsafeUnpin for Admin
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more