Commit Graph

696 Commits

Author SHA1 Message Date
Paul Donald 04b289c16d luci-base: add IPv6 LL and ULA validation
Also fix a bug in apply that assigned undefined to a value if
this.apply was used multiple times in the same caller.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2026-01-23 22:40:30 +01:00
Paul Donald fddc70391f luci-base: amend rpc to handle objects in param
This allows more complex and nested call constructions. Example:

const container_create = rpc.declare({
	object: 'frob',
	method: 'glob',
	params: { foo: { }, bar: { } },
});

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2026-01-23 04:27:51 +01:00
LASER-Yi d52b59cbf0 luci-base: fix JSDoc errors in form.Flag and form.Button
Fix incorrect @lends, @name, @class, and @classdesc annotations to match the actual
public API (LuCI.form.Flag and LuCI.form.Button).

Signed-off-by: LASER-Yi <liangyi0007@gmail.com>
2026-01-23 04:20:57 +01:00
Ramon Van Gorkom 720c96ce5b luci-base: make some tables better searchable
This changes the "name" in specific tables from being painted to
being rendered. This allows the use of "ctrl-f" in browsers to e.g.
search for firewall rule names.

Closes https://github.com/openwrt/luci/issues/7708
Signed-off-by: Ramon Van Gorkom <Ramon00c00@gmail.com>
Link: https://github.com/openwrt/luci/pull/8191
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2026-01-23 04:10:13 +01:00
Paul Donald b5cb136860 luci-base: fix null error
When working with JSONMap backed data sources in tables, sort
triggers a null error because this.state is not available.
Prevent the null error if it is unavailable.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2026-01-18 18:14:41 +01:00
Paul Donald f894913007 luci-base: document delbtntitle clonebtntitle
We also implement delbtntitle functionality for various *Table
types. This means one can implement a table and rename its
Delete button like so:

s.delbtntitle = _('Kill it with fire!');

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2026-01-18 18:14:41 +01:00
Paul Donald 2012b36215 luci-base: extend FileUpload; create DirectoryPicker
FileUpload was extended to accommodate the new features, since
it has nearly everything already. Create a DirectoryPicker
convenience wrapper.

Additions are:
-directory creation (dialogue); set directory_create to true
-directory select mode (instead of file); set directory_select to true

Also fix a bug in the breadcrumb generation which produced:

/foo » » bar

for /foo/bar if root_directory is not '/', and another bug that
merged links together when navigating upward again using the
breadcrumbs.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2026-01-18 18:05:21 +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 db91dbcdf7 luci-static: fix race condition when probing features
follow-up to a2fce95248

hasSystemFeature() inspects the cached result of
probeSystemFeatures() which needs to have completed.

Once all of the legacy (Lua) stuff is ready, this block
runs:

initDOM() {
	...
	L.loaded = true;
	document.dispatchEvent(new CustomEvent('luci-loaded'));
},

This commit now calls View.load() once system feature
probing has completed, and LuCI itself has loaded. This
ensures that the following load paradigm succeeds:

