mirror of
https://github.com/Matewoo/pdf-writer.git
synced 2026-11-18 18:42:50 +01:00
more subtle user bar on top
This commit is contained in:
@@ -3,26 +3,80 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
const isAdmin = localStorage.getItem('userRole') === 'admin';
|
||||
const userName = localStorage.getItem('userName') || 'Benutzer';
|
||||
|
||||
// Header-Bereich mit Benutzerinfos und Logout-Button hinzufügen
|
||||
const header = document.createElement('div');
|
||||
header.className = 'user-header';
|
||||
header.innerHTML = `
|
||||
<div class="user-info">
|
||||
Angemeldet als: <span class="user-name">${userName}</span>
|
||||
${isAdmin ? '<span class="admin-badge">Administrator</span>' : ''}
|
||||
// Erstelle einen minimalistischen Header mit Dropdown
|
||||
const userMenu = document.createElement('div');
|
||||
userMenu.className = 'user-menu';
|
||||
userMenu.innerHTML = `
|
||||
<div class="user-dropdown">
|
||||
<span class="user-name-display">${userName} ▼</span>
|
||||
<div class="dropdown-content">
|
||||
${isAdmin ? '<a href="/admin/settings">Admin-Bereich</a>' : ''}
|
||||
<a href="/logout">Abmelden</a>
|
||||
</div>
|
||||
<div class="header-buttons">
|
||||
${isAdmin ? '<button onclick="window.location.href=\'/admin/settings\'" class="admin-button">Admin-Bereich</button>' : ''}
|
||||
<button onclick="window.location.href=\'/logout\'" class="logout-button">Abmelden</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Header vor dem Container einfügen
|
||||
const container = document.querySelector('.container');
|
||||
if (container) {
|
||||
container.parentNode.insertBefore(header, container);
|
||||
// Füge CSS für das Dropdown-Menü hinzu
|
||||
const style = document.createElement('style');
|
||||
style.textContent = `
|
||||
.user-menu {
|
||||
position: fixed;
|
||||
top: 10px;
|
||||
right: 20px;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.user-dropdown {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.user-name-display {
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
padding: 5px 10px;
|
||||
border-radius: 4px;
|
||||
background-color: rgba(168, 20, 17, 0.8);
|
||||
}
|
||||
|
||||
.dropdown-content {
|
||||
display: none;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
background-color: white;
|
||||
min-width: 160px;
|
||||
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
|
||||
z-index: 1;
|
||||
border-radius: 4px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.dropdown-content a {
|
||||
color: black;
|
||||
padding: 12px 16px;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
border-bottom: 1px solid #f1f1f1;
|
||||
}
|
||||
|
||||
.dropdown-content a:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.dropdown-content a:hover {
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
|
||||
.user-dropdown:hover .dropdown-content {
|
||||
display: block;
|
||||
}
|
||||
`;
|
||||
document.head.appendChild(style);
|
||||
|
||||
// Füge das Menü zum Body hinzu
|
||||
document.body.appendChild(userMenu);
|
||||
|
||||
// Admin-spezifische Elemente anzeigen/verbergen
|
||||
const adminElements = document.querySelectorAll('.admin-only');
|
||||
adminElements.forEach(element => {
|
||||
|
||||
@@ -207,59 +207,6 @@ button {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.user-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 10px 20px;
|
||||
background-color: white;
|
||||
margin-bottom: 15px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.user-name {
|
||||
font-weight: bold;
|
||||
margin-right: 10px;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
color: black
|
||||
}
|
||||
|
||||
.admin-badge {
|
||||
background-color: #a81411;
|
||||
color: white;
|
||||
padding: 3px 8px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.header-buttons {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.logout-button {
|
||||
padding: 6px 12px;
|
||||
background-color: #6c757d;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.admin-button {
|
||||
padding: 6px 12px;
|
||||
background-color: #a81411;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Für Admin-Only Elemente */
|
||||
.admin-only {
|
||||
display: none; /* Standardmäßig versteckt, wird via JS eingeblendet */
|
||||
|
||||
Reference in New Issue
Block a user