secubox-openwrt/luci-app-system-hub/htdocs/luci-static/resources/view/system-hub/components.js
CyberMind-FR aad081e841 chore: Release v0.4.2 - Menu reorganization and CSS enhancements
This release focuses on improved menu structure, enhanced CSS styling
across all modules, and documentation cleanup.

## Menu & Navigation (2 modules)
- Reorganized SecuBox menu with new "Network & Connectivity" category
- Moved Network Modes from top-level to Network submenu
- New menu path: admin/secubox/network/modes

## Network Modes Enhancements (14 files)
- Enhanced all mode views: Overview, Wizard, Router, Multi-WAN, Double NAT,
  Access Point, Relay, VPN Relay, Travel, Sniffer, Settings
- Improved dashboard.css styling
- Updated API and helpers for better functionality

## System Hub Improvements (11 files)
- Added dedicated CSS files for Backup and Health views
- Enhanced styling: common.css, components.css, logs.css, services.css
- Updated views: backup.js, components.js, health.js, logs.js, services.js
- Removed deprecated settings.js view

## SecuBox Dashboard Updates (4 files)
- Refined dashboard.css and modules.css styling
- Enhanced dashboard.js and modules.js functionality

## Theme Updates (1 file)
- Improved navigation.css component styling

## Documentation Cleanup (15 files deleted)
- Removed obsolete documentation from docs/ directory
- Migrated documentation to DOCS/ (uppercase) structure
- Cleaned up archive files and outdated guides

## Configuration (1 file)
- Updated Claude settings for new permissions

Summary:
- 50 files changed
- 3 modules enhanced (network-modes, system-hub, secubox)
- 15 documentation files cleaned up
- 2 new CSS files added
- Menu structure reorganized

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-28 19:07:44 +01:00

270 lines
7.1 KiB
JavaScript

