Commit graph

557 commits

Author SHA1 Message Date
Paul Donald
f630f2241c luci-base: docs house-keeping
Signed-off-by: Paul Donald <newtwen@gmail.com>
2024-03-06 02:03:57 +01:00
Jo-Philipp Wich
06c0fbbef7 luci-base: static.js: fix validation of netmask option
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-02-21 15:38:37 +01:00
Jo-Philipp Wich
317ed4a043 luci-base: ui.js: further keyboard navigation improvements for dropdowns
- Ensure that pressing escape within the custom choice input closes the
   dropdown list but not the parent modal dialog

 - Ensure that added custom choice elements are tabbable

 - Retain focus on dropdown when closing dropdown

 - Consistently focus input textarea when tabbing into custom choice item

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-02-21 15:33:08 +01:00
Jo-Philipp Wich
cf09f89df3 luci-base: validation.js: add iprange, iprange4 and iprange6 validators
Add datatype validators for IP address ranges which are required for certain
firewall inputs.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-02-21 15:33:08 +01:00
Jo-Philipp Wich
3980c192cd luci-base: ui.js: rework dropdown focus behavior
Drop mouse following focus behavior as it interferes with custom value inputs,
rely on CSS based hover effects instead.

Also slightly improve keyboard navigation by auto-focussing the custom value
input when entering the last dropdown choice via arrow down or tab key, and
by allowing to leave the text input again with the arrow up key.

Fixes: #6903
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-02-19 00:04:16 +01:00
Paul Donald
8a0ee6689f luci-mod-network: add disabled option for interface
Enabled by default. If the interface is in use, the user will be asked
to confirm.

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
2024-01-31 03:39:02 +01:00
Paul Donald
2dc1fccbd1 luci-base: Code quality fixes
reduce backtracking in regex

Signed-off-by: Paul Donald <newtwen@gmail.com>
2024-01-31 02:55:13 +01:00
Paul Donald
4c2090afd8 luci-base: Code quality fixes
handle (possibly incorrect) comment variants
<!-- -->
<!-- --!>

Signed-off-by: Paul Donald <newtwen@gmail.com>
2024-01-31 02:53:21 +01:00
Paul Donald
0617d301d9 luci-base: fix docs for TableSection
There are repeated values (TableSection inherits identically named
values from TypedSection which do not make sense to recreate).

There seemed to be other errors. E.g. TypedSection for FlagValue
properties, which mean that TypedSection got tooltip + tooltipicon,
and by virtue of the above error, GridSection inherited this too.

Signed-off-by: Paul Donald <newtwen@gmail.com>
2024-01-25 03:52:16 +01:00
Sergey Ponomarev
a4fd238ab2 luci-base: FlagValue fix type of enabled and disabled properties
The form.Flag checkbox allows to specify a value for enabled/disabled e.g. for a dropbear:

    o = s.option(form.Flag, 'PasswordAuth');
    o.enabled  = 'on';

So the property type should be a string but not just a number.

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
2024-01-23 09:29:12 +02:00
Sergey Ponomarev
b18960f600 luci-base: JsDoc: exec_direct(): fix "type" enum
The "type" can be "json"

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
2024-01-23 09:29:12 +02:00
Paul Donald
5355b7b576 luci-base: comment fixes (sp)
Signed-off-by: Paul Donald <newtwen@gmail.com>
2023-12-23 14:33:16 +00:00
Evan Benn
e02df6505f luci-base: Use getMode in getActiveMode
Signed-off-by: Evan Benn <evan.benn@morsemicro.com>
2023-12-15 09:11:13 +11:00
Evan Benn
23931c3778 luci-base: Replace mode: Master with Access Point
Access Point is the string used on the network wireless setup dialogue.
Use Access Point to report the mode on the network wireless and status
screens.

Signed-off-by: Evan Benn <evan.benn@morsemicro.com>
2023-12-15 09:11:13 +11:00
Evan Benn
22101eb50a luci-base: Make uci mode strings match iwinfo mode strings
uci mesh was being displayed as 'Mesh', while iwinfo mesh was being
reported as 'Mesh Point'. Unify those. Update getActiveModeI18n to deal
with all the values iwinfo returns. Fix the incorrect 'Mash'
translation.

Signed-off-by: Evan Benn <evan.benn@morsemicro.com>
2023-12-15 09:11:10 +11:00
Jo-Philipp Wich
ee6a4da00b luci-base: ui.js: sorting fixes for tables initialized from markup
- Populate id option from table id attribute
 - Update column head sort indicator in UITable.update()
 - Don't store sort state for tables without id

Ref: https://github.com/openwrt/luci/issues/6640
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2023-10-19 23:46:03 +02:00
Sergey Ponomarev
7744ad0075 luci-base: Fix typos in JsDocs
In some places argument name was renamed but in the JsDoc it's remain old.

Added more typing for string enum fields like:

 @param {string} [type=text]

