Commit graph

500 commits

Author SHA1 Message Date
Jo-Philipp Wich
f2fa59e89a luci-base: form.js: rework stacked modal CBI map logic
Only stack a new modal CBI map on top of the currently displayed modal one
if the related map or section differs. This prevents misbehavior when
switching the protocol of interfaces.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-05-06 13:42:54 +02:00
Jo-Philipp Wich
180d39dcd2 luci-base: ui: resolve aliases and rewrites on obtaining menu node children
Extend LuCI.ui.menu.getChildren() to resolve aliases and rewrites prior to
returning the menu nodes. This allows aliasing entire menu trees instead of
just single pages.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-04-28 16:06:25 +02:00
Jo-Philipp Wich
d29400ea09 luci-base: ui: fix null access in ui.Table.update()
Fixes: #5702
Fixes: e0e6989a4a ("luci-base: introduce new LuCI.ui.Table class")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-02-27 20:33:02 +01:00
Jo-Philipp Wich
d8ed1e7b7d luci-base: form.js: add column sorting to TableSections and GridSections
Add ability to reorder TableSection and GridSection rows by clicking on
column headers.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-02-24 23:45:18 +01:00
Jo-Philipp Wich
e0e6989a4a luci-base: introduce new LuCI.ui.Table class
Introduce a new `LuCI.ui.Table` class to simplify generating HTML tables
for data output and turn the existing `cbi_update_table()` procedure into
a wrapper around this new facility.

Tables generated by the new class closely resemble the old markup but
provide additional sorting capabilities.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-02-24 23:45:17 +01:00
Jo-Philipp Wich
5663fd596b luci-base: properly handle promise targets in Request.request()
Under some circumstances, ubus RPC requests may be initiated while LuCI is
still resolving the `rpcBaseURL` value. In this situation, the `target`
argument of the `request()` call will be a pending promise object which
results in an invalid URL when serialized by `expandURL()`, leading to an
`Failed to execute 'open' on 'XMLHttpRequest': Invalid URL` exception.

This commonly occured on the index status page which immediately initiates
ubus RPC calls on load to discover existing status page partials.

Solve the issue by filtering the given `target` argument through
`Promise.resolve()` before expanding the URL and initiating the actual
request.

Fixes: #3747
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-02-21 14:59:16 +01: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
63d9bcb682 luci.js: remove unsafe fallback code from dom.parse()
Do not fallback to .innerHTML if DOMParser() failed for whatever reason.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-12-23 17:09:13 +01:00
Jo-Philipp Wich
993151504e luci-base: form.js: do not execute embedded script code in stripTags()
Instead of relying on .innerHTML which executes embedded script code to
parse a given HTML fragment, use dom.parse() which utilizies DOMParser()
internally in order to extract textContent in a safe manner.

Fixes: FS#4199
Ref: https://bugs.openwrt.org/index.php?do=details&task_id=4199
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-12-23 17:08:21 +01:00
Jo-Philipp Wich
008bd89310 luci-base: cbi.js: properly handle non-strings in %h and %q formats
Only replace null, objects and function values with the empty string but
return booleans and numbers as strings.

Spotted while debugging #5587.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-12-09 16:25:50 +01:00
Jo-Philipp Wich
604c009059 luci-base: ui.js: avoid error tooltips overlapping dropdowns
Fixes: #5588
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-12-09 15:29:36 +01:00
Jo-Philipp Wich
f5fbecf132 luci-base: form.js: implement AbstractValue.retain property
The new `retain` boolean property controls whether the related option value
is purged from the configuration when the dependencies of the option are
not satisifed.

