Add node deletion functionality to FARMQ Admin
- Add DELETE API endpoint for node deletion via Headscale CLI - Add delete buttons to both table and card views in machine list - Implement confirmation dialog with clear warning message - Add proper error handling and user feedback with toast messages - Auto-refresh page after successful deletion - Match Headplane functionality for complete node management 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -189,6 +189,11 @@
|
||||
<i class="fas fa-redo"></i>
|
||||
</button>
|
||||
{% endif %}
|
||||
<button class="btn btn-outline-danger"
|
||||
onclick="confirmDeleteNode({{ machine_data.id }}, '{{ machine_data.machine_name or machine_data.hostname }}')"
|
||||
title="노드 삭제">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -298,6 +303,10 @@
|
||||
onclick="showMonitoring({{ machine_data.id }})">
|
||||
<i class="fas fa-chart-line"></i> 모니터링
|
||||
</button>
|
||||
<button class="btn btn-outline-danger btn-sm"
|
||||
onclick="confirmDeleteNode({{ machine_data.id }}, '{{ machine_data.machine_name or machine_data.hostname }}')">
|
||||
<i class="fas fa-trash"></i> 삭제
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -396,6 +405,41 @@ function refreshMachineList() {
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
// 노드 삭제 확인
|
||||
function confirmDeleteNode(nodeId, nodeName) {
|
||||
if (confirm(`정말로 노드 "${nodeName}"를 삭제하시겠습니까?\n\n삭제된 노드는 복구할 수 없으며, 해당 머신은 네트워크에서 완전히 제거됩니다.`)) {
|
||||
deleteNode(nodeId, nodeName);
|
||||
}
|
||||
}
|
||||
|
||||
// 노드 삭제 실행
|
||||
function deleteNode(nodeId, nodeName) {
|
||||
showToast(`노드 ${nodeName} 삭제 중...`, 'info');
|
||||
|
||||
fetch(`/api/nodes/${nodeId}/delete`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
showToast(`노드 ${nodeName}가 성공적으로 삭제되었습니다.`, 'success');
|
||||
// 페이지 새로고침으로 목록 업데이트
|
||||
setTimeout(() => {
|
||||
location.reload();
|
||||
}, 1500);
|
||||
} else {
|
||||
showToast(`노드 삭제 실패: ${data.error}`, 'danger');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('노드 삭제 오류:', error);
|
||||
showToast('노드 삭제 중 오류가 발생했습니다.', 'danger');
|
||||
});
|
||||
}
|
||||
|
||||
// 초기 카운터 설정
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
filterMachines();
|
||||
|
||||
Reference in New Issue
Block a user