389 lines
14 KiB
HTML
389 lines
14 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>APtool - Submitted APs</title>
|
|
<style>
|
|
*, *::before, *::after { box-sizing: border-box; }
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
margin: 0;
|
|
padding: 16px;
|
|
background: #1a1a2e;
|
|
color: #e0e0e0;
|
|
}
|
|
h1 { font-size: 1.5rem; text-align: center; margin: 0 0 20px; }
|
|
.container { max-width: 700px; margin: 0 auto; }
|
|
.badge {
|
|
background: #1e3a5f;
|
|
color: #93c5fd;
|
|
padding: 6px 14px;
|
|
border-radius: 6px;
|
|
font-weight: 600;
|
|
font-size: 0.95rem;
|
|
}
|
|
.back-link {
|
|
color: #93c5fd;
|
|
font-size: 0.9rem;
|
|
text-decoration: none;
|
|
margin-left: 12px;
|
|
}
|
|
.back-link:hover { text-decoration: underline; }
|
|
.count {
|
|
text-align: center;
|
|
margin: 16px 0;
|
|
color: #999;
|
|
font-size: 0.9rem;
|
|
}
|
|
.empty {
|
|
text-align: center;
|
|
padding: 40px 16px;
|
|
color: #666;
|
|
font-size: 1rem;
|
|
background: #16213e;
|
|
border-radius: 8px;
|
|
margin-top: 16px;
|
|
}
|
|
.footer { text-align: center; margin-top: 32px; }
|
|
.footer a { color: #666; font-size: 0.8rem; text-decoration: none; }
|
|
|
|
/* ── Card layout ─────────────────────────────────── */
|
|
.card {
|
|
background: #16213e;
|
|
border-radius: 10px;
|
|
padding: 16px;
|
|
margin-bottom: 14px;
|
|
border: 1px solid #2a2a4a;
|
|
}
|
|
.card-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
margin-bottom: 10px;
|
|
}
|
|
.ap-num {
|
|
font-size: 1.15rem;
|
|
font-weight: 700;
|
|
color: #93c5fd;
|
|
}
|
|
.ap-location {
|
|
font-size: 0.85rem;
|
|
color: #aaa;
|
|
margin-top: 2px;
|
|
}
|
|
.card-meta {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
gap: 4px 16px;
|
|
font-size: 0.82rem;
|
|
color: #bbb;
|
|
}
|
|
.card-meta dt { color: #777; font-weight: 600; margin: 0; }
|
|
.card-meta dd { margin: 0 0 6px 0; }
|
|
|
|
/* ── Photo toggle ────────────────────────────────── */
|
|
.photo-toggle {
|
|
display: inline-block;
|
|
margin-top: 10px;
|
|
background: none;
|
|
border: 1px solid #3b5998;
|
|
color: #93c5fd;
|
|
padding: 6px 14px;
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
font-size: 0.82rem;
|
|
font-family: inherit;
|
|
}
|
|
.photo-toggle:hover { background: rgba(59, 89, 152, 0.3); }
|
|
|
|
/* ── Photo grid ──────────────────────────────────── */
|
|
.photo-grid {
|
|
display: none;
|
|
grid-template-columns: repeat(3, 1fr);
|
|
gap: 10px;
|
|
margin-top: 12px;
|
|
}
|
|
.photo-grid.open { display: grid; }
|
|
@media (max-width: 400px) {
|
|
.photo-grid { grid-template-columns: repeat(2, 1fr); }
|
|
}
|
|
.photo-cell {
|
|
text-align: center;
|
|
}
|
|
.photo-cell .label {
|
|
font-size: 0.72rem;
|
|
color: #888;
|
|
margin-bottom: 4px;
|
|
}
|
|
.thumb-wrap {
|
|
position: relative;
|
|
width: 100%;
|
|
aspect-ratio: 4/3;
|
|
background: #0f1729;
|
|
border-radius: 6px;
|
|
overflow: hidden;
|
|
cursor: pointer;
|
|
border: 1px solid #2a2a4a;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
.thumb-wrap img {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
}
|
|
.thumb-wrap .no-photo {
|
|
color: #555;
|
|
font-size: 0.75rem;
|
|
}
|
|
.photo-actions {
|
|
margin-top: 4px;
|
|
}
|
|
.btn-replace {
|
|
background: none;
|
|
border: 1px solid #3b5998;
|
|
color: #93c5fd;
|
|
padding: 3px 10px;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
font-size: 0.72rem;
|
|
font-family: inherit;
|
|
}
|
|
.btn-replace:hover { background: rgba(59, 89, 152, 0.3); }
|
|
.btn-upload {
|
|
background: none;
|
|
border: 1px solid #4a7a3a;
|
|
color: #86efac;
|
|
padding: 3px 10px;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
font-size: 0.72rem;
|
|
font-family: inherit;
|
|
}
|
|
.btn-upload:hover { background: rgba(74, 122, 58, 0.3); }
|
|
|
|
/* ── Modal overlay ───────────────────────────────── */
|
|
.modal-overlay {
|
|
display: none;
|
|
position: fixed;
|
|
top: 0; left: 0; right: 0; bottom: 0;
|
|
background: rgba(0,0,0,0.88);
|
|
z-index: 1000;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 20px;
|
|
}
|
|
.modal-overlay.open {
|
|
display: flex;
|
|
}
|
|
.modal-overlay img {
|
|
max-width: 100%;
|
|
max-height: 90vh;
|
|
border-radius: 8px;
|
|
box-shadow: 0 4px 30px rgba(0,0,0,0.6);
|
|
}
|
|
.modal-close {
|
|
position: fixed;
|
|
top: 14px;
|
|
right: 18px;
|
|
background: rgba(255,255,255,0.15);
|
|
border: none;
|
|
color: #fff;
|
|
font-size: 1.8rem;
|
|
width: 40px;
|
|
height: 40px;
|
|
border-radius: 50%;
|
|
cursor: pointer;
|
|
z-index: 1001;
|
|
line-height: 1;
|
|
}
|
|
|
|
/* ── Toast notifications ─────────────────────────── */
|
|
.toast {
|
|
position: fixed;
|
|
bottom: 24px;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
padding: 10px 24px;
|
|
border-radius: 8px;
|
|
font-size: 0.88rem;
|
|
font-weight: 500;
|
|
z-index: 2000;
|
|
opacity: 0;
|
|
transition: opacity 0.3s;
|
|
pointer-events: none;
|
|
}
|
|
.toast.show { opacity: 1; }
|
|
.toast.success { background: #166534; color: #bbf7d0; }
|
|
.toast.error { background: #7f1d1d; color: #fca5a5; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div style="text-align:center;color:#999;font-size:0.8rem;margin-bottom:8px;">JCP Wifi Migration 2026</div>
|
|
<h1>APtool</h1>
|
|
<div style="text-align:center;margin-bottom:16px;">
|
|
<span class="badge">Site {{ site }}</span>
|
|
<a href="/" class="back-link">Back to form</a>
|
|
</div>
|
|
|
|
<div class="count">{{ rows|length }} AP{{ 's' if rows|length != 1 else '' }} submitted</div>
|
|
|
|
{% if rows %}
|
|
{% for row in rows %}
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<div>
|
|
<div class="ap-num">AP {{ row.ap_number }}</div>
|
|
<div class="ap-location">{{ row.ap_location }}</div>
|
|
</div>
|
|
</div>
|
|
<dl class="card-meta">
|
|
<dt>Serial</dt>
|
|
<dd>{{ row.serial_number }}</dd>
|
|
<dt>MAC</dt>
|
|
<dd>{{ row.mac_address }}</dd>
|
|
<dt>Cable</dt>
|
|
<dd>{{ row.cable_length }}</dd>
|
|
</dl>
|
|
|
|
{% if row.photos %}
|
|
<button class="photo-toggle" onclick="togglePhotos(this)">Show Photos</button>
|
|
<div class="photo-grid" data-ap="{{ row.ap_number }}">
|
|
{% for p in row.photos %}
|
|
<div class="photo-cell">
|
|
<div class="label">{{ p.label }}</div>
|
|
<div class="thumb-wrap"
|
|
onclick="{% if p.exists %}openModal('/photo/{{ row.ap_number }}/{{ p.suffix }}'){% endif %}"
|
|
id="thumb-{{ row.ap_number }}-{{ p.suffix }}">
|
|
{% if p.exists %}
|
|
<img src="/photo/{{ row.ap_number }}/{{ p.suffix }}"
|
|
loading="lazy"
|
|
alt="{{ p.label }}">
|
|
{% else %}
|
|
<span class="no-photo">No photo</span>
|
|
{% endif %}
|
|
</div>
|
|
<div class="photo-actions">
|
|
{% if p.exists %}
|
|
<button class="btn-replace"
|
|
onclick="pickFile('{{ row.ap_number }}','{{ p.suffix }}')">Replace</button>
|
|
{% else %}
|
|
<button class="btn-upload"
|
|
onclick="pickFile('{{ row.ap_number }}','{{ p.suffix }}')">Upload</button>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endfor %}
|
|
{% else %}
|
|
<div class="empty">No APs submitted yet for this site.</div>
|
|
{% endif %}
|
|
|
|
<div class="footer">
|
|
<a href="/admin/login">Admin</a>
|
|
<div style="color:#555;font-size:0.7rem;margin-top:12px;">© 2026 Mack Allison, sdAnywhere LLC (with Claude Code)</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Full-size photo modal -->
|
|
<div class="modal-overlay" id="photoModal" onclick="closeModal()">
|
|
<button class="modal-close" onclick="closeModal()">×</button>
|
|
<img id="modalImg" src="" alt="Full size photo" onclick="event.stopPropagation()">
|
|
</div>
|
|
|
|
<!-- Toast -->
|
|
<div class="toast" id="toast"></div>
|
|
|
|
<!-- Hidden file input for uploads -->
|
|
<input type="file" id="fileInput" accept="image/*" style="display:none">
|
|
|
|
<script>
|
|
/* ── Photo grid toggle ──────────────────────────── */
|
|
function togglePhotos(btn) {
|
|
const grid = btn.nextElementSibling;
|
|
const open = grid.classList.toggle('open');
|
|
btn.textContent = open ? 'Hide Photos' : 'Show Photos';
|
|
}
|
|
|
|
/* ── Full-size modal ────────────────────────────── */
|
|
function openModal(src) {
|
|
const modal = document.getElementById('photoModal');
|
|
document.getElementById('modalImg').src = src + '?t=' + Date.now();
|
|
modal.classList.add('open');
|
|
}
|
|
function closeModal() {
|
|
document.getElementById('photoModal').classList.remove('open');
|
|
}
|
|
document.addEventListener('keydown', function(e) {
|
|
if (e.key === 'Escape') closeModal();
|
|
});
|
|
|
|
/* ── File picker + AJAX upload ──────────────────── */
|
|
let pendingAp = null;
|
|
let pendingSuffix = null;
|
|
|
|
function pickFile(ap, suffix) {
|
|
pendingAp = ap;
|
|
pendingSuffix = suffix;
|
|
document.getElementById('fileInput').click();
|
|
}
|
|
|
|
document.getElementById('fileInput').addEventListener('change', function() {
|
|
if (!this.files.length || !pendingAp) return;
|
|
const file = this.files[0];
|
|
const fd = new FormData();
|
|
fd.append('photo', file);
|
|
|
|
const url = '/photo/' + pendingAp + '/' + pendingSuffix + '/replace';
|
|
fetch(url, { method: 'POST', body: fd })
|
|
.then(r => r.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
showToast(data.message, 'success');
|
|
// Update thumbnail in-place
|
|
const wrap = document.getElementById('thumb-' + pendingAp + '-' + pendingSuffix);
|
|
if (wrap) {
|
|
const cacheBuster = '?t=' + Date.now();
|
|
const imgUrl = '/photo/' + pendingAp + '/' + pendingSuffix;
|
|
wrap.innerHTML = '<img src="' + imgUrl + cacheBuster + '" loading="lazy" alt="Photo">';
|
|
wrap.setAttribute('onclick', "openModal('" + imgUrl + "')");
|
|
|
|
// Switch "Upload" button to "Replace"
|
|
const actions = wrap.nextElementSibling;
|
|
if (actions) {
|
|
const btn = actions.querySelector('button');
|
|
if (btn && btn.classList.contains('btn-upload')) {
|
|
btn.classList.remove('btn-upload');
|
|
btn.classList.add('btn-replace');
|
|
btn.textContent = 'Replace';
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
showToast(data.error || 'Upload failed', 'error');
|
|
}
|
|
})
|
|
.catch(() => showToast('Network error', 'error'));
|
|
|
|
// Reset so the same file can be re-selected
|
|
this.value = '';
|
|
});
|
|
|
|
/* ── Toast notifications ────────────────────────── */
|
|
function showToast(msg, type) {
|
|
const t = document.getElementById('toast');
|
|
t.textContent = msg;
|
|
t.className = 'toast ' + type + ' show';
|
|
clearTimeout(t._timer);
|
|
t._timer = setTimeout(() => t.classList.remove('show'), 3000);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|