replaced with:

 @param {"blob"|"text"|"blob"} [type=text]

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
2023-09-23 10:39:34 +03:00
Sergey Ponomarev
d35dd2d489 luci-base: network.js: simplify getWifiNetidBySid
Remove unused variables i and netid and reuse radioname

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
2023-09-23 10:34:35 +03:00
Sergey Ponomarev
f423025927 luci-base: "an URL" replace with "a URL"
This is a correct form

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
2023-09-23 10:16:49 +03:00
Sergey Ponomarev
9d384a2140 luci-base: cbi.js cbi_validate_named_section_add() simplify
Reduce if to a simple boolean evaluation

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
2023-09-23 10:11:02 +03:00
Paul Dee
2c3018d426 luci-base: grammar fixes
Login (n) -> Log (v) in

Logout (n) -> Log (v) out

Signed-off-by: Paul Dee <itsascambutmailmeanyway@gmail.com>
2023-08-11 13:17:04 +02:00
Jo-Philipp Wich
23a246e4b4 luci-base: ui.js: set autocomplete="new-password" for password fields
Attempt to prevent Firefox from randomly filling nonesense into arbitrary
password fields such as the WireGuard private key field by setting the
`autocomplete="new-password"` attribute on any password type fields.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2023-06-07 23:40:04 +02:00
Jo-Philipp Wich
6fb185f956 luci-base: ui.js: make upload cancellation message translatable
Resync base translation templates as well.

Fixes: #6364
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2023-04-28 23:58:41 +02:00
Jo-Philipp Wich
b07ac8add8 luci-base: validation.js: fix xgettext quirk
The xgettext utility does not properly discard `/` inside regex character
classes, causing a false positive unterminated string error.

Avoid the issue by explicitly escaping the embedded slash.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2023-04-03 14:05:00 +02:00
Glenn Washburn
6ad6a241c3 luci-mod-network: add stricter wireless interface name validation
Linux wireless interface names have the following restrictions:

 * It must not be an empty string
 * It must not be '.' or '..'
 * It must not contain any /, : or space character ( , \t, \n, ...)
 * It must be less than 16 chars
 * It likely must not contain any % either

Fixes: 8673aef8db ("luci-mod-network: remove uciname validation from wireless interface")
Signed-off-by: Glenn Washburn <development@efficientek.com>
[reword validation error messages, remove extended description text as it would be
 shown as part of the validation errors]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2023-03-15 23:56:59 +01:00
Jo-Philipp Wich
41e9b8d121 Revert "luci-proto-openconnect: fix server url validation"
This reverts commit f1312cadc6.

The commit contained unrelated changes.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2023-02-08 08:56:36 +01:00
Jo-Philipp Wich
2234d0c5dd
Merge pull request #6104 from dhewg/6g
luci-mod-network: enable configuring wifi ax networks on the 6G band
2023-02-07 14:05:17 +01:00
Jo-Philipp Wich
f1312cadc6 luci-proto-openconnect: fix server url validation
The OpenConnect configuration form incorrectly assumed that the server
setting must be hostname while it actually may be a full URL.

Fixes: #6184
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2023-02-07 11:53:31 +01:00
Jo-Philipp Wich
c9939a83e7 luci-base: ui.js: modal dialog tweaks
- Automatically focus modal dialog frame
 - Close modal dialog on pressing escape key

Fixes: #4609, #6205
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2023-02-05 20:22:44 +01:00
Jo-Philipp Wich
8db3e0e70f luci-base: ui.js: improve ui.Dropdown event handling
Improve overall event and focus handling, avoid registering a global
mouseover event listener, stop propagating escape keypress on closing
dropdown and avoid `Element.blur()` to prevent de-focusing open modals.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2023-02-05 19:39:13 +01:00
Jo-Philipp Wich
dd47f3f674 luci-base: form.js: reuse JSONMap data provider in GridSection modals
Reuse the same data provider as the parent JSONMap instance in order
to avoid inadvertently mangling the form data when saving the modal
edit dialog.

Fixes: bb9ede238a ("luci-base: form.js: reuse JSONMap data provider in GridSection modals")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2023-02-04 22:22:53 +01:00
Jo-Philipp Wich
6fe3499026 luci-base: form.js: fix GridSection modals in JSONMap instances
Since grid section edit modals construct a new Map instance internally,
we must take care of using the correct map constructor type for the
internal copy in order to end up with the correct data provider.

Ensure that the extended option modal of GridSection instances uses a
JSONMap when the grid section's owner map is a JSONMap to avoid stray
uci related errors.

Ref: https://forum.openwrt.org/t/luci-save-apply/149658/5
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2023-02-04 21:03:51 +01:00
Andre Heider
d53ea72a88 luci-base: use "hwmodes_text" to describe wireless radios
This is a preformatted string like "ac/ax/b/g/n" for presentation.

Signed-off-by: Andre Heider <a.heider@gmail.com>
2023-01-23 14:51:28 +01:00
Paul Dee
3c2b35cf90 luci-base: help-text spell fix
Signed-off-by: Paul Dee <itsascambutmailmeanyway@gmail.com>
2023-01-17 21:24:44 +01:00
Jo-Philipp Wich
deed6827b2 luci-base: ui.js: support div based table markup in UITable.update()
Constructing UITable instances from existing, div based markup is
supported but the UITable.update() implementation did not account
for that, leading to defunct data updates on tables built from div
based markup.

