From 6345268dd8b833f7270c5e9185646b6817cb1463 Mon Sep 17 00:00:00 2001 From: CyberMind-FR Date: Wed, 7 Jan 2026 13:24:04 +0100 Subject: [PATCH] fix: Filter wizard apps and fix profile apply/rollback (v0.6.0-r22) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wizard App Filtering: - Only show apps with has_wizard=true in App Wizards section - Previously showed all 39 catalog apps, now shows only 2 with wizards - Improved user experience by hiding apps without configuration wizards Profile Application Fixes: - Fixed API method name: apply_profile → applyProfile (camelCase) - Fixed parameter name: profile_id → profile - Added proper JSON response handling with success/message fields - Fixed rollback_profile → rollbackProfile method name - Implemented rollbackProfile RPC method using secubox-recovery - Added rollbackProfile to RPC method list registration - Profile apply now returns structured success/error responses - Rollback restores last snapshot created before profile application 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- .../luci-static/resources/secubox/api.js | 8 ++++--- .../resources/view/secubox/wizard.js | 6 +++-- .../root/usr/libexec/rpcd/luci.secubox | 24 ++++++++++++++++++- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/luci-app-secubox/htdocs/luci-static/resources/secubox/api.js b/luci-app-secubox/htdocs/luci-static/resources/secubox/api.js index 700e7f2b..d190034b 100644 --- a/luci-app-secubox/htdocs/luci-static/resources/secubox/api.js +++ b/luci-app-secubox/htdocs/luci-static/resources/secubox/api.js @@ -182,13 +182,15 @@ var callListProfiles = rpc.declare({ var callApplyProfile = rpc.declare({ object: 'luci.secubox', - method: 'apply_profile', - params: ['profile_id'] + method: 'applyProfile', + params: ['profile'], + expect: { success: false, message: '' } }); var callRollbackProfile = rpc.declare({ object: 'luci.secubox', - method: 'rollback_profile' + method: 'rollbackProfile', + expect: { success: false, message: '' } }); // App Store methods diff --git a/luci-app-secubox/htdocs/luci-static/resources/view/secubox/wizard.js b/luci-app-secubox/htdocs/luci-static/resources/view/secubox/wizard.js index ead6cfe4..b1d9db17 100644 --- a/luci-app-secubox/htdocs/luci-static/resources/view/secubox/wizard.js +++ b/luci-app-secubox/htdocs/luci-static/resources/view/secubox/wizard.js @@ -46,9 +46,11 @@ return view.extend({ console.log('[SecuBox Wizard] Profiles data:', payload[2]); this.firstRun = payload[0] || {}; // Handle both array and object formats - this.appList = Array.isArray(payload[1]) ? payload[1] : (payload[1] && payload[1].apps) || []; + var allApps = Array.isArray(payload[1]) ? payload[1] : (payload[1] && payload[1].apps) || []; + // Filter to only show apps with wizards + this.appList = allApps.filter(function(app) { return app.has_wizard === true; }); this.profileList = Array.isArray(payload[2]) ? payload[2] : (payload[2] && payload[2].profiles) || []; - console.log('[SecuBox Wizard] Parsed appList:', this.appList); + console.log('[SecuBox Wizard] Filtered appList (has_wizard only):', this.appList); console.log('[SecuBox Wizard] Parsed profileList:', this.profileList); var container = E('div', { 'class': 'secubox-wizard-page' }, [ E('link', { 'rel': 'stylesheet', 'href': L.resource('secubox-theme/core/variables.css') }), diff --git a/package/secubox/secubox-core/root/usr/libexec/rpcd/luci.secubox b/package/secubox/secubox-core/root/usr/libexec/rpcd/luci.secubox index ec27de51..8e955d0a 100755 --- a/package/secubox/secubox-core/root/usr/libexec/rpcd/luci.secubox +++ b/package/secubox/secubox-core/root/usr/libexec/rpcd/luci.secubox @@ -56,6 +56,9 @@ case "$1" in json_add_boolean "dryrun" "boolean" json_close_object + json_add_object "rollbackProfile" + json_close_object + json_add_object "validateProfile" json_add_string "profile" "string" json_close_object @@ -264,7 +267,26 @@ case "$1" in read -r input profile=$(echo "$input" | jsonfilter -e '@.profile') dryrun=$(echo "$input" | jsonfilter -e '@.dryrun') - /usr/sbin/secubox-profile apply "$profile" ${dryrun:+--dryrun} + result=$(/usr/sbin/secubox-profile apply "$profile" ${dryrun:+--dryrun} 2>&1) + if [ $? -eq 0 ]; then + echo '{"success":true,"message":"Profile applied successfully"}' + else + echo "{\"success\":false,\"message\":\"Failed to apply profile\",\"error\":\"$result\"}" + fi + ;; + + rollbackProfile) + # Rollback to last snapshot created before profile application + if [ -f /usr/sbin/secubox-recovery ]; then + result=$(/usr/sbin/secubox-recovery restore last 2>&1) + if [ $? -eq 0 ]; then + echo '{"success":true,"message":"Rolled back to last snapshot"}' + else + echo "{\"success\":false,\"message\":\"Rollback failed\",\"error\":\"$result\"}" + fi + else + echo '{"success":false,"message":"Recovery system not available"}' + fi ;; validateProfile)