feat: dashboard, visual query builder, expanded query language, cert expiry support
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="dark">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>PingQL — Login</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<style>
|
||||
body { font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', ui-monospace, monospace; background: #0a0a0a; }
|
||||
.glow { box-shadow: 0 0 40px rgba(59, 130, 246, 0.08); }
|
||||
</style>
|
||||
</head>
|
||||
<body class="bg-[#0a0a0a] text-gray-100 min-h-screen flex items-center justify-center">
|
||||
<div class="w-full max-w-md p-8">
|
||||
<div class="text-center mb-8">
|
||||
<h1 class="text-3xl font-bold tracking-tight">Ping<span class="text-blue-400">QL</span></h1>
|
||||
<p class="text-gray-500 text-sm mt-2">Uptime monitoring for developers</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-gray-900 rounded-xl p-6 glow border border-gray-800">
|
||||
<div id="login-form">
|
||||
<label class="block text-sm text-gray-400 mb-2">Account Key</label>
|
||||
<input id="key-input" type="text" placeholder="XXXX-XXXX-XXXX-XXXX"
|
||||
class="w-full bg-gray-800 border border-gray-700 rounded-lg px-4 py-3 text-gray-100 placeholder-gray-600 focus:outline-none focus:border-blue-500 tracking-widest text-center text-lg"
|
||||
maxlength="19" autocomplete="off" spellcheck="false">
|
||||
<button id="login-btn"
|
||||
class="w-full mt-4 bg-blue-600 hover:bg-blue-500 text-white font-medium py-3 rounded-lg transition-colors">
|
||||
Sign In
|
||||
</button>
|
||||
<div id="login-error" class="text-red-400 text-sm mt-3 text-center hidden"></div>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 pt-6 border-t border-gray-800 text-center">
|
||||
<p class="text-gray-500 text-sm">No account?</p>
|
||||
<button id="register-btn"
|
||||
class="mt-2 text-blue-400 hover:text-blue-300 text-sm font-medium transition-colors">
|
||||
Create Account
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const keyInput = document.getElementById('key-input');
|
||||
const loginBtn = document.getElementById('login-btn');
|
||||
const registerBtn = document.getElementById('register-btn');
|
||||
const loginError = document.getElementById('login-error');
|
||||
|
||||
// Check if already logged in
|
||||
if (localStorage.getItem('pingql_key')) {
|
||||
window.location.href = '/dashboard/home';
|
||||
}
|
||||
|
||||
// Auto-format key input with dashes
|
||||
keyInput.addEventListener('input', (e) => {
|
||||
let v = e.target.value.replace(/[^a-zA-Z0-9]/g, '').toUpperCase();
|
||||
if (v.length > 16) v = v.slice(0, 16);
|
||||
const parts = v.match(/.{1,4}/g) || [];
|
||||
e.target.value = parts.join('-');
|
||||
});
|
||||
|
||||
loginBtn.addEventListener('click', async () => {
|
||||
const key = keyInput.value.trim();
|
||||
if (!key || key.length < 19) {
|
||||
showError('Enter a valid account key');
|
||||
return;
|
||||
}
|
||||
loginBtn.disabled = true;
|
||||
loginBtn.textContent = 'Verifying...';
|
||||
try {
|
||||
const res = await fetch('/monitors/', {
|
||||
headers: { Authorization: `Bearer ${key}` },
|
||||
});
|
||||
if (res.status === 401) {
|
||||
showError('Invalid account key');
|
||||
return;
|
||||
}
|
||||
localStorage.setItem('pingql_key', key);
|
||||
window.location.href = '/dashboard/home';
|
||||
} catch (e) {
|
||||
showError('Connection error');
|
||||
} finally {
|
||||
loginBtn.disabled = false;
|
||||
loginBtn.textContent = 'Sign In';
|
||||
}
|
||||
});
|
||||
|
||||
keyInput.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') loginBtn.click();
|
||||
});
|
||||
|
||||
registerBtn.addEventListener('click', async () => {
|
||||
registerBtn.disabled = true;
|
||||
registerBtn.textContent = 'Creating...';
|
||||
try {
|
||||
const res = await fetch('/auth/register', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({}),
|
||||
});
|
||||
const data = await res.json();
|
||||
if (data.account_key) {
|
||||
localStorage.setItem('pingql_key', data.account_key);
|
||||
// Show key to user briefly
|
||||
keyInput.value = data.account_key;
|
||||
loginError.textContent = 'Account created! Key: ' + data.account_key + ' — save this!';
|
||||
loginError.classList.remove('hidden');
|
||||
loginError.classList.remove('text-red-400');
|
||||
loginError.classList.add('text-green-400');
|
||||
setTimeout(() => {
|
||||
window.location.href = '/dashboard/home';
|
||||
}, 3000);
|
||||
}
|
||||
} catch (e) {
|
||||
showError('Failed to create account');
|
||||
} finally {
|
||||
registerBtn.disabled = false;
|
||||
registerBtn.textContent = 'Create Account';
|
||||
}
|
||||
});
|
||||
|
||||
function showError(msg) {
|
||||
loginError.textContent = msg;
|
||||
loginError.classList.remove('hidden', 'text-green-400');
|
||||
loginError.classList.add('text-red-400');
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user