mirror of
https://github.com/skoelle/icloud-contacts-sync.git
synced 2026-09-18 07:50:25 +00:00
web detail view
This commit is contained in:
@@ -186,3 +186,40 @@ def web_index(
|
||||
"search": search or "",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@app.get("/contacts/{contact_id}", response_class=HTMLResponse)
|
||||
def web_contact(
|
||||
request: Request,
|
||||
contact_id: int,
|
||||
current_user: str = Depends(get_current_user),
|
||||
):
|
||||
account_name, is_admin = resolve_account_for_user(current_user)
|
||||
|
||||
with db.get_connection() as conn:
|
||||
where_clause, params = _account_filter_clause(account_name)
|
||||
id_clause = "AND id = %s" if where_clause else "WHERE id = %s"
|
||||
with conn.cursor() as cur:
|
||||
cur.execute(
|
||||
f"""SELECT id, account, uid, full_name, given_name, family_name, organization,
|
||||
job_title, birthday, notes, emails, phones, addresses, urls, categories, updated_at
|
||||
FROM contacts {where_clause} {id_clause}""",
|
||||
params + [contact_id],
|
||||
)
|
||||
row = cur.fetchone()
|
||||
|
||||
if not row:
|
||||
from fastapi.responses import RedirectResponse
|
||||
return RedirectResponse(url="/", status_code=303)
|
||||
|
||||
contact = _row_to_contact_out(row)
|
||||
|
||||
return templates.TemplateResponse(
|
||||
"contact.html",
|
||||
{
|
||||
"request": request,
|
||||
"current_user": current_user,
|
||||
"is_admin": is_admin,
|
||||
"contact": contact,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -0,0 +1,289 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{ contact.full_name or 'Kontakt' }} – Kontakte</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
||||
background: #f5f5f5;
|
||||
color: #333;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem 1rem;
|
||||
}
|
||||
|
||||
.back-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
color: #0066cc;
|
||||
text-decoration: none;
|
||||
font-size: 0.875rem;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.back-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.contact-card {
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
padding: 1.5rem;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.contact-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
gap: 1rem;
|
||||
margin-bottom: 1.5rem;
|
||||
padding-bottom: 1.5rem;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.contact-name {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
color: #222;
|
||||
}
|
||||
|
||||
.contact-subtitle {
|
||||
font-size: 0.875rem;
|
||||
color: #666;
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
.badge {
|
||||
display: inline-block;
|
||||
padding: 0.2rem 0.6rem;
|
||||
border-radius: 4px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 500;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.badge-account {
|
||||
background: #d1ecf1;
|
||||
color: #0c5460;
|
||||
}
|
||||
|
||||
.section {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.section:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
color: #888;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.section-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.section-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0.75rem;
|
||||
background: #f8f9fa;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.section-item-label {
|
||||
font-size: 0.75rem;
|
||||
color: #888;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.section-item-value {
|
||||
font-size: 0.875rem;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.section-item-value a {
|
||||
color: #0066cc;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.section-item-value a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.birthday-highlight {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.75rem;
|
||||
background: #fff3cd;
|
||||
border-radius: 6px;
|
||||
font-size: 0.875rem;
|
||||
color: #856404;
|
||||
}
|
||||
|
||||
.notes-content {
|
||||
padding: 0.75rem;
|
||||
background: #f8f9fa;
|
||||
border-radius: 6px;
|
||||
font-size: 0.875rem;
|
||||
color: #333;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.tag {
|
||||
display: inline-block;
|
||||
padding: 0.25rem 0.75rem;
|
||||
background: #e7f3ff;
|
||||
color: #0066cc;
|
||||
border-radius: 20px;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.no-data {
|
||||
color: #888;
|
||||
font-style: italic;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<a href="/" class="back-link">← Zurück zur Übersicht</a>
|
||||
|
||||
<div class="contact-card">
|
||||
<div class="contact-header">
|
||||
<div>
|
||||
<div class="contact-name">{{ contact.full_name or '(Kein Name)' }}</div>
|
||||
{% if contact.organization or contact.job_title %}
|
||||
<div class="contact-subtitle">
|
||||
{% if contact.job_title %}{{ contact.job_title }}{% endif %}
|
||||
{% if contact.job_title and contact.organization %} bei {% endif %}
|
||||
{% if contact.organization %}{{ contact.organization }}{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if is_admin and contact.account %}
|
||||
<span class="badge badge-account">{{ contact.account }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if contact.birthday %}
|
||||
<div class="section">
|
||||
<div class="birthday-highlight">
|
||||
🎂 {{ contact.birthday }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if contact.emails %}
|
||||
<div class="section">
|
||||
<div class="section-title">E-Mail</div>
|
||||
<div class="section-list">
|
||||
{% for email in contact.emails %}
|
||||
<div class="section-item">
|
||||
<span class="section-item-label">{{ email.type }}</span>
|
||||
<span class="section-item-value"><a href="mailto:{{ email.value }}">{{ email.value }}</a></span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if contact.phones %}
|
||||
<div class="section">
|
||||
<div class="section-title">Telefon</div>
|
||||
<div class="section-list">
|
||||
{% for phone in contact.phones %}
|
||||
<div class="section-item">
|
||||
<span class="section-item-label">{{ phone.type }}</span>
|
||||
<span class="section-item-value"><a href="tel:{{ phone.value }}">{{ phone.value }}</a></span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if contact.addresses %}
|
||||
<div class="section">
|
||||
<div class="section-title">Adresse</div>
|
||||
<div class="section-list">
|
||||
{% for addr in contact.addresses %}
|
||||
<div class="section-item">
|
||||
<span class="section-item-label">{{ addr.type }}</span>
|
||||
<span class="section-item-value">
|
||||
{{ addr.street }}<br>
|
||||
{% if addr.zip %}{{ addr.zip }} {% endif %}{{ addr.city }}<br>
|
||||
{{ addr.region }}{% if addr.region and addr.country %}, {% endif %}{{ addr.country }}
|
||||
</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if contact.urls %}
|
||||
<div class="section">
|
||||
<div class="section-title">Website</div>
|
||||
<div class="section-list">
|
||||
{% for url in contact.urls %}
|
||||
<div class="section-item">
|
||||
<span class="section-item-label">{{ url.type }}</span>
|
||||
<span class="section-item-value"><a href="{{ url.value }}" target="_blank">{{ url.value }}</a></span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if contact.categories %}
|
||||
<div class="section">
|
||||
<div class="section-title">Kategorien</div>
|
||||
<div class="tags">
|
||||
{% for cat in contact.categories %}
|
||||
<span class="tag">{{ cat }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if contact.notes %}
|
||||
<div class="section">
|
||||
<div class="section-title">Notizen</div>
|
||||
<div class="notes-content">{{ contact.notes }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -90,10 +90,19 @@
|
||||
}
|
||||
|
||||
.contact-card {
|
||||
display: block;
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
padding: 1rem 1.25rem;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
transition: box-shadow 0.15s, transform 0.15s;
|
||||
}
|
||||
|
||||
.contact-card:hover {
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.contact-header {
|
||||
@@ -172,7 +181,7 @@
|
||||
<div class="contacts-list">
|
||||
{% if contacts %}
|
||||
{% for c in contacts %}
|
||||
<div class="contact-card">
|
||||
<a href="/contacts/{{ c.id }}" class="contact-card">
|
||||
<div class="contact-header">
|
||||
<div>
|
||||
<div class="contact-name">{{ c.full_name or '(Kein Name)' }}</div>
|
||||
@@ -187,7 +196,7 @@
|
||||
<span class="badge badge-account">{{ c.account }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="no-contacts">
|
||||
|
||||
Reference in New Issue
Block a user