'use strict';
'require view';
'require ui';
'require dom';
'require poll';
'require system-hub.api as API';
'require system-hub.theme as Theme';
return view.extend({
componentsData: [],
currentFilter: 'all',
load: function() {
return Promise.all([
API.getComponents(),
Theme.getTheme()
]);
},
render: function(data) {
var components = (data[0] && data[0].modules) || [];
var theme = data[1];
this.componentsData = components;
var view = E('div', { 'class': 'system-hub-dashboard' }, [
E('link', { 'rel': 'stylesheet', 'href': L.resource('system-hub/components.css') }),
// Header with filter tabs
E('div', { 'class': 'sh-components-header' }, [
E('h2', { 'class': 'sh-page-title' }, [
E('span', { 'class': 'sh-title-icon' }, '🧩'),
' System Components'
]),
this.renderFilterTabs()
]),
// Components grid
E('div', { 'class': 'sh-components-grid', 'id': 'components-grid' },
this.renderComponentsGrid(components, this.currentFilter)
)
]);
// Setup auto-refresh
poll.add(L.bind(function() {
return API.getComponents().then(L.bind(function(result) {
if (result && result.modules) {
this.componentsData = result.modules;
this.updateComponentsGrid();
}
}, this));
}, this), 30);
return view;
},
renderFilterTabs: function() {
var self = this;
var tabs = [
{ id: 'all', label: 'All Components', icon: '📦' },
{ id: 'security', label: 'Security', icon: '🛡️' },
{ id: 'monitoring', label: 'Monitoring', icon: '📊' },
{ id: 'network', label: 'Network', icon: '🌐' },
{ id: 'system', label: 'System', icon: '⚙️' }
];
return E('div', { 'class': 'sh-component-tabs cyber-tablist cyber-tablist--filters' },
tabs.map(function(tab) {
return E('button', {
'class': 'cyber-tab' + (self.currentFilter === tab.id ? ' is-active' : ''),
'type': 'button',
'data-filter': tab.id,
'click': function() {
self.handleFilterChange(tab.id);
}
}, [
E('span', { 'class': 'cyber-tab-icon' }, tab.icon),
E('span', { 'class': 'cyber-tab-label' }, tab.label)
]);
})
);
},
handleFilterChange: function(filterId) {
this.currentFilter = filterId;
this.updateComponentsGrid();
this.refreshFilterTabs();
},
refreshFilterTabs: function() {
var tabs = document.querySelectorAll('.sh-component-tabs .cyber-tab');
tabs.forEach(function(tab) {
var match = tab.getAttribute('data-filter') === this.currentFilter;
tab.classList.toggle('is-active', match);
}, this);
},
renderComponentsGrid: function(components, filter) {
var filtered = filter === 'all'
? components
: components.filter(function(c) { return c.category === filter; });
if (filtered.length === 0) {
return E('div', { 'class': 'sh-empty-state' }, [
E('div', { 'class': 'sh-empty-icon' }, '📦'),
E('div', { 'class': 'sh-empty-text' },
filter === 'all'
? 'No components found'
: 'No ' + filter + ' components found')
]);
}
return filtered.map(L.bind(this.renderComponentCard, this));
},
renderComponentCard: function(component) {
var self = this;
var isRunning = component.running;
var isInstalled = component.installed;
var statusClass = isRunning ? 'running' : (isInstalled ? 'stopped' : 'not-installed');
return E('div', {
'class': 'sh-component-card sh-component-' + statusClass,
'style': 'border-left: 4px solid ' + (component.color || '#64748b')
}, [
E('div', { 'class': 'sh-component-card-header' }, [
E('div', { 'class': 'sh-component-icon' }, component.icon || '📦'),
E('div', { 'class': 'sh-component-info' }, [
E('h3', { 'class': 'sh-component-name' }, component.name || component.id),
E('div', { 'class': 'sh-component-meta' }, [
E('span', { 'class': 'sh-component-version' },
'v' + (component.version || '0.0.9')),
E('span', { 'class': 'sh-component-category' },
component.category || 'other')
])
]),
E('div', {
'class': 'sh-status-indicator sh-status-' + statusClass,
'title': isRunning ? 'Running' : (isInstalled ? 'Stopped' : 'Not Installed')
})
]),
E('div', { 'class': 'sh-component-card-body' }, [
E('p', { 'class': 'sh-component-description' },
component.description || 'System component')
]),
E('div', { 'class': 'sh-component-card-actions' },
this.renderComponentActions(component)
)
]);
},
renderComponentActions: function(component) {
var self = this;
var actions = [];
if (component.installed) {
if (component.running) {
// Stop button
actions.push(
E('button', {
'class': 'sh-action-btn sh-btn-danger',
'click': function() { self.handleComponentAction(component.id, 'stop'); }
}, [
E('span', {}, '⏹️'),
' Stop'
])
);
// Restart button
actions.push(
E('button', {
'class': 'sh-action-btn sh-btn-warning',
'click': function() { self.handleComponentAction(component.id, 'restart'); }
}, [
E('span', {}, '🔄'),
' Restart'
])
);
// Dashboard button (if has dashboard)
if (component.package && component.package.includes('dashboard')) {
var dashboardUrl = '/cgi-bin/luci/admin/secubox/' + component.category + '/' + component.id;
actions.push(
E('a', {
'class': 'sh-action-btn sh-btn-primary',
'href': dashboardUrl
}, [
E('span', {}, '📊'),
' Dashboard'
])
);
}
} else {
// Start button
actions.push(
E('button', {
'class': 'sh-action-btn sh-btn-success',
'click': function() { self.handleComponentAction(component.id, 'start'); }
}, [
E('span', {}, '▶️'),
' Start'
])
);
}
} else {
// Install button
actions.push(
E('button', {
'class': 'sh-action-btn sh-btn-secondary',
'disabled': 'disabled',
'title': 'Manual installation required'
}, [
E('span', {}, '📥'),
' Not Installed'
])
);
}
return actions;
},
handleComponentAction: function(componentId, action) {
var self = this;
ui.showModal(_('Component Action'), [
E('p', {}, 'Performing ' + action + ' on ' + componentId + '...'),
E('div', { 'class': 'spinning' })
]);
// Call service action via system-hub API
API.serviceAction(componentId, action).then(function(result) {
ui.hideModal();
if (result && result.success) {
ui.addNotification(null,
E('p', {}, '✅ ' + componentId + ' ' + action + ' successful'),
'success');
// Refresh components
setTimeout(function() {
self.updateComponentsGrid();
}, 2000);
} else {
ui.addNotification(null,
E('p', {}, '❌ Failed to ' + action + ' ' + componentId),
'error');
}
}).catch(function(err) {
ui.hideModal();
ui.addNotification(null,
E('p', {}, '❌ Error: ' + (err.message || err)),
'error');
});
},
updateComponentsGrid: function() {
var grid = document.getElementById('components-grid');
if (grid) {
dom.content(grid, this.renderComponentsGrid(this.componentsData, this.currentFilter));
}
},
handleSaveApply: null,
handleSave: null,
handleReset: null
});