feat: customer detail page, size snapshots table, Spaces provisioning, Redis status cache
Some checks failed
Build & Release / build (push) Has been cancelled
Some checks failed
Build & Release / build (push) Has been cancelled
This commit is contained in:
@@ -9,20 +9,8 @@
|
||||
body { font-family: "Inter", system-ui, sans-serif; background: #0d1117; color: #c9d1d9; min-height: 100vh; }
|
||||
|
||||
/* ── Login ── */
|
||||
#login-view {
|
||||
display: none;
|
||||
min-height: 100vh;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.login-box {
|
||||
background: #161b22;
|
||||
border: 1px solid #30363d;
|
||||
border-radius: 10px;
|
||||
padding: 2.5rem;
|
||||
width: 100%;
|
||||
max-width: 360px;
|
||||
}
|
||||
#login-view { display: none; min-height: 100vh; align-items: center; justify-content: center; }
|
||||
.login-box { background: #161b22; border: 1px solid #30363d; border-radius: 10px; padding: 2.5rem; width: 100%; max-width: 360px; }
|
||||
.login-box h1 { font-size: 1.1rem; color: #e6edf3; margin-bottom: 0.3rem; font-weight: 600; }
|
||||
.login-box p { font-size: 0.82rem; color: #8b949e; margin-bottom: 1.8rem; }
|
||||
|
||||
@@ -31,77 +19,22 @@
|
||||
.shell { display: flex; height: 100%; }
|
||||
|
||||
/* ── Sidebar ── */
|
||||
.sidebar {
|
||||
width: 220px;
|
||||
background: #13161f;
|
||||
border-right: 1px solid #21262d;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.sidebar-brand {
|
||||
padding: 1.2rem 1.2rem 1rem;
|
||||
font-size: 0.88rem;
|
||||
font-weight: 700;
|
||||
color: #e6edf3;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
border-bottom: 1px solid #21262d;
|
||||
}
|
||||
.sidebar { width: 220px; background: #13161f; border-right: 1px solid #21262d; display: flex; flex-direction: column; flex-shrink: 0; }
|
||||
.sidebar-brand { padding: 1.2rem 1.2rem 1rem; font-size: 0.88rem; font-weight: 700; color: #e6edf3; letter-spacing: 0.06em; text-transform: uppercase; border-bottom: 1px solid #21262d; }
|
||||
.sidebar-nav { flex: 1; padding: 0.6rem 0.5rem; }
|
||||
.nav-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.65rem;
|
||||
padding: 0.55rem 0.8rem;
|
||||
border-radius: 6px;
|
||||
font-size: 0.845rem;
|
||||
color: #8b949e;
|
||||
cursor: pointer;
|
||||
transition: background 0.12s, color 0.12s;
|
||||
user-select: none;
|
||||
}
|
||||
.nav-item { display: flex; align-items: center; gap: 0.65rem; padding: 0.55rem 0.8rem; border-radius: 6px; font-size: 0.845rem; color: #8b949e; cursor: pointer; transition: background 0.12s, color 0.12s; user-select: none; }
|
||||
.nav-item:hover { background: #1c2128; color: #c9d1d9; }
|
||||
.nav-item.active { background: #1c2128; color: #e6edf3; }
|
||||
.nav-icon { font-size: 0.9rem; width: 1.1rem; text-align: center; opacity: 0.7; }
|
||||
|
||||
.sidebar-user { padding: 0.7rem; border-top: 1px solid #21262d; }
|
||||
.user-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.65rem;
|
||||
padding: 0.55rem 0.8rem;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: background 0.12s;
|
||||
width: 100%;
|
||||
background: none;
|
||||
border: none;
|
||||
color: #8b949e;
|
||||
text-align: left;
|
||||
}
|
||||
.user-btn { display: flex; align-items: center; gap: 0.65rem; padding: 0.55rem 0.8rem; border-radius: 6px; cursor: pointer; transition: background 0.12s; width: 100%; background: none; border: none; color: #8b949e; text-align: left; }
|
||||
.user-btn:hover { background: #1c2128; color: #c9d1d9; }
|
||||
.user-menu { display: none; flex-direction: column; gap: 1px; padding: 0 0.5rem 0.3rem; }
|
||||
.user-menu.open { display: flex; }
|
||||
.user-menu-item {
|
||||
font-size: 0.8rem;
|
||||
padding: 0.42rem 0.8rem;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
color: #8b949e;
|
||||
transition: background 0.12s, color 0.12s;
|
||||
}
|
||||
.user-menu-item { font-size: 0.8rem; padding: 0.42rem 0.8rem; border-radius: 6px; cursor: pointer; color: #8b949e; transition: background 0.12s, color 0.12s; }
|
||||
.user-menu-item:hover { background: #1c2128; color: #e6edf3; }
|
||||
.user-menu-item.danger:hover { background: #3d1a1a; color: #f85149; }
|
||||
.user-avatar {
|
||||
width: 26px; height: 26px;
|
||||
border-radius: 50%;
|
||||
background: #1d3a6e;
|
||||
border: 1px solid #30363d;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
font-size: 0.72rem; font-weight: 700; color: #79c0ff;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.user-avatar { width: 26px; height: 26px; border-radius: 50%; background: #1d3a6e; border: 1px solid #30363d; display: flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 700; color: #79c0ff; flex-shrink: 0; }
|
||||
.user-name { font-size: 0.83rem; }
|
||||
|
||||
/* ── Main content ── */
|
||||
@@ -111,58 +44,25 @@
|
||||
.page-title { font-size: 1rem; font-weight: 600; color: #e6edf3; margin-bottom: 1.5rem; letter-spacing: 0.01em; }
|
||||
|
||||
/* ── Cards ── */
|
||||
.card {
|
||||
background: #161b22;
|
||||
border: 1px solid #30363d;
|
||||
border-radius: 8px;
|
||||
padding: 1.5rem;
|
||||
max-width: 520px;
|
||||
}
|
||||
.card { background: #161b22; border: 1px solid #30363d; border-radius: 8px; padding: 1.5rem; max-width: 520px; }
|
||||
.card-title { font-size: 0.78rem; font-weight: 600; color: #8b949e; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 1rem; }
|
||||
|
||||
/* ── Form elements ── */
|
||||
.form-group { margin-bottom: 1.1rem; }
|
||||
label { display: block; font-size: 0.76rem; color: #8b949e; margin-bottom: 0.35rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; }
|
||||
input[type=text], input[type=password], input[type=date] {
|
||||
width: 100%; padding: 0.55rem 0.75rem;
|
||||
background: #0d1117; border: 1px solid #30363d; border-radius: 6px;
|
||||
color: #c9d1d9; font-size: 0.875rem;
|
||||
}
|
||||
input[type=text], input[type=password], input[type=date] { width: 100%; padding: 0.55rem 0.75rem; background: #0d1117; border: 1px solid #30363d; border-radius: 6px; color: #c9d1d9; font-size: 0.875rem; }
|
||||
input:focus { outline: none; border-color: #58a6ff; box-shadow: 0 0 0 3px rgba(88,166,255,0.1); }
|
||||
input[type=date]::-webkit-calendar-picker-indicator { filter: invert(0.5); }
|
||||
|
||||
/* ── Modules checkboxes ── */
|
||||
.modules-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
.module-check {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.4rem 0.6rem;
|
||||
border: 1px solid #30363d;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-size: 0.82rem;
|
||||
color: #8b949e;
|
||||
transition: border-color 0.12s, color 0.12s, background 0.12s;
|
||||
user-select: none;
|
||||
}
|
||||
/* ── Modules ── */
|
||||
.modules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
|
||||
.module-check { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.6rem; border: 1px solid #30363d; border-radius: 6px; cursor: pointer; font-size: 0.82rem; color: #8b949e; transition: border-color 0.12s, color 0.12s, background 0.12s; user-select: none; }
|
||||
.module-check:hover { border-color: #58a6ff; color: #c9d1d9; }
|
||||
.module-check input { display: none; }
|
||||
.module-check.checked { border-color: #1d3a6e; background: #0d1f3a; color: #79c0ff; }
|
||||
|
||||
/* ── Buttons ── */
|
||||
.btn {
|
||||
padding: 0.55rem 1.1rem;
|
||||
border-radius: 6px;
|
||||
font-size: 0.875rem;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
font-weight: 500;
|
||||
transition: background 0.12s, opacity 0.12s;
|
||||
}
|
||||
.btn { padding: 0.55rem 1.1rem; border-radius: 6px; font-size: 0.875rem; cursor: pointer; border: none; font-weight: 500; transition: background 0.12s, opacity 0.12s; }
|
||||
.btn-primary { background: #1d3a6e; color: #79c0ff; border: 1px solid #1d4ed8; }
|
||||
.btn-primary:hover { background: #1e4080; }
|
||||
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
|
||||
@@ -172,106 +72,101 @@
|
||||
.btn-danger:hover { background: #3d1a1a; border-color: #f85149; }
|
||||
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.78rem; }
|
||||
|
||||
/* ── Status ── */
|
||||
/* ── Status messages ── */
|
||||
.status { margin-top: 1rem; font-size: 0.83rem; padding: 0.55rem 0.8rem; border-radius: 6px; display: none; }
|
||||
.status.success { background: #0d2818; color: #3fb950; border: 1px solid #1a4731; display: block; }
|
||||
.status.error { background: #2d0f0f; color: #f85149; border: 1px solid #4a1a1a; display: block; }
|
||||
|
||||
/* ── Badges ── */
|
||||
.badge { display: inline-flex; align-items: center; padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.72rem; font-weight: 500; }
|
||||
.badge-blue { background: #1d3a6e; color: #79c0ff; border: 1px solid #1d4ed8; }
|
||||
.badge-green { background: #0d2818; color: #3fb950; border: 1px solid #1a4731; }
|
||||
.badge-red { background: #2d0f0f; color: #f85149; border: 1px solid #4a1a1a; }
|
||||
.badge-yellow { background: #2d1f0a; color: #e3a04a; border: 1px solid #5a3a10; }
|
||||
.badge-gray { background: #1c2128; color: #8b949e; border: 1px solid #30363d; }
|
||||
|
||||
/* ── Table ── */
|
||||
.table-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.search-input {
|
||||
background: #0d1117;
|
||||
border: 1px solid #30363d;
|
||||
border-radius: 6px;
|
||||
padding: 0.5rem 0.75rem;
|
||||
color: #c9d1d9;
|
||||
font-size: 0.875rem;
|
||||
width: 260px;
|
||||
}
|
||||
.table-toolbar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
|
||||
.search-input { background: #0d1117; border: 1px solid #30363d; border-radius: 6px; padding: 0.5rem 0.75rem; color: #c9d1d9; font-size: 0.875rem; width: 260px; }
|
||||
.search-input:focus { outline: none; border-color: #58a6ff; }
|
||||
.table-wrap {
|
||||
background: #161b22;
|
||||
border: 1px solid #30363d;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.table-wrap { background: #161b22; border: 1px solid #30363d; border-radius: 8px; overflow: hidden; }
|
||||
table { width: 100%; border-collapse: collapse; font-size: 0.845rem; }
|
||||
thead { background: #1c2128; }
|
||||
th {
|
||||
padding: 0.65rem 1rem;
|
||||
text-align: left;
|
||||
font-size: 0.76rem;
|
||||
font-weight: 600;
|
||||
color: #8b949e;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
border-bottom: 1px solid #30363d;
|
||||
white-space: nowrap;
|
||||
user-select: none;
|
||||
}
|
||||
th { padding: 0.65rem 1rem; text-align: left; font-size: 0.76rem; font-weight: 600; color: #8b949e; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid #30363d; white-space: nowrap; user-select: none; }
|
||||
th.sortable { cursor: pointer; }
|
||||
th.sortable:hover { color: #c9d1d9; }
|
||||
th .sort-icon { margin-left: 4px; opacity: 0.4; font-size: 0.7rem; }
|
||||
th.sort-active { color: #58a6ff; }
|
||||
th.sort-active .sort-icon { opacity: 1; }
|
||||
td {
|
||||
padding: 0.7rem 1rem;
|
||||
border-bottom: 1px solid #21262d;
|
||||
color: #c9d1d9;
|
||||
vertical-align: middle;
|
||||
}
|
||||
td { padding: 0.7rem 1rem; border-bottom: 1px solid #21262d; color: #c9d1d9; vertical-align: middle; }
|
||||
tr:last-child td { border-bottom: none; }
|
||||
tr:hover td { background: #1c2128; }
|
||||
.tag {
|
||||
display: inline-block;
|
||||
padding: 0.15rem 0.45rem;
|
||||
border-radius: 4px;
|
||||
font-size: 0.72rem;
|
||||
font-weight: 500;
|
||||
background: #1d3a6e;
|
||||
color: #79c0ff;
|
||||
border: 1px solid #1d4ed8;
|
||||
margin: 1px 2px 1px 0;
|
||||
}
|
||||
.tag { display: inline-block; padding: 0.15rem 0.45rem; border-radius: 4px; font-size: 0.72rem; font-weight: 500; background: #1d3a6e; color: #79c0ff; border: 1px solid #1d4ed8; margin: 1px 2px 1px 0; }
|
||||
.tag-expired { background: #2d1a0a; color: #e3956a; border-color: #5a3010; }
|
||||
.empty-row td { text-align: center; color: #484f58; padding: 2.5rem; }
|
||||
|
||||
/* ── Pagination ── */
|
||||
.pagination {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0.75rem 1rem;
|
||||
border-top: 1px solid #21262d;
|
||||
font-size: 0.8rem;
|
||||
color: #8b949e;
|
||||
}
|
||||
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1rem; border-top: 1px solid #21262d; font-size: 0.8rem; color: #8b949e; }
|
||||
.pagination-btns { display: flex; gap: 0.4rem; align-items: center; }
|
||||
.pagination-info { font-size: 0.78rem; }
|
||||
|
||||
/* ── Kebab menu ── */
|
||||
.kebab-btn { background: none; border: none; color: #8b949e; cursor: pointer; padding: 0.25rem 0.5rem; border-radius: 4px; font-size: 1.1rem; line-height: 1; transition: background 0.1s, color 0.1s; }
|
||||
.kebab-btn:hover { background: #21262d; color: #c9d1d9; }
|
||||
#kebab-menu { display: none; position: fixed; background: #161b22; border: 1px solid #30363d; border-radius: 6px; min-width: 160px; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,0.4); overflow: hidden; }
|
||||
#kebab-menu.open { display: block; }
|
||||
.kebab-item { padding: 0.55rem 1rem; font-size: 0.845rem; color: #c9d1d9; cursor: pointer; transition: background 0.1s; }
|
||||
.kebab-item:hover { background: #1c2128; }
|
||||
.kebab-item.danger { color: #f85149; }
|
||||
.kebab-item.danger:hover { background: #3d1a1a; }
|
||||
|
||||
/* ── Customer detail page ── */
|
||||
.detail-header { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
|
||||
.detail-title { font-size: 1.1rem; font-weight: 700; color: #e6edf3; }
|
||||
.detail-slug { font-size: 0.82rem; color: #8b949e; margin-top: 0.2rem; font-family: monospace; }
|
||||
.detail-meta { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin-top: 0.5rem; }
|
||||
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
|
||||
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }
|
||||
.stat-card { background: #161b22; border: 1px solid #30363d; border-radius: 8px; padding: 1.2rem 1.5rem; }
|
||||
.stat-card-full { grid-column: 1 / -1; }
|
||||
.stat-card .card-title { margin-bottom: 0.8rem; }
|
||||
.stat-row { display: flex; justify-content: space-between; align-items: center; padding: 0.35rem 0; border-bottom: 1px solid #21262d; font-size: 0.845rem; }
|
||||
.stat-row:last-child { border-bottom: none; }
|
||||
.stat-label { color: #8b949e; }
|
||||
.stat-value { color: #e6edf3; font-weight: 500; text-align: right; }
|
||||
|
||||
/* ── Pods table in detail ── */
|
||||
.pods-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; margin-top: 0.5rem; }
|
||||
.pods-table th { text-align: left; color: #8b949e; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 0 0 0.5rem 0; border-bottom: 1px solid #21262d; }
|
||||
.pods-table td { padding: 0.5rem 0; border-bottom: 1px solid #21262d; vertical-align: middle; }
|
||||
.pods-table tr:last-child td { border-bottom: none; }
|
||||
.pod-name { font-family: monospace; font-size: 0.8rem; color: #c9d1d9; }
|
||||
.pod-status-running { color: #3fb950; }
|
||||
.pod-status-pending { color: #e3a04a; }
|
||||
.pod-status-failed { color: #f85149; }
|
||||
.pod-status-unknown { color: #8b949e; }
|
||||
|
||||
/* ── Size history table ── */
|
||||
.history-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
|
||||
.history-table th { text-align: left; color: #8b949e; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 0 0 0.5rem 0; border-bottom: 1px solid #21262d; }
|
||||
.history-table td { padding: 0.45rem 0; border-bottom: 1px solid #21262d; color: #c9d1d9; }
|
||||
.history-table tr:last-child td { border-bottom: none; }
|
||||
|
||||
/* ── Skeleton ── */
|
||||
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
|
||||
.skeleton { background: #21262d; border-radius: 4px; animation: pulse 1.5s infinite; display: inline-block; }
|
||||
|
||||
/* ── Step list ── */
|
||||
.step-list { display: flex; flex-direction: column; gap: 0.4rem; }
|
||||
.step-item { display: flex; align-items: center; gap: 0.6rem; font-size: 0.845rem; }
|
||||
.step-icon { width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.65rem; flex-shrink: 0; }
|
||||
.step-done { background: #0d2818; color: #3fb950; border: 1px solid #1a4731; }
|
||||
.step-failed { background: #2d0f0f; color: #f85149; border: 1px solid #4a1a1a; }
|
||||
.step-pending { background: #1c2128; color: #8b949e; border: 1px solid #30363d; }
|
||||
|
||||
/* ── Confirm overlay ── */
|
||||
.overlay {
|
||||
display: none;
|
||||
position: fixed; inset: 0;
|
||||
background: rgba(0,0,0,0.6);
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 100;
|
||||
}
|
||||
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); align-items: center; justify-content: center; z-index: 100; }
|
||||
.overlay.open { display: flex; }
|
||||
.dialog {
|
||||
background: #161b22;
|
||||
border: 1px solid #30363d;
|
||||
border-radius: 10px;
|
||||
padding: 1.8rem;
|
||||
max-width: 380px;
|
||||
width: 100%;
|
||||
}
|
||||
.dialog { background: #161b22; border: 1px solid #30363d; border-radius: 10px; padding: 1.8rem; max-width: 380px; width: 100%; }
|
||||
.dialog h3 { font-size: 0.95rem; color: #e6edf3; margin-bottom: 0.5rem; }
|
||||
.dialog p { font-size: 0.845rem; color: #8b949e; margin-bottom: 1.4rem; line-height: 1.5; }
|
||||
.dialog-actions { display: flex; gap: 0.6rem; justify-content: flex-end; }
|
||||
@@ -327,11 +222,11 @@
|
||||
|
||||
<main class="main">
|
||||
|
||||
<!-- Customers -->
|
||||
<!-- Customers list -->
|
||||
<div id="page-customers" class="page">
|
||||
<div class="page-title">Customers</div>
|
||||
<div class="table-toolbar">
|
||||
<input class="search-input" id="customers-search" type="text" placeholder="Search by slug…" oninput="onSearchInput()" />
|
||||
<input class="search-input" id="customers-search" type="text" placeholder="Search customers…" oninput="onSearchInput()" />
|
||||
<button class="btn btn-slate" onclick="loadCustomers()">Refresh</button>
|
||||
</div>
|
||||
<div class="table-wrap">
|
||||
@@ -346,7 +241,7 @@
|
||||
<th class="sortable" data-col="expiration_date" onclick="setSort('expiration_date')">Expires <span class="sort-icon" id="sort-icon-expiration_date">↕</span></th>
|
||||
<th class="sortable" data-col="created_at" onclick="setSort('created_at')">Created <span class="sort-icon" id="sort-icon-created_at">↕</span></th>
|
||||
<th class="sortable" data-col="updated_at" onclick="setSort('updated_at')">Updated <span class="sort-icon" id="sort-icon-updated_at">↕</span></th>
|
||||
<th></th>
|
||||
<th style="width:40px"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="customers-tbody">
|
||||
@@ -354,7 +249,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="pagination" id="customers-pagination" style="display:none">
|
||||
<span class="pagination-info" id="pagination-info"></span>
|
||||
<span id="pagination-info" style="font-size:0.78rem;color:#8b949e"></span>
|
||||
<div class="pagination-btns">
|
||||
<button class="btn btn-slate btn-sm" id="btn-prev" onclick="changePage(-1)">← Prev</button>
|
||||
<span id="pagination-page" style="font-size:0.8rem;color:#8b949e;min-width:60px;text-align:center"></span>
|
||||
@@ -364,6 +259,30 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Customer Detail -->
|
||||
<div id="page-customer-detail" class="page">
|
||||
<div style="margin-bottom:1.2rem">
|
||||
<button class="btn btn-slate btn-sm" onclick="showPage('customers')">← Customers</button>
|
||||
</div>
|
||||
<div class="detail-header">
|
||||
<div style="flex:1">
|
||||
<div class="detail-title" id="detail-name">—</div>
|
||||
<div class="detail-slug" id="detail-slug">—</div>
|
||||
<div class="detail-meta" id="detail-meta"></div>
|
||||
</div>
|
||||
<div style="display:flex;gap:0.5rem;align-items:center">
|
||||
<button class="btn btn-slate btn-sm" onclick="refreshDetail()">↻ Refresh Status</button>
|
||||
<button class="btn btn-danger btn-sm" id="detail-delete-btn" onclick="">Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="detail-grid" id="detail-grid">
|
||||
<div class="stat-card stat-card-full">
|
||||
<div class="card-title">Loading…</div>
|
||||
<div style="height:80px;display:flex;align-items:center;justify-content:center;color:#484f58;font-size:0.845rem">Fetching status…</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Create Env -->
|
||||
<div id="page-create-env" class="page">
|
||||
<div class="page-title">Create Environment</div>
|
||||
@@ -389,24 +308,12 @@
|
||||
<div class="form-group">
|
||||
<label>Modules</label>
|
||||
<div class="modules-grid">
|
||||
<label class="module-check" id="mod-pos">
|
||||
<input type="checkbox" value="pos" onchange="toggleModule(this)" /> POS
|
||||
</label>
|
||||
<label class="module-check" id="mod-inventory">
|
||||
<input type="checkbox" value="inventory" onchange="toggleModule(this)" /> Inventory
|
||||
</label>
|
||||
<label class="module-check" id="mod-rentals">
|
||||
<input type="checkbox" value="rentals" onchange="toggleModule(this)" /> Rentals
|
||||
</label>
|
||||
<label class="module-check" id="mod-scheduling">
|
||||
<input type="checkbox" value="scheduling" onchange="toggleModule(this)" /> Scheduling
|
||||
</label>
|
||||
<label class="module-check" id="mod-repairs">
|
||||
<input type="checkbox" value="repairs" onchange="toggleModule(this)" /> Repairs
|
||||
</label>
|
||||
<label class="module-check" id="mod-accounting">
|
||||
<input type="checkbox" value="accounting" onchange="toggleModule(this)" /> Accounting
|
||||
</label>
|
||||
<label class="module-check" id="mod-pos"><input type="checkbox" value="pos" onchange="toggleModule(this)" /> POS</label>
|
||||
<label class="module-check" id="mod-inventory"><input type="checkbox" value="inventory" onchange="toggleModule(this)" /> Inventory</label>
|
||||
<label class="module-check" id="mod-rentals"><input type="checkbox" value="rentals" onchange="toggleModule(this)" /> Rentals</label>
|
||||
<label class="module-check" id="mod-scheduling"><input type="checkbox" value="scheduling" onchange="toggleModule(this)" /> Scheduling</label>
|
||||
<label class="module-check" id="mod-repairs"><input type="checkbox" value="repairs" onchange="toggleModule(this)" /> Repairs</label>
|
||||
<label class="module-check" id="mod-accounting"><input type="checkbox" value="accounting" onchange="toggleModule(this)" /> Accounting</label>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-primary" id="provision-btn" onclick="provision()" style="margin-top:0.4rem">Provision</button>
|
||||
@@ -435,11 +342,18 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Kebab dropdown (shared, repositioned via JS) -->
|
||||
<div id="kebab-menu">
|
||||
<div class="kebab-item" onclick="kebabAction('view')">View Details</div>
|
||||
<div class="kebab-item danger" onclick="kebabAction('delete')">Delete</div>
|
||||
<div class="kebab-item" onclick="kebabAction('record')">Remove Record Only</div>
|
||||
</div>
|
||||
|
||||
<!-- Delete confirm dialog -->
|
||||
<div class="overlay" id="delete-overlay" onclick="if(event.target===this)closeDeleteDialog()">
|
||||
<div class="dialog">
|
||||
<h3>Delete Customer</h3>
|
||||
<p>This will remove the ArgoCD app, database, and all associated resources for <strong id="delete-slug-label" style="color:#e6edf3"></strong>. This cannot be undone.</p>
|
||||
<p>This will remove the ArgoCD app, database, storage, and all associated resources for <strong id="delete-slug-label" style="color:#e6edf3"></strong>. This cannot be undone.</p>
|
||||
<div class="dialog-actions">
|
||||
<button class="btn btn-slate" onclick="closeDeleteDialog()">Cancel</button>
|
||||
<button class="btn btn-danger" id="delete-confirm-btn" onclick="confirmDelete()">Delete</button>
|
||||
@@ -452,26 +366,21 @@
|
||||
let tableState = { page: 1, limit: 25, q: '', sort: 'created_at', order: 'desc', total: 0, totalPages: 1 };
|
||||
let searchTimer = null;
|
||||
let pendingDeleteSlug = null;
|
||||
let kebabSlug = null;
|
||||
let currentDetailSlug = null;
|
||||
|
||||
function authHeaders() {
|
||||
const token = localStorage.getItem('token');
|
||||
return token ? { 'Authorization': 'Bearer ' + token } : {};
|
||||
const t = localStorage.getItem('token');
|
||||
return t ? { Authorization: 'Bearer ' + t } : {};
|
||||
}
|
||||
|
||||
function apiFetch(url, options = {}) {
|
||||
return fetch(url, {
|
||||
...options,
|
||||
headers: { ...authHeaders(), ...(options.headers || {}) },
|
||||
});
|
||||
function apiFetch(url, opts = {}) {
|
||||
return fetch(url, { ...opts, headers: { ...authHeaders(), ...(opts.headers || {}) } });
|
||||
}
|
||||
|
||||
// ── Auth ──────────────────────────────────────────────────────────────────
|
||||
|
||||
async function checkAuth() {
|
||||
if (!localStorage.getItem('token')) {
|
||||
document.getElementById('login-view').style.display = 'flex';
|
||||
return;
|
||||
}
|
||||
if (!localStorage.getItem('token')) { showLogin(); return; }
|
||||
const res = await apiFetch('/api/auth/me');
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
@@ -480,10 +389,15 @@
|
||||
loadCustomers();
|
||||
} else {
|
||||
localStorage.removeItem('token');
|
||||
document.getElementById('login-view').style.display = 'flex';
|
||||
showLogin();
|
||||
}
|
||||
}
|
||||
|
||||
function showLogin() {
|
||||
document.getElementById('login-view').style.display = 'flex';
|
||||
document.getElementById('app-view').style.display = 'none';
|
||||
}
|
||||
|
||||
function setUser(username) {
|
||||
currentUser = username;
|
||||
document.getElementById('user-name-label').textContent = username;
|
||||
@@ -498,8 +412,7 @@
|
||||
status.className = 'status';
|
||||
try {
|
||||
const res = await fetch('/api/auth/login', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ username, password }),
|
||||
});
|
||||
const data = await res.json();
|
||||
@@ -515,10 +428,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
function logout() {
|
||||
localStorage.removeItem('token');
|
||||
document.getElementById('app-view').style.display = 'none';
|
||||
document.getElementById('login-view').style.display = 'flex';
|
||||
showLogin();
|
||||
document.getElementById('login-password').value = '';
|
||||
}
|
||||
|
||||
@@ -531,10 +444,11 @@
|
||||
function showPage(name) {
|
||||
document.querySelectorAll('.page').forEach(p => p.classList.remove('active'));
|
||||
document.querySelectorAll('.nav-item').forEach(n => n.classList.remove('active'));
|
||||
document.getElementById('page-' + name).classList.add('active');
|
||||
document.getElementById('page-' + name)?.classList.add('active');
|
||||
const navEl = document.getElementById('nav-' + name);
|
||||
if (navEl) navEl.classList.add('active');
|
||||
document.getElementById('user-menu').classList.remove('open');
|
||||
closeKebab();
|
||||
}
|
||||
|
||||
// ── Customers table ───────────────────────────────────────────────────────
|
||||
@@ -551,6 +465,21 @@
|
||||
renderTable(data, pagination);
|
||||
}
|
||||
|
||||
function customerStatusBadge(r) {
|
||||
if (r.status === 'provisioning') return '<span class="badge badge-yellow">Provisioning</span>';
|
||||
if (r.status === 'failed') {
|
||||
const failedStep = Object.entries(r.steps || {}).find(([,v]) => v === 'failed');
|
||||
const label = failedStep ? failedStep[0].replace('_', ' ') : 'unknown';
|
||||
return `<span class="badge badge-red" title="Failed at: ${label}">Failed</span>`;
|
||||
}
|
||||
if (r.status === 'provisioned') {
|
||||
const allDone = Object.values(r.steps || {}).every(v => v === 'done');
|
||||
if (allDone) return '<span class="badge badge-green">Provisioned</span>';
|
||||
return '<span class="badge badge-yellow">Partial</span>';
|
||||
}
|
||||
return `<span class="badge badge-gray">${r.status}</span>`;
|
||||
}
|
||||
|
||||
function renderTable(rows, pagination) {
|
||||
const tbody = document.getElementById('customers-tbody');
|
||||
if (rows.length === 0) {
|
||||
@@ -562,30 +491,16 @@
|
||||
const expiry = r.expiration_date
|
||||
? `<span class="${expired ? 'tag tag-expired' : ''}">${fmtDate(r.expiration_date)}</span>`
|
||||
: '<span style="color:#484f58">—</span>';
|
||||
const statusColor = r.status === 'provisioned' ? '#3fb950' : r.status === 'failed' ? '#f85149' : '#e3a04a';
|
||||
const STEP_LABELS = { database: 'DB', database_user: 'User', database_setup: 'Schema', pool: 'Pool', chart: 'Chart' };
|
||||
const stepsHtml = Object.entries(STEP_LABELS).map(([key, label]) => {
|
||||
const s = (r.steps || {})[key];
|
||||
const icon = s === 'done' ? '✓' : s === 'failed' ? '✗' : '·';
|
||||
const color = s === 'done' ? '#3fb950' : s === 'failed' ? '#f85149' : '#484f58';
|
||||
return `<span style="color:${color};font-size:0.75rem;margin-right:6px" title="${key}">${icon} ${label}</span>`;
|
||||
}).join('');
|
||||
return `<tr>
|
||||
return `<tr style="cursor:pointer" ondblclick="openDetail('${r.slug}')">
|
||||
<td style="font-weight:500;color:#e6edf3">${r.slug}</td>
|
||||
<td>${r.name || '<span style="color:#484f58">—</span>'}</td>
|
||||
<td>
|
||||
<div style="color:${statusColor};font-size:0.78rem;font-weight:500;margin-bottom:3px">${r.status}</div>
|
||||
<div>${stepsHtml}</div>
|
||||
</td>
|
||||
<td>${customerStatusBadge(r)}</td>
|
||||
<td>${modules}</td>
|
||||
<td>${fmtDate(r.start_date)}</td>
|
||||
<td>${expiry}</td>
|
||||
<td style="color:#8b949e">${fmtDateTime(r.created_at)}</td>
|
||||
<td style="color:#8b949e">${fmtDateTime(r.updated_at)}</td>
|
||||
<td style="display:flex;gap:0.4rem;align-items:center">
|
||||
<button class="btn btn-danger btn-sm" onclick="openDeleteDialog('${r.slug}')">Delete</button>
|
||||
<button class="btn btn-slate btn-sm" onclick="removeRecord('${r.slug}')" title="Remove from manager DB only">Record Only</button>
|
||||
</td>
|
||||
<td><button class="kebab-btn" onclick="openKebab(event,'${r.slug}')">⋮</button></td>
|
||||
</tr>`;
|
||||
}).join('');
|
||||
}
|
||||
@@ -600,7 +515,6 @@
|
||||
document.getElementById('btn-prev').disabled = pagination.page <= 1;
|
||||
document.getElementById('btn-next').disabled = pagination.page >= pagination.totalPages;
|
||||
|
||||
// Update sort headers
|
||||
document.querySelectorAll('th[data-col]').forEach(th => {
|
||||
const col = th.dataset.col;
|
||||
const icon = document.getElementById('sort-icon-' + col);
|
||||
@@ -614,12 +528,8 @@
|
||||
}
|
||||
|
||||
function setSort(col) {
|
||||
if (tableState.sort === col) {
|
||||
tableState.order = tableState.order === 'asc' ? 'desc' : 'asc';
|
||||
} else {
|
||||
tableState.sort = col;
|
||||
tableState.order = 'asc';
|
||||
}
|
||||
if (tableState.sort === col) tableState.order = tableState.order === 'asc' ? 'desc' : 'asc';
|
||||
else { tableState.sort = col; tableState.order = 'asc'; }
|
||||
tableState.page = 1;
|
||||
loadCustomers();
|
||||
}
|
||||
@@ -640,6 +550,178 @@
|
||||
}, 300);
|
||||
}
|
||||
|
||||
// ── Kebab menu ────────────────────────────────────────────────────────────
|
||||
|
||||
function openKebab(event, slug) {
|
||||
event.stopPropagation();
|
||||
kebabSlug = slug;
|
||||
const menu = document.getElementById('kebab-menu');
|
||||
const rect = event.currentTarget.getBoundingClientRect();
|
||||
menu.style.top = (rect.bottom + 4) + 'px';
|
||||
menu.style.left = Math.min(rect.left, window.innerWidth - 170) + 'px';
|
||||
menu.classList.add('open');
|
||||
}
|
||||
|
||||
function closeKebab() {
|
||||
document.getElementById('kebab-menu').classList.remove('open');
|
||||
kebabSlug = null;
|
||||
}
|
||||
|
||||
function kebabAction(action) {
|
||||
const slug = kebabSlug;
|
||||
closeKebab();
|
||||
if (!slug) return;
|
||||
if (action === 'view') openDetail(slug);
|
||||
else if (action === 'delete') openDeleteDialog(slug);
|
||||
else if (action === 'record') removeRecord(slug);
|
||||
}
|
||||
|
||||
document.addEventListener('click', e => {
|
||||
if (!document.getElementById('kebab-menu').contains(e.target)) closeKebab();
|
||||
});
|
||||
|
||||
// ── Customer detail page ──────────────────────────────────────────────────
|
||||
|
||||
function openDetail(slug) {
|
||||
currentDetailSlug = slug;
|
||||
document.getElementById('detail-name').textContent = '…';
|
||||
document.getElementById('detail-slug').textContent = slug;
|
||||
document.getElementById('detail-meta').innerHTML = '';
|
||||
document.getElementById('detail-delete-btn').onclick = () => openDeleteDialog(slug);
|
||||
document.getElementById('detail-grid').innerHTML = `
|
||||
<div class="stat-card stat-card-full">
|
||||
<div class="card-title">Loading</div>
|
||||
<div style="padding:1rem 0;display:flex;gap:1rem;flex-wrap:wrap">
|
||||
${[120,90,140,80].map(w => `<span class="skeleton" style="width:${w}px;height:14px"></span>`).join('')}
|
||||
</div>
|
||||
</div>`;
|
||||
showPage('customer-detail');
|
||||
loadDetail(slug, false);
|
||||
}
|
||||
|
||||
function refreshDetail() {
|
||||
if (currentDetailSlug) loadDetail(currentDetailSlug, true);
|
||||
}
|
||||
|
||||
async function loadDetail(slug, forceRefresh) {
|
||||
const url = `/api/customers/${slug}/overview${forceRefresh ? '?refresh=1' : ''}`;
|
||||
try {
|
||||
const res = await apiFetch(url);
|
||||
if (!res.ok) throw new Error('Failed to load');
|
||||
const data = await res.json();
|
||||
renderDetail(data);
|
||||
} catch (err) {
|
||||
document.getElementById('detail-grid').innerHTML =
|
||||
`<div class="stat-card stat-card-full" style="color:#f85149">Failed to load: ${err.message}</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
function renderDetail({ customer, status, sizeHistory }) {
|
||||
// Header
|
||||
document.getElementById('detail-name').textContent = customer.name || customer.slug;
|
||||
document.getElementById('detail-slug').textContent = customer.slug;
|
||||
const expired = customer.expiration_date && new Date(customer.expiration_date) < new Date();
|
||||
const meta = [
|
||||
customerStatusBadge(customer),
|
||||
...(customer.modules || []).map(m => `<span class="tag">${m}</span>`),
|
||||
expired ? `<span class="badge badge-red">Expired ${fmtDate(customer.expiration_date)}</span>` : '',
|
||||
].filter(Boolean).join('');
|
||||
document.getElementById('detail-meta').innerHTML = meta;
|
||||
|
||||
// Compute overall health badge
|
||||
const pods = status.pods || [];
|
||||
const argocd = status.argocd;
|
||||
const allReady = pods.length > 0 && pods.every(p => p.ready);
|
||||
const hasRestarts = pods.some(p => p.restarts > 5);
|
||||
const argoHealthy = argocd?.healthStatus === 'Healthy';
|
||||
const argoSynced = argocd?.syncStatus === 'Synced';
|
||||
|
||||
// ── Live status card ──────────────────────────────────────────────────
|
||||
const argoSyncBadge = !argocd ? '<span class="badge badge-gray">Unknown</span>'
|
||||
: argocd.syncStatus === 'Synced' ? '<span class="badge badge-green">Synced</span>'
|
||||
: argocd.syncStatus === 'OutOfSync' ? '<span class="badge badge-yellow">OutOfSync</span>'
|
||||
: `<span class="badge badge-gray">${argocd.syncStatus}</span>`;
|
||||
|
||||
const argoHealthBadge = !argocd ? '<span class="badge badge-gray">Unknown</span>'
|
||||
: argocd.healthStatus === 'Healthy' ? '<span class="badge badge-green">Healthy</span>'
|
||||
: argocd.healthStatus === 'Degraded' ? '<span class="badge badge-red">Degraded</span>'
|
||||
: argocd.healthStatus === 'Progressing' ? '<span class="badge badge-yellow">Progressing</span>'
|
||||
: `<span class="badge badge-gray">${argocd.healthStatus}</span>`;
|
||||
|
||||
const conditionsHtml = (argocd?.conditions ?? []).filter(c => c.message)
|
||||
.map(c => `<div style="font-size:0.78rem;color:#f85149;margin-top:0.4rem">⚠ ${c.message}</div>`).join('');
|
||||
|
||||
const podsHtml = pods.length === 0
|
||||
? '<div style="color:#484f58;font-size:0.845rem;padding:0.5rem 0">No pods found</div>'
|
||||
: `<table class="pods-table">
|
||||
<thead><tr><th>Pod</th><th>Ready</th><th>Status</th><th>Restarts</th><th>Age</th></tr></thead>
|
||||
<tbody>${pods.map(p => {
|
||||
const cls = p.status === 'Running' ? 'pod-status-running'
|
||||
: p.status === 'Pending' ? 'pod-status-pending'
|
||||
: p.status === 'Failed' ? 'pod-status-failed' : 'pod-status-unknown';
|
||||
const shortName = p.name.replace(new RegExp(`^customer-${customer.slug}-`), '');
|
||||
return `<tr>
|
||||
<td class="pod-name">${shortName}</td>
|
||||
<td style="color:#8b949e">${p.readyCount}/${p.totalCount}</td>
|
||||
<td class="${cls}">${p.status}</td>
|
||||
<td style="color:${p.restarts > 5 ? '#f85149' : '#8b949e'}">${p.restarts}</td>
|
||||
<td style="color:#8b949e">${p.startedAt ? fmtAge(p.startedAt) : '—'}</td>
|
||||
</tr>`;
|
||||
}).join('')}</tbody>
|
||||
</table>`;
|
||||
|
||||
const cachedAt = status.cachedAt ? `<span style="color:#484f58;font-size:0.75rem">cached ${fmtDateTime(status.cachedAt)}</span>` : '';
|
||||
|
||||
// ── Provisioning steps card ───────────────────────────────────────────
|
||||
const STEP_LABELS = { database: 'Database', database_user: 'DB User', database_setup: 'Schema', pool: 'Connection Pool', namespace: 'K8s Namespace', secrets: 'Secrets', storage: 'Object Storage', chart: 'ArgoCD Chart' };
|
||||
const stepsHtml = Object.entries(STEP_LABELS).map(([key, label]) => {
|
||||
const s = (customer.steps || {})[key];
|
||||
const cls = s === 'done' ? 'step-done' : s === 'failed' ? 'step-failed' : 'step-pending';
|
||||
const icon = s === 'done' ? '✓' : s === 'failed' ? '✗' : '·';
|
||||
return `<div class="step-item">
|
||||
<div class="step-icon ${cls}">${icon}</div>
|
||||
<span style="color:${s === 'done' ? '#c9d1d9' : s === 'failed' ? '#f85149' : '#484f58'}">${label}</span>
|
||||
</div>`;
|
||||
}).join('');
|
||||
|
||||
// ── Size history card ─────────────────────────────────────────────────
|
||||
const latestSize = sizeHistory[0] || null;
|
||||
const sizeRowsHtml = sizeHistory.length === 0
|
||||
? '<div style="color:#484f58;font-size:0.845rem">No size data yet — collected every 12 hours</div>'
|
||||
: `<table class="history-table">
|
||||
<thead><tr><th>Date</th><th>Database</th><th>Storage</th><th>Objects</th></tr></thead>
|
||||
<tbody>${sizeHistory.slice(0, 7).map(s => `<tr>
|
||||
<td style="color:#8b949e">${fmtDate(s.recorded_at)}</td>
|
||||
<td>${s.db_size_bytes != null ? fmtBytes(s.db_size_bytes) : '—'}</td>
|
||||
<td>${s.spaces_size_bytes != null ? fmtBytes(s.spaces_size_bytes) : '—'}</td>
|
||||
<td style="color:#8b949e">${s.spaces_object_count ?? '—'}</td>
|
||||
</tr>`).join('')}</tbody>
|
||||
</table>`;
|
||||
|
||||
document.getElementById('detail-grid').innerHTML = `
|
||||
<div class="stat-card stat-card-full">
|
||||
<div class="card-title" style="display:flex;justify-content:space-between;align-items:center">
|
||||
Live Status ${cachedAt}
|
||||
</div>
|
||||
<div style="display:flex;gap:1.5rem;margin-bottom:1rem;flex-wrap:wrap">
|
||||
<div><span style="font-size:0.76rem;color:#8b949e;text-transform:uppercase;letter-spacing:0.04em">Sync </span>${argoSyncBadge}</div>
|
||||
<div><span style="font-size:0.76rem;color:#8b949e;text-transform:uppercase;letter-spacing:0.04em">Health </span>${argoHealthBadge}</div>
|
||||
</div>
|
||||
${conditionsHtml}
|
||||
${podsHtml}
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="card-title">Provisioning Steps</div>
|
||||
<div class="step-list">${stepsHtml}</div>
|
||||
<div style="margin-top:1rem;font-size:0.78rem;color:#8b949e">Provisioned ${fmtDateTime(customer.created_at)}</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="card-title">Size History</div>
|
||||
${sizeRowsHtml}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
// ── Delete ────────────────────────────────────────────────────────────────
|
||||
|
||||
function openDeleteDialog(slug) {
|
||||
@@ -666,6 +748,7 @@
|
||||
throw new Error(d.message ?? 'Delete failed');
|
||||
}
|
||||
closeDeleteDialog();
|
||||
if (currentDetailSlug === slug) showPage('customers');
|
||||
loadCustomers();
|
||||
} catch (err) {
|
||||
alert(err.message);
|
||||
@@ -676,9 +759,10 @@
|
||||
}
|
||||
|
||||
async function removeRecord(slug) {
|
||||
if (!confirm(`Remove "${slug}" from the manager database only?\n\nThis will NOT delete the ArgoCD app or DO database — use this only for failed partial deployments.`)) return;
|
||||
if (!confirm(`Remove "${slug}" from the manager database only?\n\nThis will NOT delete the ArgoCD app or DO database.`)) return;
|
||||
const res = await apiFetch(`/api/customers/${slug}/record`, { method: 'DELETE' });
|
||||
if (res.ok) {
|
||||
if (currentDetailSlug === slug) showPage('customers');
|
||||
loadCustomers();
|
||||
} else {
|
||||
const d = await res.json().catch(() => ({}));
|
||||
@@ -689,8 +773,7 @@
|
||||
// ── Provision ─────────────────────────────────────────────────────────────
|
||||
|
||||
function toggleModule(checkbox) {
|
||||
const label = checkbox.closest('.module-check');
|
||||
label.classList.toggle('checked', checkbox.checked);
|
||||
checkbox.closest('.module-check').classList.toggle('checked', checkbox.checked);
|
||||
}
|
||||
|
||||
async function provision() {
|
||||
@@ -699,10 +782,9 @@
|
||||
const startDate = document.getElementById('start-date').value;
|
||||
const expirationDate = document.getElementById('expiration-date').value || null;
|
||||
const modules = [...document.querySelectorAll('.module-check input:checked')].map(el => el.value);
|
||||
if (!name) return;
|
||||
if (!name || !slug) return;
|
||||
const btn = document.getElementById('provision-btn');
|
||||
const status = document.getElementById('provision-status');
|
||||
if (!slug) return;
|
||||
btn.disabled = true;
|
||||
btn.textContent = 'Provisioning…';
|
||||
status.className = 'status';
|
||||
@@ -736,11 +818,7 @@
|
||||
const confirm = document.getElementById('confirm-password').value;
|
||||
const status = document.getElementById('account-status');
|
||||
status.className = 'status';
|
||||
if (pw !== confirm) {
|
||||
status.textContent = 'Passwords do not match';
|
||||
status.className = 'status error';
|
||||
return;
|
||||
}
|
||||
if (pw !== confirm) { status.textContent = 'Passwords do not match'; status.className = 'status error'; return; }
|
||||
try {
|
||||
const res = await apiFetch('/api/auth/password', {
|
||||
method: 'POST',
|
||||
@@ -748,7 +826,7 @@
|
||||
body: JSON.stringify({ password: pw }),
|
||||
});
|
||||
const data = await res.json();
|
||||
if (!res.ok) throw new Error(data.message ?? 'Failed to update password');
|
||||
if (!res.ok) throw new Error(data.message ?? 'Failed');
|
||||
status.textContent = 'Password updated';
|
||||
status.className = 'status success';
|
||||
document.getElementById('new-password').value = '';
|
||||
@@ -765,14 +843,29 @@
|
||||
if (!val) return '—';
|
||||
return new Date(val).toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' });
|
||||
}
|
||||
|
||||
function fmtDateTime(val) {
|
||||
if (!val) return '—';
|
||||
return new Date(val).toLocaleString(undefined, { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' });
|
||||
}
|
||||
function fmtAge(startedAt) {
|
||||
const secs = Math.floor((Date.now() - new Date(startedAt)) / 1000);
|
||||
if (secs < 60) return `${secs}s`;
|
||||
const mins = Math.floor(secs / 60);
|
||||
if (mins < 60) return `${mins}m`;
|
||||
const hrs = Math.floor(mins / 60);
|
||||
if (hrs < 24) return `${hrs}h ${mins % 60}m`;
|
||||
return `${Math.floor(hrs / 24)}d`;
|
||||
}
|
||||
function fmtBytes(bytes) {
|
||||
if (bytes == null) return '—';
|
||||
bytes = Number(bytes);
|
||||
if (bytes < 1024) return `${bytes} B`;
|
||||
if (bytes < 1024 ** 2) return `${(bytes / 1024).toFixed(1)} KB`;
|
||||
if (bytes < 1024 ** 3) return `${(bytes / 1024 ** 2).toFixed(1)} MB`;
|
||||
return `${(bytes / 1024 ** 3).toFixed(2)} GB`;
|
||||
}
|
||||
|
||||
// ── Init ──────────────────────────────────────────────────────────────────
|
||||
|
||||
document.getElementById('start-date').value = new Date().toISOString().slice(0, 10);
|
||||
checkAuth();
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user