secubox-openwrt/luci-app-system-hub/htdocs/luci-static/resources/system-hub/api.js
CyberMind-FR 34fe2dc26a feat: complete System Hub implementation - central control dashboard
Implements comprehensive system control and monitoring dashboard with health
metrics, service management, system logs, and backup/restore functionality.

Features:
- Real-time system monitoring with visual gauges (CPU, RAM, Disk)
- Comprehensive system information (hostname, model, uptime, kernel)
- Health metrics with temperature monitoring and storage breakdown
- Service management with start/stop/restart/enable/disable actions
- System log viewer with filtering and configurable line count
- Configuration backup creation and download (base64 encoded)
- Configuration restore from backup file
- System reboot functionality with confirmation

Components:
- RPCD backend (luci.system-hub): 10 ubus methods
  * status, get_system_info, get_health
  * list_services, service_action
  * get_logs, backup_config, restore_config
  * reboot, get_storage
- 4 JavaScript views: overview, services, logs, backup
- ACL with read/write permissions segregation
- Comprehensive README with API documentation

Technical implementation:
- System info from /proc filesystem and sysinfo
- Health metrics: CPU load, memory breakdown, disk usage, temperature
- Service control via /etc/init.d scripts
- Log retrieval via logread with filtering
- Backup/restore using sysupgrade with base64 encoding
- Visual gauges with SVG circular progress indicators
- Color-coded health status (green/orange/red)

Dashboard Features:
- Circular gauges for CPU, Memory, Disk (120px with 10px stroke)
- System information cards with detailed metrics
- Temperature monitoring with thermal zone detection
- Storage table for all mount points with progress bars
- Service table with inline action buttons
- Terminal-style log display (black bg, green text)
- File upload for backup restore
- Modal confirmations for destructive actions

Architecture follows SecuBox standards:
- RPCD naming convention (luci. prefix)
- Menu paths match view file structure
- All JavaScript in strict mode
- Form-based configuration management
- Comprehensive error handling

Dependencies: coreutils, coreutils-base64

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-24 11:02:07 +01:00

79 lines
1.5 KiB
JavaScript

'use strict';
'require rpc';
var callStatus = rpc.declare({
object: 'luci.system-hub',
method: 'status',
expect: {}
});
var callGetSystemInfo = rpc.declare({
object: 'luci.system-hub',
method: 'get_system_info',
expect: {}
});
var callGetHealth = rpc.declare({
object: 'luci.system-hub',
method: 'get_health',
expect: {}
});
var callListServices = rpc.declare({
object: 'luci.system-hub',
method: 'list_services',
expect: { services: [] }
});
var callServiceAction = rpc.declare({
object: 'luci.system-hub',
method: 'service_action',
params: ['service', 'action'],
expect: {}
});
var callGetLogs = rpc.declare({
object: 'luci.system-hub',
method: 'get_logs',
params: ['lines', 'filter'],
expect: { logs: [] }
});
var callBackupConfig = rpc.declare({
object: 'luci.system-hub',
method: 'backup_config',
expect: {}
});
var callRestoreConfig = rpc.declare({
object: 'luci.system-hub',
method: 'restore_config',
params: ['data'],
expect: {}
});
var callReboot = rpc.declare({
object: 'luci.system-hub',
method: 'reboot',
expect: {}
});
var callGetStorage = rpc.declare({
object: 'luci.system-hub',
method: 'get_storage',
expect: { storage: [] }
});
return {
getStatus: callStatus,
getSystemInfo: callGetSystemInfo,
getHealth: callGetHealth,
listServices: callListServices,
serviceAction: callServiceAction,
getLogs: callGetLogs,
backupConfig: callBackupConfig,
restoreConfig: callRestoreConfig,
reboot: callReboot,
getStorage: callGetStorage
};