secubox-openwrt/package/secubox/luci-app-traffic-shaper/htdocs/luci-static/resources/view/traffic-shaper/classes.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

137 lines
4.2 KiB
JavaScript

'use strict';
'require view';
'require secubox-theme/theme as Theme';
'require network';
'require form';
'require ui';
'require uci';
'require traffic-shaper/api as API';
return view.extend({
load: function() {
return Promise.all([
API.listClasses(),
L.resolveDefault(L.network.getDevices(), [])
]);
},
render: function(data) {
var classes = data[0].classes || [];
var devices = data[1] || [];
var m, s, o;
m = new form.Map('traffic-shaper', _('Traffic Classes'),
_('Configure traffic classes for bandwidth allocation and prioritization. Each class defines guaranteed (rate) and maximum (ceil) bandwidth limits.'));
s = m.section(form.GridSection, 'class', _('Traffic Classes'));
s.anonymous = false;
s.addremove = true;
s.sortable = true;
o = s.option(form.Flag, 'enabled', _('Enable'));
o.default = '1';
o.editable = true;
o = s.option(form.Value, 'name', _('Name'));
o.placeholder = _('Descriptive name');
o.rmempty = false;
o = s.option(form.ListValue, 'priority', _('Priority'));
o.value('1', _('Highest (1)'));
o.value('2', _('High (2)'));
o.value('3', _('Medium-High (3)'));
o.value('4', _('Medium (4)'));
o.value('5', _('Normal (5)'));
o.value('6', _('Medium-Low (6)'));
o.value('7', _('Low (7)'));
o.value('8', _('Lowest (8)'));
o.default = '5';
o.rmempty = false;
o = s.option(form.Value, 'rate', _('Guaranteed Rate'));
o.placeholder = '1mbit';
o.datatype = 'string';
o.rmempty = false;
o.description = _('Minimum guaranteed bandwidth (e.g., 1mbit, 512kbit, 10mbit)');
o.validate = function(section_id, value) {
if (!value || !value.match(/^\d+[kmg]?bit$/i)) {
return _('Invalid bandwidth format. Use format like: 1mbit, 512kbit, 10mbit');
}
return true;
};
o = s.option(form.Value, 'ceil', _('Maximum Rate (Ceil)'));
o.placeholder = '10mbit';
o.datatype = 'string';
o.rmempty = false;
o.description = _('Maximum allowed bandwidth (e.g., 10mbit, 1mbit, 100mbit)');
o.validate = function(section_id, value) {
if (!value || !value.match(/^\d+[kmg]?bit$/i)) {
return _('Invalid bandwidth format. Use format like: 1mbit, 512kbit, 10mbit');
}
return true;
};
o = s.option(form.ListValue, 'interface', _('Interface'));
o.value('wan', _('WAN'));
o.value('lan', _('LAN'));
devices.forEach(function(dev) {
if (dev.getName() && dev.getName() !== 'lo') {
o.value(dev.getName(), dev.getName());
}
});
o.default = 'wan';
o.rmempty = false;
// Add priority color indicators
s.modaltitle = function(section_id) {
var name = this.cfgsections().indexOf(section_id);
return _('Edit Traffic Class') + ' "' + (uci.get('traffic-shaper', section_id, 'name') || section_id) + '"';
};
// Custom rendering for priority visualization
s.renderRowActions = function(section_id) {
var priority = parseInt(uci.get('traffic-shaper', section_id, 'priority') || 5);
var colorClass = API.getPriorityColor(priority);
var actions = form.GridSection.prototype.renderRowActions.call(this, section_id);
var row = actions.parentNode;
if (row && row.classList) {
row.classList.add(colorClass);
}
return actions;
};
return m.render().then(function(rendered) {
// Add help text at the top
var helpBox = E('div', {
'class': 'cbi-section',
'style': 'background: #e8f4f8; border-left: 4px solid #0088cc; padding: 1em; margin-bottom: 1em;'
}, [
E('h3', { 'style': 'margin-top: 0;' }, _('Traffic Class Guidelines')),
E('ul', { 'style': 'margin-bottom: 0;' }, [
E('li', {}, _('Priority 1-2: Critical traffic (VoIP, gaming, real-time)')),
E('li', {}, _('Priority 3-4: Important traffic (video streaming, VPN)')),
E('li', {}, _('Priority 5-6: Normal traffic (web browsing, email)')),
E('li', {}, _('Priority 7-8: Bulk traffic (downloads, backups)')),
E('li', {}, _('Rate: Guaranteed minimum bandwidth allocated to this class')),
E('li', {}, _('Ceil: Maximum bandwidth this class can use when available'))
])
]);
rendered.insertBefore(helpBox, rendered.firstChild);
return E('div', {}, [
E('link', { 'rel': 'stylesheet', 'href': L.resource('secubox-theme/secubox-theme.css') }),
rendered
]);
});
},
handleSaveApply: null,
handleSave: null,
handleReset: null
});