frontend: some changes

This commit is contained in:
Lennart
2024-11-10 13:18:45 +01:00
parent 43ff0c6671
commit 130d8b00ab
9 changed files with 103 additions and 27 deletions

View File

@@ -7,7 +7,7 @@ repository.workspace = true
publish = false
[dependencies]
askama = { workspace = true }
askama.workspace = true
askama_actix = { workspace = true }
actix-session = { workspace = true }
serde = { workspace = true }

View File

@@ -0,0 +1,3 @@
body {
font-family: sans-serif;
}

View File

@@ -5,6 +5,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}RustiCal{% endblock %}</title>
<link rel="stylesheet" href="/frontend/assets/style.css" />
<style>
* {
box-sizing: border-box;

View File

@@ -4,6 +4,11 @@
{% endblock %}
{% block content %}
<h1>Test</h1>
<a href="/frontend/user/{{ owner }}">Back</a>
{% let name = addressbook.displayname.to_owned().unwrap_or(addressbook.id.to_owned()) %}
<h1>{{ name }}</h1>
{% if let Some(description) = addressbook.description %}<p>{{ description }}</p>{% endif%}
<pre>{{ addressbook|yaml }}</pre>
<a href="/frontend/user/{{ addressbook.principal }}">Back</a>
{% endblock %}

View File

@@ -4,6 +4,11 @@
{% endblock %}
{% block content %}
<h1>Test</h1>
{% let name = calendar.displayname.to_owned().unwrap_or(calendar.id.to_owned()) %}
<h1>{{ name }}</h1>
{% if let Some(description) = calendar.description %}<p>{{ description }}</p>{% endif%}
<pre>{{ calendar|yaml }}</pre>
<a href="/frontend/user/{{ calendar.principal }}">Back</a>
{% endblock %}

View File

@@ -48,6 +48,23 @@ li.collection-list-item {
</li>
{% endfor %}
</ul>
{%if !deleted_calendars.is_empty() %}
<h3>Deleted Calendars</h3>
<ul>
{% 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}}">
<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 %}
</span>
<div class="color-chip"></div>
</a>
</li>
{% endfor %}
</ul>
{% endif %}
<h2>Addressbooks</h2>
<ul>
@@ -62,5 +79,20 @@ li.collection-list-item {
</li>
{% endfor %}
</ul>
{%if !deleted_addressbooks.is_empty() %}
<h3>Deleted Addressbooks</h3>
<ul>
{% for addressbook in deleted_addressbooks %}
<li class="collection-list-item">
<a href="/frontend/user/{{ user_id }}/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>
{% endfor %}
</ul>
{% endif %}
{% endblock %}

View File

@@ -30,7 +30,9 @@ pub use config::FrontendConfig;
struct UserPage {
pub user_id: String,
pub calendars: Vec<Calendar>,
pub deleted_calendars: Vec<Calendar>,
pub addressbooks: Vec<Addressbook>,
pub deleted_addressbooks: Vec<Addressbook>,
}
async fn route_user<CS: CalendarStore + ?Sized, AS: AddressbookStore + ?Sized>(
@@ -47,7 +49,9 @@ async fn route_user<CS: CalendarStore + ?Sized, AS: AddressbookStore + ?Sized>(
UserPage {
calendars: cal_store.get_calendars(&user.id).await.unwrap(),
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(),
user_id: user.id,
}
.to_response()