Commit graph

438 commits

Author SHA1 Message Date
Jo-Philipp Wich
b8d2bcd432 luci-base: ui.js: resolve parent ul early in UIDropdown.toggleItem()
The parent node of the current li might be null after collapsing the
dropdown, so resolve the parent ul early to avoid passing null to
subsequent calls.

Fixes clearing custom input values in DynamicList dropdowns.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-02-19 10:41:00 +01:00
Jo-Philipp Wich
3c166c25de luci-base: luci.js: fix sortedKeys() ordering
Chrome does not properly sort arrays when the sort function returns boolean
results, in contrast to Firefox which does.

Fix the issue by returning a numerical result instead.

Fixes: #4792
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-02-10 00:07:32 +01:00
Giovanni Giacobbi
d3280e6f5d treewide: minor fixes to typos, whitespace, and indentation
Signed-off-by: Giovanni Giacobbi <giovanni@giacobbi.net>
2021-01-20 12:36:13 +02:00
Giovanni Giacobbi
763158600a
luci-base: luci.js: fix LuCI.request.poll.add() exception handling
The try/catch is meant for the `res.json()` call and should apply to that. As it was before, an exception inside the poll callback would cause the callback to be reinvoked without the JSON parameter, which is an odd behaviour. Moreover, it makes it hard to debug because it is completely hidden from the browser console. We now differentiate between exceptions thrown due to bad JSON in `responseText` from exceptions generated inside the callback itself, which are let through for browser console logging.

Signed-off-by: Giovanni Giacobbi <giovanni@giacobbi.net>
2021-01-19 22:46:25 +01:00
Florian Eckert
df2a135a08 luci-base: make tooltip icon string configurable
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2021-01-13 12:29:02 +01:00
Florian Eckert
e951236e36 luci-base: add tooltip handling
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2021-01-13 11:59:02 +01:00
Hannu Nyman
c49d33f6cb
Merge pull request #4598 from Ansuel/wifi_chan
luci-mod-status: add new channel analysis page
2021-01-07 19:02:57 +02:00
Jo-Philipp Wich
03c77dafe3 treewide: transition div tables to actual table markup
Modern browsers allow decomposing table markup equally well as nested div
constructs, therefor migrate our <div> table markup to actual <table> tags
but keep the old table/tr/th/td CSS classes for now to allow for a smooth
theme transition.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-11-27 21:36:40 +01:00
Ansuel Smith
84ba852993
luci-base: delay cbi-tab-active event on tab init
Delay the cbi-tab-active custom event so any eventListner attached to the tab doesn't miss the first event.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
2020-11-24 02:36:50 +01:00
Ansuel Smith
44d02afab1
luci-base: generalize random color generation
Generation of pseudo random hex color from a string can be useful also for other task. Generalize it to make it available also for other purpose.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
2020-11-18 00:48:16 +01: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
Jo-Philipp Wich
5a485f8c68
Merge pull request #4531 from oldium/add-widget-changed
luci-base: Fix using isActive in widget-change notification.
2020-10-30 21:29:38 +01:00
Oldřich Jedlička
ee9b3a4e94 luci-base: Fix using isActive in widget-change notification.
The `onchange` notification handler is called too early to be able to
evaluate other widget's `isActive()` status. Solve this by changing order
of event handling - first register/execute `map.checkDepends` and then
`onchange`.

Fixes: openwrt/luci#4516.

Signed-off-by: Oldřich Jedlička <oldium.pro@gmail.com>
2020-10-30 21:18:45 +01:00
Oldřich Jedlička
ebaa50ecd8 luci-base: Replace legend element with h3.
The legend HTML element is allowed only as first element in fieldset, so
use h3 instead, which is rendered the same within themes.

Fixes #3149.

Signed-off-by: Oldřich Jedlička <oldium.pro@gmail.com>
2020-10-24 19:18:50 +02:00
Oldřich Jedlička
12e50de9db luci-base: network.js: Show clients also from wifi VLANs.
Iterate through VLANs to get the clients connected on configured wifi
VLANs (as configured by `wifi-vlan` sections in `wireless` configuration).

