secubox-openwrt/package/secubox/luci-app-secubox/htdocs/luci-static/resources/secubox/theme.js
CyberMind-FR 675b2d164e feat: Portal service detection, nDPId compat layer, CrowdSec/Netifyd packages
Portal (luci-app-secubox-portal):
- Fix service status showing 0/9 by checking if init scripts exist
- Only count installed services in status display
- Use pgrep fallback when init script status fails

nDPId Dashboard (luci-app-ndpid):
- Add default /etc/config/ndpid configuration
- Add /etc/init.d/ndpid-compat init script
- Enable compat service in postinst for app detection
- Fix Makefile to install init script and config

CrowdSec Dashboard:
- Add CLAUDE.md with OpenWrt-specific guidelines (pgrep without -x)
- CSS fixes for hiding LuCI left menu in all views
- LAPI repair improvements with retry logic

New Packages:
- secubox-app-crowdsec: OpenWrt-native CrowdSec package
- secubox-app-netifyd: Netifyd DPI integration
- luci-app-secubox: Core SecuBox hub
- luci-theme-secubox: Custom theme

Removed:
- luci-app-secubox-crowdsec (replaced by crowdsec-dashboard)
- secubox-crowdsec-setup (functionality moved to dashboard)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 13:51:40 +01:00

96 lines
2.6 KiB
JavaScript

'use strict';
'require baseclass';
'require secubox/api as API';
/**
* SecuBox Theme Manager
* Manages dark/light/system/cyberpunk theme switching across SecuBox modules
* Version: 1.1.0
*/
var SUPPORTED_THEMES = ['dark', 'light', 'system', 'cyberpunk'];
console.log('🎨 SecuBox Theme Manager v1.1.0 loaded');
return baseclass.extend({
/**
* Initialize theme system
* Loads theme preference and applies it to the page
*/
init: function() {
var self = this;
return API.getTheme().then(function(data) {
var themePref = data.theme || 'dark';
if (SUPPORTED_THEMES.indexOf(themePref) === -1) {
themePref = 'dark';
}
self.applyTheme(themePref);
// Listen for system theme changes if preference is 'system'
if (themePref === 'system' && window.matchMedia) {
var darkModeQuery = window.matchMedia('(prefers-color-scheme: dark)');
darkModeQuery.addListener(function() {
self.applyTheme('system');
});
}
}).catch(function(err) {
console.error('Failed to load theme preference, using dark theme:', err);
self.applyTheme('dark');
});
},
/**
* Apply theme to the page
* @param {string} theme - Theme preference: 'dark', 'light', 'system', or 'cyberpunk'
*/
applyTheme: function(theme) {
var selectedTheme = SUPPORTED_THEMES.indexOf(theme) > -1 ? theme : 'dark';
var effectiveTheme = selectedTheme;
// If 'system', detect from OS
if (selectedTheme === 'system' && window.matchMedia) {
effectiveTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
}
// Apply theme to document root
document.documentElement.setAttribute('data-theme', effectiveTheme);
console.log('🎨 Theme applied:', selectedTheme, '(effective:', effectiveTheme + ')');
},
/**
* Get current effective theme
* @returns {string} 'dark' or 'light'
*/
getCurrentTheme: function() {
return document.documentElement.getAttribute('data-theme') || 'dark';
},
/**
* Get theme preference from backend
* @returns {Promise<string>} Theme preference ('dark', 'light', 'system', or 'cyberpunk')
*/
getTheme: function() {
return API.getTheme().then(function(data) {
return data.theme || 'dark';
}).catch(function(err) {
console.error('Failed to load theme preference:', err);
return 'dark';
});
},
/**
* Apply and persist theme preference
* @param {string} theme
* @returns {Promise<object>}
*/
setTheme: function(theme) {
this.applyTheme(theme);
return API.setTheme(theme).catch(function(err) {
console.error('Failed to persist theme preference:', err);
throw err;
});
}
});