Ref: #5579
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-12-09 15:11:07 +01:00
Jo-Philipp Wich
ff4f52983e
Merge pull request #5540 from jow-/wireguard-peer-gridsection
Implement nested grid section support and use it for wireguard peer config
2021-12-02 10:54:36 +01:00
Jo-Philipp Wich
e982c05671 luci-base: cbi.js: properly handle falsy values in cbi_update_table()
Fixes: #5544
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-11-23 19:12:18 +01:00
Jo-Philipp Wich
1c798d1a08 luci-base: form.js: allow nesting Grid and Table sections
Implement a simple view stack within the modal overlay to allow the modal
edit dialog of a table or grid section to render another table or grid
section which recursively opens another modal edit dialog.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-11-22 09:43:29 +01:00
Jo-Philipp Wich
6507b1f04b
Merge pull request #5442 from lvoegl/validation-error-popup-message
luci-base: show validation message in save error
2021-11-18 11:39:45 +01:00
Jo-Philipp Wich
de4c4f7fd4 luci-base: luci.js: fix undefined variable access in Request.request()
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-11-16 13:06:03 +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
d775279dbd luci-base: firewall.js: add getZoneColorStyle() helper
The getZoneColorStyle() function will produce CSS style properties that
describe the color value of the zone. The color declaration is divided
into a CSS variable called `--zone-color-rgb` which holds the RGB value
of the color and a `background-color` property assigning these values
as background property.

This allows themes to override the color with derived values, e.g. by
applying an alpha channel.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-11-11 13:00:50 +01:00
Jo-Philipp Wich
d4092b15ce luci-base: network.js: ignore wireless ifname patterns on retrieving devices
Only treat the given identifier as Linux netdev name if we can find a
corresponding entry in the device info cache and do not consider strings
starting with "wlan", "ath" or "wl" to be existing devices.

This fixes incorrectly adding wireless sections as ifnames to network
interfaces when the wifi-iface section name begins with one of the
`iface_patterns_wireless` patterns.

Fixes: #5069
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-11-10 11:57:43 +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
Jo-Philipp Wich
ad360ec00a luci-base: add legacy directory, file and device validator JS stubs
Fixes: #5466
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-10-28 15:08:35 +02:00
Lukas Voegl
735d949bfc luci-base: show validation message in error
Signed-off-by: Lukas Voegl <lvoegl@tdt.de>
2021-10-26 12:31:05 +02:00
Jo-Philipp Wich
63034c3607 luci-base: remove further related section types on deleting network
When removing a `config interface` section in `/etc/config/network`, drop
related `rule` and `rule6` sections too, as well as related `dhcp` sections
in `/etc/config/dhcp`.

Ref: https://forum.openwrt.org/t/grooming-etc-config/109764/7
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-10-22 19:44:43 +02:00
Jo-Philipp Wich
e4d24f07c9 luci-base: dispatcher: rework dispatching and menu filtering logic
- Prefer nodes that do not require authentication over nodes that do
 - Honour ACL dependencies while resolving firstchild nodes
 - Consider currently active session while scanning menu tree instead
   of only loading effective ACLs when a login node is encountered
 - Do not consider nodes for firstchild dispatching which specify a
   special "firstchild_ineligible" property
 - Hide menu nodes that have no accessible children

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-10-11 20:38:04 +02:00
Jo-Philipp Wich
0a31efc858 luci-base: cbi.js: use IEC 80000-13 units to format base 2 byte values
Fixes: #5354
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-10-08 20:53:45 +02:00
Jo-Philipp Wich
df75163e68 luci-base: form.js: add drag-drop sorting support for mobile
Fixes: #5416
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-10-08 16:54:38 +02: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
6045f584ce
Merge pull request #5239 from aparcar/seconds 2021-08-11 18:57:20 +02:00
Florian Eckert
d81564e064
Merge pull request #5154 from TDT-AG/pr/20210628-luci-compat
luci-base: prevent empty field for adding new entry
2021-08-11 09:35:24 +02:00
Helge Mader
58447640eb luci-base: prevent empty field for adding new entry
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2021-08-11 08:48:41 +02:00
Paul Spooren
292e198884 luci-base: fix request timeout docstring
The `timeout` is defined in milliseconds, not seconds.

