frontend: Show group calendars

This commit is contained in:
Lennart
2025-04-12 13:13:16 +02:00
parent 30b0bf5b56
commit 63c16f411d
5 changed files with 22 additions and 35 deletions

View File

@@ -60,7 +60,7 @@ li.collection-list-item {
{% for calendar in calendars %}
{% let color = calendar.color.to_owned().unwrap_or("red".to_owned()) %}
<li class="collection-list-item" style="--color: {{ color }}">
<a href="/frontend/user/{{ user_id }}/calendar/{{ calendar.id}}">
<a href="/frontend/user/{{ calendar.principal }}/calendar/{{ calendar.id}}">
<span class="title">{{ calendar.displayname.to_owned().unwrap_or(calendar.id.to_owned()) }}</span>
<span class="description">
{% if let Some(description) = calendar.description %}{{ description }}{% endif %}
@@ -71,6 +71,8 @@ li.collection-list-item {
<div class="color-chip"></div>
</a>
</li>
{% else %}
You do not have any calendars yet
{% endfor %}
</ul>
{%if !deleted_calendars.is_empty() %}
@@ -79,7 +81,7 @@ li.collection-list-item {
{% for calendar in deleted_calendars %}
{% let color = calendar.color.to_owned().unwrap_or("red".to_owned()) %}
<li class="collection-list-item" style="--color: {{ color }}">
<a href="/frontend/user/{{ user_id }}/calendar/{{ calendar.id}}">
<a href="/frontend/user/{{ calendar.principal }}/calendar/{{ calendar.id}}">
<span class="title">{{ calendar.displayname.to_owned().unwrap_or(calendar.id.to_owned()) }}</span>
<span class="description">
{% if let Some(description) = calendar.description %}{{ description }}{% endif %}
@@ -98,13 +100,15 @@ li.collection-list-item {
<ul>
{% for addressbook in addressbooks %}
<li class="collection-list-item">
<a href="/frontend/user/{{ user_id }}/addressbook/{{ addressbook.id}}">
<a href="/frontend/user/{{ addressbook.principal }}/addressbook/{{ addressbook.id}}">
<span class="title">{{ addressbook.displayname.to_owned().unwrap_or(addressbook.id.to_owned()) }}</span>
<span class="description">
{% if let Some(description) = addressbook.description %}{{ description }}{% endif %}
</span>
</a>
</li>
{% else %}
You do not have any addressbooks yet
{% endfor %}
</ul>
{%if !deleted_addressbooks.is_empty() %}
@@ -112,7 +116,7 @@ li.collection-list-item {
<ul>
{% for addressbook in deleted_addressbooks %}
<li class="collection-list-item">
<a href="/frontend/user/{{ user_id }}/addressbook/{{ addressbook.id}}">
<a href="/frontend/user/{{ addressbook.principal }}/addressbook/{{ addressbook.id}}">
<span class="title">{{ addressbook.displayname.to_owned().unwrap_or(addressbook.id.to_owned()) }}</span>
<span class="description">
{% if let Some(description) = addressbook.description %}{{ description }}{% endif %}

View File

@@ -51,9 +51,15 @@ async fn route_user<CS: CalendarStore, AS: AddressbookStore>(
if user_id != user.id {
return actix_web::HttpResponse::Unauthorized().body("Unauthorized");
}
dbg!(&user);
let mut calendars = vec![];
for group in user.memberships() {
calendars.extend(cal_store.get_calendars(group).await.unwrap());
}
UserPage {
calendars: cal_store.get_calendars(&user.id).await.unwrap(),
calendars,
deleted_calendars: cal_store.get_deleted_calendars(&user.id).await.unwrap(),
addressbooks: addr_store.get_addressbooks(&user.id).await.unwrap(),
deleted_addressbooks: addr_store.get_deleted_addressbooks(&user.id).await.unwrap(),

View File

@@ -1,13 +1,13 @@
use actix_web::{
body::BoxBody,
http::{header, StatusCode},
FromRequest, HttpMessage, HttpResponse, ResponseError,
body::BoxBody,
http::{StatusCode, header},
};
use chrono::{DateTime, Utc};
use derive_more::Display;
use rustical_xml::ValueSerialize;
use serde::{Deserialize, Serialize};
use std::future::{ready, Ready};
use std::future::{Ready, ready};
/// https://datatracker.ietf.org/doc/html/rfc5545#section-3.2.3
#[derive(Debug, Clone, Deserialize, Serialize, Default, PartialEq)]
@@ -54,7 +54,7 @@ pub struct User {
#[serde(default)]
pub app_tokens: Vec<AppToken>,
#[serde(default)]
pub memberships: Vec<String>,
memberships: Vec<String>,
}
impl User {