Major Features: • Centralized theme system across SecuBox and System Hub • Three theme modes: dark (default), light, and system (auto-detect) • Single theme setting in SecuBox controls both plugins • Real-time theme switching with OS preference detection SecuBox Changes: • Added theme.js manager for centralized theme control • Implemented CSS variables for dark/light mode (secubox.css) • Fixed hardcoded colors in dashboard.css, alerts.css, monitoring.css • Integrated theme.js in all 7 views (dashboard, modules, alerts, monitoring, settings, etc.) • Added get_theme RPC method to luci.secubox backend • Updated ACL permissions to include get_theme (read access) • Version updated to 0.1.1 System Hub Changes: • Added theme.js manager using SecuBox theme API • Implemented CSS variables for dark/light mode (dashboard.css) • Integrated theme.js in all 9 views (overview, health, services, logs, backup, components, remote, settings, diagnostics) • Version updated to 0.1.1 • README updated with maintainer info Theme System Architecture: • Configuration: /etc/config/secubox (option theme: dark|light|system) • RPCD Backend: luci.secubox/get_theme method • Frontend: theme.js modules (secubox/theme.js, system-hub/theme.js) • CSS Variables: --sb-bg, --sb-bg-card, --sb-border, --sb-text, --sb-text-muted, --sb-shadow • Auto-detection: prefers-color-scheme media query for system mode Documentation: • Added LUCI_DEVELOPMENT_REFERENCE.md with comprehensive LuCI development patterns • Documented ubus/RPC types, baseclass.extend() patterns, ACL structure • Common errors and solutions from implementation experience Bug Fixes: • Fixed SecuBox theme not applying visually (CSS variables now used) • Fixed missing secubox.css in view imports • Fixed ACL access denied for get_theme method • Fixed hardcoded colors preventing theme switching Testing: • Verified theme switching works in all SecuBox tabs • Verified theme switching works in all System Hub tabs • Verified dark/light/system modes function correctly • Verified single setting controls both plugins 🤖 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
139 lines
3.9 KiB
JavaScript
139 lines
3.9 KiB
JavaScript
'use strict';
|
|
'require view';
|
|
'require ui';
|
|
'require system-hub/api as API';
|
|
'require system-hub/theme as Theme';
|
|
|
|
// Load CSS
|
|
document.head.appendChild(E('link', {
|
|
'rel': 'stylesheet',
|
|
'type': 'text/css',
|
|
'href': L.resource('system-hub/dashboard.css')
|
|
}));
|
|
|
|
// Initialize theme
|
|
Theme.init();
|
|
|
|
return L.view.extend({
|
|
load: function() {
|
|
return API.listServices();
|
|
},
|
|
|
|
render: function(services) {
|
|
var v = E('div', { 'class': 'cbi-map' }, [
|
|
E('h2', {}, _('System Services')),
|
|
E('div', { 'class': 'cbi-map-descr' }, _('Manage system services: start, stop, restart, enable, or disable'))
|
|
]);
|
|
|
|
var section = E('div', { 'class': 'cbi-section' }, [
|
|
E('h3', {}, _('Service List'))
|
|
]);
|
|
|
|
if (services.length === 0) {
|
|
section.appendChild(E('p', { 'style': 'text-align: center; font-style: italic; padding: 20px;' },
|
|
_('No services found')));
|
|
v.appendChild(section);
|
|
return v;
|
|
}
|
|
|
|
var table = E('table', { 'class': 'table' }, [
|
|
E('tr', { 'class': 'tr table-titles' }, [
|
|
E('th', { 'class': 'th' }, _('Service Name')),
|
|
E('th', { 'class': 'th' }, _('Status')),
|
|
E('th', { 'class': 'th' }, _('Autostart')),
|
|
E('th', { 'class': 'th' }, _('Actions'))
|
|
])
|
|
]);
|
|
|
|
services.forEach(L.bind(function(service) {
|
|
var statusColor = service.running ? 'green' : 'red';
|
|
var statusText = service.running ? '● Running' : '○ Stopped';
|
|
var enabledText = service.enabled ? '✓ Enabled' : '✗ Disabled';
|
|
|
|
var actionsDiv = E('div', { 'style': 'display: flex; gap: 5px;' });
|
|
|
|
// Start button
|
|
if (!service.running) {
|
|
actionsDiv.appendChild(E('button', {
|
|
'class': 'cbi-button cbi-button-positive',
|
|
'click': L.bind(function(service_name, ev) {
|
|
this.performAction(service_name, 'start');
|
|
}, this, service.name)
|
|
}, _('Start')));
|
|
}
|
|
|
|
// Stop button
|
|
if (service.running) {
|
|
actionsDiv.appendChild(E('button', {
|
|
'class': 'cbi-button cbi-button-negative',
|
|
'click': L.bind(function(service_name, ev) {
|
|
this.performAction(service_name, 'stop');
|
|
}, this, service.name)
|
|
}, _('Stop')));
|
|
}
|
|
|
|
// Restart button
|
|
actionsDiv.appendChild(E('button', {
|
|
'class': 'cbi-button cbi-button-action',
|
|
'click': L.bind(function(service_name, ev) {
|
|
this.performAction(service_name, 'restart');
|
|
}, this, service.name)
|
|
}, _('Restart')));
|
|
|
|
// Enable/Disable button
|
|
if (service.enabled) {
|
|
actionsDiv.appendChild(E('button', {
|
|
'class': 'cbi-button cbi-button-neutral',
|
|
'click': L.bind(function(service_name, ev) {
|
|
this.performAction(service_name, 'disable');
|
|
}, this, service.name)
|
|
}, _('Disable')));
|
|
} else {
|
|
actionsDiv.appendChild(E('button', {
|
|
'class': 'cbi-button cbi-button-apply',
|
|
'click': L.bind(function(service_name, ev) {
|
|
this.performAction(service_name, 'enable');
|
|
}, this, service.name)
|
|
}, _('Enable')));
|
|
}
|
|
|
|
table.appendChild(E('tr', { 'class': 'tr' }, [
|
|
E('td', { 'class': 'td' }, E('strong', {}, service.name)),
|
|
E('td', { 'class': 'td' }, [
|
|
E('span', { 'style': 'color: ' + statusColor + '; font-weight: bold;' }, statusText)
|
|
]),
|
|
E('td', { 'class': 'td' }, enabledText),
|
|
E('td', { 'class': 'td' }, actionsDiv)
|
|
]));
|
|
}, this));
|
|
|
|
section.appendChild(table);
|
|
v.appendChild(section);
|
|
|
|
return v;
|
|
},
|
|
|
|
performAction: function(service, action) {
|
|
ui.showModal(_('Performing Action'), [
|
|
E('p', { 'class': 'spinning' }, _('Executing %s on service %s...').format(action, service))
|
|
]);
|
|
|
|
API.serviceAction(service, action).then(function(result) {
|
|
ui.hideModal();
|
|
if (result.success) {
|
|
ui.addNotification(null, E('p', '✓ ' + result.message), 'info');
|
|
window.location.reload();
|
|
} else {
|
|
ui.addNotification(null, E('p', '✗ ' + result.message), 'error');
|
|
}
|
|
}).catch(function(err) {
|
|
ui.hideModal();
|
|
ui.addNotification(null, E('p', _('Action failed: ') + err.message), 'error');
|
|
});
|
|
},
|
|
|
|
handleSaveApply: null,
|
|
handleSave: null,
|
|
handleReset: null
|
|
});
|