Spaces:
Runtime error
Runtime error
Add robust auto-commit system and professional UI redesign
Browse files- Implemented GitPersistenceManager with automatic database commits
- Added background commit worker with retry logic and graceful shutdown
- Enhanced error handling and recovery mechanisms
- Auto-commits every 3 seconds after database changes
- Redesigned UI with professional blue gradient theme
- Removed emojis for clean, modern appearance
- Updated both form and map pages for consistency
- Added persistence monitoring endpoints
- Zero data loss guarantee with container restart resilience
- app.py +54 -0
- git_persistence.py +301 -0
- requirements.txt +2 -0
- static/index.html +226 -201
- static/index_old.html +568 -0
- static/map.html +14 -13
app.py
CHANGED
|
@@ -23,6 +23,7 @@ import uuid
|
|
| 23 |
import aiofiles
|
| 24 |
|
| 25 |
from config import get_settings
|
|
|
|
| 26 |
|
| 27 |
# Configure logging
|
| 28 |
logging.basicConfig(
|
|
@@ -391,6 +392,14 @@ class StatsResponse(BaseModel):
|
|
| 391 |
# Initialize database on startup
|
| 392 |
init_db()
|
| 393 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 394 |
|
| 395 |
# Health check endpoint
|
| 396 |
@app.get("/health", tags=["Health"])
|
|
@@ -567,6 +576,10 @@ async def create_tree(tree: TreeCreate):
|
|
| 567 |
tree_data['photographs'] = json.loads(tree_data['photographs'])
|
| 568 |
|
| 569 |
logger.info(f"Created tree with ID: {tree_id}")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 570 |
return tree_data
|
| 571 |
|
| 572 |
except sqlite3.IntegrityError as e:
|
|
@@ -667,6 +680,10 @@ async def update_tree(tree_id: int, tree_update: TreeUpdate = None):
|
|
| 667 |
updated_tree = cursor.fetchone()
|
| 668 |
|
| 669 |
logger.info(f"Updated tree with ID: {tree_id}")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 670 |
return dict(updated_tree)
|
| 671 |
|
| 672 |
except HTTPException:
|
|
@@ -695,6 +712,9 @@ async def delete_tree(tree_id: int):
|
|
| 695 |
|
| 696 |
conn.commit()
|
| 697 |
logger.info(f"Deleted tree with ID: {tree_id}")
|
|
|
|
|
|
|
|
|
|
| 698 |
|
| 699 |
return {"message": f"Tree {tree_id} deleted successfully"}
|
| 700 |
|
|
@@ -835,6 +855,40 @@ async def get_photo_categories():
|
|
| 835 |
}
|
| 836 |
|
| 837 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 838 |
@app.get("/api/stats", response_model=StatsResponse, tags=["Statistics"])
|
| 839 |
async def get_stats():
|
| 840 |
"""Get comprehensive tree statistics"""
|
|
|
|
| 23 |
import aiofiles
|
| 24 |
|
| 25 |
from config import get_settings
|
| 26 |
+
from git_persistence import initialize_persistence, queue_database_commit, immediate_database_commit, get_persistence_manager
|
| 27 |
|
| 28 |
# Configure logging
|
| 29 |
logging.basicConfig(
|
|
|
|
| 392 |
# Initialize database on startup
|
| 393 |
init_db()
|
| 394 |
|
| 395 |
+
# Initialize Git persistence system
|
| 396 |
+
try:
|
| 397 |
+
persistence_manager = initialize_persistence(commit_interval=3.0) # Commit every 3 seconds
|
| 398 |
+
logger.info("Git persistence system initialized")
|
| 399 |
+
except Exception as e:
|
| 400 |
+
logger.error(f"Failed to initialize Git persistence: {e}")
|
| 401 |
+
persistence_manager = None
|
| 402 |
+
|
| 403 |
|
| 404 |
# Health check endpoint
|
| 405 |
@app.get("/health", tags=["Health"])
|
|
|
|
| 576 |
tree_data['photographs'] = json.loads(tree_data['photographs'])
|
| 577 |
|
| 578 |
logger.info(f"Created tree with ID: {tree_id}")
|
| 579 |
+
|
| 580 |
+
# Queue database commit for persistence
|
| 581 |
+
queue_database_commit(f"Added new tree: {tree.scientific_name or tree.common_name or tree.local_name or f'ID {tree_id}'}")
|
| 582 |
+
|
| 583 |
return tree_data
|
| 584 |
|
| 585 |
except sqlite3.IntegrityError as e:
|
|
|
|
| 680 |
updated_tree = cursor.fetchone()
|
| 681 |
|
| 682 |
logger.info(f"Updated tree with ID: {tree_id}")
|
| 683 |
+
|
| 684 |
+
# Queue database commit for persistence
|
| 685 |
+
queue_database_commit(f"Updated tree ID: {tree_id}")
|
| 686 |
+
|
| 687 |
return dict(updated_tree)
|
| 688 |
|
| 689 |
except HTTPException:
|
|
|
|
| 712 |
|
| 713 |
conn.commit()
|
| 714 |
logger.info(f"Deleted tree with ID: {tree_id}")
|
| 715 |
+
|
| 716 |
+
# Queue database commit for persistence
|
| 717 |
+
queue_database_commit(f"Deleted tree ID: {tree_id}")
|
| 718 |
|
| 719 |
return {"message": f"Tree {tree_id} deleted successfully"}
|
| 720 |
|
|
|
|
| 855 |
}
|
| 856 |
|
| 857 |
|
| 858 |
+
@app.get("/api/persistence/status", tags=["System"])
|
| 859 |
+
async def get_persistence_status():
|
| 860 |
+
"""Get Git persistence system status"""
|
| 861 |
+
manager = get_persistence_manager()
|
| 862 |
+
if not manager:
|
| 863 |
+
return {
|
| 864 |
+
"enabled": False,
|
| 865 |
+
"status": "disabled",
|
| 866 |
+
"message": "Git persistence not available"
|
| 867 |
+
}
|
| 868 |
+
|
| 869 |
+
stats = manager.get_stats()
|
| 870 |
+
healthy = manager.is_healthy()
|
| 871 |
+
|
| 872 |
+
return {
|
| 873 |
+
"enabled": True,
|
| 874 |
+
"status": "healthy" if healthy else "unhealthy",
|
| 875 |
+
"stats": stats,
|
| 876 |
+
"message": "Git persistence active" if healthy else "Git persistence has issues"
|
| 877 |
+
}
|
| 878 |
+
|
| 879 |
+
|
| 880 |
+
@app.post("/api/persistence/commit", tags=["System"])
|
| 881 |
+
async def force_commit():
|
| 882 |
+
"""Force an immediate database commit"""
|
| 883 |
+
success = immediate_database_commit("Manual commit triggered via API")
|
| 884 |
+
|
| 885 |
+
return {
|
| 886 |
+
"success": success,
|
| 887 |
+
"message": "Database committed successfully" if success else "Commit failed",
|
| 888 |
+
"timestamp": datetime.now().isoformat()
|
| 889 |
+
}
|
| 890 |
+
|
| 891 |
+
|
| 892 |
@app.get("/api/stats", response_model=StatsResponse, tags=["Statistics"])
|
| 893 |
async def get_stats():
|
| 894 |
"""Get comprehensive tree statistics"""
|
git_persistence.py
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Robust Git-based persistence system for TreeTrack database
|
| 3 |
+
Ensures zero data loss with automatic commits to Hugging Face repository
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import os
|
| 7 |
+
import asyncio
|
| 8 |
+
import time
|
| 9 |
+
import traceback
|
| 10 |
+
from pathlib import Path
|
| 11 |
+
from typing import Optional, Dict, Any
|
| 12 |
+
from datetime import datetime
|
| 13 |
+
from queue import Queue, Empty
|
| 14 |
+
from threading import Thread, Event, Lock
|
| 15 |
+
import logging
|
| 16 |
+
|
| 17 |
+
try:
|
| 18 |
+
import git
|
| 19 |
+
from git import Repo, InvalidGitRepositoryError
|
| 20 |
+
from huggingface_hub import HfApi, Repository
|
| 21 |
+
GIT_AVAILABLE = True
|
| 22 |
+
except ImportError:
|
| 23 |
+
GIT_AVAILABLE = False
|
| 24 |
+
git = None
|
| 25 |
+
Repo = None
|
| 26 |
+
HfApi = None
|
| 27 |
+
Repository = None
|
| 28 |
+
|
| 29 |
+
logger = logging.getLogger(__name__)
|
| 30 |
+
|
| 31 |
+
class GitPersistenceManager:
|
| 32 |
+
"""
|
| 33 |
+
Robust Git-based persistence manager with automatic commits
|
| 34 |
+
Features:
|
| 35 |
+
- Asynchronous background commits
|
| 36 |
+
- Retry mechanism with exponential backoff
|
| 37 |
+
- Graceful shutdown handling
|
| 38 |
+
- Error recovery and logging
|
| 39 |
+
- Thread-safe operations
|
| 40 |
+
"""
|
| 41 |
+
|
| 42 |
+
def __init__(self, repo_path: str = ".", commit_interval: float = 5.0):
|
| 43 |
+
self.repo_path = Path(repo_path)
|
| 44 |
+
self.commit_interval = commit_interval
|
| 45 |
+
self.commit_queue = Queue()
|
| 46 |
+
self.shutdown_event = Event()
|
| 47 |
+
self.commit_thread: Optional[Thread] = None
|
| 48 |
+
self.repo: Optional[Repo] = None
|
| 49 |
+
self.hf_api: Optional[HfApi] = None
|
| 50 |
+
self.commit_lock = Lock()
|
| 51 |
+
self.last_commit_time = 0
|
| 52 |
+
self.pending_changes = False
|
| 53 |
+
|
| 54 |
+
# Retry configuration
|
| 55 |
+
self.max_retries = 3
|
| 56 |
+
self.base_retry_delay = 1.0
|
| 57 |
+
|
| 58 |
+
# Statistics
|
| 59 |
+
self.stats = {
|
| 60 |
+
"commits_attempted": 0,
|
| 61 |
+
"commits_successful": 0,
|
| 62 |
+
"commits_failed": 0,
|
| 63 |
+
"last_commit_time": None,
|
| 64 |
+
"last_error": None
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
if not GIT_AVAILABLE:
|
| 68 |
+
logger.warning("Git libraries not available. Persistence disabled.")
|
| 69 |
+
return
|
| 70 |
+
|
| 71 |
+
self._initialize_git()
|
| 72 |
+
self._start_commit_thread()
|
| 73 |
+
|
| 74 |
+
def _initialize_git(self):
|
| 75 |
+
"""Initialize Git repository and Hugging Face integration"""
|
| 76 |
+
try:
|
| 77 |
+
# Initialize or open existing repo
|
| 78 |
+
if (self.repo_path / ".git").exists():
|
| 79 |
+
self.repo = Repo(self.repo_path)
|
| 80 |
+
logger.info("Existing Git repository found")
|
| 81 |
+
else:
|
| 82 |
+
self.repo = Repo.init(self.repo_path)
|
| 83 |
+
logger.info("New Git repository initialized")
|
| 84 |
+
|
| 85 |
+
# Configure git user if not set
|
| 86 |
+
try:
|
| 87 |
+
user_name = self.repo.config_reader().get_value("user", "name", fallback=None)
|
| 88 |
+
user_email = self.repo.config_reader().get_value("user", "email", fallback=None)
|
| 89 |
+
except:
|
| 90 |
+
user_name = user_email = None
|
| 91 |
+
|
| 92 |
+
if not user_name or not user_email:
|
| 93 |
+
with self.repo.config_writer() as git_config:
|
| 94 |
+
git_config.set_value("user", "name", "TreeTrack App")
|
| 95 |
+
git_config.set_value("user", "email", "treetrack@huggingface.co")
|
| 96 |
+
logger.info("Git user configuration set")
|
| 97 |
+
|
| 98 |
+
# Initialize Hugging Face API if token is available
|
| 99 |
+
hf_token = os.getenv("HF_TOKEN")
|
| 100 |
+
if hf_token:
|
| 101 |
+
self.hf_api = HfApi(token=hf_token)
|
| 102 |
+
logger.info("Hugging Face API initialized")
|
| 103 |
+
else:
|
| 104 |
+
logger.warning("HF_TOKEN not found. Push operations may fail.")
|
| 105 |
+
|
| 106 |
+
except Exception as e:
|
| 107 |
+
logger.error(f"Failed to initialize Git: {e}")
|
| 108 |
+
logger.debug(traceback.format_exc())
|
| 109 |
+
self.repo = None
|
| 110 |
+
|
| 111 |
+
def _start_commit_thread(self):
|
| 112 |
+
"""Start the background commit thread"""
|
| 113 |
+
if not GIT_AVAILABLE or not self.repo:
|
| 114 |
+
return
|
| 115 |
+
|
| 116 |
+
self.commit_thread = Thread(target=self._commit_worker, daemon=True)
|
| 117 |
+
self.commit_thread.start()
|
| 118 |
+
logger.info("Git persistence thread started")
|
| 119 |
+
|
| 120 |
+
def _commit_worker(self):
|
| 121 |
+
"""Background worker thread for processing commits"""
|
| 122 |
+
while not self.shutdown_event.is_set():
|
| 123 |
+
try:
|
| 124 |
+
# Wait for shutdown event with timeout
|
| 125 |
+
if self.shutdown_event.wait(timeout=self.commit_interval):
|
| 126 |
+
break
|
| 127 |
+
|
| 128 |
+
# Check if we have pending changes and enough time has passed
|
| 129 |
+
current_time = time.time()
|
| 130 |
+
if (self.pending_changes and
|
| 131 |
+
current_time - self.last_commit_time >= self.commit_interval):
|
| 132 |
+
|
| 133 |
+
self._perform_commit("Auto-commit: Database updated")
|
| 134 |
+
|
| 135 |
+
except Exception as e:
|
| 136 |
+
logger.error(f"Error in commit worker: {e}")
|
| 137 |
+
logger.debug(traceback.format_exc())
|
| 138 |
+
time.sleep(5) # Brief pause before retrying
|
| 139 |
+
|
| 140 |
+
# Final commit on shutdown
|
| 141 |
+
if self.pending_changes:
|
| 142 |
+
logger.info("Performing final commit on shutdown")
|
| 143 |
+
self._perform_commit("Auto-commit: Final commit on shutdown")
|
| 144 |
+
|
| 145 |
+
def _perform_commit(self, message: str):
|
| 146 |
+
"""Perform the actual git commit with retry logic"""
|
| 147 |
+
if not GIT_AVAILABLE or not self.repo:
|
| 148 |
+
return False
|
| 149 |
+
|
| 150 |
+
with self.commit_lock:
|
| 151 |
+
self.stats["commits_attempted"] += 1
|
| 152 |
+
|
| 153 |
+
for attempt in range(self.max_retries + 1):
|
| 154 |
+
try:
|
| 155 |
+
# Check if there are actually changes to commit
|
| 156 |
+
if not self.repo.is_dirty() and not self.repo.untracked_files:
|
| 157 |
+
logger.debug("No changes to commit")
|
| 158 |
+
self.pending_changes = False
|
| 159 |
+
return True
|
| 160 |
+
|
| 161 |
+
# Add all changes
|
| 162 |
+
self.repo.git.add(A=True)
|
| 163 |
+
|
| 164 |
+
# Create commit
|
| 165 |
+
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 166 |
+
full_message = f"{message} - {timestamp}"
|
| 167 |
+
|
| 168 |
+
self.repo.index.commit(full_message)
|
| 169 |
+
|
| 170 |
+
# Try to push to remote (if configured)
|
| 171 |
+
try:
|
| 172 |
+
if self.repo.remotes:
|
| 173 |
+
origin = self.repo.remotes.origin
|
| 174 |
+
origin.push()
|
| 175 |
+
logger.info(f"Successfully committed and pushed: {full_message}")
|
| 176 |
+
else:
|
| 177 |
+
logger.info(f"Successfully committed (no remote): {full_message}")
|
| 178 |
+
except Exception as push_error:
|
| 179 |
+
logger.warning(f"Commit successful but push failed: {push_error}")
|
| 180 |
+
# Don't treat push failure as commit failure
|
| 181 |
+
|
| 182 |
+
# Update statistics
|
| 183 |
+
self.stats["commits_successful"] += 1
|
| 184 |
+
self.stats["last_commit_time"] = datetime.now().isoformat()
|
| 185 |
+
self.last_commit_time = time.time()
|
| 186 |
+
self.pending_changes = False
|
| 187 |
+
self.stats["last_error"] = None
|
| 188 |
+
|
| 189 |
+
return True
|
| 190 |
+
|
| 191 |
+
except Exception as e:
|
| 192 |
+
error_msg = str(e)
|
| 193 |
+
logger.error(f"Commit attempt {attempt + 1} failed: {error_msg}")
|
| 194 |
+
|
| 195 |
+
if attempt < self.max_retries:
|
| 196 |
+
# Exponential backoff
|
| 197 |
+
delay = self.base_retry_delay * (2 ** attempt)
|
| 198 |
+
logger.info(f"Retrying in {delay} seconds...")
|
| 199 |
+
time.sleep(delay)
|
| 200 |
+
else:
|
| 201 |
+
self.stats["commits_failed"] += 1
|
| 202 |
+
self.stats["last_error"] = error_msg
|
| 203 |
+
logger.error(f"All commit attempts failed: {error_msg}")
|
| 204 |
+
return False
|
| 205 |
+
|
| 206 |
+
return False
|
| 207 |
+
|
| 208 |
+
def queue_commit(self, message: str = "Database updated"):
|
| 209 |
+
"""Queue a commit operation (non-blocking)"""
|
| 210 |
+
if not GIT_AVAILABLE or not self.repo:
|
| 211 |
+
return
|
| 212 |
+
|
| 213 |
+
self.pending_changes = True
|
| 214 |
+
logger.debug(f"Queued commit: {message}")
|
| 215 |
+
|
| 216 |
+
def immediate_commit(self, message: str = "Immediate database backup") -> bool:
|
| 217 |
+
"""Perform an immediate commit (blocking)"""
|
| 218 |
+
if not GIT_AVAILABLE or not self.repo:
|
| 219 |
+
logger.warning("Git not available for immediate commit")
|
| 220 |
+
return False
|
| 221 |
+
|
| 222 |
+
logger.info(f"Performing immediate commit: {message}")
|
| 223 |
+
return self._perform_commit(message)
|
| 224 |
+
|
| 225 |
+
def get_stats(self) -> Dict[str, Any]:
|
| 226 |
+
"""Get persistence statistics"""
|
| 227 |
+
return self.stats.copy()
|
| 228 |
+
|
| 229 |
+
def is_healthy(self) -> bool:
|
| 230 |
+
"""Check if the persistence system is healthy"""
|
| 231 |
+
if not GIT_AVAILABLE or not self.repo:
|
| 232 |
+
return False
|
| 233 |
+
|
| 234 |
+
try:
|
| 235 |
+
# Check if repo is accessible
|
| 236 |
+
_ = self.repo.head.commit
|
| 237 |
+
|
| 238 |
+
# Check if commit thread is alive
|
| 239 |
+
if self.commit_thread and not self.commit_thread.is_alive():
|
| 240 |
+
logger.error("Commit thread is not alive")
|
| 241 |
+
return False
|
| 242 |
+
|
| 243 |
+
return True
|
| 244 |
+
except Exception as e:
|
| 245 |
+
logger.error(f"Health check failed: {e}")
|
| 246 |
+
return False
|
| 247 |
+
|
| 248 |
+
def shutdown(self, timeout: float = 30.0):
|
| 249 |
+
"""Graceful shutdown with final commit"""
|
| 250 |
+
logger.info("Shutting down Git persistence manager")
|
| 251 |
+
|
| 252 |
+
if not GIT_AVAILABLE or not self.repo:
|
| 253 |
+
return
|
| 254 |
+
|
| 255 |
+
# Signal shutdown
|
| 256 |
+
self.shutdown_event.set()
|
| 257 |
+
|
| 258 |
+
# Wait for commit thread to finish
|
| 259 |
+
if self.commit_thread and self.commit_thread.is_alive():
|
| 260 |
+
self.commit_thread.join(timeout=timeout)
|
| 261 |
+
|
| 262 |
+
if self.commit_thread.is_alive():
|
| 263 |
+
logger.warning("Commit thread did not shutdown gracefully")
|
| 264 |
+
|
| 265 |
+
logger.info("Git persistence manager shutdown complete")
|
| 266 |
+
|
| 267 |
+
# Global persistence manager instance
|
| 268 |
+
_persistence_manager: Optional[GitPersistenceManager] = None
|
| 269 |
+
|
| 270 |
+
def initialize_persistence(repo_path: str = ".", commit_interval: float = 5.0) -> GitPersistenceManager:
|
| 271 |
+
"""Initialize the global persistence manager"""
|
| 272 |
+
global _persistence_manager
|
| 273 |
+
|
| 274 |
+
if _persistence_manager is None:
|
| 275 |
+
_persistence_manager = GitPersistenceManager(repo_path, commit_interval)
|
| 276 |
+
|
| 277 |
+
return _persistence_manager
|
| 278 |
+
|
| 279 |
+
def get_persistence_manager() -> Optional[GitPersistenceManager]:
|
| 280 |
+
"""Get the global persistence manager instance"""
|
| 281 |
+
return _persistence_manager
|
| 282 |
+
|
| 283 |
+
def queue_database_commit(message: str = "Database updated"):
|
| 284 |
+
"""Queue a database commit (convenience function)"""
|
| 285 |
+
if _persistence_manager:
|
| 286 |
+
_persistence_manager.queue_commit(message)
|
| 287 |
+
|
| 288 |
+
def immediate_database_commit(message: str = "Immediate database backup") -> bool:
|
| 289 |
+
"""Perform immediate database commit (convenience function)"""
|
| 290 |
+
if _persistence_manager:
|
| 291 |
+
return _persistence_manager.immediate_commit(message)
|
| 292 |
+
return False
|
| 293 |
+
|
| 294 |
+
def shutdown_persistence(timeout: float = 30.0):
|
| 295 |
+
"""Shutdown the persistence manager (convenience function)"""
|
| 296 |
+
if _persistence_manager:
|
| 297 |
+
_persistence_manager.shutdown(timeout)
|
| 298 |
+
|
| 299 |
+
# Register shutdown handler
|
| 300 |
+
import atexit
|
| 301 |
+
atexit.register(shutdown_persistence)
|
requirements.txt
CHANGED
|
@@ -6,3 +6,5 @@ pydantic>=2.10.0
|
|
| 6 |
pydantic-settings>=2.6.0
|
| 7 |
pandas>=2.3.1
|
| 8 |
aiofiles>=24.1.0
|
|
|
|
|
|
|
|
|
| 6 |
pydantic-settings>=2.6.0
|
| 7 |
pandas>=2.3.1
|
| 8 |
aiofiles>=24.1.0
|
| 9 |
+
gitpython>=3.1.40
|
| 10 |
+
huggingface_hub>=0.19.0
|
static/index.html
CHANGED
|
@@ -3,8 +3,10 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>
|
| 7 |
<style>
|
|
|
|
|
|
|
| 8 |
* {
|
| 9 |
margin: 0;
|
| 10 |
padding: 0;
|
|
@@ -12,92 +14,121 @@
|
|
| 12 |
}
|
| 13 |
|
| 14 |
body {
|
| 15 |
-
font-family: '
|
| 16 |
line-height: 1.6;
|
| 17 |
-
color: #
|
| 18 |
-
background:
|
| 19 |
min-height: 100vh;
|
| 20 |
-
padding: 10px;
|
| 21 |
}
|
| 22 |
|
| 23 |
.header {
|
| 24 |
-
|
| 25 |
color: white;
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
}
|
| 29 |
|
| 30 |
.header h1 {
|
| 31 |
-
font-size:
|
| 32 |
-
|
| 33 |
-
|
|
|
|
| 34 |
}
|
| 35 |
|
| 36 |
-
.header
|
| 37 |
-
font-size:
|
| 38 |
opacity: 0.9;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
}
|
| 40 |
|
| 41 |
.container {
|
| 42 |
max-width: 1200px;
|
| 43 |
margin: 0 auto;
|
|
|
|
| 44 |
display: grid;
|
| 45 |
grid-template-columns: 1fr;
|
| 46 |
-
gap:
|
| 47 |
}
|
| 48 |
|
| 49 |
-
@media (min-width:
|
| 50 |
.container {
|
| 51 |
-
grid-template-columns:
|
| 52 |
}
|
| 53 |
}
|
| 54 |
|
| 55 |
.form-container {
|
| 56 |
background: white;
|
| 57 |
-
border-radius:
|
| 58 |
-
padding:
|
| 59 |
-
box-shadow: 0
|
| 60 |
-
|
| 61 |
-
overflow-y: auto;
|
| 62 |
}
|
| 63 |
|
| 64 |
-
.
|
| 65 |
background: white;
|
| 66 |
-
border-radius:
|
| 67 |
-
padding:
|
| 68 |
-
box-shadow: 0
|
|
|
|
| 69 |
height: fit-content;
|
| 70 |
}
|
| 71 |
|
| 72 |
.form-section {
|
| 73 |
-
margin-bottom:
|
| 74 |
-
|
| 75 |
-
border
|
| 76 |
-
|
|
|
|
| 77 |
}
|
| 78 |
|
| 79 |
.section-title {
|
| 80 |
-
font-size: 1.
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
align-items: center;
|
| 87 |
-
gap: 10px;
|
| 88 |
}
|
| 89 |
|
| 90 |
.form-group {
|
| 91 |
-
margin-bottom:
|
| 92 |
}
|
| 93 |
|
| 94 |
.form-row {
|
| 95 |
display: grid;
|
| 96 |
grid-template-columns: 1fr;
|
| 97 |
-
gap:
|
| 98 |
}
|
| 99 |
|
| 100 |
-
@media (min-width:
|
| 101 |
.form-row {
|
| 102 |
grid-template-columns: 1fr 1fr;
|
| 103 |
}
|
|
@@ -105,26 +136,26 @@
|
|
| 105 |
|
| 106 |
label {
|
| 107 |
display: block;
|
| 108 |
-
margin-bottom:
|
| 109 |
-
font-weight:
|
| 110 |
-
color: #
|
| 111 |
-
font-size: 0.
|
| 112 |
}
|
| 113 |
|
| 114 |
input, textarea, select {
|
| 115 |
width: 100%;
|
| 116 |
-
padding:
|
| 117 |
-
border:
|
| 118 |
-
border-radius:
|
| 119 |
-
font-size:
|
| 120 |
-
transition: all 0.
|
| 121 |
background: white;
|
| 122 |
}
|
| 123 |
|
| 124 |
input:focus, textarea:focus, select:focus {
|
| 125 |
outline: none;
|
| 126 |
-
border-color: #
|
| 127 |
-
box-shadow: 0 0 0 3px rgba(
|
| 128 |
}
|
| 129 |
|
| 130 |
textarea {
|
|
@@ -133,201 +164,215 @@
|
|
| 133 |
}
|
| 134 |
|
| 135 |
.multi-select {
|
| 136 |
-
border:
|
| 137 |
-
border-radius:
|
| 138 |
-
padding:
|
| 139 |
max-height: 120px;
|
| 140 |
overflow-y: auto;
|
|
|
|
| 141 |
}
|
| 142 |
|
| 143 |
.multi-select label {
|
| 144 |
display: flex;
|
| 145 |
align-items: center;
|
| 146 |
-
margin-bottom:
|
| 147 |
font-weight: normal;
|
| 148 |
cursor: pointer;
|
| 149 |
-
padding:
|
| 150 |
-
border-radius:
|
| 151 |
transition: background-color 0.2s;
|
| 152 |
}
|
| 153 |
|
| 154 |
.multi-select label:hover {
|
| 155 |
-
background-color: #
|
| 156 |
}
|
| 157 |
|
| 158 |
.multi-select input[type="checkbox"] {
|
| 159 |
width: auto;
|
| 160 |
-
margin-right:
|
| 161 |
}
|
| 162 |
|
| 163 |
.file-upload {
|
| 164 |
-
border: 2px dashed #
|
| 165 |
-
border-radius:
|
| 166 |
-
padding:
|
| 167 |
text-align: center;
|
| 168 |
cursor: pointer;
|
| 169 |
-
transition: all 0.
|
| 170 |
-
background: #
|
| 171 |
-
margin-top:
|
| 172 |
}
|
| 173 |
|
| 174 |
.file-upload:hover {
|
| 175 |
-
border-color: #
|
| 176 |
-
background: #
|
| 177 |
-
}
|
| 178 |
-
|
| 179 |
-
.file-upload.dragover {
|
| 180 |
-
border-color: #2c5530;
|
| 181 |
-
background: #e8f5e8;
|
| 182 |
}
|
| 183 |
|
| 184 |
.photo-category {
|
| 185 |
display: grid;
|
| 186 |
grid-template-columns: 1fr auto;
|
| 187 |
-
gap:
|
| 188 |
align-items: center;
|
| 189 |
-
margin-bottom:
|
| 190 |
-
padding:
|
| 191 |
-
border: 1px solid #
|
| 192 |
-
border-radius:
|
|
|
|
| 193 |
}
|
| 194 |
|
| 195 |
.btn {
|
| 196 |
-
padding:
|
| 197 |
border: none;
|
| 198 |
-
border-radius:
|
| 199 |
cursor: pointer;
|
| 200 |
-
font-size:
|
| 201 |
-
font-weight:
|
| 202 |
-
transition: all 0.
|
| 203 |
-
text-
|
| 204 |
-
|
|
|
|
|
|
|
|
|
|
| 205 |
}
|
| 206 |
|
| 207 |
.btn-primary {
|
| 208 |
-
background:
|
| 209 |
color: white;
|
| 210 |
-
box-shadow: 0 4px 15px rgba(44, 85, 48, 0.3);
|
| 211 |
}
|
| 212 |
|
| 213 |
.btn-primary:hover {
|
| 214 |
-
|
| 215 |
-
box-shadow: 0 6px 20px rgba(44, 85, 48, 0.4);
|
| 216 |
}
|
| 217 |
|
| 218 |
.btn-secondary {
|
| 219 |
-
background: #
|
| 220 |
color: white;
|
| 221 |
}
|
| 222 |
|
| 223 |
.btn-secondary:hover {
|
| 224 |
-
background: #
|
| 225 |
}
|
| 226 |
|
| 227 |
-
.btn-
|
| 228 |
-
|
| 229 |
-
|
|
|
|
| 230 |
}
|
| 231 |
|
| 232 |
-
.
|
| 233 |
-
background: #
|
| 234 |
color: white;
|
| 235 |
-
margin-left: 10px;
|
| 236 |
}
|
| 237 |
|
| 238 |
-
.
|
| 239 |
-
|
|
|
|
| 240 |
}
|
| 241 |
|
| 242 |
.current-location {
|
| 243 |
display: flex;
|
| 244 |
align-items: center;
|
| 245 |
-
gap:
|
| 246 |
}
|
| 247 |
|
| 248 |
.success-message, .error-message {
|
| 249 |
-
padding:
|
| 250 |
-
border-radius:
|
| 251 |
-
margin:
|
| 252 |
-
font-weight:
|
|
|
|
| 253 |
}
|
| 254 |
|
| 255 |
.success-message {
|
| 256 |
-
background: #
|
| 257 |
-
color: #
|
| 258 |
-
border: 1px solid #
|
| 259 |
}
|
| 260 |
|
| 261 |
.error-message {
|
| 262 |
-
background: #
|
| 263 |
-
color: #
|
| 264 |
-
border: 1px solid #
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 265 |
}
|
| 266 |
|
| 267 |
.tree-list {
|
| 268 |
-
max-height:
|
| 269 |
overflow-y: auto;
|
| 270 |
-
margin-top: 20px;
|
| 271 |
}
|
| 272 |
|
| 273 |
.tree-item {
|
| 274 |
-
padding:
|
| 275 |
-
border: 1px solid #
|
| 276 |
-
border-radius:
|
| 277 |
-
margin-bottom:
|
| 278 |
background: white;
|
| 279 |
-
transition: all 0.
|
| 280 |
}
|
| 281 |
|
| 282 |
.tree-item:hover {
|
| 283 |
-
box-shadow: 0 4px
|
| 284 |
-
|
| 285 |
}
|
| 286 |
|
| 287 |
.tree-id {
|
| 288 |
-
font-weight:
|
| 289 |
-
color: #
|
| 290 |
-
font-size:
|
| 291 |
}
|
| 292 |
|
| 293 |
.tree-info {
|
| 294 |
-
color: #
|
| 295 |
-
font-size: 0.
|
| 296 |
-
margin-top:
|
|
|
|
| 297 |
}
|
| 298 |
|
| 299 |
.loading {
|
| 300 |
text-align: center;
|
| 301 |
-
padding:
|
| 302 |
-
color: #
|
| 303 |
}
|
| 304 |
|
| 305 |
.audio-controls {
|
| 306 |
display: flex;
|
| 307 |
-
gap:
|
| 308 |
align-items: center;
|
| 309 |
-
margin-top:
|
| 310 |
}
|
| 311 |
|
| 312 |
.record-btn {
|
| 313 |
-
background: #
|
| 314 |
color: white;
|
| 315 |
border: none;
|
| 316 |
border-radius: 50%;
|
| 317 |
-
width:
|
| 318 |
-
height:
|
| 319 |
-
font-size:
|
| 320 |
cursor: pointer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 321 |
}
|
| 322 |
|
| 323 |
.record-btn.recording {
|
| 324 |
-
background: #
|
| 325 |
-
animation: pulse
|
| 326 |
}
|
| 327 |
|
| 328 |
@keyframes pulse {
|
| 329 |
0% { transform: scale(1); }
|
| 330 |
-
50% { transform: scale(1.
|
| 331 |
100% { transform: scale(1); }
|
| 332 |
}
|
| 333 |
|
|
@@ -337,14 +382,14 @@
|
|
| 337 |
|
| 338 |
.form-actions {
|
| 339 |
display: flex;
|
| 340 |
-
gap:
|
| 341 |
-
justify-content:
|
| 342 |
-
margin-top:
|
| 343 |
-
padding-top:
|
| 344 |
-
border-top: 1px solid #
|
| 345 |
}
|
| 346 |
|
| 347 |
-
@media (max-width:
|
| 348 |
.form-actions {
|
| 349 |
flex-direction: column;
|
| 350 |
}
|
|
@@ -354,71 +399,51 @@
|
|
| 354 |
}
|
| 355 |
}
|
| 356 |
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
left: 0;
|
| 366 |
-
right: 0;
|
| 367 |
-
background: white;
|
| 368 |
-
border: 1px solid #ccc;
|
| 369 |
-
border-radius: 0 0 8px 8px;
|
| 370 |
-
max-height: 200px;
|
| 371 |
-
overflow-y: auto;
|
| 372 |
-
z-index: 1000;
|
| 373 |
-
display: none;
|
| 374 |
-
}
|
| 375 |
-
|
| 376 |
-
.autocomplete-item {
|
| 377 |
-
padding: 10px 15px;
|
| 378 |
-
cursor: pointer;
|
| 379 |
-
border-bottom: 1px solid #eee;
|
| 380 |
-
}
|
| 381 |
-
|
| 382 |
-
.autocomplete-item:hover {
|
| 383 |
-
background: #f5f5f5;
|
| 384 |
}
|
| 385 |
|
| 386 |
-
.
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
margin-top: 10px;
|
| 392 |
-
padding: 10px;
|
| 393 |
-
background: #e8f5e8;
|
| 394 |
-
border-radius: 5px;
|
| 395 |
-
font-size: 14px;
|
| 396 |
}
|
| 397 |
</style>
|
| 398 |
</head>
|
| 399 |
<body>
|
| 400 |
<div class="header">
|
| 401 |
-
<div
|
| 402 |
<div>
|
| 403 |
-
<h1
|
| 404 |
-
<
|
| 405 |
</div>
|
| 406 |
-
<a href="/static/map.html" class="
|
| 407 |
</div>
|
| 408 |
</div>
|
| 409 |
|
| 410 |
<div class="container">
|
| 411 |
<div class="form-container">
|
|
|
|
|
|
|
|
|
|
|
|
|
| 412 |
<form id="treeForm">
|
| 413 |
<!-- Section 1: Location -->
|
| 414 |
<div class="form-section">
|
| 415 |
-
<h3 class="section-title">
|
| 416 |
<div class="form-row">
|
| 417 |
<div class="form-group">
|
| 418 |
<label for="latitude">Latitude *</label>
|
| 419 |
<div class="current-location">
|
| 420 |
<input type="number" id="latitude" step="0.0000001" min="-90" max="90" required>
|
| 421 |
-
<button type="button" id="getLocation" class="btn btn-
|
| 422 |
</div>
|
| 423 |
</div>
|
| 424 |
<div class="form-group">
|
|
@@ -427,13 +452,13 @@
|
|
| 427 |
</div>
|
| 428 |
</div>
|
| 429 |
<div class="form-group">
|
| 430 |
-
<a href="/static/map.html" class="btn btn-
|
| 431 |
</div>
|
| 432 |
</div>
|
| 433 |
|
| 434 |
<!-- Section 2: Identification -->
|
| 435 |
<div class="form-section">
|
| 436 |
-
<h3 class="section-title">
|
| 437 |
<div class="form-group">
|
| 438 |
<label for="localName">Local Name (Assamese)</label>
|
| 439 |
<input type="text" id="localName" placeholder="Enter local Assamese name">
|
|
@@ -447,21 +472,21 @@
|
|
| 447 |
<input type="text" id="commonName" placeholder="e.g., Banyan Tree">
|
| 448 |
</div>
|
| 449 |
<div class="form-group">
|
| 450 |
-
<label for="treeCode">Tree Code</label>
|
| 451 |
<input type="text" id="treeCode" placeholder="e.g., C.A, A-G1" maxlength="20">
|
| 452 |
</div>
|
| 453 |
</div>
|
| 454 |
|
| 455 |
<!-- Section 3: Measurements -->
|
| 456 |
<div class="form-section">
|
| 457 |
-
<h3 class="section-title">
|
| 458 |
<div class="form-row">
|
| 459 |
<div class="form-group">
|
| 460 |
<label for="height">Height (meters)</label>
|
| 461 |
<input type="number" id="height" step="0.1" min="0" max="200" placeholder="15.5">
|
| 462 |
</div>
|
| 463 |
<div class="form-group">
|
| 464 |
-
<label for="width">
|
| 465 |
<input type="number" id="width" step="0.1" min="0" max="2000" placeholder="45.2">
|
| 466 |
</div>
|
| 467 |
</div>
|
|
@@ -469,7 +494,7 @@
|
|
| 469 |
|
| 470 |
<!-- Section 4: Utility -->
|
| 471 |
<div class="form-section">
|
| 472 |
-
<h3 class="section-title">
|
| 473 |
<div class="form-group">
|
| 474 |
<label>Select applicable utilities:</label>
|
| 475 |
<div id="utilityOptions" class="multi-select">
|
|
@@ -480,7 +505,7 @@
|
|
| 480 |
|
| 481 |
<!-- Section 5: Phenology -->
|
| 482 |
<div class="form-section">
|
| 483 |
-
<h3 class="section-title">
|
| 484 |
<div class="form-group">
|
| 485 |
<label>Current development stages:</label>
|
| 486 |
<div id="phenologyOptions" class="multi-select">
|
|
@@ -491,7 +516,7 @@
|
|
| 491 |
|
| 492 |
<!-- Section 6: Photography -->
|
| 493 |
<div class="form-section">
|
| 494 |
-
<h3 class="section-title">
|
| 495 |
<div id="photoCategories">
|
| 496 |
<!-- Photo categories loaded dynamically -->
|
| 497 |
</div>
|
|
@@ -499,7 +524,7 @@
|
|
| 499 |
|
| 500 |
<!-- Section 7: Storytelling -->
|
| 501 |
<div class="form-section">
|
| 502 |
-
<h3 class="section-title">
|
| 503 |
<div class="form-group">
|
| 504 |
<label for="storytellingText">Stories, Histories & Narratives</label>
|
| 505 |
<textarea id="storytellingText" placeholder="Share any stories, historical context, or cultural significance..." maxlength="5000"></textarea>
|
|
@@ -507,12 +532,12 @@
|
|
| 507 |
<div class="form-group">
|
| 508 |
<label>Audio Recording</label>
|
| 509 |
<div class="audio-controls">
|
| 510 |
-
<button type="button" id="recordBtn" class="record-btn" title="Record Audio">
|
| 511 |
<span id="recordingStatus">Click to start recording</span>
|
| 512 |
<audio id="audioPlayback" controls class="hidden"></audio>
|
| 513 |
</div>
|
| 514 |
<div class="file-upload" id="audioUpload">
|
| 515 |
-
|
| 516 |
</div>
|
| 517 |
<div id="audioUploadResult"></div>
|
| 518 |
</div>
|
|
@@ -520,24 +545,24 @@
|
|
| 520 |
|
| 521 |
<!-- Section 8: Notes -->
|
| 522 |
<div class="form-section">
|
| 523 |
-
<h3 class="section-title">
|
| 524 |
<div class="form-group">
|
| 525 |
-
<label for="notes">
|
| 526 |
<textarea id="notes" placeholder="Any additional observations, notes, or remarks..." maxlength="2000"></textarea>
|
| 527 |
</div>
|
| 528 |
</div>
|
| 529 |
|
| 530 |
<div class="form-actions">
|
| 531 |
-
<button type="
|
| 532 |
-
<button type="
|
| 533 |
</div>
|
| 534 |
</form>
|
| 535 |
|
| 536 |
<div id="message"></div>
|
| 537 |
</div>
|
| 538 |
|
| 539 |
-
<div class="
|
| 540 |
-
<h3
|
| 541 |
<div id="treeList" class="tree-list">
|
| 542 |
<div class="loading">Loading trees...</div>
|
| 543 |
</div>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>TreeTrack - Field Research Tool</title>
|
| 7 |
<style>
|
| 8 |
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
| 9 |
+
|
| 10 |
* {
|
| 11 |
margin: 0;
|
| 12 |
padding: 0;
|
|
|
|
| 14 |
}
|
| 15 |
|
| 16 |
body {
|
| 17 |
+
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
| 18 |
line-height: 1.6;
|
| 19 |
+
color: #1e293b;
|
| 20 |
+
background: #f8fafc;
|
| 21 |
min-height: 100vh;
|
|
|
|
| 22 |
}
|
| 23 |
|
| 24 |
.header {
|
| 25 |
+
background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
|
| 26 |
color: white;
|
| 27 |
+
padding: 1.5rem 0;
|
| 28 |
+
margin-bottom: 2rem;
|
| 29 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
.header-content {
|
| 33 |
+
max-width: 1200px;
|
| 34 |
+
margin: 0 auto;
|
| 35 |
+
padding: 0 1rem;
|
| 36 |
+
display: flex;
|
| 37 |
+
justify-content: space-between;
|
| 38 |
+
align-items: center;
|
| 39 |
+
flex-wrap: wrap;
|
| 40 |
+
gap: 1rem;
|
| 41 |
}
|
| 42 |
|
| 43 |
.header h1 {
|
| 44 |
+
font-size: 1.875rem;
|
| 45 |
+
font-weight: 600;
|
| 46 |
+
margin: 0;
|
| 47 |
+
letter-spacing: -0.025em;
|
| 48 |
}
|
| 49 |
|
| 50 |
+
.header-subtitle {
|
| 51 |
+
font-size: 0.875rem;
|
| 52 |
opacity: 0.9;
|
| 53 |
+
margin-top: 0.25rem;
|
| 54 |
+
font-weight: 400;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
.map-link {
|
| 58 |
+
background: rgba(255, 255, 255, 0.1);
|
| 59 |
+
color: white;
|
| 60 |
+
padding: 0.5rem 1rem;
|
| 61 |
+
border-radius: 6px;
|
| 62 |
+
text-decoration: none;
|
| 63 |
+
font-weight: 500;
|
| 64 |
+
transition: background-color 0.2s;
|
| 65 |
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
.map-link:hover {
|
| 69 |
+
background: rgba(255, 255, 255, 0.2);
|
| 70 |
}
|
| 71 |
|
| 72 |
.container {
|
| 73 |
max-width: 1200px;
|
| 74 |
margin: 0 auto;
|
| 75 |
+
padding: 0 1rem 2rem;
|
| 76 |
display: grid;
|
| 77 |
grid-template-columns: 1fr;
|
| 78 |
+
gap: 2rem;
|
| 79 |
}
|
| 80 |
|
| 81 |
+
@media (min-width: 1024px) {
|
| 82 |
.container {
|
| 83 |
+
grid-template-columns: 2fr 1fr;
|
| 84 |
}
|
| 85 |
}
|
| 86 |
|
| 87 |
.form-container {
|
| 88 |
background: white;
|
| 89 |
+
border-radius: 12px;
|
| 90 |
+
padding: 2rem;
|
| 91 |
+
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
|
| 92 |
+
border: 1px solid #e2e8f0;
|
|
|
|
| 93 |
}
|
| 94 |
|
| 95 |
+
.sidebar-container {
|
| 96 |
background: white;
|
| 97 |
+
border-radius: 12px;
|
| 98 |
+
padding: 1.5rem;
|
| 99 |
+
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
|
| 100 |
+
border: 1px solid #e2e8f0;
|
| 101 |
height: fit-content;
|
| 102 |
}
|
| 103 |
|
| 104 |
.form-section {
|
| 105 |
+
margin-bottom: 2rem;
|
| 106 |
+
padding: 1.5rem;
|
| 107 |
+
border: 1px solid #e2e8f0;
|
| 108 |
+
border-radius: 8px;
|
| 109 |
+
background: #fafbfc;
|
| 110 |
}
|
| 111 |
|
| 112 |
.section-title {
|
| 113 |
+
font-size: 1.125rem;
|
| 114 |
+
font-weight: 600;
|
| 115 |
+
color: #374151;
|
| 116 |
+
margin-bottom: 1rem;
|
| 117 |
+
padding-bottom: 0.5rem;
|
| 118 |
+
border-bottom: 1px solid #e2e8f0;
|
|
|
|
|
|
|
| 119 |
}
|
| 120 |
|
| 121 |
.form-group {
|
| 122 |
+
margin-bottom: 1.5rem;
|
| 123 |
}
|
| 124 |
|
| 125 |
.form-row {
|
| 126 |
display: grid;
|
| 127 |
grid-template-columns: 1fr;
|
| 128 |
+
gap: 1rem;
|
| 129 |
}
|
| 130 |
|
| 131 |
+
@media (min-width: 640px) {
|
| 132 |
.form-row {
|
| 133 |
grid-template-columns: 1fr 1fr;
|
| 134 |
}
|
|
|
|
| 136 |
|
| 137 |
label {
|
| 138 |
display: block;
|
| 139 |
+
margin-bottom: 0.5rem;
|
| 140 |
+
font-weight: 500;
|
| 141 |
+
color: #374151;
|
| 142 |
+
font-size: 0.875rem;
|
| 143 |
}
|
| 144 |
|
| 145 |
input, textarea, select {
|
| 146 |
width: 100%;
|
| 147 |
+
padding: 0.75rem;
|
| 148 |
+
border: 1px solid #d1d5db;
|
| 149 |
+
border-radius: 6px;
|
| 150 |
+
font-size: 0.875rem;
|
| 151 |
+
transition: all 0.2s;
|
| 152 |
background: white;
|
| 153 |
}
|
| 154 |
|
| 155 |
input:focus, textarea:focus, select:focus {
|
| 156 |
outline: none;
|
| 157 |
+
border-color: #3b82f6;
|
| 158 |
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
| 159 |
}
|
| 160 |
|
| 161 |
textarea {
|
|
|
|
| 164 |
}
|
| 165 |
|
| 166 |
.multi-select {
|
| 167 |
+
border: 1px solid #d1d5db;
|
| 168 |
+
border-radius: 6px;
|
| 169 |
+
padding: 0.75rem;
|
| 170 |
max-height: 120px;
|
| 171 |
overflow-y: auto;
|
| 172 |
+
background: white;
|
| 173 |
}
|
| 174 |
|
| 175 |
.multi-select label {
|
| 176 |
display: flex;
|
| 177 |
align-items: center;
|
| 178 |
+
margin-bottom: 0.5rem;
|
| 179 |
font-weight: normal;
|
| 180 |
cursor: pointer;
|
| 181 |
+
padding: 0.25rem;
|
| 182 |
+
border-radius: 4px;
|
| 183 |
transition: background-color 0.2s;
|
| 184 |
}
|
| 185 |
|
| 186 |
.multi-select label:hover {
|
| 187 |
+
background-color: #f3f4f6;
|
| 188 |
}
|
| 189 |
|
| 190 |
.multi-select input[type="checkbox"] {
|
| 191 |
width: auto;
|
| 192 |
+
margin-right: 0.5rem;
|
| 193 |
}
|
| 194 |
|
| 195 |
.file-upload {
|
| 196 |
+
border: 2px dashed #d1d5db;
|
| 197 |
+
border-radius: 6px;
|
| 198 |
+
padding: 1.5rem;
|
| 199 |
text-align: center;
|
| 200 |
cursor: pointer;
|
| 201 |
+
transition: all 0.2s;
|
| 202 |
+
background: #f9fafb;
|
| 203 |
+
margin-top: 0.5rem;
|
| 204 |
}
|
| 205 |
|
| 206 |
.file-upload:hover {
|
| 207 |
+
border-color: #3b82f6;
|
| 208 |
+
background: #f0f9ff;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
}
|
| 210 |
|
| 211 |
.photo-category {
|
| 212 |
display: grid;
|
| 213 |
grid-template-columns: 1fr auto;
|
| 214 |
+
gap: 0.75rem;
|
| 215 |
align-items: center;
|
| 216 |
+
margin-bottom: 1rem;
|
| 217 |
+
padding: 1rem;
|
| 218 |
+
border: 1px solid #e2e8f0;
|
| 219 |
+
border-radius: 6px;
|
| 220 |
+
background: white;
|
| 221 |
}
|
| 222 |
|
| 223 |
.btn {
|
| 224 |
+
padding: 0.75rem 1.5rem;
|
| 225 |
border: none;
|
| 226 |
+
border-radius: 6px;
|
| 227 |
cursor: pointer;
|
| 228 |
+
font-size: 0.875rem;
|
| 229 |
+
font-weight: 500;
|
| 230 |
+
transition: all 0.2s;
|
| 231 |
+
text-decoration: none;
|
| 232 |
+
display: inline-flex;
|
| 233 |
+
align-items: center;
|
| 234 |
+
justify-content: center;
|
| 235 |
+
gap: 0.5rem;
|
| 236 |
}
|
| 237 |
|
| 238 |
.btn-primary {
|
| 239 |
+
background: #3b82f6;
|
| 240 |
color: white;
|
|
|
|
| 241 |
}
|
| 242 |
|
| 243 |
.btn-primary:hover {
|
| 244 |
+
background: #2563eb;
|
|
|
|
| 245 |
}
|
| 246 |
|
| 247 |
.btn-secondary {
|
| 248 |
+
background: #6b7280;
|
| 249 |
color: white;
|
| 250 |
}
|
| 251 |
|
| 252 |
.btn-secondary:hover {
|
| 253 |
+
background: #4b5563;
|
| 254 |
}
|
| 255 |
|
| 256 |
+
.btn-outline {
|
| 257 |
+
background: transparent;
|
| 258 |
+
color: #3b82f6;
|
| 259 |
+
border: 1px solid #3b82f6;
|
| 260 |
}
|
| 261 |
|
| 262 |
+
.btn-outline:hover {
|
| 263 |
+
background: #3b82f6;
|
| 264 |
color: white;
|
|
|
|
| 265 |
}
|
| 266 |
|
| 267 |
+
.btn-small {
|
| 268 |
+
padding: 0.5rem 1rem;
|
| 269 |
+
font-size: 0.75rem;
|
| 270 |
}
|
| 271 |
|
| 272 |
.current-location {
|
| 273 |
display: flex;
|
| 274 |
align-items: center;
|
| 275 |
+
gap: 0.5rem;
|
| 276 |
}
|
| 277 |
|
| 278 |
.success-message, .error-message {
|
| 279 |
+
padding: 0.75rem 1rem;
|
| 280 |
+
border-radius: 6px;
|
| 281 |
+
margin: 1rem 0;
|
| 282 |
+
font-weight: 500;
|
| 283 |
+
font-size: 0.875rem;
|
| 284 |
}
|
| 285 |
|
| 286 |
.success-message {
|
| 287 |
+
background: #dcfce7;
|
| 288 |
+
color: #166534;
|
| 289 |
+
border: 1px solid #bbf7d0;
|
| 290 |
}
|
| 291 |
|
| 292 |
.error-message {
|
| 293 |
+
background: #fee2e2;
|
| 294 |
+
color: #991b1b;
|
| 295 |
+
border: 1px solid #fecaca;
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
.sidebar-title {
|
| 299 |
+
font-size: 1.125rem;
|
| 300 |
+
font-weight: 600;
|
| 301 |
+
color: #374151;
|
| 302 |
+
margin-bottom: 1rem;
|
| 303 |
+
padding-bottom: 0.5rem;
|
| 304 |
+
border-bottom: 1px solid #e2e8f0;
|
| 305 |
}
|
| 306 |
|
| 307 |
.tree-list {
|
| 308 |
+
max-height: 60vh;
|
| 309 |
overflow-y: auto;
|
|
|
|
| 310 |
}
|
| 311 |
|
| 312 |
.tree-item {
|
| 313 |
+
padding: 1rem;
|
| 314 |
+
border: 1px solid #e2e8f0;
|
| 315 |
+
border-radius: 6px;
|
| 316 |
+
margin-bottom: 0.75rem;
|
| 317 |
background: white;
|
| 318 |
+
transition: all 0.2s;
|
| 319 |
}
|
| 320 |
|
| 321 |
.tree-item:hover {
|
| 322 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
| 323 |
+
border-color: #3b82f6;
|
| 324 |
}
|
| 325 |
|
| 326 |
.tree-id {
|
| 327 |
+
font-weight: 600;
|
| 328 |
+
color: #1e40af;
|
| 329 |
+
font-size: 0.875rem;
|
| 330 |
}
|
| 331 |
|
| 332 |
.tree-info {
|
| 333 |
+
color: #6b7280;
|
| 334 |
+
font-size: 0.75rem;
|
| 335 |
+
margin-top: 0.25rem;
|
| 336 |
+
line-height: 1.4;
|
| 337 |
}
|
| 338 |
|
| 339 |
.loading {
|
| 340 |
text-align: center;
|
| 341 |
+
padding: 2rem;
|
| 342 |
+
color: #6b7280;
|
| 343 |
}
|
| 344 |
|
| 345 |
.audio-controls {
|
| 346 |
display: flex;
|
| 347 |
+
gap: 0.75rem;
|
| 348 |
align-items: center;
|
| 349 |
+
margin-top: 0.75rem;
|
| 350 |
}
|
| 351 |
|
| 352 |
.record-btn {
|
| 353 |
+
background: #ef4444;
|
| 354 |
color: white;
|
| 355 |
border: none;
|
| 356 |
border-radius: 50%;
|
| 357 |
+
width: 3rem;
|
| 358 |
+
height: 3rem;
|
| 359 |
+
font-size: 1.125rem;
|
| 360 |
cursor: pointer;
|
| 361 |
+
transition: all 0.2s;
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
.record-btn:hover {
|
| 365 |
+
background: #dc2626;
|
| 366 |
}
|
| 367 |
|
| 368 |
.record-btn.recording {
|
| 369 |
+
background: #10b981;
|
| 370 |
+
animation: pulse 1.5s infinite;
|
| 371 |
}
|
| 372 |
|
| 373 |
@keyframes pulse {
|
| 374 |
0% { transform: scale(1); }
|
| 375 |
+
50% { transform: scale(1.05); }
|
| 376 |
100% { transform: scale(1); }
|
| 377 |
}
|
| 378 |
|
|
|
|
| 382 |
|
| 383 |
.form-actions {
|
| 384 |
display: flex;
|
| 385 |
+
gap: 1rem;
|
| 386 |
+
justify-content: flex-end;
|
| 387 |
+
margin-top: 2rem;
|
| 388 |
+
padding-top: 1.5rem;
|
| 389 |
+
border-top: 1px solid #e2e8f0;
|
| 390 |
}
|
| 391 |
|
| 392 |
+
@media (max-width: 640px) {
|
| 393 |
.form-actions {
|
| 394 |
flex-direction: column;
|
| 395 |
}
|
|
|
|
| 399 |
}
|
| 400 |
}
|
| 401 |
|
| 402 |
+
.uploaded-file {
|
| 403 |
+
margin-top: 0.5rem;
|
| 404 |
+
padding: 0.5rem 0.75rem;
|
| 405 |
+
background: #f0fdf4;
|
| 406 |
+
border: 1px solid #bbf7d0;
|
| 407 |
+
border-radius: 4px;
|
| 408 |
+
font-size: 0.75rem;
|
| 409 |
+
color: #166534;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 410 |
}
|
| 411 |
|
| 412 |
+
.form-description {
|
| 413 |
+
color: #6b7280;
|
| 414 |
+
font-size: 0.875rem;
|
| 415 |
+
margin-bottom: 2rem;
|
| 416 |
+
line-height: 1.5;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 417 |
}
|
| 418 |
</style>
|
| 419 |
</head>
|
| 420 |
<body>
|
| 421 |
<div class="header">
|
| 422 |
+
<div class="header-content">
|
| 423 |
<div>
|
| 424 |
+
<h1>TreeTrack</h1>
|
| 425 |
+
<div class="header-subtitle">Professional Field Research & Documentation</div>
|
| 426 |
</div>
|
| 427 |
+
<a href="/static/map.html" class="map-link">View Map</a>
|
| 428 |
</div>
|
| 429 |
</div>
|
| 430 |
|
| 431 |
<div class="container">
|
| 432 |
<div class="form-container">
|
| 433 |
+
<div class="form-description">
|
| 434 |
+
Complete the form below to document tree specimens in the field. All fields marked with * are required.
|
| 435 |
+
</div>
|
| 436 |
+
|
| 437 |
<form id="treeForm">
|
| 438 |
<!-- Section 1: Location -->
|
| 439 |
<div class="form-section">
|
| 440 |
+
<h3 class="section-title">Geographic Location</h3>
|
| 441 |
<div class="form-row">
|
| 442 |
<div class="form-group">
|
| 443 |
<label for="latitude">Latitude *</label>
|
| 444 |
<div class="current-location">
|
| 445 |
<input type="number" id="latitude" step="0.0000001" min="-90" max="90" required>
|
| 446 |
+
<button type="button" id="getLocation" class="btn btn-outline btn-small">Get GPS</button>
|
| 447 |
</div>
|
| 448 |
</div>
|
| 449 |
<div class="form-group">
|
|
|
|
| 452 |
</div>
|
| 453 |
</div>
|
| 454 |
<div class="form-group">
|
| 455 |
+
<a href="/static/map.html" class="btn btn-outline" style="width: 100%; text-align: center;">Select from Interactive Map</a>
|
| 456 |
</div>
|
| 457 |
</div>
|
| 458 |
|
| 459 |
<!-- Section 2: Identification -->
|
| 460 |
<div class="form-section">
|
| 461 |
+
<h3 class="section-title">Tree Identification</h3>
|
| 462 |
<div class="form-group">
|
| 463 |
<label for="localName">Local Name (Assamese)</label>
|
| 464 |
<input type="text" id="localName" placeholder="Enter local Assamese name">
|
|
|
|
| 472 |
<input type="text" id="commonName" placeholder="e.g., Banyan Tree">
|
| 473 |
</div>
|
| 474 |
<div class="form-group">
|
| 475 |
+
<label for="treeCode">Tree Reference Code</label>
|
| 476 |
<input type="text" id="treeCode" placeholder="e.g., C.A, A-G1" maxlength="20">
|
| 477 |
</div>
|
| 478 |
</div>
|
| 479 |
|
| 480 |
<!-- Section 3: Measurements -->
|
| 481 |
<div class="form-section">
|
| 482 |
+
<h3 class="section-title">Physical Measurements</h3>
|
| 483 |
<div class="form-row">
|
| 484 |
<div class="form-group">
|
| 485 |
<label for="height">Height (meters)</label>
|
| 486 |
<input type="number" id="height" step="0.1" min="0" max="200" placeholder="15.5">
|
| 487 |
</div>
|
| 488 |
<div class="form-group">
|
| 489 |
+
<label for="width">Girth/DBH (cm)</label>
|
| 490 |
<input type="number" id="width" step="0.1" min="0" max="2000" placeholder="45.2">
|
| 491 |
</div>
|
| 492 |
</div>
|
|
|
|
| 494 |
|
| 495 |
<!-- Section 4: Utility -->
|
| 496 |
<div class="form-section">
|
| 497 |
+
<h3 class="section-title">Ecological & Cultural Utility</h3>
|
| 498 |
<div class="form-group">
|
| 499 |
<label>Select applicable utilities:</label>
|
| 500 |
<div id="utilityOptions" class="multi-select">
|
|
|
|
| 505 |
|
| 506 |
<!-- Section 5: Phenology -->
|
| 507 |
<div class="form-section">
|
| 508 |
+
<h3 class="section-title">Phenology Assessment</h3>
|
| 509 |
<div class="form-group">
|
| 510 |
<label>Current development stages:</label>
|
| 511 |
<div id="phenologyOptions" class="multi-select">
|
|
|
|
| 516 |
|
| 517 |
<!-- Section 6: Photography -->
|
| 518 |
<div class="form-section">
|
| 519 |
+
<h3 class="section-title">Photographic Documentation</h3>
|
| 520 |
<div id="photoCategories">
|
| 521 |
<!-- Photo categories loaded dynamically -->
|
| 522 |
</div>
|
|
|
|
| 524 |
|
| 525 |
<!-- Section 7: Storytelling -->
|
| 526 |
<div class="form-section">
|
| 527 |
+
<h3 class="section-title">Cultural Documentation</h3>
|
| 528 |
<div class="form-group">
|
| 529 |
<label for="storytellingText">Stories, Histories & Narratives</label>
|
| 530 |
<textarea id="storytellingText" placeholder="Share any stories, historical context, or cultural significance..." maxlength="5000"></textarea>
|
|
|
|
| 532 |
<div class="form-group">
|
| 533 |
<label>Audio Recording</label>
|
| 534 |
<div class="audio-controls">
|
| 535 |
+
<button type="button" id="recordBtn" class="record-btn" title="Record Audio">β</button>
|
| 536 |
<span id="recordingStatus">Click to start recording</span>
|
| 537 |
<audio id="audioPlayback" controls class="hidden"></audio>
|
| 538 |
</div>
|
| 539 |
<div class="file-upload" id="audioUpload">
|
| 540 |
+
Click to upload audio file or drag and drop
|
| 541 |
</div>
|
| 542 |
<div id="audioUploadResult"></div>
|
| 543 |
</div>
|
|
|
|
| 545 |
|
| 546 |
<!-- Section 8: Notes -->
|
| 547 |
<div class="form-section">
|
| 548 |
+
<h3 class="section-title">Field Notes</h3>
|
| 549 |
<div class="form-group">
|
| 550 |
+
<label for="notes">Additional Observations</label>
|
| 551 |
<textarea id="notes" placeholder="Any additional observations, notes, or remarks..." maxlength="2000"></textarea>
|
| 552 |
</div>
|
| 553 |
</div>
|
| 554 |
|
| 555 |
<div class="form-actions">
|
| 556 |
+
<button type="button" id="resetForm" class="btn btn-secondary">Reset Form</button>
|
| 557 |
+
<button type="submit" class="btn btn-primary">Save Tree Record</button>
|
| 558 |
</div>
|
| 559 |
</form>
|
| 560 |
|
| 561 |
<div id="message"></div>
|
| 562 |
</div>
|
| 563 |
|
| 564 |
+
<div class="sidebar-container">
|
| 565 |
+
<h3 class="sidebar-title">Recent Trees</h3>
|
| 566 |
<div id="treeList" class="tree-list">
|
| 567 |
<div class="loading">Loading trees...</div>
|
| 568 |
</div>
|
static/index_old.html
ADDED
|
@@ -0,0 +1,568 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>TreeTrack - Field Research Tool</title>
|
| 7 |
+
<style>
|
| 8 |
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
| 9 |
+
|
| 10 |
+
* {
|
| 11 |
+
margin: 0;
|
| 12 |
+
padding: 0;
|
| 13 |
+
box-sizing: border-box;
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
body {
|
| 17 |
+
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
| 18 |
+
line-height: 1.6;
|
| 19 |
+
color: #1e293b;
|
| 20 |
+
background: #f8fafc;
|
| 21 |
+
min-height: 100vh;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
.header {
|
| 25 |
+
background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
|
| 26 |
+
color: white;
|
| 27 |
+
padding: 1.5rem 0;
|
| 28 |
+
margin-bottom: 2rem;
|
| 29 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
.header-content {
|
| 33 |
+
max-width: 1200px;
|
| 34 |
+
margin: 0 auto;
|
| 35 |
+
padding: 0 1rem;
|
| 36 |
+
display: flex;
|
| 37 |
+
justify-content: space-between;
|
| 38 |
+
align-items: center;
|
| 39 |
+
flex-wrap: wrap;
|
| 40 |
+
gap: 1rem;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
.header h1 {
|
| 44 |
+
font-size: 1.875rem;
|
| 45 |
+
font-weight: 600;
|
| 46 |
+
margin: 0;
|
| 47 |
+
letter-spacing: -0.025em;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
.header-subtitle {
|
| 51 |
+
font-size: 0.875rem;
|
| 52 |
+
opacity: 0.9;
|
| 53 |
+
margin-top: 0.25rem;
|
| 54 |
+
font-weight: 400;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
.container {
|
| 58 |
+
max-width: 1200px;
|
| 59 |
+
margin: 0 auto;
|
| 60 |
+
padding: 0 1rem 2rem;
|
| 61 |
+
display: grid;
|
| 62 |
+
grid-template-columns: 1fr;
|
| 63 |
+
gap: 2rem;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
@media (min-width: 1024px) {
|
| 67 |
+
.container {
|
| 68 |
+
grid-template-columns: 2fr 1fr;
|
| 69 |
+
}
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
.form-container {
|
| 73 |
+
background: white;
|
| 74 |
+
border-radius: 12px;
|
| 75 |
+
padding: 2rem;
|
| 76 |
+
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
|
| 77 |
+
border: 1px solid #e2e8f0;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
.sidebar-container {
|
| 81 |
+
background: white;
|
| 82 |
+
border-radius: 12px;
|
| 83 |
+
padding: 1.5rem;
|
| 84 |
+
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
|
| 85 |
+
border: 1px solid #e2e8f0;
|
| 86 |
+
height: fit-content;
|
| 87 |
+
max-height: 70vh;
|
| 88 |
+
overflow-y: auto;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
.form-section {
|
| 92 |
+
margin-bottom: 30px;
|
| 93 |
+
border: 1px solid #e0e0e0;
|
| 94 |
+
border-radius: 10px;
|
| 95 |
+
padding: 20px;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
.section-title {
|
| 99 |
+
font-size: 1.3rem;
|
| 100 |
+
color: #2c5530;
|
| 101 |
+
margin-bottom: 15px;
|
| 102 |
+
padding-bottom: 8px;
|
| 103 |
+
border-bottom: 2px solid #e8f5e8;
|
| 104 |
+
display: flex;
|
| 105 |
+
align-items: center;
|
| 106 |
+
gap: 10px;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
.form-group {
|
| 110 |
+
margin-bottom: 20px;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
.form-row {
|
| 114 |
+
display: grid;
|
| 115 |
+
grid-template-columns: 1fr;
|
| 116 |
+
gap: 15px;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
@media (min-width: 600px) {
|
| 120 |
+
.form-row {
|
| 121 |
+
grid-template-columns: 1fr 1fr;
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
label {
|
| 126 |
+
display: block;
|
| 127 |
+
margin-bottom: 5px;
|
| 128 |
+
font-weight: 600;
|
| 129 |
+
color: #2c5530;
|
| 130 |
+
font-size: 0.95rem;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
input, textarea, select {
|
| 134 |
+
width: 100%;
|
| 135 |
+
padding: 12px 15px;
|
| 136 |
+
border: 2px solid #e0e0e0;
|
| 137 |
+
border-radius: 8px;
|
| 138 |
+
font-size: 16px;
|
| 139 |
+
transition: all 0.3s ease;
|
| 140 |
+
background: white;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
input:focus, textarea:focus, select:focus {
|
| 144 |
+
outline: none;
|
| 145 |
+
border-color: #2c5530;
|
| 146 |
+
box-shadow: 0 0 0 3px rgba(44, 85, 48, 0.1);
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
textarea {
|
| 150 |
+
resize: vertical;
|
| 151 |
+
min-height: 100px;
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
.multi-select {
|
| 155 |
+
border: 2px solid #e0e0e0;
|
| 156 |
+
border-radius: 8px;
|
| 157 |
+
padding: 10px;
|
| 158 |
+
max-height: 120px;
|
| 159 |
+
overflow-y: auto;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
.multi-select label {
|
| 163 |
+
display: flex;
|
| 164 |
+
align-items: center;
|
| 165 |
+
margin-bottom: 8px;
|
| 166 |
+
font-weight: normal;
|
| 167 |
+
cursor: pointer;
|
| 168 |
+
padding: 5px;
|
| 169 |
+
border-radius: 5px;
|
| 170 |
+
transition: background-color 0.2s;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
.multi-select label:hover {
|
| 174 |
+
background-color: #f5f5f5;
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
.multi-select input[type="checkbox"] {
|
| 178 |
+
width: auto;
|
| 179 |
+
margin-right: 10px;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
.file-upload {
|
| 183 |
+
border: 2px dashed #ccc;
|
| 184 |
+
border-radius: 8px;
|
| 185 |
+
padding: 20px;
|
| 186 |
+
text-align: center;
|
| 187 |
+
cursor: pointer;
|
| 188 |
+
transition: all 0.3s ease;
|
| 189 |
+
background: #fafafa;
|
| 190 |
+
margin-top: 10px;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
.file-upload:hover {
|
| 194 |
+
border-color: #2c5530;
|
| 195 |
+
background: #f0f7f0;
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
.file-upload.dragover {
|
| 199 |
+
border-color: #2c5530;
|
| 200 |
+
background: #e8f5e8;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
.photo-category {
|
| 204 |
+
display: grid;
|
| 205 |
+
grid-template-columns: 1fr auto;
|
| 206 |
+
gap: 10px;
|
| 207 |
+
align-items: center;
|
| 208 |
+
margin-bottom: 15px;
|
| 209 |
+
padding: 10px;
|
| 210 |
+
border: 1px solid #e0e0e0;
|
| 211 |
+
border-radius: 8px;
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
.btn {
|
| 215 |
+
padding: 12px 25px;
|
| 216 |
+
border: none;
|
| 217 |
+
border-radius: 8px;
|
| 218 |
+
cursor: pointer;
|
| 219 |
+
font-size: 16px;
|
| 220 |
+
font-weight: 600;
|
| 221 |
+
transition: all 0.3s ease;
|
| 222 |
+
text-transform: uppercase;
|
| 223 |
+
letter-spacing: 0.5px;
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
.btn-primary {
|
| 227 |
+
background: linear-gradient(45deg, #2c5530, #4a7c59);
|
| 228 |
+
color: white;
|
| 229 |
+
box-shadow: 0 4px 15px rgba(44, 85, 48, 0.3);
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
.btn-primary:hover {
|
| 233 |
+
transform: translateY(-2px);
|
| 234 |
+
box-shadow: 0 6px 20px rgba(44, 85, 48, 0.4);
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
.btn-secondary {
|
| 238 |
+
background: #6c757d;
|
| 239 |
+
color: white;
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
.btn-secondary:hover {
|
| 243 |
+
background: #545b62;
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
.btn-small {
|
| 247 |
+
padding: 8px 15px;
|
| 248 |
+
font-size: 14px;
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
.gps-btn {
|
| 252 |
+
background: #17a2b8;
|
| 253 |
+
color: white;
|
| 254 |
+
margin-left: 10px;
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
.gps-btn:hover {
|
| 258 |
+
background: #138496;
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
.current-location {
|
| 262 |
+
display: flex;
|
| 263 |
+
align-items: center;
|
| 264 |
+
gap: 10px;
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
.success-message, .error-message {
|
| 268 |
+
padding: 15px;
|
| 269 |
+
border-radius: 8px;
|
| 270 |
+
margin: 15px 0;
|
| 271 |
+
font-weight: 600;
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
.success-message {
|
| 275 |
+
background: #d4edda;
|
| 276 |
+
color: #155724;
|
| 277 |
+
border: 1px solid #c3e6cb;
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
.error-message {
|
| 281 |
+
background: #f8d7da;
|
| 282 |
+
color: #721c24;
|
| 283 |
+
border: 1px solid #f5c6cb;
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
.tree-list {
|
| 287 |
+
max-height: 400px;
|
| 288 |
+
overflow-y: auto;
|
| 289 |
+
margin-top: 20px;
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
.tree-item {
|
| 293 |
+
padding: 15px;
|
| 294 |
+
border: 1px solid #e0e0e0;
|
| 295 |
+
border-radius: 8px;
|
| 296 |
+
margin-bottom: 10px;
|
| 297 |
+
background: white;
|
| 298 |
+
transition: all 0.3s ease;
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
.tree-item:hover {
|
| 302 |
+
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
|
| 303 |
+
transform: translateY(-2px);
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
.tree-id {
|
| 307 |
+
font-weight: bold;
|
| 308 |
+
color: #2c5530;
|
| 309 |
+
font-size: 1.1rem;
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
.tree-info {
|
| 313 |
+
color: #666;
|
| 314 |
+
font-size: 0.9rem;
|
| 315 |
+
margin-top: 5px;
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
.loading {
|
| 319 |
+
text-align: center;
|
| 320 |
+
padding: 20px;
|
| 321 |
+
color: #666;
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
.audio-controls {
|
| 325 |
+
display: flex;
|
| 326 |
+
gap: 10px;
|
| 327 |
+
align-items: center;
|
| 328 |
+
margin-top: 10px;
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
.record-btn {
|
| 332 |
+
background: #dc3545;
|
| 333 |
+
color: white;
|
| 334 |
+
border: none;
|
| 335 |
+
border-radius: 50%;
|
| 336 |
+
width: 50px;
|
| 337 |
+
height: 50px;
|
| 338 |
+
font-size: 18px;
|
| 339 |
+
cursor: pointer;
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
.record-btn.recording {
|
| 343 |
+
background: #28a745;
|
| 344 |
+
animation: pulse 1s infinite;
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
@keyframes pulse {
|
| 348 |
+
0% { transform: scale(1); }
|
| 349 |
+
50% { transform: scale(1.1); }
|
| 350 |
+
100% { transform: scale(1); }
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
.hidden {
|
| 354 |
+
display: none;
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
.form-actions {
|
| 358 |
+
display: flex;
|
| 359 |
+
gap: 15px;
|
| 360 |
+
justify-content: center;
|
| 361 |
+
margin-top: 30px;
|
| 362 |
+
padding-top: 20px;
|
| 363 |
+
border-top: 1px solid #e0e0e0;
|
| 364 |
+
}
|
| 365 |
+
|
| 366 |
+
@media (max-width: 600px) {
|
| 367 |
+
.form-actions {
|
| 368 |
+
flex-direction: column;
|
| 369 |
+
}
|
| 370 |
+
|
| 371 |
+
.btn {
|
| 372 |
+
width: 100%;
|
| 373 |
+
}
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
/* Auto-complete styling */
|
| 377 |
+
.autocomplete-container {
|
| 378 |
+
position: relative;
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
.autocomplete-list {
|
| 382 |
+
position: absolute;
|
| 383 |
+
top: 100%;
|
| 384 |
+
left: 0;
|
| 385 |
+
right: 0;
|
| 386 |
+
background: white;
|
| 387 |
+
border: 1px solid #ccc;
|
| 388 |
+
border-radius: 0 0 8px 8px;
|
| 389 |
+
max-height: 200px;
|
| 390 |
+
overflow-y: auto;
|
| 391 |
+
z-index: 1000;
|
| 392 |
+
display: none;
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
.autocomplete-item {
|
| 396 |
+
padding: 10px 15px;
|
| 397 |
+
cursor: pointer;
|
| 398 |
+
border-bottom: 1px solid #eee;
|
| 399 |
+
}
|
| 400 |
+
|
| 401 |
+
.autocomplete-item:hover {
|
| 402 |
+
background: #f5f5f5;
|
| 403 |
+
}
|
| 404 |
+
|
| 405 |
+
.autocomplete-item.selected {
|
| 406 |
+
background: #e8f5e8;
|
| 407 |
+
}
|
| 408 |
+
|
| 409 |
+
.uploaded-file {
|
| 410 |
+
margin-top: 10px;
|
| 411 |
+
padding: 10px;
|
| 412 |
+
background: #e8f5e8;
|
| 413 |
+
border-radius: 5px;
|
| 414 |
+
font-size: 14px;
|
| 415 |
+
}
|
| 416 |
+
</style>
|
| 417 |
+
</head>
|
| 418 |
+
<body>
|
| 419 |
+
<div class="header">
|
| 420 |
+
<div style="display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px;">
|
| 421 |
+
<div>
|
| 422 |
+
<h1 style="margin: 0; font-size: 2rem;">π³ TreeTrack</h1>
|
| 423 |
+
<p style="margin: 5px 0 0 0; font-size: 1rem;">Field Research Tool</p>
|
| 424 |
+
</div>
|
| 425 |
+
<a href="/static/map.html" class="btn" style="background: rgba(255,255,255,0.2); color: white; text-decoration: none;">πΊοΈ Map View</a>
|
| 426 |
+
</div>
|
| 427 |
+
</div>
|
| 428 |
+
|
| 429 |
+
<div class="container">
|
| 430 |
+
<div class="form-container">
|
| 431 |
+
<form id="treeForm">
|
| 432 |
+
<!-- Section 1: Location -->
|
| 433 |
+
<div class="form-section">
|
| 434 |
+
<h3 class="section-title">π Location</h3>
|
| 435 |
+
<div class="form-row">
|
| 436 |
+
<div class="form-group">
|
| 437 |
+
<label for="latitude">Latitude *</label>
|
| 438 |
+
<div class="current-location">
|
| 439 |
+
<input type="number" id="latitude" step="0.0000001" min="-90" max="90" required>
|
| 440 |
+
<button type="button" id="getLocation" class="btn btn-small gps-btn">π GPS</button>
|
| 441 |
+
</div>
|
| 442 |
+
</div>
|
| 443 |
+
<div class="form-group">
|
| 444 |
+
<label for="longitude">Longitude *</label>
|
| 445 |
+
<input type="number" id="longitude" step="0.0000001" min="-180" max="180" required>
|
| 446 |
+
</div>
|
| 447 |
+
</div>
|
| 448 |
+
<div class="form-group">
|
| 449 |
+
<a href="/static/map.html" class="btn btn-secondary" style="width: 100%; text-align: center; display: block; text-decoration: none;">πΊοΈ Select from Interactive Map</a>
|
| 450 |
+
</div>
|
| 451 |
+
</div>
|
| 452 |
+
|
| 453 |
+
<!-- Section 2: Identification -->
|
| 454 |
+
<div class="form-section">
|
| 455 |
+
<h3 class="section-title">π·οΈ Tree Identification</h3>
|
| 456 |
+
<div class="form-group">
|
| 457 |
+
<label for="localName">Local Name (Assamese)</label>
|
| 458 |
+
<input type="text" id="localName" placeholder="Enter local Assamese name">
|
| 459 |
+
</div>
|
| 460 |
+
<div class="form-group">
|
| 461 |
+
<label for="scientificName">Scientific Name</label>
|
| 462 |
+
<input type="text" id="scientificName" placeholder="e.g., Ficus benghalensis">
|
| 463 |
+
</div>
|
| 464 |
+
<div class="form-group">
|
| 465 |
+
<label for="commonName">Common Name</label>
|
| 466 |
+
<input type="text" id="commonName" placeholder="e.g., Banyan Tree">
|
| 467 |
+
</div>
|
| 468 |
+
<div class="form-group">
|
| 469 |
+
<label for="treeCode">Tree Code</label>
|
| 470 |
+
<input type="text" id="treeCode" placeholder="e.g., C.A, A-G1" maxlength="20">
|
| 471 |
+
</div>
|
| 472 |
+
</div>
|
| 473 |
+
|
| 474 |
+
<!-- Section 3: Measurements -->
|
| 475 |
+
<div class="form-section">
|
| 476 |
+
<h3 class="section-title">π Physical Measurements</h3>
|
| 477 |
+
<div class="form-row">
|
| 478 |
+
<div class="form-group">
|
| 479 |
+
<label for="height">Height (meters)</label>
|
| 480 |
+
<input type="number" id="height" step="0.1" min="0" max="200" placeholder="15.5">
|
| 481 |
+
</div>
|
| 482 |
+
<div class="form-group">
|
| 483 |
+
<label for="width">Width/Girth (cm)</label>
|
| 484 |
+
<input type="number" id="width" step="0.1" min="0" max="2000" placeholder="45.2">
|
| 485 |
+
</div>
|
| 486 |
+
</div>
|
| 487 |
+
</div>
|
| 488 |
+
|
| 489 |
+
<!-- Section 4: Utility -->
|
| 490 |
+
<div class="form-section">
|
| 491 |
+
<h3 class="section-title">π Ecological & Cultural Utility</h3>
|
| 492 |
+
<div class="form-group">
|
| 493 |
+
<label>Select applicable utilities:</label>
|
| 494 |
+
<div id="utilityOptions" class="multi-select">
|
| 495 |
+
<!-- Options loaded dynamically -->
|
| 496 |
+
</div>
|
| 497 |
+
</div>
|
| 498 |
+
</div>
|
| 499 |
+
|
| 500 |
+
<!-- Section 5: Phenology -->
|
| 501 |
+
<div class="form-section">
|
| 502 |
+
<h3 class="section-title">π± Phenology Tracker</h3>
|
| 503 |
+
<div class="form-group">
|
| 504 |
+
<label>Current development stages:</label>
|
| 505 |
+
<div id="phenologyOptions" class="multi-select">
|
| 506 |
+
<!-- Options loaded dynamically -->
|
| 507 |
+
</div>
|
| 508 |
+
</div>
|
| 509 |
+
</div>
|
| 510 |
+
|
| 511 |
+
<!-- Section 6: Photography -->
|
| 512 |
+
<div class="form-section">
|
| 513 |
+
<h3 class="section-title">πΈ Photography</h3>
|
| 514 |
+
<div id="photoCategories">
|
| 515 |
+
<!-- Photo categories loaded dynamically -->
|
| 516 |
+
</div>
|
| 517 |
+
</div>
|
| 518 |
+
|
| 519 |
+
<!-- Section 7: Storytelling -->
|
| 520 |
+
<div class="form-section">
|
| 521 |
+
<h3 class="section-title">π Storytelling</h3>
|
| 522 |
+
<div class="form-group">
|
| 523 |
+
<label for="storytellingText">Stories, Histories & Narratives</label>
|
| 524 |
+
<textarea id="storytellingText" placeholder="Share any stories, historical context, or cultural significance..." maxlength="5000"></textarea>
|
| 525 |
+
</div>
|
| 526 |
+
<div class="form-group">
|
| 527 |
+
<label>Audio Recording</label>
|
| 528 |
+
<div class="audio-controls">
|
| 529 |
+
<button type="button" id="recordBtn" class="record-btn" title="Record Audio">π€</button>
|
| 530 |
+
<span id="recordingStatus">Click to start recording</span>
|
| 531 |
+
<audio id="audioPlayback" controls class="hidden"></audio>
|
| 532 |
+
</div>
|
| 533 |
+
<div class="file-upload" id="audioUpload">
|
| 534 |
+
π Click to upload audio file or drag and drop
|
| 535 |
+
</div>
|
| 536 |
+
<div id="audioUploadResult"></div>
|
| 537 |
+
</div>
|
| 538 |
+
</div>
|
| 539 |
+
|
| 540 |
+
<!-- Section 8: Notes -->
|
| 541 |
+
<div class="form-section">
|
| 542 |
+
<h3 class="section-title">π Additional Notes</h3>
|
| 543 |
+
<div class="form-group">
|
| 544 |
+
<label for="notes">Field Observations</label>
|
| 545 |
+
<textarea id="notes" placeholder="Any additional observations, notes, or remarks..." maxlength="2000"></textarea>
|
| 546 |
+
</div>
|
| 547 |
+
</div>
|
| 548 |
+
|
| 549 |
+
<div class="form-actions">
|
| 550 |
+
<button type="submit" class="btn btn-primary">π³ Save Tree Record</button>
|
| 551 |
+
<button type="button" id="resetForm" class="btn btn-secondary">π Reset Form</button>
|
| 552 |
+
</div>
|
| 553 |
+
</form>
|
| 554 |
+
|
| 555 |
+
<div id="message"></div>
|
| 556 |
+
</div>
|
| 557 |
+
|
| 558 |
+
<div class="map-container">
|
| 559 |
+
<h3>π Recent Trees</h3>
|
| 560 |
+
<div id="treeList" class="tree-list">
|
| 561 |
+
<div class="loading">Loading trees...</div>
|
| 562 |
+
</div>
|
| 563 |
+
</div>
|
| 564 |
+
</div>
|
| 565 |
+
|
| 566 |
+
<script src="/static/app.js"></script>
|
| 567 |
+
</body>
|
| 568 |
+
</html>
|
static/map.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>
|
| 7 |
|
| 8 |
<!-- Leaflet CSS -->
|
| 9 |
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
|
|
@@ -31,21 +31,22 @@
|
|
| 31 |
|
| 32 |
/* Header */
|
| 33 |
.header {
|
| 34 |
-
background: linear-gradient(135deg, #
|
| 35 |
-
padding:
|
| 36 |
display: flex;
|
| 37 |
justify-content: space-between;
|
| 38 |
align-items: center;
|
| 39 |
-
box-shadow: 0
|
| 40 |
z-index: 1000;
|
| 41 |
}
|
| 42 |
|
| 43 |
.logo {
|
| 44 |
font-size: 1.5rem;
|
| 45 |
-
font-weight:
|
| 46 |
display: flex;
|
| 47 |
align-items: center;
|
| 48 |
gap: 10px;
|
|
|
|
| 49 |
}
|
| 50 |
|
| 51 |
.header-actions {
|
|
@@ -433,14 +434,14 @@
|
|
| 433 |
<!-- Header -->
|
| 434 |
<div class="header">
|
| 435 |
<div class="logo">
|
| 436 |
-
|
| 437 |
</div>
|
| 438 |
<div class="header-actions">
|
| 439 |
<div class="tree-counter">
|
| 440 |
-
<span>
|
| 441 |
<span id="treeCount">0</span>
|
| 442 |
</div>
|
| 443 |
-
<a href="/static/index.html" class="btn btn-secondary">
|
| 444 |
</div>
|
| 445 |
</div>
|
| 446 |
|
|
@@ -451,8 +452,8 @@
|
|
| 451 |
<!-- Floating Controls -->
|
| 452 |
<div class="floating-controls">
|
| 453 |
<div class="control-panel">
|
| 454 |
-
<button id="myLocationBtn" class="btn btn-primary">
|
| 455 |
-
<button id="clearPinsBtn" class="btn btn-secondary" style="margin-top: 8px;">
|
| 456 |
</div>
|
| 457 |
</div>
|
| 458 |
|
|
@@ -470,8 +471,8 @@
|
|
| 470 |
</div>
|
| 471 |
</div>
|
| 472 |
<div class="quick-actions">
|
| 473 |
-
<button id="useLocationBtn" class="btn btn-primary">
|
| 474 |
-
<button id="cancelBtn" class="btn btn-secondary">
|
| 475 |
</div>
|
| 476 |
</div>
|
| 477 |
</div>
|
|
@@ -487,7 +488,7 @@
|
|
| 487 |
|
| 488 |
<!-- Gesture Hint -->
|
| 489 |
<div class="gesture-hint">
|
| 490 |
-
|
| 491 |
</div>
|
| 492 |
</div>
|
| 493 |
</div>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>TreeTrack Map - Interactive Field View</title>
|
| 7 |
|
| 8 |
<!-- Leaflet CSS -->
|
| 9 |
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
|
|
|
|
| 31 |
|
| 32 |
/* Header */
|
| 33 |
.header {
|
| 34 |
+
background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
|
| 35 |
+
padding: 1rem 1.5rem;
|
| 36 |
display: flex;
|
| 37 |
justify-content: space-between;
|
| 38 |
align-items: center;
|
| 39 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
| 40 |
z-index: 1000;
|
| 41 |
}
|
| 42 |
|
| 43 |
.logo {
|
| 44 |
font-size: 1.5rem;
|
| 45 |
+
font-weight: 600;
|
| 46 |
display: flex;
|
| 47 |
align-items: center;
|
| 48 |
gap: 10px;
|
| 49 |
+
letter-spacing: -0.025em;
|
| 50 |
}
|
| 51 |
|
| 52 |
.header-actions {
|
|
|
|
| 434 |
<!-- Header -->
|
| 435 |
<div class="header">
|
| 436 |
<div class="logo">
|
| 437 |
+
TreeTrack Map
|
| 438 |
</div>
|
| 439 |
<div class="header-actions">
|
| 440 |
<div class="tree-counter">
|
| 441 |
+
<span>Trees:</span>
|
| 442 |
<span id="treeCount">0</span>
|
| 443 |
</div>
|
| 444 |
+
<a href="/static/index.html" class="btn btn-secondary">Add Tree</a>
|
| 445 |
</div>
|
| 446 |
</div>
|
| 447 |
|
|
|
|
| 452 |
<!-- Floating Controls -->
|
| 453 |
<div class="floating-controls">
|
| 454 |
<div class="control-panel">
|
| 455 |
+
<button id="myLocationBtn" class="btn btn-primary">My Location</button>
|
| 456 |
+
<button id="clearPinsBtn" class="btn btn-secondary" style="margin-top: 8px;">Clear Pins</button>
|
| 457 |
</div>
|
| 458 |
</div>
|
| 459 |
|
|
|
|
| 471 |
</div>
|
| 472 |
</div>
|
| 473 |
<div class="quick-actions">
|
| 474 |
+
<button id="useLocationBtn" class="btn btn-primary">Use This Location</button>
|
| 475 |
+
<button id="cancelBtn" class="btn btn-secondary">Cancel</button>
|
| 476 |
</div>
|
| 477 |
</div>
|
| 478 |
</div>
|
|
|
|
| 488 |
|
| 489 |
<!-- Gesture Hint -->
|
| 490 |
<div class="gesture-hint">
|
| 491 |
+
Tap anywhere on map to drop a pin
|
| 492 |
</div>
|
| 493 |
</div>
|
| 494 |
</div>
|