Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Quokka Admin

The Quokka Admin project provides an extensible UI for managing your application and especially entities.

It allows you to extend various parts with your custom UIs, widgets and entities. All that you need is a URL which provides valid HTML to display it in whatever parts of the Admin UI that you want to extend.

This documentation part expect's you to already know how Quokka works and uses parts that were mentioned as optional parts like custom states or the command system

Usage

To use Quokka Admin add the quokka_admin::state::AdminState to your custom state and load the quokka_admin::AdminBundle. You now can open the admin-ui under /admin.

#[derive(Clone, State, ProvideState)]
pub struct YourCustomState {
    // ...,
    admin_state: quokka_admin::state::AdminState<Self>,
    // ...,
}

#[tokio::main]
async fn main() -> quokka::Result<()> {
    quokka::Quokka::<YourCustomState>::try_default()?
        // ...
        .load::<quokka_admin::AdminBundle>()?
        // ...
        .serve()
        .await
}

To create a user you have to start up your applications cli with the quokka-admin:user:admin:create <username> <email> --password <password> command (if no --password argument is provided, the command will ask you for a password).

Getting started

To get started with adding your custom parts to the UI you want to set up the configure_state callback of your bundle to set up things on the AdminState like shown here


impl<S> Pouch<S> for YourCustomState where
    /// ...
    S: ProvideStateRef<AdminState<S>>,
    /// ...
{
    /// ...

    fn configure_state(&mut self, state: &mut S) -> quokka::Result<()> {
        /// ...

        // If you just use the `provide()` function you will get a `Clone` of the AdminState to which the changes will not make it to the actual instance of the AdminState
        let admin: &mut AdminState<_> = state.provide_mut();

        ///...
    }

    /// ...
}

The documentation here is barely done. For now check the Quokka Admin examples to see everything that you can do with the Quokka Admin.