Signed-off-by: Paul Spooren <mail@aparcar.org>
2021-08-09 09:39:21 -10:00
Jo-Philipp Wich
7d9ab8d4a7 luci-base: fix off-by-one in cbi_update_table()
Fixes: #5189
Fixes: f919635310 ("luci-base: batch DOM updates to prevent slowdown")
Ref: f919635310 (commitcomment-53495580)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-07-15 08:13:31 +02:00
Olli Asikainen
f919635310 luci-base: batch DOM updates to prevent slowdown
Signed-off-by: Olli Asikainen <olli.asikainen@gmail.com>
2021-07-13 19:55:26 +02:00
DeYu Liu
0e4b4c5b42 luci-base: Fix time display error
Signed-off-by: DeYu Liu <vito_sam@outlook.com>
2021-07-06 13:57:54 +08:00
Jo-Philipp Wich
00e41c3c49 luci-base: validation: disallow mutlicast MACs by default
Extend the MAC address validator to disallow multicast MAC addresses and
add a new optional validator option to require multicast MACs instead of
unicast ones.

Fixes: #5166
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-07-03 20:12:33 +02:00
Florian Eckert
1a2b7fef6c luci-base: do not add validation for named section if readonly is set
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2021-07-01 15:54:51 +02:00
Helge Mader
87215e3d1b luci-base: prevent empty field for adding new named section in JavaScript
Suggested-by: Helge Mader <ma@dev.tdt.de>
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2021-07-01 13:10:15 +02:00
Florian Eckert
80262bb9a7 luci-base: change css class btn to cbi-button
The css class btn is only a valid input element on lua rendered pages.
Use instead cbi-button for javascript rendered pages.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2021-07-01 13:10:15 +02:00
Florian Eckert
97e673b72c luci-base: use button tag instead of input tag on named section add
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2021-07-01 13:09:37 +02:00
Jo-Philipp Wich
1bcb12570c luci-base: network.js: add link status information accessors
Fixes: #5121
Fixes: 8c71b1d01e ("luci-mod-network: add port status to bridge vlan filter matrix")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-06-12 18:42:37 +02:00
Jo-Philipp Wich
e3bf521edb luci-base: ui.js: determine dropdown position relative to overflow parent
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-06-09 21:55:43 +02:00
David Bauer
516c58e133
Merge pull request #5070 from blocktrron/pr-luci-wifi6
luci-mod-network: add 802.11ax HE support
2021-06-05 19:04:11 +02:00
David Bauer
4b17f8baa3 luci-base: add 11ax HW / HT modes
Add the known values returned for 802.11ax HW as well as HT modes to the
respective method descriptions.

Signed-off-by: David Bauer <mail@david-bauer.net>
2021-06-05 16:24:19 +02:00
David Bauer
f35e877dc6 luci-mod-network: add 802.11ax HE support
This commit adds the ability to configure HE-modes for radios
(HE20 / HE40 / HE80 / HE160) as well as HE rate information in the
assiciation view.

Tested-on: Ubiquiti UniFi 6 Lite / LR

Signed-off-by: David Bauer <mail@david-bauer.net>
2021-06-05 16:24:19 +02:00
Jo-Philipp Wich
e35041e0a8 luci-base: network.js: sorting fixes
Ensure that sort callbacks consistently return [-N .. 0 .. +N] values
instead of just true/false.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-06-03 09:51:09 +02:00
Niels Widger
c7b7b42cd3 treewide: Update JS using luci-rpc getHostHints
Update frontend JS code which uses luci-rpc getHostHints to support the new
response format which removes the `ipv4` and `ipv6` host hint string fields
and replaces them with `ipaddrs` and `ip6addrs` weighted string list fields.

Signed-off-by: Niels Widger <niels@qacafe.com>
[rework code to be forwards/backwards compatible, fix some Network.Hosts
 methods, fix IP choice ordering, change commit subject, rewrap commit
 message]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-06-03 09:51:09 +02:00
Jo-Philipp Wich
1255c4832e
Merge pull request #4770 from nickberry17/update_DummyValue
luci-base: add new member 'hidden' to DummyValue
2021-06-02 08:23:45 +02:00
Jo-Philipp Wich
f3f74bd0fe luci-base: form.js: consider aliased options in AbstractValue.remove()
If different options point to the same underlying uci option, we must only
remove the uci value if none of the other alias options is active in order
to prevent inactive options (due to unsatisfied depends) removing the uci
value of active once on save.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-06-01 15:34:11 +02:00
Jo-Philipp Wich
dece9b063c luci-base: fix network data type validation
Fixes: #5085
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-05-31 11:39:15 +02:00