secubox-openwrt/package/secubox/luci-app-ksm-manager/htdocs/luci-static/resources/view/ksm-manager/audit.js
CyberMind-FR 31a87c5d7a feat(structure): reorganize luci-app packages into package/secubox/ + appstore migration
Major structural reorganization and feature additions:

## Folder Reorganization
- Move 17 luci-app-* packages to package/secubox/ (except luci-app-secubox core hub)
- Update all tooling to support new structure:
  - secubox-tools/quick-deploy.sh: search both locations
  - secubox-tools/validate-modules.sh: validate both directories
  - secubox-tools/fix-permissions.sh: fix permissions in both locations
  - .github/workflows/test-validate.yml: build from both paths
- Update README.md links to new package/secubox/ paths

## AppStore Migration (Complete)
- Add catalog entries for all remaining luci-app packages:
  - network-tweaks.json: Network optimization tools
  - secubox-bonus.json: Documentation & demos hub
- Total: 24 apps in AppStore catalog (22 existing + 2 new)
- New category: 'documentation' for docs/demos/tutorials

## VHost Manager v2.0 Enhancements
- Add profile activation system for Internal Services and Redirects
- Implement createVHost() API wrapper for template-based deployment
- Fix Virtual Hosts view rendering with proper LuCI patterns
- Fix RPCD backend shell script errors (remove invalid local declarations)
- Extend backend validation for nginx return directives (redirect support)
- Add section_id parameter for named VHost profiles
- Add Remove button to Redirects page for feature parity
- Update README to v2.0 with comprehensive feature documentation

## Network Tweaks Dashboard
- Close button added to component details modal

Files changed: 340+ (336 renames with preserved git history)
Packages affected: 19 luci-app, 2 secubox-app, 1 theme, 4 tools

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

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

139 lines
3.8 KiB
JavaScript

'use strict';
'require view';
'require secubox-theme/theme as Theme';
'require poll';
'require ui';
'require ksm-manager/api as KSM';
return view.extend({
load: function() {
return KSM.getAuditLogs(100, 0, '');
},
pollLogs: function() {
return KSM.getAuditLogs(100, 0, '').then(L.bind(function(data) {
var container = document.getElementById('audit-logs-container');
if (container) {
container.innerHTML = '';
container.appendChild(this.renderLogsTable(data.logs || []));
}
}, this));
},
render: function(data) {
var logs = data.logs || [];
poll.add(L.bind(this.pollLogs, this), 15);
return E([], [
E('h2', {}, _('Audit Logs')),
E('p', {}, _('Review all key management activities and access events.')),
E('div', { 'class': 'cbi-section' }, [
E('div', { 'class': 'cbi-section-node' }, [
E('button', {
'class': 'cbi-button cbi-button-action',
'click': L.bind(this.handleExportLogs, this)
}, _('Export Logs (CSV)')),
' ',
E('button', {
'class': 'cbi-button cbi-button-neutral',
'click': function() { window.location.reload(); }
}, _('Refresh'))
])
]),
E('div', { 'class': 'cbi-section' }, [
E('h3', {}, _('Activity Timeline')),
E('div', { 'class': 'cbi-section-node', 'id': 'audit-logs-container' }, [
this.renderLogsTable(logs)
])
])
]);
},
renderLogsTable: function(logs) {
if (!logs || logs.length === 0) {
return E('div', { 'class': 'cbi-value' }, [
E('link', { 'rel': 'stylesheet', 'href': L.resource('secubox-theme/secubox-theme.css') }),
E('em', {}, _('No audit logs available.'))
]);
}
var table = E('table', { 'class': 'table' }, [
E('tr', { 'class': 'tr table-titles' }, [
E('th', { 'class': 'th' }, _('Timestamp')),
E('th', { 'class': 'th' }, _('User')),
E('th', { 'class': 'th' }, _('Action')),
E('th', { 'class': 'th' }, _('Resource')),
E('th', { 'class': 'th center' }, _('Status'))
])
]);
logs.forEach(function(log) {
var statusColor = log.status === 'success' ? 'green' : 'red';
var actionColor = 'blue';
if (log.action && log.action.indexOf('delete') >= 0) {
actionColor = 'red';
} else if (log.action && log.action.indexOf('generate') >= 0) {
actionColor = 'green';
} else if (log.action && log.action.indexOf('retrieve') >= 0 || log.action && log.action.indexOf('view') >= 0) {
actionColor = 'orange';
}
table.appendChild(E('tr', { 'class': 'tr' }, [
E('td', { 'class': 'td' }, KSM.formatTimestamp(log.timestamp)),
E('td', { 'class': 'td' }, log.user || _('Unknown')),
E('td', { 'class': 'td' }, [
E('span', { 'style': 'color: ' + actionColor }, log.action || _('Unknown'))
]),
E('td', { 'class': 'td' }, log.resource || _('Unknown')),
E('td', { 'class': 'td center' }, [
E('span', { 'style': 'color: ' + statusColor }, log.status || _('Unknown'))
])
]));
});
return table;
},
handleExportLogs: function() {
KSM.getAuditLogs(1000, 0, '').then(function(data) {
var logs = data.logs || [];
if (logs.length === 0) {
ui.addNotification(null, E('p', _('No logs to export')), 'info');
return;
}
// Create CSV
var csv = 'Timestamp,User,Action,Resource,Status\n';
logs.forEach(function(log) {
csv += [
log.timestamp || '',
log.user || '',
log.action || '',
log.resource || '',
log.status || ''
].join(',') + '\n';
});
// Download
var blob = new Blob([csv], { type: 'text/csv' });
var url = window.URL.createObjectURL(blob);
var a = document.createElement('a');
a.href = url;
a.download = 'ksm-audit-logs-' + new Date().toISOString().split('T')[0] + '.csv';
a.click();
window.URL.revokeObjectURL(url);
ui.addNotification(null, E('p', _('Logs exported successfully')), 'info');
});
},
handleSaveApply: null,
handleSave: null,
handleReset: null
});