Commit Graph

17 Commits

Author SHA1 Message Date
7aa08682b8 Implement smart Magic DNS copy with automatic port detection
### Magic DNS Smart Copy Features:
- **PBS servers**: Automatically append `:8007` port when copying
- **PVE servers**: Automatically append `:8006` port when copying
- **Other machines**: Copy Magic DNS address without port (existing behavior)

### UI Improvements:
- PBS servers: Blue button with `:8007` port hint
- PVE servers: Orange button with `:8006` port hint
- Enhanced tooltips with service-specific port information
- Visual distinction between different server types

### PBS Backup Server Monitoring:
- Complete PBS API integration with authentication
- Real-time backup/restore task monitoring with detailed logs
- Namespace-separated backup visualization with color coding
- Datastore usage monitoring and status tracking
- Task history with success/failure status and error details

### Technical Implementation:
- Smart port detection via JavaScript `addSmartPort()` function
- Jinja2 template logic for conditional button styling
- PBS API endpoints for comprehensive backup monitoring
- Enhanced clipboard functionality with user feedback

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-14 10:48:47 +09:00
c68ed59946 Implement Headscale machine rename functionality in FarmQ Admin
Add machine name editing feature similar to Headplane:
- REST API endpoint POST /api/machines/{id}/rename with Headscale CLI integration
- Edit button next to each machine name in the machine list
- Modal dialog with real-time Magic DNS preview
- DNS-compatible name validation (lowercase, digits, hyphens only)
- Immediate UI updates after successful rename
- Loading states and error handling

Features:
- farmq-admin/app.py: New rename API endpoint with subprocess Headscale CLI calls
- farmq-admin/templates/machines/list.html: Edit buttons, rename modal, JavaScript functions
- Real-time validation and Magic DNS preview
- Bootstrap modal with form validation
- Error handling with toast notifications

Users can now rename machines and their Magic DNS addresses directly from the web interface,
matching the functionality available in Headplane.

Tested with machine ID 2: desktop-emjd1dc ↔ desktop-emjd1dc-test 

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-13 23:38:57 +09:00
fb00b0a5fd Add multi-host Proxmox support with SSL certificate handling
- Added support for multiple Proxmox hosts (pve7.0bin.in:443, Healthport PVE:8006)
- Enhanced VM management APIs to accept host parameter
- Fixed WebSocket URL generation bug (dynamic port handling)
- Added comprehensive SSL certificate trust help system
- Implemented host selection dropdown in UI
- Added VNC connection failure detection and automatic SSL help redirection
- Updated session management to store host_key information
- Enhanced error handling for different Proxmox configurations

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-13 00:03:25 +09:00
ac620a0e15 VNC WebSocket 연결 문제 - 브라우저 보안 정책으로 인한 미해결 상태
WebSocket 1006 오류로 인해 브라우저에서 VNC 연결 실패
- 서버 환경에서는 연결 가능하나 브라우저 보안 정책으로 차단
- 역방향 프록시 솔루션 문서화 완료
- 추후 nginx 프록시 구현 필요

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 01:44:47 +09:00
1dc09101cc VNC 인증 실패 자동 해결 시스템 구현
- VNC 티켓 만료 시 자동 새로고침 API 엔드포인트 추가 (/api/vnc/refresh/<session_id>)
- credentialsrequired 및 securityfailure 이벤트 시 자동 티켓 새로고침 로직 구현
- 새 티켓으로 자동 재연결 기능 추가 (기존 연결 종료 후 새 연결 생성)
- 수동 새로고침 버튼 추가 (🔄 Refresh 버튼)
- 인증 실패 발생 시 사용자에게 진행 상황 표시
- VNC 세션 데이터 자동 업데이트 및 타임스탬프 추가

이제 "Authentication failed" 오류 시 자동으로 새 VNC 티켓을 받아와서 재연결되어
사용자가 수동으로 새로고침할 필요가 없음

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-11 23:49:41 +09:00
0dda1423f8 VNC WebSocket 직접 연결 및 Canvas 렌더링 문제 완전 해결
- noVNC API 함수명 오류 수정 (sendPointer, sendKeyEvent -> sendKey)
- Canvas 크기 자동 조정 문제 해결을 위한 단순화된 구현 도입
- 기존 Proxmox vnc_lite.html과 동일한 방식으로 재구현
- 복잡한 Canvas 조작 로직 제거하고 noVNC 자체 렌더링에 의존
- 로컬 noVNC 라이브러리 사용으로 버전 호환성 보장
- VNC 연결, 인증, 화면 표시 모든 기능 정상 작동 확인

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-11 23:17:41 +09:00
895b7a8ee7 VNC WebSocket 인증 문제 해결 및 사용자 포털 계획 추가
- Proxmox VNC 티켓 생성 시 패스워드 생성 활성화
- VNC 세션에 생성된 패스워드 저장 및 전달
- noVNC 클라이언트에서 실제 패스워드 사용으로 인증 문제 해결
- ES6 모듈 방식으로 noVNC 라이브러리 로드
- HTML 엔티티 디코딩으로 WebSocket URL 문제 해결
- PharmQ 사용자 포털 서비스 계획서 추가 (KakaoTalk SSO, TossPayments)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-11 22:56:58 +09:00
6116f3fd15 매출 대시보드 완전 구현 완료
- /revenue 경로로 매출 대시보드 페이지 추가
- 4개 매출 분석 API 엔드포인트 구현:
  * /api/analytics/revenue/monthly - 12개월 매출 트렌드
  * /api/analytics/revenue/by-service - 서비스별 매출 비중
  * /api/analytics/pharmacy-ranking - 약국별 구독료 순위
  * /api/analytics/subscription-trends - 구독 성장/해지 트렌드
