Commit Graph

42 Commits

Author SHA1 Message Date
Paul Donald a818ac89bb luci-base: correctness fixes
validation:

use correct argument position for apply

network:

spec.need_tag -> port.need_tag agrees with old lua compat

widgets:

rv.length is undefined, use firstChild

form:

Follow-up to 315dbfc749
checkDepends recursion fix and implement cache lookup

uci:

improve timeout and Promise handling

ui:

follow-up to 92381c3ca2
renderListing sort: put directories first
getActiveTabId: check isNaN for tab state
getScrollParent: fix evaluation logic
fadeOutNotification: implement immediate timeout
openDropdown: accelerate draw via getBoundingClientRect

form:
ensure FlagValue parse always resolves

fs:
parse all 'expect' keys in RpcReply

luci:

Use the same source of truth in both the check and the dispatch
for flushRequestQueue

string check for dom string additions

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2026-05-27 15:49:44 +03:00
Paul Donald 50a8d5325d luci-base: js linting fixes / ES6 treatment
prevent global variable bleed and reduce size somewhat

-cbi
-network
-protocol/static
-rpc
-tools/widgets
-tools/views
-uci

protocols

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2026-02-16 01:42:57 +01:00
Paul Donald 92381c3ca2 luci-base: jsdoc fixes
@name alone does not provide a linkable symbol.
@member and @memberof do.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2026-02-16 01:42:56 +01:00
Paul Donald 2a84e490e1 luci-base: amend ZoneSelect widget datatype
mandate proper firewall compliant zone names. Use
validation ucifw4zonename instead of uciname. The former
does not permit leading digits which

Now we only permit "*" if flags .allowany and .nocreate are
set. This is when the widget is used to select pre-existing
zones and the zone 'any' ("*") is added as a .value.
Creating a zone named "*" shall not be allowed.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2026-01-12 01:36:35 +01:00
Paul Donald 7c1696c420 luci-mod-network: Add IPSelect widget which eases selection of interface IPs
This widget is modeled after CBINetworkSelect, which is similar in nature.
It presents a dropdown box of all device IPs with an accompanying badge of the
device.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-10-28 21:01:29 +01:00
Paul Donald d3cbf6e685 luci-base: widgets: fix const -> let variable which is later reassigned
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-10-24 17:41:25 +02:00
Paul Donald fd0038d183 modules: fix device widgets for tunnel devices
Returning a device via getDevice() doesn't work out for tunnel configs,
like wireguard-wg0. Its dev property (for determining dev.getType()) is
always empty, but device is 'wireguard-wg0' and network is 'wg0'.

getDevice() returns an instantiated prototype which is not up, defeating
the purpose of querying its 'up' status.

When dealing with firewall zones and device widgets, what's interesting
is the dev. And getL3Device() is intended for this.

This effectively reverts commit f17ae7fd96
which attempted to address the problem of 'up' status; now calls via
getL3Device() get the correct up status.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-06-14 00:13:52 +02:00
Paul Donald ae5d91da90 treewide: vectorise iconography
Clear, crisp, resolution independent vector graphics replace the trusty
microscopic PNG. Some minor CSS changes were needed to constrain images
in some locations to make sure they don't consume too much space.

Iconography taken from Mate desktop theme with minor adjustments:

https://github.com/mate-desktop/mate-icon-theme/

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-06-12 18:55:53 +02:00
Paul Donald f17ae7fd96 luci-mod-network: widgets shall show devices that are online as online
follow-up to 832680bb84

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-04-24 00:13:26 +02:00
Paul Donald aa6924cd4c luci-base: prevent tools.widgets.ZoneSelect tracebacks
follow-up fix for 0be4ad51a0

It seems to have been this way for a while, for zone selections
involving the 'any' ('*') choice. firewall forwards.js has no
'this.allowany;' property on the widgets, so the any choice is absent,
leading to a traceback, caused by the 'src' widget, even though
this code block operates on the 'dst' value. Certain combinations of
'src' and 'dst' also triggered tracebacks.

This might not be the correct behaviour for this widget, but it does
prevent tracebacks caused by null values.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-04-23 14:21:41 +02:00
Paul Donald 832680bb84 luci-base: widgets shall show devices that are online as online
Tunnel devices which are up, show as down, since they don't have access
to any device status. The 'device' being enumerated is e.g.
'wireguard_wg0', a configuration for a tunnel interface, whose parent
is an 'ethernet' type.

That's a bug for another day. So they shall get parent device status.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-04-23 14:03:28 +02:00
Paul Donald 5be4cd129c luci-base: CBIDeviceSelect includes each device IP when includeips=true
For use when daemons whose interface config paradigm accept IP also.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-04-07 20:15:28 +02:00
Jan Pazdziora 66c4251cae luci-base: Allow "*" (== Any zone) in the firewall zone selection.
Signed-off-by: Jan Pazdziora <jan.pazdziora@code.adelton.com>
2025-01-30 17:55:42 +01:00
Jan Pazdziora ff52c0e358 luci-base: Enforce maximal firewall zone length in the Create / Assign scenario as well.
Signed-off-by: Jan Pazdziora <jan.pazdziora@code.adelton.com>
2025-01-22 15:48:09 +01:00
Paul Donald 7046a1cac1 luci-base: widgets; remove maximal firewall zone name length datatype
removes a075566dbb (and subsequent fixes)

enforcing a datatype on this widget generates the following error when
multiple zones are selected:

 Expecting: valid UCI identifier

(the error triggered for uciname). At its simplest: multiple selections
are no longer just a uciname, but multiple thereof.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-01-14 16:16:56 +01:00
Jan Pazdziora abaa26aa57 luci-base: addressing this.vstack[0] is undefined.
Signed-off-by: Jan Pazdziora <jan.pazdziora@code.adelton.com>
2025-01-10 23:14:49 +01:00
Paul Donald a67d68353b luci-base: Enforce maximal firewall zone name length with fw3 only
firewall3 enforces the zone name length. firewall4 does not.

