Struct feattle::AdminPanel[][src]

pub struct AdminPanel<F, P> { /* fields omitted */ }
Expand description

The administration panel, agnostic to the choice of web-framework.

This type is designed to be easily integrated with Rust web-frameworks, by providing one method per page and form submission, each returning bytes with their “Content-Type”.

Example

use feattle_ui::AdminPanel;
use feattle_core::{feattles, Feattles};
use feattle_core::persist::NoPersistence;
use std::sync::Arc;

feattles! {
    struct MyToggles { a: bool, b: i32 }
}

// `NoPersistence` here is just a mock for the sake of the example
let my_toggles = Arc::new(MyToggles::new(NoPersistence));
let admin_panel = AdminPanel::new(my_toggles, "Project Panda - DEV".to_owned());

let home_content = admin_panel.list_feattles().await?;
assert_eq!(home_content.content_type, "text/html; charset=utf-8");
assert!(home_content.content.len() > 0);

Implementations

Create a new UI provider for a given feattles and a user-visible label

Render the page that lists the current feattles values, together with navigation links to modify them. This page is somewhat the “home screen” of the UI.

To ensure fresh data is displayed, Feattles::reload() is called.

The JSON-API equivalent of AdminPanel::list_feattles().

To ensure fresh data is displayed, Feattles::reload() is called.

Render the page that shows the current and historical values of a single feattle, together with the form to modify it. The generated form submits to “/feattle/{{ key }}/edit” with the POST method in url-encoded format with a single field called “value_json”.

To ensure fresh data is displayed, Feattles::reload() is called.

The JSON-API equivalent of AdminPanel::show_feattle().

To ensure fresh data is displayed, Feattles::reload() is called.

Process a modification of a single feattle, given its key and the JSON representation of its future value. In case of success, the return is empty, so caller should usually redirect the user somewhere after.

To ensure fresh data is displayed, Feattles::reload() is called. Unlike the other pages, if the reload fails, this operation will fail.

The JSON-API equivalent of AdminPanel::edit_feattle().

To ensure fresh data is displayed, Feattles::reload() is called. Unlike the other pages, if the reload fails, this operation will fail.

Renders a public file with the given path. The pages include public files like “/public/some/path.js”, but this method should be called with only the “some/path.js” part.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.