peach-workspace/peach-web/src/routes/settings/power/menu.rs

38 lines
1.3 KiB
Rust

use maud::{html, PreEscaped};
use rouille::Request;
use crate::{
templates,
utils::{flash::FlashRequest, theme},
};
/// Power menu template builder.
///
/// Presents options for rebooting or shutting down the device.
pub fn build_template(request: &Request) -> PreEscaped<String> {
let (flash_name, flash_msg) = request.retrieve_flash();
let power_menu_template = html! {
(PreEscaped("<!-- POWER MENU -->"))
div class="card center" {
div class="card-container" {
div id="buttons" {
a id="rebootBtn" class="button button-primary center" href="/reboot" title="Reboot Device" { "Reboot" }
a id="shutdownBtn" class="button button-warning center" href="/shutdown" title="Shutdown Device" { "Shutdown" }
a id="cancelBtn" class="button button-secondary center" href="/settings" title="Cancel" { "Cancel" }
}
@if let (Some(name), Some(msg)) = (flash_name, flash_msg) {
(PreEscaped("<!-- FLASH MESSAGE -->"))
(templates::flash::build_template(name, msg))
}
}
}
};
let body = templates::nav::build_template(power_menu_template, "Power Menu", Some("/"));
let theme = theme::get_theme();
templates::base::build_template(body, theme)
}