fix: Filter wizard apps and fix profile apply/rollback (v0.6.0-r22)
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 <noreply@anthropic.com>
This commit is contained in:
parent
ed78d4bb49
commit
6345268dd8
@ -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
|
||||
|
||||
@ -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') }),
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user