This is a minimum support for VLANs on wireless network. The VLAN name is
nowhere displayed, but at least clients using VLANs are visible.

Signed-off-by: Oldřich Jedlička <oldium.pro@gmail.com>
2020-10-06 13:30:47 +02:00
Rafał Miłecki
b17ec0926d luci-base: don't append object.method to the RPC url
It was a cosmetic feature that doesn't work anymore with the latest
uhttpd ubus API. Adding RESTful API resulted in treating URL part
following the /ubus/ as the new API request.

Suggested-by: Rafał Miłecki <rafal@milecki.pl>
Fixes: #4465
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-23 16:54:18 +02:00
Anton Kikin
509bf29cc9 luci-base: make translatable default values for dhcp hostname
We must be able to translate these values.

Fixes: fd75c2b7c ("luci-base: add default value options dhcp hostname")
Signed-off-by: Anton Kikin <a.kikin@tano-systems.com>
2020-09-19 08:31:48 +03:00
Florian Eckert
fd75c2b7c5 luci-base: add default value options dhcp hostname
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-09-16 17:19:50 +02:00
Jo-Philipp Wich
bdcd094963 luci-base: dhcp.js: allow hostname to be "*"
Fixes: #4430
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-16 10:23:35 +02:00
Rafał Miłecki
bc6e4dfe29 luci-base: use actual JSON-RPC for verifying ubus RPC URL
Sending GET request to the main RPC base URL and expecting HTTP response
code 400 had two flaws:
1. It was not verifying actual JSON-RPC interface availability
2. It did not allow implementing support for new requests

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: Jo-Philipp Wich <jo@mein.io>
2020-09-15 10:34:39 +02:00
Jo-Philipp Wich
35e2735e2e luci-base: form.js: implement AbstractSection.getOption() helper
The `getOption()` function allows to easily obtain a reference to another
option object instance within the same section.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-08-06 17:56:34 +02:00
Jo-Philipp Wich
18eddc9624 luci-base: ui.js: implement AbstractElement.isChanged()
The new `isChanged()` utility functions allows to query the dirty state
of an ui input widget.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-08-06 17:56:34 +02:00
Jo-Philipp Wich
354ca57ec8 luci-base: network.js: recognize uci declared network devices
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-08-05 13:53:12 +02:00
Jo-Philipp Wich
b8d381b677 luci-base: form.js: add cfgvalue(), formvalue() and getUIElement() helpers
This commit introduces new per-section cfgvalue(), formvalue() and
getUIElement() helper functions which complement the respective per-option
functions.

Their intent is to simplify querying input data or obtaining UI widget
instances from other options within the same section.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-08-05 13:51:16 +02:00
Jo-Philipp Wich
2d774c4973 luci-base: form.js: add AbstractValue.onchange property
Introduce a new, widget agnostic onchange property which allows setting
custom handler functions to react on element value changes.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-08-05 13:51:16 +02:00
Jo-Philipp Wich
572090101d luci-base: form.js: add ability to specify regular expression dependencies
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-08-05 13:51:16 +02:00
Jo-Philipp Wich
f2965b759a luci-base: ui.js: implement AbstractElement.setPlaceholder()
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-08-05 13:51:16 +02:00
Jo-Philipp Wich
bd5e2edb46 luci-base: uci.js: fix option deletion quirks
Since option deletions are sent first, followed by ubus set commands,
a call sequence like:

    uci.set('config', 'section', 'option', ['foo', 'bar'])
    uci.set('config', 'section', 'option', ['foo'])
    uci.unset('config', 'section', 'option')

... would result in the option retainining `foo` as value, instead of it
getting removed as one would expect.

Fix this issue by reverting the internal change state of the option before
storing the deletion.

While we're at it, also rework the internal tracking of deleted options to
not result in duplicate removal requests when the same option is unset
several times.

