Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
<title>Ping Check</title>
<style>
*{box-sizing:border-box} :root{color-scheme:light;font-family:'Avenir Next',Avenir,'Segoe UI',sans-serif;background:#f0f4f9;color:#172b42}body{margin:0}header{position:sticky;top:0;z-index:10;background:#054a91;color:white;box-shadow:0 2px 8px #12345625}header .inner{max-width:1400px;margin:auto;padding:16px 32px;display:flex;align-items:center;gap:20px}h1{font-size:20px;letter-spacing:.02em;margin:0}.subtitle{font-size:13px;opacity:.7}.live{margin-left:auto;display:flex;align-items:center;gap:7px;font-size:12px}.live input{accent-color:#02bd9d}main{max-width:1400px;margin:auto;padding:24px 32px}p,small,.muted{color:#64748b;font-size:13px;line-height:1.6}h2{font-size:17px;color:#054a91;margin:0}h3{font-size:15px;color:#054a91;margin:26px 0 12px}.stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px;margin-bottom:24px}.stat-card{padding:18px 22px;background:white;border:1px solid #d6e4f4;border-radius:10px}.stat-label,.eyebrow{font-size:11px;text-transform:uppercase;letter-spacing:.08em;font-weight:700;color:#64748b}.stat-value{font-size:30px;font-weight:700;color:#054a91;margin-top:4px}.stat-value.up{color:#04755f}.stat-value.down{color:#b42332}.toolbar{display:flex;align-items:center;gap:12px;flex-wrap:wrap;padding:18px 20px;background:#fff;border:1px solid #d6e4f4;border-radius:10px;margin:0 0 20px}.toolbar label{font-size:13px;font-weight:700;color:#054a91}input,button,select{font:inherit;font-size:13px;padding:9px 12px;border:1px solid #b0c9e8;border-radius:6px;background:#f8fbff;color:#172b42}input:focus-visible,button:focus-visible,select:focus-visible{outline:3px solid #7dc1f180;outline-offset:2px}#address{width:260px;max-width:100%}button{cursor:pointer;font-weight:600;transition:background .15s}button:hover{background:#e4f0fa}.primary{background:#02bd9d;color:#fff;border-color:#02bd9d}.primary:hover{background:#039e84}.hint{font-size:12px;color:#64748b}.panel{background:#fff;border:1px solid #d6e4f4;border-radius:10px;margin-top:20px;box-shadow:0 1px 4px #12345608;overflow:hidden}.section-heading{padding:20px;display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap}.section-heading p{margin:5px 0 0}.table-scroll{overflow-x:auto}table{width:100%;border-collapse:collapse;font-size:13px}th{text-align:left;padding:12px 20px;background:#054a91;color:#fff;font-size:11px;text-transform:uppercase;letter-spacing:.06em;white-space:nowrap}td{padding:12px 20px;border-bottom:1px solid #edf2f8;white-space:nowrap}tbody tr:nth-child(even){background:#f7fafd}tbody tr:hover{background:#eaf3fb}tbody tr.selected{background:#e0eefb}.address-button{border:0;background:transparent;color:#054a91;padding:3px 0;font-family:ui-monospace,monospace;font-size:13px}.selected .address-button{font-weight:800}.remove{background:transparent;border-color:#edd0d4;color:#b42332;padding:5px 10px;font-size:12px}.remove:hover{background:#fff0f1}.badge{display:inline-block;border-radius:5px;padding:4px 9px;font-size:11px;text-transform:uppercase;font-weight:700;letter-spacing:.03em}.badge.up{background:#d8f5ee;color:#04755f}.badge.down{background:#fde2e1;color:#a11916}.badge.pending{background:#fdf0d5;color:#8a5a00}#empty{text-align:center;padding:30px;margin:0}#error:empty{display:none}#error{margin-bottom:18px;padding:12px 16px;border:1px solid #e6b8b8;border-radius:8px;background:#fff6f6;color:#8a3a3a;font-size:13px}.detail-content{padding:0 20px 20px}.range-control{display:flex;align-items:center;gap:10px;font-size:12px;color:#64748b}.legend{display:flex;gap:18px;font-size:12px;color:#64748b;margin:0 0 8px}.legend span{display:flex;align-items:center;gap:6px}.key{width:10px;height:10px;border-radius:3px;background:#3e7cb1}.key.outage{background:#e58a94}svg{width:100%;height:auto;min-height:180px;display:block;cursor:crosshair;touch-action:none;user-select:none}#custom{display:flex;align-items:center;gap:8px;flex-wrap:wrap}#custom input{padding:6px 8px}#custom button{padding:6px 10px}#range{display:block;margin:8px 0 18px;font-size:11px}footer{text-align:center;font-size:.8rem;color:#666;padding:1.5rem 2rem 2rem}footer a{color:#3e7cb1;text-decoration:none;font-weight:bold}footer a:hover{color:#054a91;text-decoration:underline}[hidden]{display:none!important}@media(max-width:650px){header .inner{padding:14px 16px;gap:10px}.subtitle{display:none}main{padding:18px 12px}.stats{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.stat-card{padding:14px}.stat-value{font-size:26px}.toolbar{padding:16px}.toolbar label{width:100%}#address{flex:1;min-width:140px}td,th{padding:12px}.section-heading{padding:16px}.detail-content{padding:0 12px 16px}}
#title{border:0;background:transparent;color:inherit;font:inherit;padding:0}#title:hover{background:#d6eafa}
#copy-address{border:0;background:transparent;color:inherit;padding:2px 5px;font-size:inherit;opacity:.6}#copy-address:hover,#copy-address:focus-visible{opacity:1;background:#d6eafa}#copy-address.copied{color:#02bd9d;opacity:1}
</style>
<header><div class="inner"><h1>Ping Check</h1><span class="subtitle">IP uptime monitor</span><label class="live"><input id="autorefresh" type="checkbox" checked> Auto-refresh · 1s</label></div></header>
<main>
<div class="stats" aria-label="Monitoring overview"><div class="stat-card"><div class="stat-label">Monitored IPs</div><div class="stat-value" id="total-count">0</div></div><div class="stat-card"><div class="stat-label">Online</div><div class="stat-value up" id="up-count">0</div></div><div class="stat-card"><div class="stat-label">In outage</div><div class="stat-value down" id="down-count">0</div></div><div class="stat-card"><div class="stat-label">Awaiting check</div><div class="stat-value" id="pending-count">0</div></div></div>
<form id="add" class="toolbar"><label for="address">Monitor an IP</label><input id="address" placeholder="IPv4 or IPv6 address…" required autocomplete="off"><button class="primary">Add target</button><span class="hint">Checks every 10s · retries every 1s during outages</span></form>
<div id="error" role="alert"></div>
<div class="panel"><div class="section-heading"><div><h2>Monitored addresses</h2><p>Select an address to view response times and outage history.</p></div></div><div class="table-scroll"><table><thead><tr><th>Address</th><th>Status</th><th>Latency</th><th>Last checked</th><th>Actions</th></tr></thead><tbody id="targets"></tbody></table></div><p id="empty">Add an IP address to start monitoring.</p></div>
<section id="detail" class="panel" hidden><div class="section-heading"><div><div class="eyebrow">Response history</div><h2 id="title"></h2><button id="copy-address" type="button">Copy IP</button><span id="copy-status" class="hint" role="status"></span></div><div class="range-control"><label for="period">Time range</label><select id="period"><option value="1h" selected>1h</option><option value="3h">3h</option><option value="8h">8h</option><option value="1d">1d</option><option value="2d">2d</option><option value="7d">7d</option><option value="custom">Custom</option></select><span id="custom" hidden><label for="from">From</label><input id="from" type="datetime-local" step="1"><label for="to">To</label><input id="to" type="datetime-local" step="1"><button id="apply" type="button">Apply</button></span></div></div><div class="detail-content"><div class="legend"><span><i class="key"></i>Average latency · ms</span><span><i class="key outage"></i>Outage</span></div><svg id="graph" viewBox="0 0 1000 250" role="img" aria-label="Ping response time chart"></svg><small id="range"></small><p class="hint" style="margin:-10px 0 18px">Tip: drag across the chart to zoom into a custom time range.</p><h3>Outages in selected range</h3><div class="table-scroll"><table><thead><tr><th>Started</th><th>Recovered</th><th>Duration</th></tr></thead><tbody id="outages"></tbody></table></div></div></section>
<section id="detail" class="panel" hidden><div class="section-heading"><div><div class="eyebrow">Response history</div><h2><button id="title" type="button" aria-label="Copy IP address" title="Copy IP address"></button> <button id="copy-address" type="button" aria-label="Copy IP address" title="Copy IP address"><span aria-hidden="true">⎘</span></button></h2><span id="copy-status" class="hint" role="status"></span></div><div class="range-control"><label for="period">Time range</label><select id="period"><option value="1h" selected>1h</option><option value="3h">3h</option><option value="8h">8h</option><option value="1d">1d</option><option value="2d">2d</option><option value="7d">7d</option><option value="custom">Custom</option></select><span id="custom" hidden><label for="from">From</label><input id="from" type="datetime-local" step="1"><label for="to">To</label><input id="to" type="datetime-local" step="1"><button id="apply" type="button">Apply</button></span></div></div><div class="detail-content"><div class="legend"><span><i class="key"></i>Average latency · ms</span><span><i class="key outage"></i>Outage</span></div><svg id="graph" viewBox="0 0 1000 250" role="img" aria-label="Ping response time chart"></svg><small id="range"></small><p class="hint" style="margin:-10px 0 18px">Tip: drag across the chart to zoom into a custom time range.</p><h3>Outages in selected range</h3><div class="table-scroll"><table><thead><tr><th>Started</th><th>Recovered</th><th>Duration</th></tr></thead><tbody id="outages"></tbody></table></div></div></section>
</main><footer>Made by <a href="https://19points.lv/" target="_blank" rel="noopener">19 points</a>, <a href="https://github.com/19points/ping-check" target="_blank" rel="noopener">source</a>, licensed under the <a href="https://github.com/19points/ping-check/blob/main/LICENSE" target="_blank" rel="noopener">MIT License</a></footer>
<script>
let selected=null, targets=[], custom=null, view=null, dragging=null;
Expand Down Expand Up @@ -58,7 +60,8 @@
graph.onpointerdown=e=>{if(!view||e.button!==0)return;graph.setPointerCapture(e.pointerId);dragging={from:graphX(e),rect:null};};
graph.onpointermove=e=>{if(!dragging)return;const to=graphX(e),a=Math.min(dragging.from,to),w=Math.abs(to-dragging.from);if(!dragging.rect){dragging.rect=document.createElementNS('http://www.w3.org/2000/svg','rect');dragging.rect.setAttribute('y',15);dragging.rect.setAttribute('height',200);dragging.rect.setAttribute('fill','#3e7cb1');dragging.rect.setAttribute('opacity',.25);graph.append(dragging.rect);}dragging.rect.setAttribute('x',a);dragging.rect.setAttribute('width',w);};
graph.onpointerup=graph.onpointercancel=e=>{if(!dragging)return;const from=dragging.from,to=graphX(e);dragging.rect?.remove();dragging=null;if(Math.abs(to-from)<5)return;setCustom(toTime(Math.min(from,to)),toTime(Math.max(from,to)));};
$('copy-address').onclick=async()=>{const address=$('title').textContent;try{await navigator.clipboard.writeText(address);$('copy-status').textContent=` Copied ${address}`;}catch{const selection=window.getSelection(),range=document.createRange();range.selectNodeContents($('title'));selection.removeAllRanges();selection.addRange(range);$('copy-status').textContent=' Select and copy the IP manually (clipboard unavailable).';}};
$('copy-address').onclick=async()=>{const address=$('title').textContent;try{await navigator.clipboard.writeText(address);$('copy-status').textContent=` Copied ${address}`;$('copy-address').classList.add('copied');$('copy-address').firstElementChild.textContent='✓';setTimeout(()=>{$('copy-address').classList.remove('copied');$('copy-address').firstElementChild.textContent='⎘';$('copy-status').textContent='';},1500);}catch{const selection=window.getSelection(),range=document.createRange();range.selectNodeContents($('title'));selection.removeAllRanges();selection.addRange(range);$('copy-status').textContent=' Select and copy the IP manually (clipboard unavailable).';}};
$('title').onclick=()=>$('copy-address').click();
$('add').onsubmit=async e=>{e.preventDefault();$('error').textContent='';try{const t=await api('/api/targets',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({address:$('address').value})});selected=t.id;$('address').value='';await refresh()}catch(e){$('error').textContent=e.message}};
refresh();
setInterval(()=>{if($('autorefresh').checked)refresh()},1000);
Expand Down
Loading