Fixed JavaScript errors in multiple modules by adding missing API functions: 1. auth-guardian: - Added getSessions() alias for listSessions compatibility 2. netifyd-dashboard: - Added getAllData() aggregating status, stats, flows, applications 3. wireguard-dashboard: - Added getAllData() aggregating status, peers, interfaces, traffic 4. network-modes: - Added getAllData() aggregating status, mode, available_modes, interfaces 5. netdata-dashboard: - Fixed ACL permissions: changed ubus object from 'netdata' to 'luci.netdata-dashboard' - Added missing RPC methods to ACL (netdata_status, netdata_alarms, netdata_info) - Added write permissions for service control methods Resolves: - TypeError: api.getSessions is not a function (auth-guardian) - TypeError: api.getAllData is not a function (netifyd, wireguard, network-modes) - RPC error -32002: Access denied (netdata-dashboard) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
83 lines
1.7 KiB
JavaScript
83 lines
1.7 KiB
JavaScript
'use strict';
|
|
'require baseclass';
|
|
'require rpc';
|
|
|
|
/**
|
|
* Netifyd Dashboard API
|
|
* Package: luci-app-netifyd-dashboard
|
|
* RPCD object: luci.netifyd-dashboard
|
|
*/
|
|
|
|
// Version: 0.2.2
|
|
|
|
var callStatus = rpc.declare({
|
|
object: 'luci.netifyd-dashboard',
|
|
method: 'status',
|
|
expect: { }
|
|
});
|
|
|
|
var callFlows = rpc.declare({
|
|
object: 'luci.netifyd-dashboard',
|
|
method: 'flows',
|
|
expect: { flows: [] }
|
|
});
|
|
|
|
var callApplications = rpc.declare({
|
|
object: 'luci.netifyd-dashboard',
|
|
method: 'applications',
|
|
expect: { applications: [] }
|
|
});
|
|
|
|
var callHosts = rpc.declare({
|
|
object: 'luci.netifyd-dashboard',
|
|
method: 'hosts',
|
|
expect: { hosts: [] }
|
|
});
|
|
|
|
var callProtocols = rpc.declare({
|
|
object: 'luci.netifyd-dashboard',
|
|
method: 'protocols',
|
|
expect: { protocols: [] }
|
|
});
|
|
|
|
var callStats = rpc.declare({
|
|
object: 'luci.netifyd-dashboard',
|
|
method: 'stats',
|
|
expect: { }
|
|
});
|
|
|
|
function formatBytes(bytes) {
|
|
if (bytes === 0) return '0 B';
|
|
var k = 1024;
|
|
var sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
var i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
|
}
|
|
|
|
return baseclass.extend({
|
|
getStatus: callStatus,
|
|
getFlows: callFlows,
|
|
getApplications: callApplications,
|
|
getHosts: callHosts,
|
|
getProtocols: callProtocols,
|
|
getStats: callStats,
|
|
formatBytes: formatBytes,
|
|
|
|
// Aggregate function for overview page
|
|
getAllData: function() {
|
|
return Promise.all([
|
|
callStatus(),
|
|
callStats(),
|
|
callFlows(),
|
|
callApplications()
|
|
]).then(function(results) {
|
|
return {
|
|
status: results[0] || {},
|
|
stats: results[1] || {},
|
|
flows: results[2] || { flows: [] },
|
|
applications: results[3] || { applications: [] }
|
|
};
|
|
});
|
|
}
|
|
});
|