use super::*;
pub(super) async fn dashboard_index() -> Response {
let html = include_str!("../../../dashboard/dist/index.html");
(
StatusCode::OK,
[(
header::CONTENT_TYPE,
HeaderValue::from_static("text/html; charset=utf-8"),
)],
html,
)
.into_response()
}
pub(super) async fn dashboard_assets(Path(filename): Path<String>) -> Response {
let content_type = if filename.ends_with(".js") {
"application/javascript"
} else if filename.ends_with(".css") {
"text/css"
} else if filename.ends_with(".svg") {
"image/svg+xml"
} else if filename.ends_with(".json") {
"application/json"
} else {
"application/octet-stream"
};
let response = match filename.as_str() {
env!("DASHBOARD_CSS") => (
StatusCode::OK,
[(header::CONTENT_TYPE, HeaderValue::from_static(content_type))],
include_str!(concat!(
"../../../dashboard/dist/assets/",
env!("DASHBOARD_CSS")
)),
)
.into_response(),
env!("DASHBOARD_JS") => (
StatusCode::OK,
[(header::CONTENT_TYPE, HeaderValue::from_static(content_type))],
include_str!(concat!(
"../../../dashboard/dist/assets/",
env!("DASHBOARD_JS")
)),
)
.into_response(),
_ => {
error!("Dashboard asset not found: {}", filename);
(StatusCode::NOT_FOUND, "Asset not found").into_response()
}
};
response
}
pub(super) async fn dashboard_favicon() -> Response {
(
StatusCode::OK,
[(
header::CONTENT_TYPE,
HeaderValue::from_static("image/svg+xml"),
)],
include_str!("../../../dashboard/dist/favicon.svg"),
)
.into_response()
}
pub(super) async fn dashboard_icons() -> Response {
(
StatusCode::OK,
[(
header::CONTENT_TYPE,
HeaderValue::from_static("image/svg+xml"),
)],
include_str!("../../../dashboard/dist/icons.svg"),
)
.into_response()
}