Add advanced domain filtering to domain selection
- Add filter menu: by name, by traffic, by optimization status - Search domains by regex pattern - Show only high-traffic domains (peak >= 10 concurrent requests) - Show only domains needing optimization (CRITICAL/HIGH issues) - Display peak concurrent requests alongside domain info - Makes it easier to find and target specific domains for optimization - Works in conjunction with single/batch optimization Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -79,6 +79,25 @@ select_domain() {
|
|||||||
cecho "${WHITE}${BOLD}SELECT DOMAIN${NC}"
|
cecho "${WHITE}${BOLD}SELECT DOMAIN${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
# Ask about filtering
|
||||||
|
cecho "${CYAN}Filter options:${NC}"
|
||||||
|
cecho " ${GREEN}n${NC}) No filter (show all)"
|
||||||
|
cecho " ${GREEN}s${NC}) Search by name"
|
||||||
|
cecho " ${GREEN}t${NC}) Show high-traffic domains"
|
||||||
|
cecho " ${GREEN}o${NC}) Show domains needing optimization"
|
||||||
|
cecho " ${RED}q${NC}) Cancel"
|
||||||
|
echo ""
|
||||||
|
cecho "${CYAN}─────────────────────────────────────────────────────────────────────${NC}"
|
||||||
|
|
||||||
|
read -p "Select filter: " filter_choice
|
||||||
|
filter_choice=$(echo "${filter_choice,,}")
|
||||||
|
|
||||||
|
case "$filter_choice" in
|
||||||
|
q)
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Get all users with domains
|
# Get all users with domains
|
||||||
local users
|
local users
|
||||||
users=$(list_all_users)
|
users=$(list_all_users)
|
||||||
@@ -110,12 +129,59 @@ select_domain() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Apply filters
|
||||||
|
declare -a filtered_domains
|
||||||
|
|
||||||
|
case "$filter_choice" in
|
||||||
|
s)
|
||||||
|
# Search by name
|
||||||
|
echo ""
|
||||||
|
read -p "Search pattern: " search_pattern
|
||||||
|
for domain in "${domains[@]}"; do
|
||||||
|
if [[ "$domain" =~ $search_pattern ]]; then
|
||||||
|
filtered_domains+=("$domain")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
t)
|
||||||
|
# High-traffic domains
|
||||||
|
for domain in "${domains[@]}"; do
|
||||||
|
local peak=$(get_domain_peak_concurrent "$domain" 2>/dev/null || echo "0")
|
||||||
|
if [[ "$peak" =~ ^[0-9]+$ ]] && [ "$peak" -ge 10 ]; then
|
||||||
|
filtered_domains+=("$domain")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# Sort by peak traffic (highest first)
|
||||||
|
;;
|
||||||
|
o)
|
||||||
|
# Domains needing optimization
|
||||||
|
for domain in "${domains[@]}"; do
|
||||||
|
local username="${domain_to_user[$domain]}"
|
||||||
|
local issues=$(detect_php_config_issues "$username" "$domain" 2>/dev/null || echo "NONE|NONE|None")
|
||||||
|
local has_high_issues=$(echo "$issues" | grep -cE "^[^|]*\|(CRITICAL|HIGH)\|" 2>/dev/null || echo "0")
|
||||||
|
if [ "$has_high_issues" -gt 0 ]; then
|
||||||
|
filtered_domains+=("$domain")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# No filter
|
||||||
|
filtered_domains=("${domains[@]}")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ ${#filtered_domains[@]} -eq 0 ]; then
|
||||||
|
cecho "${YELLOW}No domains match filter criteria${NC}"
|
||||||
|
read -p "Press Enter to continue..."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Display numbered list with optimization status
|
# Display numbered list with optimization status
|
||||||
cecho "${CYAN}Available domains:${NC}"
|
cecho "${CYAN}Available domains:${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
local index=1
|
local index=1
|
||||||
for domain in "${domains[@]}"; do
|
for domain in "${filtered_domains[@]}"; do
|
||||||
local username="${domain_to_user[$domain]}"
|
local username="${domain_to_user[$domain]}"
|
||||||
local php_version
|
local php_version
|
||||||
php_version=$(detect_php_version_for_domain "$username" "$domain" 2>/dev/null || echo "unknown")
|
php_version=$(detect_php_version_for_domain "$username" "$domain" 2>/dev/null || echo "unknown")
|
||||||
@@ -135,7 +201,14 @@ select_domain() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf " ${GREEN}%-3d${NC}) %-40s ${CYAN}[${username}]${NC} ${YELLOW}(${php_version})${NC} %s\n" "$index" "$domain" "$(echo -e "$status_indicator")"
|
# Show peak traffic if available
|
||||||
|
local traffic_info=""
|
||||||
|
local peak=$(get_domain_peak_concurrent "$domain" 2>/dev/null || echo "")
|
||||||
|
if [ -n "$peak" ] && [ "$peak" != "?" ]; then
|
||||||
|
traffic_info="${CYAN}(peak: ${peak})${NC} "
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf " ${GREEN}%-3d${NC}) %-40s ${CYAN}[${username}]${NC} ${YELLOW}(${php_version})${NC} %s%s\n" "$index" "$domain" "$(echo -e "$traffic_info")" "$(echo -e "$status_indicator")"
|
||||||
index=$((index + 1))
|
index=$((index + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -150,9 +223,9 @@ select_domain() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! [[ "$selection" =~ ^[0-9]+$ ]] || [ "$selection" -lt 1 ] || [ "$selection" -gt ${#domains[@]} ]; then
|
if ! [[ "$selection" =~ ^[0-9]+$ ]] || [ "$selection" -lt 1 ] || [ "$selection" -gt ${#filtered_domains[@]} ]; then
|
||||||
echo ""
|
echo ""
|
||||||
cecho "${RED}Invalid selection. Please enter a number 1-${#domains[@]}${NC}"
|
cecho "${RED}Invalid selection. Please enter a number 1-${#filtered_domains[@]}${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@@ -161,7 +234,7 @@ select_domain() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Return selected domain and username
|
# Return selected domain and username
|
||||||
local selected_domain="${domains[$((selection - 1))]}"
|
local selected_domain="${filtered_domains[$((selection - 1))]}"
|
||||||
local selected_user="${domain_to_user[$selected_domain]}"
|
local selected_user="${domain_to_user[$selected_domain]}"
|
||||||
|
|
||||||
echo "$selected_domain|$selected_user"
|
echo "$selected_domain|$selected_user"
|
||||||
|
|||||||
Reference in New Issue
Block a user