fix: Add graceful fallback for RPC calls when backend not deployed

Fix 'No related RPC reply' errors by wrapping RPC calls in L.resolveDefault()
to provide fallback values when backend methods aren't available yet.

## Problem

When new LuCI views are deployed before backend packages, RPC calls fail with:
  Error: No related RPC reply

This happens because:
- Frontend (luci-app-secubox-admin) calls check_updates, get_catalog_sources
- Backend (secubox-core) hasn't been deployed yet with new RPCD methods
- RPCD returns no reply, causing frontend to crash

## Solution

Wrap all new RPC calls in L.resolveDefault() with sensible fallbacks:

**catalog-sources.js**:
- getCatalogSources() → fallback: { sources: [] }
- checkUpdates() → fallback: { updates: [] }

**updates.js**:
- checkUpdates() → fallback: { updates: [] }

This allows pages to load gracefully with empty data instead of crashing.

## Benefits

1. **Graceful degradation**: Pages load even without backend
2. **Deployment flexibility**: Can deploy frontend before backend
3. **Better UX**: Shows 'No updates' / 'No sources' instead of errors
4. **Production-ready**: Handles missing backends in production

## Testing

Before backend deployment:
- Catalog Sources page shows: 'No sources configured'
- Updates page shows: 'All applications are up to date'

After backend deployment:
- Pages populate with real data from RPCD

Incremented PKG_RELEASE: 4 → 5
This commit is contained in:
CyberMind-FR 2026-01-04 14:44:24 +01:00
parent adfeed60e2
commit 2013ea2e8c
3 changed files with 4 additions and 4 deletions

View File

@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-secubox-admin
PKG_VERSION:=1.0.0
PKG_RELEASE:=4
PKG_RELEASE:=5
PKG_LICENSE:=MIT
PKG_MAINTAINER:=CyberMind <contact@cybermind.fr>

View File

@ -8,8 +8,8 @@
return view.extend({
load: function() {
return Promise.all([
API.getCatalogSources(),
L.resolveDefault(API.checkUpdates(), {})
L.resolveDefault(API.getCatalogSources(), { sources: [] }),
L.resolveDefault(API.checkUpdates(), { updates: [] })
]);
},

View File

@ -8,7 +8,7 @@
return view.extend({
load: function() {
return Promise.all([
API.checkUpdates(),
L.resolveDefault(API.checkUpdates(), { updates: [] }),
API.getApps(),
API.getModules()
]);