Implement FarmQ Admin machine name display fix for Magic DNS
Fix machine management page to display proper Magic DNS names: - Use given_name instead of hostname for machine display - Add Magic DNS address with copy-to-clipboard functionality - Distinguish between machine name and OS hostname like Headplane - Enhance UI with Magic DNS information (.headscale.local) Changes: - farmq-admin/utils/database_new.py: Use given_name for machine_name - farmq-admin/models/farmq_models.py: Update sync logic for given_name - farmq-admin/templates/machines/list.html: Add Magic DNS display with copy feature - FARMQ_ADMIN_MACHINE_NAME_FIX_PLAN.md: Complete analysis and implementation plan Now displays: - Machine Name: pbs-hp (Magic DNS name) - Magic DNS: pbs-hp.headscale.local (with copy button) - OS Hostname: proxmox-backup-server (system name) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -432,6 +432,7 @@ class FarmqDatabaseManager:
|
||||
if machine:
|
||||
# 기존 머신 업데이트
|
||||
machine.hostname = headscale_node_data.get('hostname')
|
||||
machine.machine_name = headscale_node_data.get('given_name') or headscale_node_data.get('hostname')
|
||||
machine.tailscale_ip = headscale_node_data.get('ipv4')
|
||||
machine.tailscale_status = 'online' if headscale_node_data.get('is_online') else 'offline'
|
||||
machine.last_seen = datetime.now()
|
||||
@@ -442,7 +443,7 @@ class FarmqDatabaseManager:
|
||||
headscale_node_id=headscale_node_data.get('id'),
|
||||
headscale_machine_key=headscale_node_data.get('machine_key'),
|
||||
hostname=headscale_node_data.get('hostname'),
|
||||
machine_name=headscale_node_data.get('hostname'),
|
||||
machine_name=headscale_node_data.get('given_name') or headscale_node_data.get('hostname'),
|
||||
tailscale_ip=headscale_node_data.get('ipv4'),
|
||||
tailscale_status='online' if headscale_node_data.get('is_online') else 'offline',
|
||||
last_seen=datetime.now()
|
||||
|
||||
@@ -113,7 +113,17 @@
|
||||
</div>
|
||||
<div>
|
||||
<strong>{{ machine_data.machine_name or machine_data.hostname }}</strong>
|
||||
<div class="small text-muted">{{ machine_data.hostname }}</div>
|
||||
<div class="small text-success">
|
||||
<i class="fas fa-link"></i> <code>{{ machine_data.machine_name or machine_data.hostname }}.headscale.local</code>
|
||||
<button class="btn btn-sm btn-outline-secondary ms-1" onclick="copyToClipboard('{{ machine_data.machine_name or machine_data.hostname }}.headscale.local')" title="Magic DNS 주소 복사">
|
||||
<i class="fas fa-copy"></i>
|
||||
</button>
|
||||
</div>
|
||||
{% if machine_data.hostname != (machine_data.machine_name or machine_data.hostname) %}
|
||||
<div class="small text-muted">
|
||||
<i class="fas fa-server"></i> OS: {{ machine_data.hostname }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="small">
|
||||
<i class="fas fa-user"></i> {{ machine_data.headscale_user_name or '미지정' }}
|
||||
</div>
|
||||
@@ -440,6 +450,16 @@ function deleteNode(nodeId, nodeName) {
|
||||
});
|
||||
}
|
||||
|
||||
// Magic DNS 주소 클립보드 복사 기능
|
||||
function copyToClipboard(text) {
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
showToast(`Magic DNS 주소가 복사되었습니다: ${text}`, 'success');
|
||||
}).catch(err => {
|
||||
console.error('복사 실패:', err);
|
||||
showToast('복사에 실패했습니다.', 'danger');
|
||||
});
|
||||
}
|
||||
|
||||
// 초기 카운터 설정
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
filterMachines();
|
||||
|
||||
@@ -340,7 +340,7 @@ def get_all_machines_with_details() -> List[Dict[str, Any]]:
|
||||
machine_data = {
|
||||
'id': node.id,
|
||||
'hostname': node.hostname,
|
||||
'machine_name': node.hostname, # 표시용 이름
|
||||
'machine_name': node.given_name or node.hostname, # Magic DNS용 이름 (given_name 우선)
|
||||
'tailscale_ip': node.ipv4,
|
||||
'ipv6': node.ipv6,
|
||||
'headscale_user_name': node.user.name if node.user else '미지정',
|
||||
|
||||
Reference in New Issue
Block a user