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:
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user