From 46e6b9ba44a33937c7ba89273da9d2f7fde985ad Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= Date: Tue, 11 Oct 2022 22:17:34 +0300 Subject: [PATCH] luci-app-firewall: make a dropdown list for flow offloading options MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Either software or hardware offloading is in use at a time. Make a dropdown list for them to reflect this on the firewall section of LuCI. Closes #6247 Signed-off-by: Arınç ÜNAL Signed-off-by: Paul Donald --- .../resources/view/firewall/zones.js | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js index a91d4cb975..fdb77c9116 100644 --- a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js +++ b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js @@ -79,16 +79,22 @@ return view.extend({ s.anonymous = true; s.addremove = false; - o = s.option(form.Flag, 'flow_offloading', - _('Software flow offloading'), - _('Software based offloading for routing/NAT')); - o.optional = true; - - o = s.option(form.Flag, 'flow_offloading_hw', - _('Hardware flow offloading'), - _('Requires hardware NAT support.')); - o.optional = true; - o.depends('flow_offloading', '1'); + o = s.option(form.RichListValue, "offloading_type", _("Offloading type")); + o.value('0', _("None")); + o.value('1', _("Software offloading"), _('Software based offloading for routing with/without NAT.')); + o.value('2', _("Hardware offloading"), _('Hardware based offloading for routing with/without NAT. Requires hardware support.')); + o.optional = false; + o.load = function (section_id) { + var flow_offloading = uci.get('firewall', section_id, 'flow_offloading'); + var flow_offloading_hw = uci.get('firewall', section_id, 'flow_offloading_hw'); + return (flow_offloading === '1') + ? (flow_offloading_hw === '1' ? '2' : '1') + : '0'; + }; + o.write = function(section_id, value) { + uci.set('firewall', section_id, 'flow_offloading', value === '0' ? null : '1'); + uci.set('firewall', section_id, 'flow_offloading_hw', value === '2' ? '1' : null); + }; } -- 2.30.2