Commit Graph

137 Commits

Author SHA1 Message Date
Ramon Van Gorkom
80f18df48f luci-base: make items of UIDynamicList drag-sortable
Signed-off-by: Ramon Van Gorkom <Ramon00c00@gmail.com>
2024-11-27 21:43:16 +01:00
Paul Donald
53e36e3293 luci-base: ui: extend addNotification to handle a user-provided timeout
A millisecond value after which the notification will disappear
automatically. If omitted, the notification will remain until it
receives the click event.

Existing calls are unaffected.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2024-11-21 01:30:48 +01:00
Paul Donald
ade3606800 luci-base: space -> tab
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2024-10-17 17:31:26 +02:00
Florian Eckert
e229e1a0e2 luci-base: revert replacing button tags with div tags
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-07-19 11:01:33 +02:00
Florian Eckert
a0dcba5b78 Merge pull request #7153 from TDT-AG/pr/20240607-luci-base
treewide: add new css class button-row
2024-07-17 09:31:52 +02:00
Florian Eckert
8691cba695 luci-base: replace css class right with css class button-row
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-07-09 16:19:51 +02:00
Florian Eckert
4d2364dbe4 luci-base: update connectivity change help text and button text
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-07-09 16:19:51 +02:00
Joseph Mory
d3bf67507f luci-base: Correct how textarea's wrap works
Signed-off-by: Joseph Mory <morytyann@outlook.com>
2024-07-06 13:32:12 +02:00
Florian Eckert
ce34e99400 luci-base: replace button tag with div tag in ui.js
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-06-07 13:33:00 +02:00
Florian Eckert
f6bc735b68 luci-base: add missing css class cbi-button to ui.js
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-06-07 13:33:00 +02:00
Florian Eckert
fca31270aa luci-base: move cancel button to the top
This change is required, so that the cancel button is the first and thus
closes the modal when the 'ESC' button is pressed.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-06-07 13:33:00 +02:00
Florian Eckert
9bb8f7aaa3 luci-base: remove flex style tags
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-06-07 13:33:00 +02:00
Florian Eckert
f83e68bea0 luci-base: replace button tag with div tag in ui.js
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-06-07 13:33:00 +02:00
Florian Eckert
5eeb0856dc luci-base: add missing css class cbi-button to ui.js
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-06-07 13:33:00 +02:00
Florian Eckert
0466acb85f luci-base: move button one level up for Save & Apply
This is a preparation commit so the buttons could get the new css class
'button-row'

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-06-07 13:33:00 +02:00
Florian Eckert
4440b00b2b luci-base: replace button tag with div tag in ui.js
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-06-07 13:33:00 +02:00
Florian Eckert
e9e9229b95 luci-base: add missing css classes btn and cbi-button to ui.js
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2024-06-07 13:33:00 +02:00
Paul Donald
a6f8361a14 luci-base: clarify apply-settings strings
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
2024-06-06 02:56:28 +02:00
Jo-Philipp Wich
11819152de Merge pull request #6553 from stokito/luc-mod-system_filemanager
Add File Manager / File Browser based on form.FileUpload
2024-04-09 10:13:35 +02:00
Sergey Ponomarev
4b771b3df0 luci-base: ui.js FileUpload: option to enable Download button
Allow downloading from a file browser.
The Download button is located near to Delete.
It's shown only for files: folders or /dev/ devices can't be downloaded.
The downloading is made via fs.read_direct() which internally calls cgi-download.

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
2024-04-09 10:43:35 +03:00
Hannu Nyman
f2a49104c4 Revert "luci-base: force menu to regenerate after uci change"
This reverts commit 97ebdcbddb.

The commit seems to cause errors already before the login screen.
Discussion in 97ebdcbddb (commitcomment-139871175)

Errors like:

 In error(), file [C]
 called from function [anonymous function] (/usr/lib/lua/luci/ucodebridge.lua:23)
 called from function ((tail call))
 In [anonymous function](), file /usr/share/ucode/luci/runtime.uc, line 148, byte 45:
   called from function build_pagetree (/usr/share/ucode/luci/dispatcher.uc:382:73)
   called from function menu_json (/usr/share/ucode/luci/dispatcher.uc:439:26)
   called from function [anonymous function] (/usr/share/ucode/luci/dispatcher.uc:898:24)
   called from anonymous function (/www/cgi-bin/luci:39:13)

  `        return lcall.call(modname, method, ...args);`
   Near here ----------------------------------------^

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2024-03-17 09:17:20 +02:00
James Haggerty
97ebdcbddb luci-base: force menu to regenerate after uci change
Because the menu JSON can have 'depends' in them, uci changes
should force the menu to regenerate.

Closes #6423

Signed-off-by: James Haggerty <james.haggerty@morsemicro.com>
Signed-off-by: Paul Donald <newtwen@gmail.com>
2024-03-17 00:23:45 +01:00
Erik Karlsson
6abb5ed709 luci-base: ui.js: avoid polling in a tight loop on confirm/rollback
The call function was based on the legacy XHR interface and it has not
been updated to comply with the new request interface which passes the
duration as part of the response object rather than as a separate
argument. This resulted in polling in a tight loop in certain cases
since the duration was undefined.

In addition there is no need to adjust apply_holdoff based on elapsed
time as no significant amount of time has elapsed at this point.

Signed-off-by: Erik Karlsson <erik.karlsson@genexis.eu>
2024-03-17 00:11:14 +01:00
Sergey Ponomarev
5d2d528022 luci-base: CBIFileUpload support file browser mode
In the Browser mode the file tree dialog won't be closed when clicking on a file.
The mode is used by a File Browser.

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
2024-03-08 19:23:55 +02:00
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
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
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
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
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
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
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
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
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
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
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
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
733ee9a7b6 luci-base: ui.js: warn about connectivity loss on changing iface settings
If specific settings such as the protocol, IP address or netmask of an
interface the user is connected to are changed, the apply/rollback
mechanism might interfere. Display an additional warning dialog in this
case, instructing the user to manually reconnect and offering to continue
with a less safe unchecked apply mechanism.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-05-16 13:35:18 +02:00
Jo-Philipp Wich
8583efb5a9 luci-base: ui.js: make "Apply unchecked" available from the changes dialog
Previously, "Apply unchecked" was only possible from the save action of CBI
maps, allow to invoke it from the configuration change dialog as well.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-05-06 13:42:55 +02:00
Jo-Philipp Wich
b6797821b8 luci-base: ui.js: gracefully handle failing confirm calls on rollback
Do not abort the poll loop if some confirm request attempts fail, which
might happen when the device starts rolling back its configuration.

Before that fix, the rollback information dialog offering an unchecked
apply was not reliably presented in such situations.

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
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
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
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
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