pub struct AdminSidebarWidget {
pub template: String,
pub data: HashMap<String, Value>,
}Expand description
Provides a way to add widgets to the sidebar by loading a template and populating it with the provided data.
For more-interactive widgets see the AdminSidebarWidget::htmx constructor which allows you to include a widget from any HTML-serving URL using htmx.
Fields§
§template: String§data: HashMap<String, Value>Implementations§
Source§impl AdminSidebarWidget
impl AdminSidebarWidget
Sourcepub fn htmx(url: impl ToString) -> Self
pub fn htmx(url: impl ToString) -> Self
Examples found in repository?
examples/full-admin.rs (line 80)
67 fn configure_state(&mut self, state: &mut S) -> quokka::Result<()> {
68 let admin: &mut AdminState<_> = state.provide_mut();
69
70 admin.super_admin_group = EXAMPLE_SUPER_USER_GROUP.to_string().into(); // This can be and usually should be set via the config
71 admin.add_auth_provider(TestAuthProvider);
72 admin.add_login_provider(TestLoginProvider);
73
74 admin.add_navigation(
75 AdminNavigationGroup::new("Example").add(
76 NavigationItem::new("example_page", "Example Page").link("/admin/example/page"),
77 ),
78 );
79
80 admin.add_sidebar_widget(AdminSidebarWidget::htmx("/example/admin/test_widget"));
81 admin.add_sidebar_widget(AdminSidebarWidget::htmx("/example/admin/time_widget")); // .hx_trigger("load, every 1s") // This widget should be refreshed, but as it spams the console I leave this comment here so you know that it is possible
82
83 admin.add_dashboard_widget(AdminDashboardWidget::htmx("/example/admin/test_widget"));
84 admin.add_dashboard_widget(AdminDashboardWidget::htmx("/example/admin/test_widget"));
85 admin.add_dashboard_widget(AdminDashboardWidget::htmx("/example/admin/test_widget"));
86 admin.add_dashboard_widget(AdminDashboardWidget::htmx("/example/admin/test_widget"));
87
88 admin.register_entity_handler(EntityHandler::<
89 S,
90 TestEntityCreateForm,
91 TestEntityUpdateForm,
92 TestEntityListing,
93 >::new("Example"));
94
95 Ok(())
96 }pub fn new(template: impl ToString) -> Self
pub fn data<S: Serialize>(self, name: impl ToString, value: S) -> Self
pub fn hx_trigger(self, trigger: impl ToString) -> Self
Trait Implementations§
Source§impl Clone for AdminSidebarWidget
impl Clone for AdminSidebarWidget
Source§fn clone(&self) -> AdminSidebarWidget
fn clone(&self) -> AdminSidebarWidget
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AdminSidebarWidget
impl Debug for AdminSidebarWidget
Source§impl Default for AdminSidebarWidget
impl Default for AdminSidebarWidget
Source§fn default() -> AdminSidebarWidget
fn default() -> AdminSidebarWidget
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for AdminSidebarWidget
impl<'de> Deserialize<'de> for AdminSidebarWidget
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for AdminSidebarWidget
impl RefUnwindSafe for AdminSidebarWidget
impl Send for AdminSidebarWidget
impl Sync for AdminSidebarWidget
impl Unpin for AdminSidebarWidget
impl UnsafeUnpin for AdminSidebarWidget
impl UnwindSafe for AdminSidebarWidget
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
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>
Converts
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>
Converts
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