fix: Remove deprecated code and complete menu-functions integration
CLEANUP: - Removed unused safe_read_choice() function (replaced by menu-functions.sh) - Converted remaining handle_loadwatch_analyzer() to use new menu system - All menu handlers now use MENU_CHOICE and menu-functions consistently QA VERIFICATION: ✓ Syntax check: PASSED ✓ No deprecated read patterns remaining ✓ All 11 menu functions using new system ✓ All 11 handlers using MENU_CHOICE ✓ All error handling using menu_invalid_choice STATUS: Complete menu system migration to lib/menu-functions.sh Ready for production use in dev branch
This commit is contained in:
+15
-31
@@ -33,18 +33,6 @@ source "$LIB_DIR/user-manager.sh" || { echo "ERROR: Failed to load user-manager.
|
||||
source "$LIB_DIR/reference-db.sh" || { echo "ERROR: Failed to load reference-db.sh"; return 1; }
|
||||
source "$LIB_DIR/menu-functions.sh" || { echo "ERROR: Failed to load menu-functions.sh"; return 1; }
|
||||
|
||||
# Safe read helper function - handles both interactive and non-interactive modes
|
||||
safe_read_choice() {
|
||||
if [ "$INTERACTIVE_MODE" -eq 0 ]; then
|
||||
# Non-interactive: return 1 to indicate read failed
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Color codes
|
||||
RED='\033[0;31m'
|
||||
YELLOW='\033[1;33m'
|
||||
@@ -502,33 +490,29 @@ handle_loadwatch_analyzer() {
|
||||
fi
|
||||
|
||||
show_banner
|
||||
echo -e "📊 Loadwatch Health Analyzer"
|
||||
echo ""
|
||||
echo -e "Select time range for analysis:"
|
||||
echo ""
|
||||
echo -e " 1) Last 1 Hour - Recent activity"
|
||||
echo -e " 2) Last 6 Hours - Mid-term trending"
|
||||
echo -e " 3) Last 24 Hours - Full day analysis"
|
||||
echo -e " 4) Last 7 Days - Weekly patterns"
|
||||
echo -e " 5) Last 30 Days - Monthly overview"
|
||||
echo ""
|
||||
echo -e " 0) Back"
|
||||
echo ""
|
||||
echo -e "──────────────────────────────────────────────────────────────"
|
||||
echo -n "Select time range: "
|
||||
menu_header "Loadwatch Health Analyzer"
|
||||
|
||||
if ! read -r range_choice </dev/tty 2>/dev/null; then
|
||||
return 0 # Exit if read fails
|
||||
fi
|
||||
menu_section "Select time range for analysis"
|
||||
menu_option 1 "Last 1 Hour" "Recent activity"
|
||||
menu_option 2 "Last 6 Hours" "Mid-term trending"
|
||||
menu_option 3 "Last 24 Hours" "Full day analysis"
|
||||
menu_option 4 "Last 7 Days" "Weekly patterns"
|
||||
menu_option 5 "Last 30 Days" "Monthly overview"
|
||||
|
||||
case "$range_choice" in
|
||||
echo ""
|
||||
menu_back "Performance Menu"
|
||||
menu_divider
|
||||
|
||||
read_menu_choice "Select time range" 0 5
|
||||
|
||||
case "$MENU_CHOICE" in
|
||||
1) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "1h" ;;
|
||||
2) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "6h" ;;
|
||||
3) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "24h" ;;
|
||||
4) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "7d" ;;
|
||||
5) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "30d" ;;
|
||||
0) return ;;
|
||||
*) echo -e "Invalid option"; sleep 1 ;;
|
||||
*) menu_invalid_choice ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user