frontend: Add basic information about collections

This commit is contained in:
Lennart K
2025-07-04 20:54:37 +02:00
parent 32f5c01716
commit 6bcc03d659
13 changed files with 219 additions and 22 deletions

View File

@@ -5,7 +5,7 @@ use askama::Template;
use askama_web::WebTemplate;
use axum::{Extension, extract::Path, response::IntoResponse};
use http::StatusCode;
use rustical_store::{Calendar, CalendarStore, auth::Principal};
use rustical_store::{Calendar, CalendarStore, CollectionMetadata, auth::Principal};
impl Section for CalendarsSection {
fn name() -> &'static str {
@@ -17,8 +17,8 @@ impl Section for CalendarsSection {
#[template(path = "components/sections/calendars_section.html")]
pub struct CalendarsSection {
pub user: Principal,
pub calendars: Vec<Calendar>,
pub deleted_calendars: Vec<Calendar>,
pub calendars: Vec<(CollectionMetadata, Calendar)>,
pub deleted_calendars: Vec<(CollectionMetadata, Calendar)>,
}
pub async fn route_calendars<CS: CalendarStore>(
@@ -35,16 +35,38 @@ pub async fn route_calendars<CS: CalendarStore>(
calendars.extend(cal_store.get_calendars(group).await.unwrap());
}
let mut calendar_infos = vec![];
for calendar in calendars {
calendar_infos.push((
cal_store
.calendar_metadata(&calendar.principal, &calendar.id)
.await
.unwrap(),
calendar,
));
}
let mut deleted_calendars = vec![];
for group in user.memberships() {
deleted_calendars.extend(cal_store.get_deleted_calendars(group).await.unwrap());
}
let mut deleted_calendar_infos = vec![];
for calendar in deleted_calendars {
deleted_calendar_infos.push((
cal_store
.calendar_metadata(&calendar.principal, &calendar.id)
.await
.unwrap(),
calendar,
));
}
UserPage {
section: CalendarsSection {
user: user.clone(),
calendars,
deleted_calendars,
calendars: calendar_infos,
deleted_calendars: deleted_calendar_infos,
},
user,
}