- base.html 상단 네비게이션 브랜딩 변경
- 팜큐 약국 관리 시스템 → PharmQ Super Admin (PSA)
- UI 일관성 향상을 위한 브랜딩 통합
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- get_pharmacy_detail 함수를 Headscale CLI 기반으로 완전 재작성
- 기존 FARMQ DB의 MachineProfile 의존성 제거
- 약국 상세 페이지 템플릿 신규 생성 (detail.html)
- 실시간 머신 상태 및 통계 표시: "머신: 2/4 온라인"
- 사용자-약국 매핑을 통한 머신 연결 관리
- 연결된 머신 목록: IP, 상태, 등록방식, 마지막 접속시간
- datetime 객체 안전 처리로 strftime 오류 방지
- 머신별 상세보기/재연결/연결해제 액션 버튼
- 빈 상태 처리 및 사용자 가이드 제공
- 약국 기본정보: 사업자번호, 담당자, 연락처, 주소
- 네트워크 정보: Proxmox 호스트, Headscale 사용자 연결
- 상태별 아이콘 및 배지 시각화 (온라인/부분연결/오프라인)
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- get_machine_detail 함수를 Headscale CLI 기반으로 완전 교체
- 기존 FARMQ DB 의존성에서 실시간 Headscale 데이터로 전환
- strftime 템플릿 오류 완전 해결 (datetime 객체 타입 체크 추가)
- 실제 머신 정보 표시: 호스트명, IP 주소, 온라인 상태, 사용자 정보
- 약국 정보 매핑: Headscale 사용자명을 통한 약국 연동
- 시간 정보 인간화: "N시간 전", "N분 전" 형식으로 표시
- 네트워크 정보: IPv4/IPv6 주소, 엔드포인트, 키 정보 표시
- 조건부 모니터링 데이터 표시 (향후 확장 대비)
- 전체 머신 상세 페이지 기능 정상화
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- 자동 매핑 버그 수정: 이름만으로 자동 연결되던 문제 해결
- 매핑되지 않은 약국 목록 API 추가 (/api/pharmacies/available)
- 사용자 연결 드롭다운에서 매핑 가능한 약국만 표시하도록 개선
- 기존 잘못된 매핑 초기화하여 명시적 링크만 허용
- UI 텍스트 업데이트: "Headscale 사용자 목록" → "PQON 사용자 목록"
- UI 텍스트 업데이트: "Headscale 네트워크 사용자" → "PharmQ-ON 사용자"
- 사이드 메뉴 링크 변경: "Headplane UI" → "Medivault" (https://medivault.co.kr/)
- SQLAlchemy or_ import 추가하여 복합 조건 쿼리 지원
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
🏥 약국 관리 API 구현:
- POST /api/pharmacy - 새 약국 생성 (모든 DB 칼럼 지원)
- PUT /api/pharmacy/<id> - 약국 정보 수정
- DELETE /api/pharmacy/<id>/delete - 약국 삭제
- 약국 관리 페이지 UI 완전 연동
👤 사용자-약국 매칭 시스템:
- POST /api/users/<user>/link-pharmacy - 사용자와 약국 연결
- 실시간 매칭 상태 표시 및 업데이트
- Headscale 사용자와 FARMQ 약국 간 완전한 연결
🔧 핵심 설계 원칙 100% 준수:
- Headscale CLI 기반 제어 (사용자 생성/삭제)
- 이중 사용자 구분 (Headscale ↔ FARMQ 약국)
- 느슨한 결합 (headscale_user_name 매핑)
- 실시간 동기화 (API 호출 즉시 반영)
✅ 전체 시스템 통합 테스트 완료:
- 약국 생성 → 사용자 생성 → 매칭 → 실시간 확인
- DB 칼럼 구조와 완벽 일치
- UI/API 완전 연동
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Headscale CLI 기반 사용자 생성/삭제 API 엔드포인트 추가
- 사용자-약국 매칭 정보 실시간 표시 및 관리
- 완전한 사용자 관리 웹 인터페이스 구현
- 통계 대시보드: 총 사용자, 약국 연결, 미연결, 노드 수
- 사용자별 노드 연결 상태 및 약국 정보 매칭 표시
- 새 사용자 생성 모달 (display_name, email 지원)
- 안전한 사용자 삭제 확인 기능
- 네비게이션 메뉴에 사용자 관리 추가
- Headplane과 동일한 기능 + 약국 매칭 정보 추가 제공
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- 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>
- Add Headscale CLI integration to get real-time online status
- Replace timeout-based logic with exact same logic as Headplane
- Use 'online' field from Headscale CLI JSON output
- Update dashboard statistics to show 3 online nodes matching Headplane
- Update pharmacy and machine management views with real-time status
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
🔧 Machine Management Fixes:
- Fix duplicate machine counting (was showing 10 instead of 5)
- Update dashboard stats to use Headscale nodes instead of FARMQ profiles
- Fix JavaScript counting to only count active view (List/Card)
- Add view change listeners to update counters correctly
🏥 Pharmacy Management Fixes:
- Add API endpoint for individual pharmacy data retrieval
- Fix pharmacy edit modal to load existing data as form values
- Add proper form validation and error handling
- Implement edit vs add mode detection
📊 Database Integration:
- Improve machine counting logic using Headscale Node table
- Fix online/offline status calculation with 5-minute threshold
- Add debug logging for machine data retrieval
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fix database initialization to use correct Headscale DB path
- Implement proper data synchronization between Headscale and FARMQ
- Resolve timezone comparison error in machine online status detection
- Update machine listing to use actual Headscale Node data instead of MachineProfile
- Add proper pharmacy-to-machine mapping display
- Show both technical Headscale usernames and actual pharmacy business names
- Fix machine offline status display - now correctly shows online machines
- Add humanize_datetime utility function for better timestamp display
All machines now correctly display:
- Online status (matching actual Headscale status)
- Technical username (myuser)
- Actual pharmacy name (세종온누리약국)
- Manager name and business details
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
## Features
- 한국어 Flask 관리 인터페이스 with Bootstrap 5
- Headscale과 분리된 독립 데이터베이스 구조
- 약국 관리 시스템 (pharmacy management)
- 머신 모니터링 및 상태 관리
- 실시간 대시보드 with 통계 및 알림
- Headscale 사용자명과 약국명 분리 관리
## Database Architecture
- 별도 FARMQ SQLite DB (farmq.sqlite)
- Headscale DB와 외래키 충돌 방지
- 느슨한 결합 설계 (ID 참조만 사용)
## UI Components
- 반응형 대시보드 with 실시간 통계
- 약국별 머신 상태 모니터링
- 한국어 지역화 및 사용자 친화적 인터페이스
- 머신 온라인/오프라인 상태 표시 (24시간 타임아웃)
## API Endpoints
- `/api/sync/machines` - Headscale 머신 동기화
- `/api/sync/users` - Headscale 사용자 동기화
- `/api/pharmacy/<id>/update` - 약국 정보 업데이트
- 대시보드 통계 및 알림 API
## Problem Resolution
- Fixed foreign key conflicts preventing Windows client connections
- Resolved machine online status detection with proper timeout handling
- Separated technical Headscale usernames from business pharmacy names
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>