fix(cyberfeed): Wrap RPCD array responses in objects for LuCI RPC

- get_feeds now returns {"feeds": [...]} instead of raw array
- get_items now returns {"items": [...]} instead of raw array
- Updated api.js to extract arrays from wrapped responses
- Fixes feed list not displaying in LuCI dashboard

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
CyberMind-FR 2026-01-23 22:15:31 +01:00
parent 22f6f26a01
commit 0607ed5628
3 changed files with 15 additions and 11 deletions

View File

@ -11,7 +11,7 @@ LUCI_PKGARCH:=all
PKG_NAME:=luci-app-cyberfeed
PKG_VERSION:=0.1.0
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_MAINTAINER:=CyberMind <contact@cybermind.fr>
PKG_LICENSE:=MIT

View File

@ -16,13 +16,13 @@ var callGetStatus = rpc.declare({
var callGetFeeds = rpc.declare({
object: 'luci.cyberfeed',
method: 'get_feeds',
expect: { }
expect: { feeds: [] }
});
var callGetItems = rpc.declare({
object: 'luci.cyberfeed',
method: 'get_items',
expect: { }
expect: { items: [] }
});
var callAddFeed = rpc.declare({
@ -83,11 +83,15 @@ return baseclass.extend({
},
getFeeds: function() {
return callGetFeeds();
return callGetFeeds().then(function(res) {
return res.feeds || [];
});
},
getItems: function() {
return callGetItems();
return callGetItems().then(function(res) {
return res.items || [];
});
},
addFeed: function(name, url, type, category) {

View File

@ -77,20 +77,20 @@ EOF
# Get feeds list
get_feeds() {
local feeds="[]"
if [ -x "$CYBERFEED_BIN" ]; then
$CYBERFEED_BIN list
else
echo "[]"
feeds=$($CYBERFEED_BIN list)
fi
echo "{\"feeds\":$feeds}"
}
# Get feed items
get_items() {
local items="[]"
if [ -f "${OUTPUT_DIR}/feeds.json" ]; then
cat "${OUTPUT_DIR}/feeds.json"
else
echo "[]"
items=$(cat "${OUTPUT_DIR}/feeds.json")
fi
echo "{\"items\":$items}"
}
# Add a feed