https://github.com/openwrt/luci/pull/7549#issuecomment-2583290810

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-01-10 18:41:28 +01:00
Jan Pazdziora a075566dbb luci-base: Enforce maximal firewall zone length in the Create / Assign scenario as well.
Signed-off-by: Jan Pazdziora <jan.pazdziora@code.adelton.com>
2025-01-10 15:41:58 +01:00
Florian Eckert 5b706f52d7 luci-base: show default forwarding target in general firewall settings
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-10-23 02:38:01 +02:00
Luca Barbato 4728618896 luci-base: refactor network devices enumeration
And make sure to return an empty list if getDevices() returns null.

It happens with batadv.
2024-09-14 22:25:57 +02:00
Jo-Philipp Wich 37422e891a luci-base: revise array sorting
Refactor various sort operations throughout luci-base to use the new
L.naturalCompare() comparator function.

This primarily ensures that embedded numbers are sorted numerically and
not in a lexicographical way.

It also simplifies some code as a side effect.

Ref: #5899
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-07-27 17:32:58 +02:00
Jo-Philipp Wich 21784446c1 luci-app-firewall: fix setting unspecified zone on forwardings
Fixes: #5685
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-02-16 00:27:37 +01:00
Jo-Philipp Wich a812b26cb8 luci-base: widget.js: use firewall.getZoneColorStyle() in zone widgets
Use the new `firewall.getZoneColorStyle()` helper to apply background
color styles.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-11-11 13:00:50 +01:00
Jo-Philipp Wich 21995f0cf3 luci-base: tools.widgets: adjust zone selector dropdown markup
No functional changes but required for styling rules.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-11-10 11:57:43 +01:00
Vladislav Grigoryev 376af36975 luci-base: support loopback by widgets.NetworkSelect
Support the "loopback" interface by "widgets.NetworkSelect".
Enable the "loopback" option to include this interface.
Can be used to configure interface binding for services.

Signed-off-by: Vladislav Grigoryev <vg.aetera@gmail.com>
2021-08-15 02:56:45 +03:00
Jo-Philipp Wich 5c5b1340e5 luci-base: tools.widgets.NetworkSelect: properly validate multi select
Fixes: 2b99473f2 ("luci-base: tools.widget.NetworkSelect: disallow invalid network names")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-11-07 00:46:30 +01:00
Jo-Philipp Wich 2b99473f2c luci-base: tools.widget.NetworkSelect: disallow invalid network names
Fixes: #4523, #4573
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-11-07 00:41:56 +01:00
Helge Mader 95d004fc5d luci-base: fix widgets CBIUserSelect appending list on load
The user list was appended to the dropdown again each time the page is loaded.

Signed-off-by: Helge Mader <ma@dev.tdt.de>
2020-07-24 11:03:40 +02:00
Jo-Philipp Wich c89fd0a7f3 luci-base: tools/widgets.js: honour map readonly property too
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-14 17:12:47 +02:00
Jo-Philipp Wich 0f8e5b2536 luci-base: tools/widgets.js: honour readonly property
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-14 17:09:12 +02:00
Richard Yu 02a0291d14 luci-base: widgets.js: add user and group select
Signed-off-by: Richard Yu <yurichard3839@gmail.com>
2019-10-11 01:05:08 +08:00
Jo-Philipp Wich 34e73fd983 luci-base: widgets.js: fix display quirk in tools.widgets.DeviceSelect
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-11 12:44:34 +02:00
Jo-Philipp Wich 24aa675a46 luci-base: widgets.js: CBINetworkSelect: honour exclude option
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-08-16 09:49:11 +02:00
Jo-Philipp Wich d19e97bcb0 luci-base: widgets.js: support alias interfaces in CBIDeviceSelect
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-08-14 23:02:25 +02:00
Jo-Philipp Wich ac96b8be43 luci-base: widgets.js: implement CBIDeviceSelect netdev picker
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-07-22 16:31:25 +02:00
Jo-Philipp Wich 3c332c6075 luci-base: widgets.js: handle devices or subnets in CBIZoneForwards
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-07-22 16:30:33 +02:00
Jo-Philipp Wich e6ff0f39bb luci-base: widgets.js: CBIZoneSelect: improve initial rendering
Ref: https://github.com/openwrt/luci/issues/2889
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-07-22 08:58:59 +02:00
Jo-Philipp Wich d1841af2f0 luci-base: widgets.js: CBIZoneSelect: fix availability of "device" choice
Ref: https://github.com/openwrt/luci/issues/2889
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-07-22 08:40:38 +02:00
Jo-Philipp Wich 0be4ad51a0 luci-app-firewall: fix cbi form for rules
- Set src/dest defaults only in initial section create state, otherwise it
   is impossible to specify output rules
 - Get rid of dest_remote/dest_local widget switching and implement change
   logic directly in tools.widgets.CBIZoneSelect
 - Remove leftover debug code

Ref: https://github.com/openwrt/luci/issues/2889
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-07-21 22:35:24 +02:00
Jo-Philipp Wich f970c485cf treewide: switch to shared isObject(), toArray() and sortedKeys() helpers
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-07-07 20:11:35 +02:00
Jo-Philipp Wich f8e6caf552 luci-base: widgets.js: add textvalude representation for network select
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-07-07 19:12:59 +02:00
Jo-Philipp Wich a13dba8071 luci-base: add tools.widgets JS library
Add a tools.widgets library which bundles a number of useful, higher
level CBI widgets like firewall zone list or network interface dropdowns

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-07-07 15:36:26 +02:00