사용자 정보 팝오버 추가
This commit is contained in:
@@ -6,6 +6,7 @@ const loginForm = document.getElementById("login-form");
|
||||
const loginMessage = document.getElementById("login-message");
|
||||
const logoutBtn = document.getElementById("logout-btn");
|
||||
const userBadge = document.getElementById("user-badge");
|
||||
const userPopover = document.getElementById("user-popover");
|
||||
const currentViewTitle = document.getElementById("current-view-title");
|
||||
const navButtons = Array.from(document.querySelectorAll(".header-center [data-view]"));
|
||||
const organizationFrame = document.getElementById("organization-frame");
|
||||
@@ -37,6 +38,14 @@ function clearSession() {
|
||||
sessionStorage.removeItem(sessionKey);
|
||||
}
|
||||
|
||||
function hideUserPopover() {
|
||||
userPopover?.classList.add("hidden");
|
||||
}
|
||||
|
||||
function toggleUserPopover() {
|
||||
userPopover?.classList.toggle("hidden");
|
||||
}
|
||||
|
||||
function setActiveView(view) {
|
||||
const previousView = currentView;
|
||||
currentView = view in viewLabels ? view : "organization";
|
||||
@@ -71,8 +80,29 @@ function renderAuth() {
|
||||
dashboardPanel.classList.toggle("hidden", !authenticated);
|
||||
if (authenticated) {
|
||||
const displayName = session.user.display_name || "접속자";
|
||||
userBadge.innerHTML = `<span class="user-chip-icon">◎</span><span class="user-chip-text"><strong>${displayName}</strong><em>-</em></span>`;
|
||||
const rank = "-";
|
||||
userBadge.innerHTML = `<span class="user-chip-icon">◎</span><span class="user-chip-text"><strong>${displayName}</strong><em>${rank}</em></span>`;
|
||||
userBadge.title = `${displayName} / -`;
|
||||
if (userPopover) {
|
||||
userPopover.innerHTML = `
|
||||
<div class="user-popover-row">
|
||||
<span class="user-popover-label">이름</span>
|
||||
<strong>${displayName}</strong>
|
||||
</div>
|
||||
<div class="user-popover-row">
|
||||
<span class="user-popover-label">직급</span>
|
||||
<span>${rank}</span>
|
||||
</div>
|
||||
<div class="user-popover-row">
|
||||
<span class="user-popover-label">권한</span>
|
||||
<span>${session.user.role || "-"}</span>
|
||||
</div>
|
||||
<div class="user-popover-row">
|
||||
<span class="user-popover-label">아이디</span>
|
||||
<span>${session.user.username || "-"}</span>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,15 +130,28 @@ if (loginForm) {
|
||||
if (logoutBtn) {
|
||||
logoutBtn.addEventListener("click", () => {
|
||||
clearSession();
|
||||
hideUserPopover();
|
||||
renderAuth();
|
||||
});
|
||||
}
|
||||
|
||||
if (userBadge) {
|
||||
userBadge.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
toggleUserPopover();
|
||||
});
|
||||
}
|
||||
|
||||
navButtons.forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
hideUserPopover();
|
||||
setActiveView(button.dataset.view || "organization");
|
||||
});
|
||||
});
|
||||
|
||||
document.addEventListener("click", () => {
|
||||
hideUserPopover();
|
||||
});
|
||||
|
||||
setActiveView(currentView);
|
||||
renderAuth();
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
|
||||
<div class="header-actions">
|
||||
<button id="user-badge" class="ghost-button ghost-button-soft user-chip" type="button"></button>
|
||||
<div id="user-popover" class="user-popover hidden"></div>
|
||||
<button id="logout-btn" class="ghost-button icon-button" type="button" title="로그아웃" aria-label="로그아웃">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path d="M15 3h-4a2 2 0 0 0-2 2v3" />
|
||||
|
||||
@@ -230,6 +230,7 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.ghost-button {
|
||||
@@ -252,6 +253,7 @@
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 0 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.user-chip-icon {
|
||||
@@ -305,6 +307,39 @@
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
|
||||
.user-popover {
|
||||
position: absolute;
|
||||
top: calc(100% + 10px);
|
||||
right: 42px;
|
||||
min-width: 220px;
|
||||
padding: 14px;
|
||||
border: 1px solid #dbe2ea;
|
||||
border-radius: 16px;
|
||||
background: rgba(255, 255, 255, 0.96);
|
||||
box-shadow: 0 18px 36px rgba(15, 23, 42, 0.14);
|
||||
backdrop-filter: blur(12px);
|
||||
z-index: 30;
|
||||
}
|
||||
|
||||
.user-popover-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
font-size: 12px;
|
||||
padding: 6px 0;
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.user-popover-row + .user-popover-row {
|
||||
border-top: 1px solid #eef2f7;
|
||||
}
|
||||
|
||||
.user-popover-label {
|
||||
color: var(--color-text-muted);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.dashboard-main {
|
||||
flex: 1;
|
||||
min-height: calc(100vh - 68px);
|
||||
|
||||
Reference in New Issue
Block a user