secubox-openwrt/package/secubox/luci-app-bandwidth-manager/htdocs/luci-static/resources/view/bandwidth-manager/overview.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

173 lines
5.4 KiB
JavaScript

'use strict';
'require view';
'require secubox-theme/theme as Theme';
'require bandwidth-manager/api as API';
return L.view.extend({
load: function() {
return Promise.all([
API.getStatus(),
API.listRules(),
API.listQuotas()
]);
},
render: function(data) {
var status = data[0] || {};
var rules = data[1] || [];
var quotas = data[2] || [];
var v = E('div', { 'class': 'cbi-map' }, [
E('link', { 'rel': 'stylesheet', 'href': L.resource('secubox-theme/secubox-theme.css') }),
E('h2', {}, _('Bandwidth Manager - Overview')),
E('div', { 'class': 'cbi-map-descr' }, _('QoS rules, client quotas, and traffic control'))
]);
// System status
var statusSection = E('div', { 'class': 'cbi-section' }, [
E('h3', {}, _('System Status')),
E('div', { 'class': 'table' }, [
E('div', { 'class': 'tr' }, [
E('div', { 'class': 'td left', 'width': '25%' }, [
E('strong', {}, _('QoS Engine: ')),
status.qos_active ?
E('span', { 'style': 'color: green' }, '● ' + _('Active')) :
E('span', { 'style': 'color: red' }, '● ' + _('Inactive'))
]),
E('div', { 'class': 'td left', 'width': '25%' }, [
E('strong', {}, _('Interface: ')),
E('span', {}, status.interface || 'br-lan')
]),
E('div', { 'class': 'td left', 'width': '25%' }, [
E('strong', {}, _('SQM: ')),
status.sqm_enabled ?
E('span', { 'style': 'color: green' }, '✓ ' + _('Enabled')) :
E('span', {}, '✗ ' + _('Disabled'))
]),
E('div', { 'class': 'td left', 'width': '25%' }, [
E('strong', {}, _('Rules: ')),
E('span', { 'style': 'font-size: 1.3em; color: #0088cc' }, String(status.rule_count || 0))
])
])
])
]);
v.appendChild(statusSection);
// Traffic statistics
if (status.stats) {
var statsSection = E('div', { 'class': 'cbi-section' }, [
E('h3', {}, _('Traffic Statistics')),
E('div', { 'class': 'table' }, [
E('div', { 'class': 'tr' }, [
E('div', { 'class': 'td left', 'width': '50%' }, [
E('strong', {}, '⬇ ' + _('Download: ')),
E('span', {}, this.formatBytes(status.stats.rx_bytes || 0))
]),
E('div', { 'class': 'td left', 'width': '50%' }, [
E('strong', {}, '⬆ ' + _('Upload: ')),
E('span', {}, this.formatBytes(status.stats.tx_bytes || 0))
])
]),
E('div', { 'class': 'tr' }, [
E('div', { 'class': 'td left', 'width': '50%' }, [
E('strong', {}, _('RX Packets: ')),
E('span', {}, String(status.stats.rx_packets || 0))
]),
E('div', { 'class': 'td left', 'width': '50%' }, [
E('strong', {}, _('TX Packets: ')),
E('span', {}, String(status.stats.tx_packets || 0))
])
])
])
]);
v.appendChild(statsSection);
}
// Active rules summary
if (rules.length > 0) {
var rulesSection = E('div', { 'class': 'cbi-section' }, [
E('h3', {}, _('Active QoS Rules'))
]);
var rulesTable = E('table', { 'class': 'table' }, [
E('tr', { 'class': 'tr table-titles' }, [
E('th', { 'class': 'th' }, _('Name')),
E('th', { 'class': 'th' }, _('Type')),
E('th', { 'class': 'th' }, _('Target')),
E('th', { 'class': 'th' }, _('Download Limit')),
E('th', { 'class': 'th' }, _('Priority'))
])
]);
rules.slice(0, 5).forEach(function(rule) {
if (!rule.enabled)
return;
rulesTable.appendChild(E('tr', { 'class': 'tr' }, [
E('td', { 'class': 'td' }, rule.name),
E('td', { 'class': 'td' }, rule.type),
E('td', { 'class': 'td' }, rule.target),
E('td', { 'class': 'td' }, rule.limit_down > 0 ? rule.limit_down + ' kbit/s' : _('Unlimited')),
E('td', { 'class': 'td' }, String(rule.priority))
]));
});
rulesSection.appendChild(rulesTable);
v.appendChild(rulesSection);
}
// Client quotas summary
if (quotas.length > 0) {
var quotasSection = E('div', { 'class': 'cbi-section' }, [
E('h3', {}, _('Client Quotas'))
]);
var quotasTable = E('table', { 'class': 'table' }, [
E('tr', { 'class': 'tr table-titles' }, [
E('th', { 'class': 'th' }, _('Client')),
E('th', { 'class': 'th' }, _('MAC')),
E('th', { 'class': 'th' }, _('Usage')),
E('th', { 'class': 'th' }, _('Limit')),
E('th', { 'class': 'th' }, _('Progress'))
])
]);
quotas.slice(0, 5).forEach(function(quota) {
var progressColor = quota.percent > 90 ? 'red' : (quota.percent > 75 ? 'orange' : 'green');
quotasTable.appendChild(E('tr', { 'class': 'tr' }, [
E('td', { 'class': 'td' }, quota.name || quota.mac),
E('td', { 'class': 'td' }, E('code', {}, quota.mac)),
E('td', { 'class': 'td' }, quota.used_mb + ' MB'),
E('td', { 'class': 'td' }, quota.limit_mb + ' MB'),
E('td', { 'class': 'td' }, [
E('div', { 'style': 'background: #eee; width: 100px; height: 10px; border-radius: 5px;' }, [
E('div', {
'style': 'background: ' + progressColor + '; width: ' + Math.min(quota.percent, 100) + '%; height: 100%; border-radius: 5px;'
})
]),
E('small', {}, quota.percent + '%')
])
]));
});
quotasSection.appendChild(quotasTable);
v.appendChild(quotasSection);
}
return v;
},
formatBytes: function(bytes) {
if (bytes === 0) return '0 B';
var k = 1024;
var sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
var i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
},
handleSaveApply: null,
handleSave: null,
handleReset: null
});