fix: system-hub v0.0.2 - Fix API method calls for components, health, remote, settings
Resolves TypeErrors in 4 views by adding missing API methods: API Enhancements: - Added call* prefix methods for view compatibility (callStatus, callGetHealth) - Added stub methods for planned features: * callGetComponents() - Returns mock component data (Netdata, CrowdSec, Netifyd) * callManageComponent() - Component management stub * callGetRemote() - Remote access config stub * callStartRemoteSession() - Remote session stub * callGetSchedules() - Scheduled tasks stub * callGenerateReport() - Health report generation stub - Added helper functions: * getComponentIcon() - Component icon helper * getHealthStatus() - Health score to status converter Fixed Views: - components.js: Now has callGetComponents, getComponentIcon, callManageComponent - health.js: Now has callGetHealth, getHealthStatus, callGenerateReport - remote.js: Now has callGetRemote, callStartRemoteSession - settings.js: Now has callStatus, callGetSchedules Version Update: - Bumped to v0.0.2 in Makefile and README - All 9 views now functional (stub data for planned features) 🤖 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
cffe67d43b
commit
fb899321cb
@ -1,7 +1,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=luci-app-system-hub
|
PKG_NAME:=luci-app-system-hub
|
||||||
PKG_VERSION:=0.0.1-alpha
|
PKG_VERSION:=0.0.2
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
PKG_LICENSE:=Apache-2.0
|
PKG_LICENSE:=Apache-2.0
|
||||||
PKG_MAINTAINER:=SecuBox Project <support@secubox.com>
|
PKG_MAINTAINER:=SecuBox Project <support@secubox.com>
|
||||||
|
|||||||
@ -442,4 +442,4 @@ SecuBox Project <support@secubox.com>
|
|||||||
|
|
||||||
## Version
|
## Version
|
||||||
|
|
||||||
0.0.1-alpha
|
0.0.2
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
* System Hub API
|
* System Hub API
|
||||||
* Package: luci-app-system-hub
|
* Package: luci-app-system-hub
|
||||||
* RPCD object: luci.system-hub
|
* RPCD object: luci.system-hub
|
||||||
|
* Version: 0.0.2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var callStatus = rpc.declare({
|
var callStatus = rpc.declare({
|
||||||
@ -71,6 +72,7 @@ var callGetStorage = rpc.declare({
|
|||||||
expect: { storage: [] }
|
expect: { storage: [] }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Helper: Format uptime seconds to human-readable string
|
||||||
function formatUptime(seconds) {
|
function formatUptime(seconds) {
|
||||||
if (!seconds) return '0s';
|
if (!seconds) return '0s';
|
||||||
var d = Math.floor(seconds / 86400);
|
var d = Math.floor(seconds / 86400);
|
||||||
@ -81,6 +83,7 @@ function formatUptime(seconds) {
|
|||||||
return m + 'm';
|
return m + 'm';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper: Format bytes to human-readable size
|
||||||
function formatBytes(bytes) {
|
function formatBytes(bytes) {
|
||||||
if (!bytes) return '0 B';
|
if (!bytes) return '0 B';
|
||||||
var k = 1024;
|
var k = 1024;
|
||||||
@ -89,7 +92,105 @@ function formatBytes(bytes) {
|
|||||||
return (bytes / Math.pow(k, i)).toFixed(2) + ' ' + sizes[i];
|
return (bytes / Math.pow(k, i)).toFixed(2) + ' ' + sizes[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper: Get component icon (stub for planned feature)
|
||||||
|
function getComponentIcon(icon) {
|
||||||
|
return icon || '📦';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper: Get health status info based on score
|
||||||
|
function getHealthStatus(score) {
|
||||||
|
if (score >= 90) return { status: 'excellent', label: 'Excellent', color: '#22c55e' };
|
||||||
|
if (score >= 75) return { status: 'good', label: 'Bon', color: '#3b82f6' };
|
||||||
|
if (score >= 50) return { status: 'warning', label: 'Attention', color: '#f59e0b' };
|
||||||
|
return { status: 'critical', label: 'Critique', color: '#ef4444' };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stub: Get components (planned feature - returns mock data)
|
||||||
|
function stubGetComponents() {
|
||||||
|
return Promise.resolve({
|
||||||
|
components: [
|
||||||
|
{
|
||||||
|
id: 'netdata',
|
||||||
|
name: 'Netdata',
|
||||||
|
description: 'Real-time performance monitoring',
|
||||||
|
status: 'installed',
|
||||||
|
running: true,
|
||||||
|
icon: '📊',
|
||||||
|
color: '#00C851',
|
||||||
|
web_port: 19999
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'crowdsec',
|
||||||
|
name: 'CrowdSec',
|
||||||
|
description: 'Collaborative security engine',
|
||||||
|
status: 'installed',
|
||||||
|
running: true,
|
||||||
|
icon: '🛡️',
|
||||||
|
color: '#0091EA',
|
||||||
|
web_port: null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'netifyd',
|
||||||
|
name: 'Netifyd',
|
||||||
|
description: 'Deep packet inspection',
|
||||||
|
status: 'planned',
|
||||||
|
roadmap_date: 'Q1 2026'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stub: Manage component (planned feature)
|
||||||
|
function stubManageComponent(id, action) {
|
||||||
|
return Promise.resolve({
|
||||||
|
success: true,
|
||||||
|
message: 'Component ' + id + ' ' + action + ' - Feature coming soon'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stub: Get remote access config (planned feature)
|
||||||
|
function stubGetRemote() {
|
||||||
|
return Promise.resolve({
|
||||||
|
rustdesk_enabled: false,
|
||||||
|
rustdesk_installed: false,
|
||||||
|
rustdesk_id: null,
|
||||||
|
allow_unattended: false,
|
||||||
|
require_approval: true,
|
||||||
|
notify_on_connect: true,
|
||||||
|
support: {
|
||||||
|
provider: 'CyberMind.fr',
|
||||||
|
email: 'support@cybermind.fr',
|
||||||
|
phone: '+33 1 23 45 67 89',
|
||||||
|
website: 'https://cybermind.fr'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stub: Start remote session (planned feature)
|
||||||
|
function stubStartRemoteSession(type) {
|
||||||
|
return Promise.resolve({
|
||||||
|
success: false,
|
||||||
|
error: 'Remote session feature not yet implemented'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stub: Get scheduled tasks (planned feature)
|
||||||
|
function stubGetSchedules() {
|
||||||
|
return Promise.resolve({
|
||||||
|
schedules: []
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stub: Generate health report (planned feature)
|
||||||
|
function stubGenerateReport() {
|
||||||
|
return Promise.resolve({
|
||||||
|
success: false,
|
||||||
|
error: 'Report generation not yet implemented'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return baseclass.extend({
|
return baseclass.extend({
|
||||||
|
// Main RPC methods (camelCase)
|
||||||
getStatus: callStatus,
|
getStatus: callStatus,
|
||||||
getSystemInfo: callGetSystemInfo,
|
getSystemInfo: callGetSystemInfo,
|
||||||
getHealth: callGetHealth,
|
getHealth: callGetHealth,
|
||||||
@ -100,6 +201,20 @@ return baseclass.extend({
|
|||||||
restoreConfig: callRestoreConfig,
|
restoreConfig: callRestoreConfig,
|
||||||
reboot: callReboot,
|
reboot: callReboot,
|
||||||
getStorage: callGetStorage,
|
getStorage: callGetStorage,
|
||||||
|
|
||||||
|
// RPC methods (call* prefix for view compatibility)
|
||||||
|
callStatus: callStatus,
|
||||||
|
callGetHealth: callGetHealth,
|
||||||
|
callGetComponents: stubGetComponents,
|
||||||
|
callManageComponent: stubManageComponent,
|
||||||
|
callGetRemote: stubGetRemote,
|
||||||
|
callStartRemoteSession: stubStartRemoteSession,
|
||||||
|
callGetSchedules: stubGetSchedules,
|
||||||
|
callGenerateReport: stubGenerateReport,
|
||||||
|
|
||||||
|
// Helper functions
|
||||||
formatUptime: formatUptime,
|
formatUptime: formatUptime,
|
||||||
formatBytes: formatBytes
|
formatBytes: formatBytes,
|
||||||
|
getComponentIcon: getComponentIcon,
|
||||||
|
getHealthStatus: getHealthStatus
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user