Add base status bar

This commit is contained in:
Pierre HUBERT 2025-01-22 21:09:45 +01:00
parent 3b208c0103
commit d133513daf
3 changed files with 29 additions and 4 deletions

View File

@ -31,7 +31,7 @@ async fn main() -> std::io::Result<()> {
.build(), .build(),
) )
// Web configuration routes // Web configuration routes
.route("/static/{tail:.*}", web::get().to(web_ui::static_file)) .route("/assets/{tail:.*}", web::get().to(web_ui::static_file))
.route("/", web::get().to(web_ui::home)) .route("/", web::get().to(web_ui::home))
.route("/oidc_cb", web::get().to(web_ui::oidc_cb)) .route("/oidc_cb", web::get().to(web_ui::oidc_cb))
.route("/sign_out", web::get().to(web_ui::sign_out)) .route("/sign_out", web::get().to(web_ui::sign_out))

View File

@ -29,7 +29,9 @@ pub async fn static_file(path: web::Path<String>) -> HttpResult {
#[derive(askama::Template)] #[derive(askama::Template)]
#[template(path = "index.html")] #[template(path = "index.html")]
struct HomeTemplate {} struct HomeTemplate {
name: String,
}
/// Main route /// Main route
pub async fn home(session: Session) -> HttpResult { pub async fn home(session: Session) -> HttpResult {
@ -53,7 +55,7 @@ pub async fn home(session: Session) -> HttpResult {
Ok(HttpResponse::Ok() Ok(HttpResponse::Ok()
.insert_header(("content-type", "text/html")) .insert_header(("content-type", "text/html"))
.body(HomeTemplate {}.render().unwrap())) .body(HomeTemplate { name: user.name }.render().unwrap()))
} }
#[derive(serde::Deserialize)] #[derive(serde::Deserialize)]

View File

@ -3,9 +3,32 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Matrix GW</title> <title>Matrix GW</title>
<link rel="icon" type="image/png" href="/static/favicon.png" /> <link rel="icon" type="image/png" href="/assets/favicon.png"/>
<link rel="stylesheet" href="/assets/bootstrap.css"/>
</head> </head>
<body> <body>
<!-- Header -->
<header data-bs-theme="dark">
<div class="navbar navbar-dark bg-dark shadow-sm">
<div class="container">
<a href="#" class="navbar-brand d-flex align-items-center">
<svg xxmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="none" stroke="currentColor"
stroke-linecap="round" stroke-linejoin="round" stroke-width="1" aria-hidden="true" class="me-2"
viewBox="0 0 24 24">
<path d="M10 11.5H17V13H10V11.5M10 8.5H19V10H10V8.5M20 5H9C7.9 5 7 5.9 7 7V21L11 17H20C21.1 17 22 16.1 22 15V7C22 5.9 21.1 5 20 5M20 15H10.2L9 16.2V7H20V15M3 7C2.4 7 2 7.4 2 8S2.4 9 3 9H5V7H3M2 11C1.4 11 1 11.4 1 12S1.4 13 2 13H5V11H2M1 15C.4 15 0 15.4 0 16C0 16.6 .4 17 1 17H5V15H1Z"/>
</svg>
<strong>Matrix GW</strong>
</a>
<div class="navbar">
<span>Hi <span style="font-style: italic;">{{ name }}</span>&nbsp;&nbsp;</span>
<a href="/sign_out">Sign out</a>
</div>
</div>
</div>
</header>
</body> </body>
</html> </html>