mirror of
https://github.com/skoelle/icloud-contacts-sync.git
synced 2026-09-17 23:40:24 +00:00
new layout
This commit is contained in:
+14
-2
@@ -149,15 +149,26 @@ def list_sync_runs(current_user: str = Depends(get_current_user)):
|
|||||||
|
|
||||||
|
|
||||||
@app.get("/", response_class=HTMLResponse)
|
@app.get("/", response_class=HTMLResponse)
|
||||||
def web_index(request: Request, current_user: str = Depends(get_current_user)):
|
def web_index(
|
||||||
|
request: Request,
|
||||||
|
search: str | None = Query(default=None),
|
||||||
|
current_user: str = Depends(get_current_user),
|
||||||
|
):
|
||||||
account_name, is_admin = resolve_account_for_user(current_user)
|
account_name, is_admin = resolve_account_for_user(current_user)
|
||||||
|
|
||||||
with db.get_connection() as conn:
|
with db.get_connection() as conn:
|
||||||
where_clause, params = _account_filter_clause(account_name)
|
where_clause, params = _account_filter_clause(account_name)
|
||||||
|
search_clause = ""
|
||||||
|
if search:
|
||||||
|
search_op = "AND" if where_clause else "WHERE"
|
||||||
|
search_clause = f" {search_op} (full_name LIKE %s OR organization LIKE %s)"
|
||||||
|
like = f"%{search}%"
|
||||||
|
params.extend([like, like])
|
||||||
|
|
||||||
with conn.cursor() as cur:
|
with conn.cursor() as cur:
|
||||||
cur.execute(
|
cur.execute(
|
||||||
f"""SELECT id, full_name, organization, birthday, account
|
f"""SELECT id, full_name, organization, birthday, account
|
||||||
FROM contacts {where_clause}
|
FROM contacts {where_clause}{search_clause}
|
||||||
ORDER BY full_name
|
ORDER BY full_name
|
||||||
LIMIT 200""",
|
LIMIT 200""",
|
||||||
params,
|
params,
|
||||||
@@ -172,5 +183,6 @@ def web_index(request: Request, current_user: str = Depends(get_current_user)):
|
|||||||
"is_admin": is_admin,
|
"is_admin": is_admin,
|
||||||
"account_name": account_name or "alle Accounts",
|
"account_name": account_name or "alle Accounts",
|
||||||
"contacts": rows,
|
"contacts": rows,
|
||||||
|
"search": search or "",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
+186
-20
@@ -1,38 +1,204 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Kontakte – {{ account_name }}</title>
|
<title>Kontakte – {{ account_name }}</title>
|
||||||
<style>
|
<style>
|
||||||
body { font-family: sans-serif; margin: 2rem; background: #111; color: #eee; }
|
* {
|
||||||
h1 { font-size: 1.4rem; }
|
margin: 0;
|
||||||
table { border-collapse: collapse; width: 100%; margin-top: 1rem; }
|
padding: 0;
|
||||||
th, td { border-bottom: 1px solid #333; padding: 0.4rem 0.6rem; text-align: left; }
|
box-sizing: border-box;
|
||||||
th { background: #1c1c1c; }
|
}
|
||||||
.meta { color: #999; font-size: 0.85rem; margin-bottom: 1rem; }
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
color: #222;
|
||||||
|
}
|
||||||
|
|
||||||
|
.meta {
|
||||||
|
color: #666;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-form {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.5rem;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-form input[type="text"] {
|
||||||
|
flex: 1;
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 1rem;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-form input[type="text"]:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: #0066cc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-form button {
|
||||||
|
padding: 0.75rem 1.5rem;
|
||||||
|
background: #0066cc;
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 1rem;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-form button:hover {
|
||||||
|
background: #0055aa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-form a {
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
background: #e0e0e0;
|
||||||
|
color: #333;
|
||||||
|
text-decoration: none;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-form a:hover {
|
||||||
|
background: #d0d0d0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contacts-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contact-card {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 1rem 1.25rem;
|
||||||
|
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: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contact-name {
|
||||||
|
font-size: 1.125rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #222;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contact-organization {
|
||||||
|
font-size: 0.875rem;
|
||||||
|
color: #666;
|
||||||
|
margin-top: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contact-birthday {
|
||||||
|
font-size: 0.875rem;
|
||||||
|
color: #888;
|
||||||
|
margin-top: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contact-birthday::before {
|
||||||
|
content: "\1F382 ";
|
||||||
|
}
|
||||||
|
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-contacts {
|
||||||
|
text-align: center;
|
||||||
|
color: #888;
|
||||||
|
padding: 3rem 1rem;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<div class="container">
|
||||||
<h1>Kontakte</h1>
|
<h1>Kontakte</h1>
|
||||||
<div class="meta">
|
<div class="meta">
|
||||||
Angemeldet als <strong>{{ current_user }}</strong>
|
Angemeldet als <strong>{{ current_user }}</strong>
|
||||||
{% if is_admin %}(Admin, sieht alle Accounts){% else %}(Account: {{ account_name }}){% endif %}
|
{% if is_admin %}(Admin, sieht alle Accounts){% else %}(Account: {{ account_name }}){% endif %}
|
||||||
· {{ contacts|length }} Kontakte (max. 200 angezeigt)
|
· {{ contacts|length }} Kontakte (max. 200 angezeigt)
|
||||||
</div>
|
</div>
|
||||||
<table>
|
|
||||||
<thead>
|
<form class="search-form" method="get" action="/">
|
||||||
<tr><th>Name</th><th>Organisation</th><th>Geburtstag</th>{% if is_admin %}<th>Account</th>{% endif %}</tr>
|
<input type="text" name="search" value="{{ search }}" placeholder="Suche nach Name oder Organisation...">
|
||||||
</thead>
|
<button type="submit">Suchen</button>
|
||||||
<tbody>
|
{% if search %}
|
||||||
|
<a href="/">Zurücksetzen</a>
|
||||||
|
{% endif %}
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div class="contacts-list">
|
||||||
|
{% if contacts %}
|
||||||
{% for c in contacts %}
|
{% for c in contacts %}
|
||||||
<tr>
|
<div class="contact-card">
|
||||||
<td>{{ c.full_name or "-" }}</td>
|
<div class="contact-header">
|
||||||
<td>{{ c.organization or "-" }}</td>
|
<div>
|
||||||
<td>{{ c.birthday or "-" }}</td>
|
<div class="contact-name">{{ c.full_name or '(Kein Name)' }}</div>
|
||||||
{% if is_admin %}<td>{{ c.account }}</td>{% endif %}
|
{% if c.organization %}
|
||||||
</tr>
|
<div class="contact-organization">{{ c.organization }}</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if c.birthday %}
|
||||||
|
<div class="contact-birthday">{{ c.birthday }}</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% if is_admin and c.account %}
|
||||||
|
<span class="badge badge-account">{{ c.account }}</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
{% else %}
|
||||||
</table>
|
<div class="no-contacts">
|
||||||
|
{% if search %}
|
||||||
|
Keine Kontakte für "{{ search }}" gefunden.
|
||||||
|
{% else %}
|
||||||
|
Keine Kontakte vorhanden.
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user