secubox-openwrt/luci-app-vhost-manager/htdocs/luci-static/resources/vhost-manager/api.js
CyberMind-FR 12774589fc feat(vhost-manager,network-tweaks): major v2.0 upgrade with dashboards and automation
VHost Manager v2.0:
- Add modern dashboard UI with auto-refresh for Internal Services, Redirects, and Virtual Hosts tabs
- Implement template activation system with one-click deployment (19 services, 6 redirects)
- Add section_id parameter to RPC backend for named VHost profiles
- Enhance API with createVHost() wrapper for template-based creation
- Fix redirect support with nginx return directive validation
- Add action buttons (Edit/Enable/Disable/Remove) to all VHost cards
- Implement confirmation modals for destructive actions
- Update README with comprehensive v2.0 feature documentation
- Add templates.json catalog with pre-configured service/redirect templates

Network Tweaks v1.0:
- Create network services dashboard with dynamic component discovery
- Add RPC backend with component filtering by network capabilities
- Implement cumulative impact tracking (DNS entries, VHosts, ports)
- Add network mode integration for profile-based settings
- Create dashboard.css with responsive grid layouts
- Add 10-second auto-refresh polling for live status updates

New Applications:
- Add luci-app-magicmirror (Smart mirror application)
- Add secubox-app-magicmirror with Docker runtime
- Add luci-app-network-tweaks (Network services monitoring)
- Add secubox-app-adguardhome (DNS filtering)
- Add secubox-app-nextcloud (File sync and sharing)
- Add plugin catalog manifests for AdGuard Home, MagicMirror, Nextcloud

Bug Fixes:
- Fix RPC backend shell script errors (remove local declarations from case statements)
- Fix fs.exec usage in vhosts.js (replace with uci module)
- Fix form rendering in Virtual Hosts view (use proper LuCI patterns)
- Fix file ownership issues (ensure root:root for deployed files)

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-01 14:30:57 +01:00

120 lines
2.7 KiB
JavaScript

'use strict';
'require baseclass';
'require rpc';
var callStatus = rpc.declare({
object: 'luci.vhost-manager',
method: 'status',
expect: { }
});
var callListVHosts = rpc.declare({
object: 'luci.vhost-manager',
method: 'list_vhosts',
expect: { vhosts: [] }
});
var callGetVHost = rpc.declare({
object: 'luci.vhost-manager',
method: 'get_vhost',
params: ['domain'],
expect: { }
});
var callAddVHost = rpc.declare({
object: 'luci.vhost-manager',
method: 'add_vhost',
params: ['domain', 'backend', 'tls_mode', 'auth', 'auth_user', 'auth_pass', 'websocket', 'enabled', 'cert_path', 'key_path', 'section_id'],
expect: { }
});
var callUpdateVHost = rpc.declare({
object: 'luci.vhost-manager',
method: 'update_vhost',
params: ['domain', 'backend', 'tls_mode', 'auth', 'auth_user', 'auth_pass', 'websocket', 'enabled', 'cert_path', 'key_path'],
expect: { }
});
var callDeleteVHost = rpc.declare({
object: 'luci.vhost-manager',
method: 'delete_vhost',
params: ['domain'],
expect: { }
});
var callTestBackend = rpc.declare({
object: 'luci.vhost-manager',
method: 'test_backend',
params: ['backend'],
expect: { }
});
var callRequestCert = rpc.declare({
object: 'luci.vhost-manager',
method: 'request_cert',
params: ['domain', 'email'],
expect: { }
});
var callListCerts = rpc.declare({
object: 'luci.vhost-manager',
method: 'list_certs',
expect: { certificates: [] }
});
var callReloadNginx = rpc.declare({
object: 'luci.vhost-manager',
method: 'reload_nginx',
expect: { }
});
var callGetAccessLogs = rpc.declare({
object: 'luci.vhost-manager',
method: 'get_access_logs',
params: ['domain', 'lines'],
expect: { logs: [] }
});
return baseclass.extend({
getStatus: callStatus,
listVHosts: callListVHosts,
getVHost: callGetVHost,
addVHost: callAddVHost,
updateVHost: callUpdateVHost,
deleteVHost: callDeleteVHost,
testBackend: callTestBackend,
requestCert: callRequestCert,
listCerts: callListCerts,
reloadNginx: callReloadNginx,
getAccessLogs: callGetAccessLogs,
// Wrapper for template-based VHost creation
createVHost: function(config) {
var domain = config.domain;
var backend = config.backend || config.upstream;
var tlsMode = config.tls_mode || (config.requires_ssl ? 'acme' : 'off');
var auth = config.auth || false;
var authUser = config.auth_user || null;
var authPass = config.auth_pass || null;
var websocket = config.websocket_enabled || config.websocket_support || false;
var enabled = config.enabled !== false;
var certPath = config.cert_path || null;
var keyPath = config.key_path || null;
var sectionId = config.section_id || config.id || null;
return callAddVHost(
domain,
backend,
tlsMode,
auth,
authUser,
authPass,
websocket,
enabled,
certPath,
keyPath,
sectionId
);
}
});