feat(secubox): Add P2P Hub API and wizard-first menu
- Make Setup Wizard the first menu item in SecuBox (order 5) - Add P2P Hub collaborative catalog API methods: - Peer discovery and management - Catalog sharing between SecuBox instances - Settings for P2P sharing preferences - Fix crowdsec-dashboard theme.js to return class instead of instance - Update views to properly instantiate theme class Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
31be5e0797
commit
693c18be2f
@ -12,9 +12,12 @@
|
|||||||
* - cyberpunk: Neon glow effects with orange/cyan accents
|
* - cyberpunk: Neon glow effects with orange/cyan accents
|
||||||
*
|
*
|
||||||
* Profiles can extend themes with custom configurations
|
* Profiles can extend themes with custom configurations
|
||||||
|
*
|
||||||
|
* Usage: var theme = new (require('crowdsec-dashboard.theme'))();
|
||||||
|
* theme.init().then(function() { ... });
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var ThemeManager = baseclass.extend({
|
return baseclass.extend({
|
||||||
// Available themes
|
// Available themes
|
||||||
themes: {
|
themes: {
|
||||||
'classic': {
|
'classic': {
|
||||||
@ -241,5 +244,3 @@ var ThemeManager = baseclass.extend({
|
|||||||
return 'cs-dashboard theme-' + (this.currentTheme || 'classic');
|
return 'cs-dashboard theme-' + (this.currentTheme || 'classic');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return new ThemeManager();
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
'require ui';
|
'require ui';
|
||||||
'require uci';
|
'require uci';
|
||||||
'require crowdsec-dashboard.api as api';
|
'require crowdsec-dashboard.api as api';
|
||||||
'require crowdsec-dashboard.theme as theme';
|
'require crowdsec-dashboard.theme as ThemeClass';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CrowdSec SOC Dashboard - Overview
|
* CrowdSec SOC Dashboard - Overview
|
||||||
@ -13,12 +13,16 @@
|
|||||||
* Version 1.1.0
|
* Version 1.1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var themeInstance = new ThemeClass();
|
||||||
|
|
||||||
return view.extend({
|
return view.extend({
|
||||||
title: _('CrowdSec SOC'),
|
title: _('CrowdSec SOC'),
|
||||||
|
theme: themeInstance,
|
||||||
|
|
||||||
load: function() {
|
load: function() {
|
||||||
|
var self = this;
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
theme.init(),
|
self.theme.init(),
|
||||||
api.getOverview().catch(function() { return {}; })
|
api.getOverview().catch(function() { return {}; })
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
@ -30,7 +34,7 @@ return view.extend({
|
|||||||
// Apply theme class
|
// Apply theme class
|
||||||
document.body.classList.add('cs-fullwidth');
|
document.body.classList.add('cs-fullwidth');
|
||||||
|
|
||||||
var view = E('div', { 'class': theme.getDashboardClass() }, [
|
var view = E('div', { 'class': self.theme.getDashboardClass() }, [
|
||||||
this.renderHeader(status),
|
this.renderHeader(status),
|
||||||
this.renderNav('overview'),
|
this.renderNav('overview'),
|
||||||
E('div', { 'id': 'cs-stats' }, this.renderStats(status)),
|
E('div', { 'id': 'cs-stats' }, this.renderStats(status)),
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
'require ui';
|
'require ui';
|
||||||
'require uci';
|
'require uci';
|
||||||
'require crowdsec-dashboard.api as api';
|
'require crowdsec-dashboard.api as api';
|
||||||
'require crowdsec-dashboard.theme as theme';
|
'require crowdsec-dashboard.theme as ThemeClass';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CrowdSec SOC - Settings View
|
* CrowdSec SOC - Settings View
|
||||||
@ -12,15 +12,19 @@
|
|||||||
* With theme/appearance settings
|
* With theme/appearance settings
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var themeInstance = new ThemeClass();
|
||||||
|
|
||||||
return view.extend({
|
return view.extend({
|
||||||
title: _('Settings'),
|
title: _('Settings'),
|
||||||
status: {},
|
status: {},
|
||||||
machines: [],
|
machines: [],
|
||||||
collections: [],
|
collections: [],
|
||||||
|
theme: themeInstance,
|
||||||
|
|
||||||
load: function() {
|
load: function() {
|
||||||
|
var self = this;
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
theme.init(),
|
self.theme.init(),
|
||||||
api.getStatus(),
|
api.getStatus(),
|
||||||
api.getMachines(),
|
api.getMachines(),
|
||||||
api.getCollections(),
|
api.getCollections(),
|
||||||
@ -42,7 +46,7 @@ return view.extend({
|
|||||||
|
|
||||||
document.body.classList.add('cs-fullwidth');
|
document.body.classList.add('cs-fullwidth');
|
||||||
|
|
||||||
return E('div', { 'class': theme.getDashboardClass() }, [
|
return E('div', { 'class': self.theme.getDashboardClass() }, [
|
||||||
this.renderHeader(),
|
this.renderHeader(),
|
||||||
this.renderNav('settings'),
|
this.renderNav('settings'),
|
||||||
E('div', { 'class': 'cs-stats' }, this.renderServiceStats()),
|
E('div', { 'class': 'cs-stats' }, this.renderServiceStats()),
|
||||||
@ -89,8 +93,8 @@ return view.extend({
|
|||||||
var currentTheme = uci.get('crowdsec-dashboard', 'main', 'theme') || 'classic';
|
var currentTheme = uci.get('crowdsec-dashboard', 'main', 'theme') || 'classic';
|
||||||
var currentProfile = uci.get('crowdsec-dashboard', 'main', 'profile') || 'default';
|
var currentProfile = uci.get('crowdsec-dashboard', 'main', 'profile') || 'default';
|
||||||
|
|
||||||
var themes = theme.getThemes();
|
var themes = this.theme.getThemes();
|
||||||
var profiles = theme.getProfiles();
|
var profiles = this.theme.getProfiles();
|
||||||
|
|
||||||
return E('div', {}, [
|
return E('div', {}, [
|
||||||
E('div', { 'style': 'margin-bottom: 16px;' }, [
|
E('div', { 'style': 'margin-bottom: 16px;' }, [
|
||||||
@ -127,11 +131,11 @@ return view.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
previewTheme: function(themeName) {
|
previewTheme: function(themeName) {
|
||||||
theme.switchTheme(themeName);
|
this.theme.switchTheme(themeName);
|
||||||
},
|
},
|
||||||
|
|
||||||
previewProfile: function(profileName) {
|
previewProfile: function(profileName) {
|
||||||
theme.switchProfile(profileName);
|
this.theme.switchProfile(profileName);
|
||||||
},
|
},
|
||||||
|
|
||||||
saveAppearance: function() {
|
saveAppearance: function() {
|
||||||
|
|||||||
@ -227,6 +227,60 @@ var callRemoveAppstoreApp = rpc.declare({
|
|||||||
expect: { success: false }
|
expect: { success: false }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// P2P Hub methods - Collaborative peer-to-peer app catalog sharing
|
||||||
|
var callGetP2PPeers = rpc.declare({
|
||||||
|
object: 'luci.secubox',
|
||||||
|
method: 'p2p_get_peers',
|
||||||
|
expect: { peers: [] }
|
||||||
|
});
|
||||||
|
|
||||||
|
var callP2PDiscover = rpc.declare({
|
||||||
|
object: 'luci.secubox',
|
||||||
|
method: 'p2p_discover',
|
||||||
|
expect: { peers: [], discovered: 0 }
|
||||||
|
});
|
||||||
|
|
||||||
|
var callP2PAddPeer = rpc.declare({
|
||||||
|
object: 'luci.secubox',
|
||||||
|
method: 'p2p_add_peer',
|
||||||
|
params: ['address', 'name'],
|
||||||
|
expect: { success: false }
|
||||||
|
});
|
||||||
|
|
||||||
|
var callP2PRemovePeer = rpc.declare({
|
||||||
|
object: 'luci.secubox',
|
||||||
|
method: 'p2p_remove_peer',
|
||||||
|
params: ['peer_id'],
|
||||||
|
expect: { success: false }
|
||||||
|
});
|
||||||
|
|
||||||
|
var callP2PGetPeerCatalog = rpc.declare({
|
||||||
|
object: 'luci.secubox',
|
||||||
|
method: 'p2p_get_peer_catalog',
|
||||||
|
params: ['peer_id'],
|
||||||
|
expect: { apps: [] }
|
||||||
|
});
|
||||||
|
|
||||||
|
var callP2PShareCatalog = rpc.declare({
|
||||||
|
object: 'luci.secubox',
|
||||||
|
method: 'p2p_share_catalog',
|
||||||
|
params: ['enabled'],
|
||||||
|
expect: { success: false }
|
||||||
|
});
|
||||||
|
|
||||||
|
var callP2PGetSettings = rpc.declare({
|
||||||
|
object: 'luci.secubox',
|
||||||
|
method: 'p2p_get_settings',
|
||||||
|
expect: { }
|
||||||
|
});
|
||||||
|
|
||||||
|
var callP2PSetSettings = rpc.declare({
|
||||||
|
object: 'luci.secubox',
|
||||||
|
method: 'p2p_set_settings',
|
||||||
|
params: ['settings'],
|
||||||
|
expect: { success: false }
|
||||||
|
});
|
||||||
|
|
||||||
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);
|
||||||
@ -284,6 +338,15 @@ return baseclass.extend({
|
|||||||
getAppstoreApp: callGetAppstoreApp,
|
getAppstoreApp: callGetAppstoreApp,
|
||||||
installAppstoreApp: callInstallAppstoreApp,
|
installAppstoreApp: callInstallAppstoreApp,
|
||||||
removeAppstoreApp: callRemoveAppstoreApp,
|
removeAppstoreApp: callRemoveAppstoreApp,
|
||||||
|
// P2P Hub - Collaborative catalog sharing
|
||||||
|
getP2PPeers: callGetP2PPeers,
|
||||||
|
p2pDiscover: callP2PDiscover,
|
||||||
|
p2pAddPeer: callP2PAddPeer,
|
||||||
|
p2pRemovePeer: callP2PRemovePeer,
|
||||||
|
p2pGetPeerCatalog: callP2PGetPeerCatalog,
|
||||||
|
p2pShareCatalog: callP2PShareCatalog,
|
||||||
|
p2pGetSettings: callP2PGetSettings,
|
||||||
|
p2pSetSettings: callP2PSetSettings,
|
||||||
// Utilities
|
// Utilities
|
||||||
formatUptime: formatUptime,
|
formatUptime: formatUptime,
|
||||||
formatBytes: formatBytes
|
formatBytes: formatBytes
|
||||||
|
|||||||
@ -9,6 +9,17 @@
|
|||||||
"acl": ["luci-app-secubox"]
|
"acl": ["luci-app-secubox"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"admin/secubox/wizard": {
|
||||||
|
"title": "Setup Wizard",
|
||||||
|
"order": 5,
|
||||||
|
"action": {
|
||||||
|
"type": "view",
|
||||||
|
"path": "secubox/wizard"
|
||||||
|
},
|
||||||
|
"depends": {
|
||||||
|
"acl": ["luci-app-secubox"]
|
||||||
|
}
|
||||||
|
},
|
||||||
"admin/secubox/dashboard": {
|
"admin/secubox/dashboard": {
|
||||||
"title": "Dashboard",
|
"title": "Dashboard",
|
||||||
"order": 10,
|
"order": 10,
|
||||||
@ -20,17 +31,6 @@
|
|||||||
"acl": ["luci-app-secubox"]
|
"acl": ["luci-app-secubox"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/secubox/wizard": {
|
|
||||||
"title": "First-Run Wizard",
|
|
||||||
"order": 15,
|
|
||||||
"action": {
|
|
||||||
"type": "view",
|
|
||||||
"path": "secubox/wizard"
|
|
||||||
},
|
|
||||||
"depends": {
|
|
||||||
"acl": ["luci-app-secubox"]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"admin/secubox/apps": {
|
"admin/secubox/apps": {
|
||||||
"title": "App Store",
|
"title": "App Store",
|
||||||
"order": 18,
|
"order": 18,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user