diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index adbaaf7..9aabd04 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -147,7 +147,10 @@ const App = () => { const deptMatch = emp.department_name && emp.department_name.toLowerCase().includes(queryClean); const buildingMatch = emp.building && emp.building.toLowerCase().includes(queryClean); - return nameMatch || phoneMatch || internalPhoneMatch || internalPhoneStringMatch || titleMatch || companyMatch || deptMatch || buildingMatch; + // Match email fragment (by start, middle, domain, part before @) + const emailMatch = emp.email && emp.email.toLowerCase().includes(queryClean); + + return nameMatch || phoneMatch || internalPhoneMatch || internalPhoneStringMatch || titleMatch || companyMatch || deptMatch || buildingMatch || emailMatch; } return true; diff --git a/frontend/src/components/AdminPanel.jsx b/frontend/src/components/AdminPanel.jsx index 2d4c99a..c0d4be6 100644 --- a/frontend/src/components/AdminPanel.jsx +++ b/frontend/src/components/AdminPanel.jsx @@ -305,12 +305,27 @@ const AdminPanel = ({ token, employees, departments, companies, onRefreshData }) }; // Filter employees within the admin table - const filteredEmployees = employees.filter(emp => - emp.name.toLowerCase().includes(adminSearch.toLowerCase()) || - emp.job_title.toLowerCase().includes(adminSearch.toLowerCase()) || - (emp.company_name && emp.company_name.toLowerCase().includes(adminSearch.toLowerCase())) || - (emp.department_name && emp.department_name.toLowerCase().includes(adminSearch.toLowerCase())) - ); + const filteredEmployees = employees.filter(emp => { + const cleanSearch = adminSearch.toLowerCase().trim(); + if (!cleanSearch) return true; + + const nameMatch = emp.name.toLowerCase().includes(cleanSearch); + const jobMatch = emp.job_title.toLowerCase().includes(cleanSearch); + const companyMatch = emp.company_name && emp.company_name.toLowerCase().includes(cleanSearch); + const deptMatch = emp.department_name && emp.department_name.toLowerCase().includes(cleanSearch); + const emailMatch = emp.email && emp.email.toLowerCase().includes(cleanSearch); + + // Normalize phone numbers for search + const cleanDigits = cleanSearch.replace(/\D/g, ''); + const empPhoneDigits = emp.phone ? emp.phone.replace(/\D/g, '') : ''; + const phoneMatch = cleanDigits.length > 0 && empPhoneDigits.includes(cleanDigits); + + const empInternalPhoneDigits = emp.internal_phone ? emp.internal_phone.replace(/\D/g, '') : ''; + const internalPhoneMatch = cleanDigits.length > 0 && empInternalPhoneDigits.includes(cleanDigits); + const internalPhoneStringMatch = emp.internal_phone && emp.internal_phone.toLowerCase().includes(cleanSearch); + + return nameMatch || jobMatch || companyMatch || deptMatch || emailMatch || phoneMatch || internalPhoneMatch || internalPhoneStringMatch; + }); return (
diff --git a/update.sh b/update.sh index 7d25737..7a4c1e7 100755 --- a/update.sh +++ b/update.sh @@ -26,6 +26,13 @@ fi log "Navigating to ${INSTALL_DIR}" cd "$INSTALL_DIR" || die "Directory ${INSTALL_DIR} does not exist. Run install.sh first." +# 2.1. Backup existing database +if [ -f "${INSTALL_DIR}/data/database.db" ]; then + log "Backing up existing database" + cp "${INSTALL_DIR}/data/database.db" "${INSTALL_DIR}/data/database.db.bak" + log "Database backup created at ${INSTALL_DIR}/data/database.db.bak" +fi + # 3. Configure git safe directory log "Configuring git safe directory" git config --global --add safe.directory "$INSTALL_DIR" || true @@ -79,6 +86,7 @@ log "Running health check..." sleep 5 if curl -fsSI "http://127.0.0.1:${HOST_PORT}/" >/dev/null; then log "Update completed successfully!" + log "Service HTTP Status: $(curl -o /dev/null -s -w "%{http_code}" http://127.0.0.1:${HOST_PORT}/)" log "Container Status:" docker ps --filter "name=${CONTAINER_NAME}"