Some refactoring and app token management

This commit is contained in:
Lennart
2025-04-14 17:17:36 +02:00
parent 354c6c97eb
commit 2ce8529002
12 changed files with 256 additions and 135 deletions

View File

@@ -5,8 +5,30 @@
{% block content %}
{% let name = calendar.displayname.to_owned().unwrap_or(calendar.id.to_owned()) %}
<h1>{{ name }}</h1>
<h1>{{ calendar.principal }}/{{ name }}</h1>
{% if let Some(description) = calendar.description %}<p>{{ description }}</p>{% endif%}
{% if let Some(subscription_url) = calendar.subscription_url %}
<h2>Subscription URL</h2>
<a href="{{ subscription_url }}">{{ subscription_url }}</a>
{% endif %}
<h2>Components</h2>
<ul>
{% for comp in calendar.components %}
<li>{{ comp.as_str() }}</li>
{% endfor %}
</ul>
<h2>Timezone</h2>
{% if let Some(timezone_id) = calendar.timezone_id %}
<p>{{ timezone_id }}</p>
{% endif %}
{% if let Some(timezone) = calendar.timezone %}
<pre>{{ timezone }}</pre>
{% endif %}
<pre>{{ calendar|json }}</pre>
{% endblock %}
{%endblock %}

View File

@@ -72,24 +72,47 @@ li.collection-list-item {
<h3>App tokens</h3>
<ul>
<table>
<tr>
<th>Name</th>
<th>Created at</th>
<th></th>
</tr>
{% for app_token in user.app_tokens %}
<li>
{{ app_token.name }}
{% if let Some(created_at) = app_token.created_at %}
{{ created_at.to_rfc3339() }}
{% endif %}
</li>
<tr>
<td>{{ app_token.name }}</td>
<td>
{% if let Some(created_at) = app_token.created_at %}
{{ created_at.to_rfc3339() }}
{% endif %}
</td>
<td>
<form action="/frontend/user/{{ user.id }}/app_token/{{ app_token.id }}/delete" method="POST">
<button type="submit">Delete</button>
</form>
</td>
</tr>
{% endfor %}
</ul>
<tr>
<form action="/frontend/user/{{ user.id }}/app_token" method="POST">
<td>
<label for="generate_app_token_name">App name</label>
<input type="text" name="name" id="generate_app_token_name" />
</td>
<td></td>
<td>
<button type="submit">Generate</button>
</td>
</form>
</tr>
</table>
<h2>Calendars</h2>
<ul>
{% 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/{{ calendar.principal }}/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 %}