Fix this issue by extending UITable.update() to consider a div based
table structure as well, like we do in UITable.initFromMarkup() already.

Fixes: #5713
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-12-27 20:24:25 +01:00
Florian Eckert
440a2e79a7 luci-base: fix button handling for named sections
If more than one named section is added to the page, it is currently the
case, that the first button is always switched on or off during input
validation of the uci section name. This is because the usage of the
'document.querySelector' function is to imprecise. Changing the search
start to the element to be created, fixes this.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2022-12-13 13:32:50 +01:00
Jo-Philipp Wich
90a2b1eaeb luci-base: ui.js: table enhancements
- Gracefully handle cells without innerText
 - Properly handle `DocumentFragment` call values on table update
 - Introduce ability to fetch actual cell value for sorting purposes from
   `data-value` attribute

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-11-22 10:10:06 +01:00
Jo-Philipp Wich
bdfdd95a27 luci-base: cbi.js: await L.ui load before updating tables
On legacy views, the `L.ui` JavaScript class is not automatically loaded,
so request it before updating tables.

Fixes: e0e6989a4a ("luci-base: introduce new LuCI.ui.Table class")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-11-09 20:30:20 +01:00
Jo-Philipp Wich
673f38246a treewide: separate Lua runtime resources
Move classes required for Lua runtime support into a new `luci-lua-runtime`
package. Also replace the `luci.http` and `luci.util` classes in
`luci-lib-base` with stubbed versions interacting with the ucode based
runtime environment.

Finally merge `luci-base-ucode` into the remainders of `luci-base`.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-10-25 01:03:37 +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
8199b2ce9a luci-base: luci.js: add array sort utilities
Add two new utility functions L.naturalCompare() and L.sortedArray() to
simplify sorting arrays naturally.

Ref: #5899
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-07-27 17:31:01 +02:00
Jo-Philipp Wich
25dcd0b77c luci-base: uci.js: prevent sending empty uci set operations
Under certain circumstances, a staged uci option value might get unset
again before saving the config, leaving an empty section change set
behind, causing the save call to send an empty uci set request via rpc,
triggering an ubus code 4 (Resource not found) error.

In particular this prevented bridge VLANs from getting saved properly.

Fixes: #5876
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-07-23 00:10:17 +02:00
Jo-Philipp Wich
2771360108 luci-base: form.js: fix removing just created named GridSection
Since the `handleModalSave()` handler of the GridSection class invokes
`handleModalCancel()` after saving the data but before removing the
`addedSection` property, the `handleModalCancel` handler incorrectly
removed the uci section that has just been created.

This bug didn't affect anonymous GridSections because after saving the
id of the created section changes, causing the remove command to fail,
but for named ones with stable section IDs, the bug manifested.

Solve the issue by passing a flag to `handleModalCancel()` indicating
whether the method was called from a safe operation and use it do
decide whether to delete the new staged uci section or not.

Fixes: #5760
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-07-22 23:41:05 +02:00
y04
37477ca614
luci-base: optimized icons filesizes
Optimized PNG filesize without any quality loss.

Signed-off-by: Alexander Semukhin <semukhin@mail.com>
2022-06-25 01:45:55 +02:00
Jo-Philipp Wich
8effea58d7 luci-base: network.js: consider uci config for Device.getType()/getParent()
For network devices declared in uci but not yet created by netifd, the
runtime status information will be unavailable, causing methods such as
`getType()` to assume plain ethernet interfaces and `getParent()` to fail
resolving parent devices.

Fall back to infer the information from uci configuration settings in such
cases to give accurate type hints to callers.

In particular, this prevents LuCI from turning wireless target networks
containing a to-be-created bridge device into bridges themselves.

Fixes: https://github.com/openwrt/packages/issues/18768
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-06-16 09:52:36 +02:00
Jo-Philipp Wich
d6dbedd9e2 luci-base: ui.js: add required CSS class to dynlist widget
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-05-17 21:48:01 +02:00
Jo-Philipp Wich
9c136c9bea luci-base: form.js: minor tweaks for mobile styling
- Annotate gridsection textvalue cells as CBI.DummyValue widgets
 - Replace `<br>` elements with newlines in `stripTags()`

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-05-17 15:07:48 +02:00
Jo-Philipp Wich
b6ae1d4f4a luci-base: form.js: trim option description
If a whitespace-only description is set on an element, the CSS :empty
selector will not match, causing description icons to be shown when
there's no actual content.

To avoid that, trim the description string when building the element.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-05-16 16:12:01 +02:00
Jo-Philipp Wich
4e090e38d2 luci-base: luci.js: remove wrong CSS class from page footer
The `control-group` class is meant for gapless grouping of inputs with
buttons, while the page actions are just distinct buttons in a row.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-05-16 16:04:56 +02:00
Jo-Philipp Wich
e4e001b596 luci-base: form.js: remove stray <br> elements from section placeholder
Theme CSS styles shoudl take care of introducing padding as needed.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-05-16 16:03:14 +02:00