ux: More style (bulma / fork-awesome) for logged in users
This commit is contained in:
parent
1d09019875
commit
a60434e662
14 changed files with 275 additions and 62 deletions
|
|
@ -7,6 +7,29 @@ use serde::Deserialize;
|
|||
use crate::db::{DatabaseInterface, Operation};
|
||||
use crate::http::{HttpSession, HttpState};
|
||||
|
||||
pub async fn list_domains(State(state): State<HttpState>, session: HttpSession) -> Response {
|
||||
let domains = match state.db.domains_user_can_see(&session.user).await {
|
||||
Ok(domains) => domains,
|
||||
Err(e) => {
|
||||
return format!("Database error: {e}").into_response();
|
||||
}
|
||||
};
|
||||
|
||||
let ctx = context! {
|
||||
domains,
|
||||
user => session.user,
|
||||
can_create_domain => session.user.can_create_domain(),
|
||||
};
|
||||
|
||||
let page = state
|
||||
.templates
|
||||
.get_template("domains.html")
|
||||
.unwrap()
|
||||
.render(ctx)
|
||||
.unwrap();
|
||||
(StatusCode::OK, Html(page)).into_response()
|
||||
}
|
||||
|
||||
pub async fn get_domain(
|
||||
State(state): State<HttpState>,
|
||||
session: HttpSession,
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ pub async fn http_listen(listener: Listener, db: Database) {
|
|||
.route("/login", post(login::post_login))
|
||||
.route("/logout", get(logout::logout))
|
||||
.route("/domain/{domain}", get(domain::get_domain))
|
||||
.route("/domain", get(domain::list_domains))
|
||||
.route("/domain", post(domain::create_domain))
|
||||
.route("/user", post(user::create_user))
|
||||
.with_state(HttpState::new(db));
|
||||
|
|
|
|||
Loading…
Reference in a new issue