mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
frontend: Add basic information about collections
This commit is contained in:
@@ -4,7 +4,7 @@ use askama::Template;
|
||||
use askama_web::WebTemplate;
|
||||
use axum::{Extension, extract::Path, response::IntoResponse};
|
||||
use http::StatusCode;
|
||||
use rustical_store::{Addressbook, AddressbookStore, auth::Principal};
|
||||
use rustical_store::{Addressbook, AddressbookStore, CollectionMetadata, auth::Principal};
|
||||
|
||||
use crate::pages::user::{Section, UserPage};
|
||||
|
||||
@@ -18,8 +18,8 @@ impl Section for AddressbooksSection {
|
||||
#[template(path = "components/sections/addressbooks_section.html")]
|
||||
pub struct AddressbooksSection {
|
||||
pub user: Principal,
|
||||
pub addressbooks: Vec<Addressbook>,
|
||||
pub deleted_addressbooks: Vec<Addressbook>,
|
||||
pub addressbooks: Vec<(CollectionMetadata, Addressbook)>,
|
||||
pub deleted_addressbooks: Vec<(CollectionMetadata, Addressbook)>,
|
||||
}
|
||||
|
||||
pub async fn route_addressbooks<AS: AddressbookStore>(
|
||||
@@ -41,11 +41,33 @@ pub async fn route_addressbooks<AS: AddressbookStore>(
|
||||
deleted_addressbooks.extend(addr_store.get_deleted_addressbooks(group).await.unwrap());
|
||||
}
|
||||
|
||||
let mut addressbook_infos = vec![];
|
||||
for addressbook in addressbooks {
|
||||
addressbook_infos.push((
|
||||
addr_store
|
||||
.addressbook_metadata(&addressbook.principal, &addressbook.id)
|
||||
.await
|
||||
.unwrap(),
|
||||
addressbook,
|
||||
));
|
||||
}
|
||||
|
||||
let mut deleted_addressbook_infos = vec![];
|
||||
for addressbook in deleted_addressbooks {
|
||||
deleted_addressbook_infos.push((
|
||||
addr_store
|
||||
.addressbook_metadata(&addressbook.principal, &addressbook.id)
|
||||
.await
|
||||
.unwrap(),
|
||||
addressbook,
|
||||
));
|
||||
}
|
||||
|
||||
UserPage {
|
||||
section: AddressbooksSection {
|
||||
user: user.clone(),
|
||||
addressbooks,
|
||||
deleted_addressbooks,
|
||||
addressbooks: addressbook_infos,
|
||||
deleted_addressbooks: deleted_addressbook_infos,
|
||||
},
|
||||
user,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user