return view.extend({
	load() {
		return Promise.all([
			...,
			L.hasSystemFeature('x'),
		]);
	}, ...

The luci-loaded check prevents waiting when LuCI is already
loaded (the common case after initial page load), but the
listener handles the race condition where a View is
instantiated before initDOM() completes.

The flow:

If L.loaded is true: initDOM() already ran --> skip waiting,
proceed immediately.

If L.loaded is false: initDOM() hasn't run yet --> add
listener --> wait for it to complete.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-12-24 17:34:16 +01:00
Paul Donald 66d0d6eeda luci-base: propagate the multiple flag for RichListValue
This allows disabling selection of multiple entries by removing all
checkboxes from the dropdown list.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-12-13 18:58:45 +01:00
Richard Yu ece28ab5a4 luci-base: add responseProgress callback and stderr option
for LuCI.request and `fs.exec_direct()`.

This commit adds XHR response progress event option in luci.js and fs.js.
And diagnostics.js will use this new event to update command output.

This commit also adds a `stderr` option in `fs.exec_direct()`, and
requires a patch for `cgi-io`.

Currently `cgi-io` redirects stderr to /dev/null, which makes user
unable to see error messages. The patch adds a `stderr` option,
and if it's set to `1`, redirects stderr to stdout.

Signed-off-by: Richard Yu <yurichard3839@gmail.com>
Link: https://github.com/openwrt/luci/pull/7920
2025-12-12 16:39:55 +01:00
Paul Donald de5ddebeed luci-base: add a validation for fw4 zone names
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-12-03 16:51:47 +01:00
Eric Fahlgren 9717162fd0 luci-base: improve docs for uci.get_bool
The get_bool function documentation was missing an option value, so
add it.  Provide a link into the developer's guide on how it's used
in scripts, for better background.

Signed-off-by: Eric Fahlgren <ericfahlgren@gmail.com>
2025-11-12 22:17:23 +01:00
Paul Donald 1da88cc888 luci-base: fix static proto trace-back when a netmask is set but no IP is set
A trace-back is produced when a netmask is set, and the contents of the IPv4
address field are removed or otherwise unset.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-10-30 18:53:14 +01:00
Paul Donald 7722292e88 luci-mod-network: prevent loading non-existent protocol/bonding
Bonding is configured under interface properties, and handled by netifd.
luci-proto-bonding was removed, even if the proto-bonding package is still
useful. This change prevents the trace-back from attempting to load
luci-proto-bonding.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-10-30 14:30:46 +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
David Härdeman 545de2a4b5 luci-base: add ability to hide section titles
The rationale here is that tabbed CBIMaps were introduced in commit
082fd9ff10.

With tabbed maps, code could typically look like this:

	m = new form.Map('foobar', _('FooBar'));
	m.tabbed = true;
	s = m.section(form.TypedSection, 'foo', _('foo Settings'));

The problem is that the title of "s" will be used as the name of the tab
rendered in "m", but also rendered as an <h3> right below the tab. IOW,
the same information will be presented twice, which looks weird.

Doing this instead...

	m = new form.Map('foobar', _('FooBar'));
	m.tabbed = true;
	s = m.section(form.TypedSection, 'foo');

...means that the superfluous <h3> won't be rendered (since "s" has no
title), but the tab will then simply have the name of the section
("foo"), which can't be translated (bad).

After this change, the tabbed map can be written like this:

	m = new form.Map('foobar', _('FooBar'));
	m.tabbed = true;
	s = m.section(form.TypedSection, 'foo', _('foo Settings'));
	s.hidetitle = true;

Which will give the Map tab the name "foo Settings", but won't add a
title for the TypedSection right under the tab.

Signed-off-by: David Härdeman <david@hardeman.nu>
2025-10-23 17:05:03 +02:00
Andy Chiang 0563adb234 luci-app: fix translation strings
The current handling method introduces extraneous spaces into the translations.
For instance, 'System Log', which is correctly translated to Japanese as 'システムログ' (without extra spaces), is being displayed as 'システム ログ' under the current approach.
Other CJK/Southeast Asian languages are experiencing similar issues, including Chinese, Thai, and Lao.
Therefore, these elements should be translated together as a single unit, rather than separately.

Signed-off-by: Andy Chiang <AndyChiang_git@outlook.com>
2025-10-23 00:16:35 +02:00
Andy Chiang f83fe35dae modules: fix default values
fix default values for luci-base and luci-mod-{dashboard,status,system}

Signed-off-by: Andy Chiang <AndyChiang_git@outlook.com>
2025-10-21 16:12:03 +02:00
Paul Donald 0a6180d1cc luci-base: remodel the LogreadBox after the syslog viewer
Remodeled the CBILogreadBox after the syslog viewer. Also
updated to use ubus log read, and drops the use of the logread binary
(logread is broken on snapshots). The JSON output from ubus is nice
enough to work with.

One potential drawback is that all log entries are sent to the browser
(as it always has been), and no on-device pre-filtering is available yet
except for line count.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-10-20 21:11:10 +02:00
Florian Eckert 7b6b0d0139 luci-base: add getPending ubus function call
Exporting the ubus “pending” information so that this information can be
used in LuCI.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2025-10-10 14:08:24 +02:00
Sergey Ponomarev 6c5f78ffd2 luci-base: form.js, luci.js, network.js: fix typos and add articles
Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
[ minor adjustments ]
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-10-08 00:40:00 +02:00
Sergey Ponomarev ebfb4f73ec luci-base: form.js depends(): make value optional
Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
2025-10-08 00:39:59 +02:00
James Haggerty a2fce95248 luci-base: don't render until luci-loaded is done
Because the setupDOM/initDOM methods do strange things related
to the old lua server rendered templates
(like remove all the elements currently hidden by dependencies...),
we want to be sure that these have finished before the view
itself renders.

This also ensures that any caching (e.g. from probeSystemFeatures)
is finished before the view render.

This feels like a hacky fix, but it's not clear to me what the best
one is.

Signed-off-by: James Haggerty <james.haggerty@morsemicro.com>
2025-10-07 16:16:51 +02:00
TGSAN 77e01d3d8c luci-base: standards compliant dropdown fix for mobile keyboards
Signed-off-by: TGSAN <h@iloli.tv>
2025-09-18 14:48:44 +02:00
Paul Donald 3ec92523dc luci-base: jsdoc RangeSlider
Small correction.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-08-01 15:33:40 +02:00
Paul Donald b7c08475e7 luci-base: jsdoc Slider -> RangeSlider and fixes for RangeSlider
The usecalc property suffers from recursive calculation; that is, its
output becomes its input at the next save. It is not known in advance
whether a stored value is one that was calculated or not. So this part
was removed. The getCalculatedValue() function is retained should it be
desirable to get this value.

The 'optional' property was removed since it didn't do anything.
The 'validate' property is now correctly bound.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-07-31 00:31:38 +02:00
Ramon Van Gorkom 5cb2eb619e luci-base: allow submitting new value in android chromium
Update ui.js to allow submitting from dropdown on android chromium.

Signed-off-by: Ramon Van Gorkom <Ramon00c00@gmail.com>
2025-07-28 22:30:58 +02:00
Paul Donald b9145754d2 luci-base: give TextValue form elements separate readonly and disabled
textarea widgets have more value as readonly and not disabled, than
just disabled: you can scroll through them when they're readonly and
not disabled.

So give the form element separate readonly and disabled properties, so
textarea elements defined as readonly with a large amount of content
still cannot be modified, but at least the whole content can be viewed
(because the textarea scrollbars still function).

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-07-03 17:11:27 +02:00
Paul Donald 3c16c59007 luci-base: implement a range slider input/control
This control is used to set values within a predefined range, and uses
the HTML 'input' element of type 'range' supported in all browsers.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-06-24 15:20:50 +02:00
Paul Donald 9c0f071bbd luci-base: check for wifi system feature before Promise.all
Allows the hasSystemFeature call to complete before executing the
Promise bundle.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-06-22 22:35:46 +02:00
Paul Donald f5da7a6016 luci-base: implement Virtual Routing and Forwarding (VRF) options
VRF in netifd is now in main. See:
https://github.com/openwrt/netifd/pull/38/
https://github.com/openwrt/openwrt/commit/15c2ca0a834752cc9505751fc6d2f51861d34dfd

VRF netifd management was added to 24.10 in
https://github.com/openwrt/openwrt/pull/19125

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-06-17 00:08:06 +02:00
Paul Donald 750aa9e25b treewide: vectorise iconography
follow-up to ae5d91da90

tweaks to more closely resemble the old png iconography

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-06-15 23:03:33 +02:00
Paul Donald 22bcf11db7 treewide: vectorise iconography
follow-up to ae5d91da90

tweaks to more closely resemble the old png iconography

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-06-15 17:46:31 +02:00
Paul Donald fa6ca8a618 treewide: vectorise iconography
follow-up to ae5d91da90

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-06-14 00:13:52 +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 85fde70cd2 treewide: vectorise iconography
follow-up to ae5d91da90

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-06-13 15:55:41 +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 fabaa87666 luci-base: fix jsdoc errors in form.js
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-06-10 00:13:05 +02:00
Paul Donald 63bd859e17 luci-base: set output elements to use output element type
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-06-10 00:06:17 +02:00
Joseph Mory 55c93e60b4 luci-base: fix table option does not show in non-Bootstrap themes when it has depends
Signed-off-by: Joseph Mory <morytyann@outlook.com>
2025-06-02 22:01:49 +03:00
Dirk Brenken 723de2a7f2 Merge pull request #7746 from dwfreed/patch-1
luci-base: remove bad Unicode on clone button
2025-06-01 07:05:10 +02:00
Doug Freed c71dbb61ca luci-base: remove bad Unicode on clone button
This Unicode character is intended to be followed by 2 more characters
which are combined. It's entirely unnecessary, so just remove it.

Fixes: #7754
Signed-off-by: Doug Freed <dwfreed@mtu.edu>
2025-05-01 12:42:07 -05:00
Paul Donald 089903105f Revert "luci-base: override the load() function to return boolean for FlagValue"
This reverts commit 1355a6fa25.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-04-30 22:21:01 +02:00
Paul Donald 1355a6fa25 luci-base: override the load() function to return boolean for FlagValue
In the underlying uci system, all variables are effectively strings, so
for those configuration values which serve as 'boolean' flags, we need
to coerce the various forms into a real boolean. Only the following
string values result in true: 1|on|true|yes|enabled. Otherwise, false.

Checkboxes now fill correctly.

"Unchanged" configurations may write changed values as the Flag values
are coerced to '1' or '0' on write, but the configuration behaviour
remains synonymous.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-04-25 17:17:51 +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 68082d24e6 luci-base: spell fix
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2025-04-21 23:32:13 +02:00