Finally change all `undefined` returns to `null` in order to comply with
the function documentation.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-08-04 18:55:21 +02:00
Jo-Philipp Wich
1c92d9f706 luci-base: form.js: add CSS class to invalid option dismiss button
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-07-28 20:57:04 +02:00
Jo-Philipp Wich
b0cd7ff705 luci-base: form.js: don't destroy modal form on invalid values when saving
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-07-28 20:57:04 +02: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
0c479891ae luci-base: ui.js: order menu entries with the same weight by name
The previous server side menu rendering ordered items first by their order
weight value, then by their internal name.

Do the same for client side menu rendering.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-07-05 00:11:59 +02:00
Jo-Philipp Wich
682f628ea6 luci-base: form.js: fix handling of array sections in JSONMap forms
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-06-14 16:41:49 +02:00
Jo-Philipp Wich
6be8f8dbae luci-base: luci.js: properly skip comments when finding require tokens
Fixes: #4020, #4022, #4111
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-05-29 09:57:29 +02:00
Jo-Philipp Wich
f6f4005d0b luci-base: firewall.js: remove further zone network/name fallback logic
Fixes: #4093
Fixes: 4052436d8 ("luci-base: firewall.js: don't treat zone name as network fallback")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-05-24 17:33:26 +02:00
Anton Kikin
c00d0d9473 luci-base: ui.js: fix function declaration in nested statement
Fix "SyntaxError: Strict mode does not allow function declarations
in a lexically nested statement" error that may occur in some old
browsers (detected on QtWebKit 5.212).

Signed-off-by: Anton Kikin <a.kikin@tano-systems.com>
2020-05-24 02:12:20 +03:00
Florian Eckert
aac1a8d512
Merge pull request #4053 from TDT-AG/pr/20200515-luci-base
luci-base: fix host validation function
2020-05-19 14:06:07 +02:00
Florian Eckert
c8d24f04de luci-base: fix host validation function
Allow only ipv4 or ipv6 addresses without IP mask.
A host IP with mask does not make sense in this context.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-05-19 14:05:26 +02:00
Jo-Philipp Wich
9a41673488 luci-base: validation.js: count byte- instead of character length of strings
Fixes: #4055
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-05-17 21:40:27 +02:00
Jo-Philipp Wich
f8cf115d9b luci-base: optimize some PNG files
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-05-07 20:05:52 +02:00
Jo-Philipp Wich
102124115d luci-base: move old cbi icons to luci-compat
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-05-07 19:40:29 +02:00
Jo-Philipp Wich
b34b7fc504 luci-base: replace filebrowser icons with SVG variants
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-05-07 19:39:32 +02:00
Jo-Philipp Wich
f0a0d28fdd luci-base: form.js: forward section ID in CBISectionValue methods
This is useful for custom subclasses that want to perform conditional
rendering of contents, depending on the parent section ID.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-05-04 21:34:12 +02:00
Jo-Philipp Wich
915e446c07 luci-base: ui.js: fix UITextfield.setValue()
Fixes: d02c26772 ("luci-base: ui.js: rework password input handling")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-05-04 21:31:38 +02:00
Jo-Philipp Wich
28cf5cd576 luci-base: firewall.js: fix Zone.addRule()
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-05-04 21:29:01 +02:00
Jo-Philipp Wich
4df3a90b3d luci-base: ui.js: reset scroll position when opening modal overlay
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-05-02 23:53:03 +02:00
Jo-Philipp Wich
e3ef463ccd luci-base: ui.js: fix input value reading for select widgets
Fixes: #3989
Fixes: 81effc111 ("luci-base: ui.js: assume select widget by default for ListValue widget")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-05-02 23:53:03 +02:00
Jo-Philipp Wich
d02c26772b luci-base: ui.js: rework password input handling
- Get rid of dummy element
 - Render password field as text input initially and later transform
   it to a password field
 - Use .control-group markup to allow better styling

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-05-02 23:53:02 +02:00
Jo-Philipp Wich
81effc1112 luci-base: ui.js: assume select widget by default for ListValue widget
Fixes: #3973
Fixes: 2fb55e1ab ("luci-base: ui.js: fixes for radio widget type of select element")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-28 15:37:02 +02:00