pre refactor
This commit is contained in:
@@ -26,6 +26,11 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Unknown Emitters Section -->
|
||||
<div hx-get="/partials/unknown-emitters" hx-trigger="load, every 10s" hx-swap="innerHTML">
|
||||
<!-- Loading placeholder -->
|
||||
</div>
|
||||
|
||||
<!-- Auto-refresh roster every 10 seconds -->
|
||||
<div hx-get="/partials/roster-table" hx-trigger="load, every 10s" hx-swap="innerHTML">
|
||||
<!-- Initial loading state -->
|
||||
@@ -155,6 +160,42 @@
|
||||
document.getElementById('addUnitForm').reset();
|
||||
}
|
||||
|
||||
// Add unknown unit to roster
|
||||
function addUnknownUnit(unitId) {
|
||||
openAddUnitModal();
|
||||
// Pre-fill the unit ID
|
||||
document.querySelector('#addUnitForm input[name="id"]').value = unitId;
|
||||
// Set deployed to true by default
|
||||
document.querySelector('#addUnitForm input[name="deployed"]').checked = true;
|
||||
}
|
||||
|
||||
// Ignore unknown unit
|
||||
async function ignoreUnknownUnit(unitId) {
|
||||
if (!confirm(`Ignore unit ${unitId}? It will no longer appear in the unknown emitters list.`)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append('reason', 'Ignored from unknown emitters');
|
||||
|
||||
const response = await fetch(`/api/roster/ignore/${unitId}`, {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
// Trigger refresh of unknown emitters
|
||||
htmx.trigger(document.querySelector('[hx-get="/partials/unknown-emitters"]'), 'load');
|
||||
} else {
|
||||
const result = await response.json();
|
||||
alert(`Error ignoring unit: ${result.detail || 'Unknown error'}`);
|
||||
}
|
||||
} catch (error) {
|
||||
alert(`Error ignoring unit: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Import Modal
|
||||
function openImportModal() {
|
||||
document.getElementById('importModal').classList.remove('hidden');
|
||||
|
||||
Reference in New Issue
Block a user