15f7e6a64d
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
462 lines
15 KiB
HTML
462 lines
15 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
{% include 'head.html' %}
|
|
|
|
<style>
|
|
html, body { overflow: visible; }
|
|
|
|
.container {
|
|
max-width: 900px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
h1 {
|
|
color: #333;
|
|
margin-bottom: 4px;
|
|
font-size: 1.5em;
|
|
}
|
|
|
|
.subtitle {
|
|
color: #666;
|
|
margin-bottom: 24px;
|
|
font-size: 0.9em;
|
|
}
|
|
|
|
/* ---- Profile card ---- */
|
|
.profile-card {
|
|
background: #fff;
|
|
border-radius: 8px;
|
|
box-shadow: 0 1px 6px rgba(0,0,0,0.1);
|
|
padding: 28px 32px;
|
|
margin-bottom: 24px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 28px;
|
|
}
|
|
|
|
.avatar-large {
|
|
width: 80px;
|
|
height: 80px;
|
|
border-radius: 50%;
|
|
object-fit: cover;
|
|
flex-shrink: 0;
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
|
|
}
|
|
|
|
.avatar-initials-large {
|
|
width: 80px;
|
|
height: 80px;
|
|
border-radius: 50%;
|
|
background: #0066cc;
|
|
color: #fff;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 2em;
|
|
font-weight: 700;
|
|
flex-shrink: 0;
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
|
|
}
|
|
|
|
.profile-info { flex: 1; }
|
|
|
|
.profile-name {
|
|
font-size: 1.4em;
|
|
font-weight: 700;
|
|
color: #222;
|
|
margin-bottom: 4px;
|
|
}
|
|
|
|
.profile-username {
|
|
font-size: 0.9em;
|
|
color: #666;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.badge {
|
|
display: inline-block;
|
|
padding: 2px 10px;
|
|
border-radius: 12px;
|
|
font-size: 0.78em;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.4px;
|
|
}
|
|
|
|
.badge-admin { background: #e8f0fe; color: #1a73e8; }
|
|
.badge-user { background: #f1f3f4; color: #555; }
|
|
|
|
.profile-logout {
|
|
margin-top: 14px;
|
|
}
|
|
|
|
.btn-logout {
|
|
display: inline-block;
|
|
padding: 6px 16px;
|
|
border-radius: 4px;
|
|
background: #f44336;
|
|
color: #fff;
|
|
font-size: 0.85em;
|
|
font-weight: 500;
|
|
text-decoration: none;
|
|
transition: background 0.15s;
|
|
}
|
|
.btn-logout:hover { background: #d32f2f; text-decoration: none; }
|
|
|
|
/* ---- Section cards ---- */
|
|
.section {
|
|
background: #fff;
|
|
border-radius: 8px;
|
|
box-shadow: 0 1px 6px rgba(0,0,0,0.1);
|
|
padding: 20px 24px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.section h2 {
|
|
font-size: 1em;
|
|
font-weight: 700;
|
|
color: #333;
|
|
margin: 0 0 16px;
|
|
padding-bottom: 10px;
|
|
border-bottom: 1px solid #eee;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
}
|
|
|
|
/* ---- Settings rows ---- */
|
|
.settings-row {
|
|
display: flex;
|
|
align-items: baseline;
|
|
padding: 8px 0;
|
|
border-bottom: 1px solid #f5f5f5;
|
|
font-size: 0.9em;
|
|
}
|
|
.settings-row:last-child { border-bottom: none; }
|
|
|
|
.settings-label {
|
|
width: 180px;
|
|
flex-shrink: 0;
|
|
color: #666;
|
|
font-size: 0.88em;
|
|
}
|
|
|
|
.settings-value { color: #222; }
|
|
|
|
.settings-empty { color: #aaa; font-style: italic; }
|
|
|
|
/* ---- Host lists ---- */
|
|
.host-grid {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 8px;
|
|
}
|
|
|
|
.host-chip {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
padding: 4px 12px;
|
|
border-radius: 16px;
|
|
font-size: 0.85em;
|
|
font-weight: 500;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.host-chip.owner { background: #e8f5e9; color: #2e7d32; }
|
|
.host-chip.manager { background: #e3f2fd; color: #1565c0; }
|
|
.host-chip.monitor { background: #f3e5f5; color: #6a1b9a; }
|
|
|
|
.host-chip-dot {
|
|
width: 7px; height: 7px; border-radius: 50%;
|
|
}
|
|
.owner .host-chip-dot { background: #2e7d32; }
|
|
.manager .host-chip-dot { background: #1565c0; }
|
|
.monitor .host-chip-dot { background: #6a1b9a; }
|
|
|
|
.no-hosts {
|
|
color: #aaa;
|
|
font-size: 0.9em;
|
|
font-style: italic;
|
|
}
|
|
|
|
/* ---- Notification channels ---- */
|
|
.channel-row {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
padding: 6px 0;
|
|
border-bottom: 1px solid #f5f5f5;
|
|
font-size: 0.9em;
|
|
}
|
|
.channel-row:last-child { border-bottom: none; }
|
|
|
|
.channel-type {
|
|
display: inline-block;
|
|
padding: 2px 8px;
|
|
border-radius: 10px;
|
|
font-size: 0.78em;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
background: #f1f3f4;
|
|
color: #555;
|
|
min-width: 70px;
|
|
text-align: center;
|
|
}
|
|
|
|
.channel-name { color: #333; }
|
|
|
|
.edit-section { margin-top: 20px; }
|
|
.edit-section h4 { font-size: .88em; font-weight: 600; color: #333; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid #eee; padding-bottom: 6px; }
|
|
.edit-field { margin-bottom: 10px; }
|
|
.edit-field label { display: block; font-size: .82em; color: #666; margin-bottom: 3px; }
|
|
.edit-input { width: 100%; border: 1px solid #ccc; border-radius: 4px; padding: 5px 8px; font-size: .88em; box-sizing: border-box; }
|
|
.edit-input:focus { border-color: #0066cc; outline: none; }
|
|
.status-msg { font-size: .82em; margin-left: 8px; }
|
|
.save-row { display: flex; align-items: center; margin-top: 8px; }
|
|
.btn-save { background: #0066cc; color: #fff; border: none; border-radius: 4px; padding: 5px 14px; font-size: .85em; cursor: pointer; }
|
|
.btn-save:hover { background: #0055aa; }
|
|
.channel-item { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; border-bottom: 1px solid #f5f5f5; }
|
|
.channel-item:last-child { border-bottom: none; }
|
|
.channel-item label { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; font-size: .88em; }
|
|
.channel-item .ch-name { font-weight: 500; color: #222; }
|
|
.channel-item .ch-meta { font-size: .8em; color: #888; }
|
|
</style>
|
|
|
|
<body>
|
|
{% include 'nav.html' %}
|
|
|
|
<div class="container">
|
|
<h1>{{ header }}</h1>
|
|
<p class="subtitle">Your account settings and host access</p>
|
|
|
|
<!-- Profile card -->
|
|
<div class="profile-card">
|
|
{% if current_user and current_user.avatar %}
|
|
<img class="avatar-large" src="{{ current_user.avatar_url }}" alt="">
|
|
{% else %}
|
|
<div class="avatar-initials-large">
|
|
{{ ((current_user.full_name if current_user else '') or (current_user.username if current_user else '?'))[:1] | upper }}
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="profile-info">
|
|
<div class="profile-name">{{ current_user.full_name if current_user and current_user.full_name else (current_user.username if current_user else '—') }}</div>
|
|
<div class="profile-username">@{{ current_user.username if current_user else '—' }}</div>
|
|
{% if current_user and current_user.admin %}
|
|
<span class="badge badge-admin">Admin</span>
|
|
{% else %}
|
|
<span class="badge badge-user">User</span>
|
|
{% endif %}
|
|
<div class="profile-logout">
|
|
<a href="/logout" class="btn-logout">Sign out</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Account settings -->
|
|
<div class="section">
|
|
<h2>Account</h2>
|
|
<div class="settings-row">
|
|
<span class="settings-label">Username</span>
|
|
<span class="settings-value">{{ current_user.username if current_user else '—' }}</span>
|
|
</div>
|
|
<div class="settings-row">
|
|
<span class="settings-label">Full name</span>
|
|
{% if current_user and current_user.full_name %}
|
|
<span class="settings-value">{{ current_user.full_name }}</span>
|
|
{% else %}
|
|
<span class="settings-empty">Not set</span>
|
|
{% endif %}
|
|
</div>
|
|
<div class="settings-row">
|
|
<span class="settings-label">Role</span>
|
|
<span class="settings-value">{{ 'Administrator' if current_user and current_user.admin else 'User' }}</span>
|
|
</div>
|
|
<div class="settings-row">
|
|
<span class="settings-label">Avatar</span>
|
|
{% if current_user and current_user.avatar %}
|
|
<span class="settings-value" style="word-break:break-all;">{{ current_user.avatar }}</span>
|
|
{% else %}
|
|
<span class="settings-empty">Not set (initials used)</span>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
{% if current_user %}
|
|
<!-- ---- Editable identity ---- -->
|
|
<div class="section edit-section">
|
|
<h4>Identity</h4>
|
|
<div class="edit-field">
|
|
<label for="profile-fullname">Display name</label>
|
|
<input id="profile-fullname" class="edit-input" type="text" value="{{ current_user.full_name | e }}" placeholder="Full name">
|
|
</div>
|
|
<div class="edit-field">
|
|
<label for="profile-avatar">Avatar URL or path</label>
|
|
<input id="profile-avatar" class="edit-input" type="text" value="{{ current_user.avatar | e }}" placeholder="/path/to/avatar.png or https://…">
|
|
</div>
|
|
<div class="save-row">
|
|
<button class="btn-save" onclick="saveIdentity()">Save</button>
|
|
<span id="identity-status" class="status-msg"></span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ---- Change password ---- -->
|
|
<div class="section edit-section">
|
|
<h4>Change password</h4>
|
|
<div class="edit-field">
|
|
<label for="profile-current-pw">Current password</label>
|
|
<input id="profile-current-pw" class="edit-input" type="password" autocomplete="current-password">
|
|
</div>
|
|
<div class="edit-field">
|
|
<label for="profile-new-pw">New password</label>
|
|
<input id="profile-new-pw" class="edit-input" type="password" autocomplete="new-password">
|
|
</div>
|
|
<div class="save-row">
|
|
<button class="btn-save" onclick="changePassword()">Change password</button>
|
|
<span id="password-status" class="status-msg"></span>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Notification channels -->
|
|
<div class="section">
|
|
<h2>Notification Channels</h2>
|
|
{% if current_user %}
|
|
<p style="font-size:.82em;color:#888;margin:0 0 10px">Select which channels send you alerts. Channels are defined by the administrator.</p>
|
|
{% if all_channel_names %}
|
|
<div id="channel-checkboxes">
|
|
{% for ch_name in all_channel_names %}
|
|
<div class="channel-item">
|
|
<label>
|
|
<input type="checkbox" class="channel-checkbox" value="{{ ch_name | e }}"
|
|
{% if ch_name in (current_user.notification_channels or []) %}checked{% endif %}>
|
|
<div>
|
|
<div class="ch-name">{{ ch_name | e }}</div>
|
|
</div>
|
|
</label>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
{% else %}
|
|
<p style="font-size:.83em;color:#bbb;font-style:italic">No notification channels configured.</p>
|
|
{% endif %}
|
|
<div class="save-row" style="margin-top:10px">
|
|
<button class="btn-save" onclick="saveChannels()">Save channels</button>
|
|
<span id="channels-status" class="status-msg"></span>
|
|
</div>
|
|
{% else %}
|
|
<span class="no-hosts">No personal notification channels configured.</span>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- Host access -->
|
|
<div class="section">
|
|
<h2>Host Access</h2>
|
|
|
|
<div class="settings-row" style="align-items: flex-start; padding-bottom: 14px;">
|
|
<span class="settings-label" style="padding-top: 2px;">Owner</span>
|
|
<div class="host-grid">
|
|
{% if owned_hosts %}
|
|
{% for h in owned_hosts %}
|
|
<span class="host-chip owner"><span class="host-chip-dot"></span>{{ h }}</span>
|
|
{% endfor %}
|
|
{% else %}
|
|
<span class="no-hosts">None</span>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="settings-row" style="align-items: flex-start; padding-bottom: 14px;">
|
|
<span class="settings-label" style="padding-top: 2px;">Manager</span>
|
|
<div class="host-grid">
|
|
{% if managed_hosts %}
|
|
{% for h in managed_hosts %}
|
|
<span class="host-chip manager"><span class="host-chip-dot"></span>{{ h }}</span>
|
|
{% endfor %}
|
|
{% else %}
|
|
<span class="no-hosts">None</span>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="settings-row" style="align-items: flex-start; padding-bottom: 4px;">
|
|
<span class="settings-label" style="padding-top: 2px;">Monitor</span>
|
|
<div class="host-grid">
|
|
{% if monitored_hosts %}
|
|
{% for h in monitored_hosts %}
|
|
<span class="host-chip monitor"><span class="host-chip-dot"></span>{{ h }}</span>
|
|
{% endfor %}
|
|
{% else %}
|
|
<span class="no-hosts">None</span>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
<script>
|
|
async function saveIdentity() {
|
|
const full_name = document.getElementById('profile-fullname').value;
|
|
const avatar = document.getElementById('profile-avatar').value;
|
|
const resp = await fetch('/api/0/users/me', {
|
|
method: 'PUT',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({full_name, avatar}),
|
|
});
|
|
if (resp.ok) {
|
|
showStatus('identity-status', 'Saved', '#2e7d32');
|
|
} else {
|
|
const err = await resp.json().catch(() => ({}));
|
|
showStatus('identity-status', err.error || 'Error saving', '#c62828');
|
|
}
|
|
}
|
|
|
|
async function changePassword() {
|
|
const current = document.getElementById('profile-current-pw').value;
|
|
const newpw = document.getElementById('profile-new-pw').value;
|
|
if (!current || !newpw) {
|
|
showStatus('password-status', 'Both fields are required', '#c62828');
|
|
return;
|
|
}
|
|
const resp = await fetch('/api/0/users/me', {
|
|
method: 'PUT',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({password: {current, new: newpw}}),
|
|
});
|
|
if (resp.ok) {
|
|
document.getElementById('profile-current-pw').value = '';
|
|
document.getElementById('profile-new-pw').value = '';
|
|
showStatus('password-status', 'Password changed', '#2e7d32');
|
|
} else {
|
|
const err = await resp.json().catch(() => ({}));
|
|
showStatus('password-status', err.error || 'Error', '#c62828');
|
|
}
|
|
}
|
|
|
|
async function saveChannels() {
|
|
const notification_channels = [...document.querySelectorAll('.channel-checkbox:checked')]
|
|
.map(cb => cb.value);
|
|
const resp = await fetch('/api/0/users/me', {
|
|
method: 'PUT',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({notification_channels}),
|
|
});
|
|
if (resp.ok) {
|
|
showStatus('channels-status', 'Saved', '#2e7d32');
|
|
} else {
|
|
const err = await resp.json().catch(() => ({}));
|
|
showStatus('channels-status', err.error || 'Error saving', '#c62828');
|
|
}
|
|
}
|
|
|
|
function showStatus(id, msg, color) {
|
|
const el = document.getElementById(id);
|
|
if (!el) return;
|
|
el.textContent = msg;
|
|
el.style.color = color;
|
|
setTimeout(() => { el.textContent = ''; }, 3000);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|