Files
pingql/apps/web/src/views/new.ejs
T

41 lines
1.4 KiB
Plaintext

<%~ include('./partials/head', { title: 'New Monitor', scripts: ['/dashboard/query-builder.js'] }) %>
<%~ include('./partials/nav', { nav: 'monitors' }) %>
<main class="max-w-2xl mx-auto px-6 py-8">
<div class="mb-6">
<a href="/dashboard/home" class="text-sm text-gray-500 hover:text-gray-300 transition-colors">&larr; Back to monitors</a>
<h2 class="text-lg font-semibold text-gray-200 mt-2">Create Monitor</h2>
</div>
<%~ include('./partials/monitor-form', { _form: { monitor: {}, isEdit: false, prefix: '', bg: 'bg-gray-900', border: 'border-gray-800' }, plan: it.plan }) %>
</main>
<script>
const _prefix = '';
const _initialQuery = null;
<%~ include('./partials/monitor-form-js') %>
document.getElementById('form').addEventListener('submit', async (e) => {
e.preventDefault();
const btn = document.getElementById('submit-btn');
const errEl = document.getElementById('error');
errEl.classList.add('hidden');
btn.disabled = true;
btn.textContent = 'Creating...';
try {
const body = collectFormData(_prefix);
await api('/monitors/', { method: 'POST', body });
window.location.href = '/dashboard/home';
} catch (err) {
errEl.textContent = err.message;
errEl.classList.remove('hidden');
} finally {
btn.disabled = false;
btn.textContent = 'Create Monitor';
}
});
</script>
<%~ include('./partials/foot') %>