- Chart.js 기반 종합 시각화 대시보드:
  * 월별 매출 라인 차트
  * 서비스별 매출 도넛 차트
  * 약국 순위 테이블
  * 구독 트렌드 바 차트
- 실시간 데이터 로딩 및 오류 처리 구현

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-11 19:59:29 +09:00
35ecd4748e PharmQ SaaS 구독 서비스 관리 시스템 완전 구현
📋 기획 및 설계:
- PharmQ SaaS 서비스 기획서 작성
- 구독 서비스 라인업 정의 (클라우드PC, AI CCTV, CRM)
- DB 스키마 설계 및 API 아키텍처 설계

🗄️ 데이터베이스 구조:
- service_products: 서비스 상품 마스터 테이블
- pharmacy_subscriptions: 약국별 구독 현황 테이블
- subscription_usage_logs: 서비스 이용 로그 테이블
- billing_history: 결제 이력 테이블
- 샘플 데이터 자동 생성 (21개 구독, 월 118만원 매출)

🔧 백엔드 API 구현:
- 구독 현황 통계 API (/api/subscriptions/stats)
- 약국별 구독 조회 API (/api/pharmacies/subscriptions)
- 구독 상세 정보 API (/api/pharmacy/{id}/subscriptions)
- 구독 생성/해지 API (/api/subscriptions)

🖥️ 프론트엔드 UI 구현:
- 대시보드 구독 현황 카드 (월 매출, 구독 수, 구독률 등)
- 약국 목록에 구독 상태 아이콘 및 월 구독료 표시
- 약국 상세 페이지 구독 서비스 섹션 추가
- 실시간 구독 생성/해지 기능 구현

 주요 특징:
- 서비스별 색상 코딩 및 이모지 아이콘 시스템
- 실시간 업데이트 (구독 생성/해지 즉시 반영)
- 반응형 디자인 (모바일/태블릿 최적화)
- 툴팁 기반 상세 정보 표시

📊 현재 구독 현황:
- 총 월 매출: ₩1,180,000
- 구독 약국: 10/14개 (71.4%)
- AI CCTV: 6개 약국, CRM: 10개 약국, 클라우드PC: 5개 약국

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-11 19:48:12 +09:00
f3965a67fd 머신 상세 페이지 Headscale CLI 기반 완전 재구현
- 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>
2025-09-11 12:07:53 +09:00
56b72629f9 사용자-약국 매핑 시스템 개선 및 UI 업데이트
- 자동 매핑 버그 수정: 이름만으로 자동 연결되던 문제 해결
- 매핑되지 않은 약국 목록 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>
2025-09-11 11:49:17 +09:00
e71cdb2cda 완전한 약국 관리 및 사용자-약국 매칭 시스템 구현
🏥 약국 관리 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>
2025-09-11 11:17:13 +09:00
fd8c5cbb81 Headscale 사용자 관리 기능 완전 구현
- Headscale CLI 기반 사용자 생성/삭제 API 엔드포인트 추가
- 사용자-약국 매칭 정보 실시간 표시 및 관리
- 완전한 사용자 관리 웹 인터페이스 구현
- 통계 대시보드: 총 사용자, 약국 연결, 미연결, 노드 수
- 사용자별 노드 연결 상태 및 약국 정보 매칭 표시
- 새 사용자 생성 모달 (display_name, email 지원)
- 안전한 사용자 삭제 확인 기능
- 네비게이션 메뉴에 사용자 관리 추가
- Headplane과 동일한 기능 + 약국 매칭 정보 추가 제공

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-11 11:00:34 +09:00
45c952258b 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>
2025-09-11 10:44:49 +09:00
1f0afd4cae Fix machine count display and pharmacy edit functionality
🔧 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>
2025-09-11 09:41:55 +09:00
1ea11a6a3c 🔧 Fix machine connectivity and pharmacy display issues
- 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>
2025-09-09 17:56:38 +09:00
ca61a89739 🏥 Add complete FARMQ Admin Flask application
## 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>
2025-09-09 17:44:56 +09:00