Commit graph

295 commits

Author SHA1 Message Date
Jo-Philipp Wich
71d370a964 luci-base: ui.js: ensure that select choice labels are properly escaped
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-12-04 18:06:58 +01:00
Jo-Philipp Wich
ee36066947 luci-base: ui.js: properly escape dynlist items for rendering
Ref: https://forum.openwrt.org/t/luci-theme-openwrt-reports-error/49736
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-12-04 16:09:23 +01:00
Jo-Philipp Wich
4a08fdd2d3 luci-base: luci.js: further nested Class.super() call fixes
Use stacks keyed by class id + symbol internally to not clobber the
prototype scope pointer when repeatedly calling super() in invoked
methods.

Ref: https://github.com/openwrt/luci/issues/3316#issuecomment-558531111
Fixes: 374c23cda ("luci-base: luci.js: properly handle nested Class.super() calls")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-11-26 11:39:14 +01:00
Jo-Philipp Wich
374c23cdab luci-base: luci.js: properly handle nested Class.super() calls
Introduce a unique __id__ attribute per class and use that, together with
the symbol name being looked up to, to form a unique key which is used to
store the prototype scope pointer.

This fixes cases where a call to super() invokes a procedure which is
calling super() as well on a different class or symbol.

Fixes: #3316
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-11-26 09:37:27 +01:00
Jo-Philipp Wich
4f0d67a289 luci-base: validation.js: fix "unique" validator
Previous refactoring renamed the "data-type" attribute of widget markup
containers to "data-widget", breaking the "unique" validator as it relies
on it to lookup options.

Fixes: #3341
Fixes: 13e9e3e9e ("treewide: fix "Unhandled token" errors with Lua CBI maps")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-11-22 08:42:58 +01:00
Jo-Philipp Wich
13e9e3e9e8 treewide: fix "Unhandled token" errors with Lua CBI maps
The `data-type` attribute is used to bind datatype validators to a widget
while some templates used the same attribute to denote the name of the
underlying widget.

Change the `data-type` attributes referring to the widget name to
`data-widget` in order to stop the JS token error spam.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-11-16 18:25:52 +01:00
Kevin Darbyshire-Bryant
9b266d11c6 luci-base: Improve change application message
As a native English speaker the luci message displayed when clicking
'Save & Apply' has a somewhat uncomfortable English phrasing of "Waiting
for configuration to get applied".  It could be improved by replacing
'get' with 'be' but once you've got that far you might as well replace
this with the shorter & simpler "Applying configuration changes".  This
is also technically more correct since luci/openwrt should only be
updating/restarting processes that are related to the changed areas, not
changing the entire configuration.

As a result of that, change both the 'success' and 'rolled back'
messages to "Configuration changes have been applied" & "Configuration
changes have been rolled back"

Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
2019-11-15 14:29:57 +00:00
Jo-Philipp Wich
304dd37e3f luci-base: network.js: fix getDevices()
- Don't filter virtual interfaces
 - Skip duplicate wireless devices

Fixes: #3304
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-11-13 18:36:15 +01:00
Jo-Philipp Wich
4cc7772ed5 luci-base: ui.js: show filename after selecting upload file
Fixes: #3286
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-11-10 19:45:58 +01:00
Jo-Philipp Wich
3b3a1d9cc9 luci-base: luci.js: add optional apply unchecked action
Turn the "Save & Apply" button into a combo button which allows to
toggle between apply with rollback and unchecked apply modes.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-11-10 18:21:09 +01:00
Jo-Philipp Wich
97a3bef84b luci-base: ui.js: add ComboButton widget
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-11-10 18:20:39 +01:00
Jo-Philipp Wich
a2dc6c8216 luci-base: network.js: introduce further API functions
- Add Network.getWifiNetworks() to simplify fetching *all* networks
   instead of building a list by iterating each radio first

 - Add Network.WifiNetwork.isClientDisconnectSupported() to check whether
   a wireless network supports client disconnections

 - Add Network.WifiNetwork.disconnectClient() to trigger client
   disconnections via hostapd

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-11-07 12:08:15 +01:00
Jo-Philipp Wich
a8a7697829 luci-base: network.js: prevent duplicate wan interface reporting
Fixes: #3269
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-11-06 13:22:10 +01:00
Richard Yu
fa15370f0e
luci-base: form.js: fix GridSection not using user-input name when add
Signed-off-by: Richard Yu <yurichard3839@gmail.com>
2019-11-04 00:19:33 +08:00
Jo-Philipp Wich
33346dadf4 luci-base, luci-mod-system: move file upload handling to ui.js
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-11-01 12:03:33 +01:00
Jo-Philipp Wich
6e633b3ed2 luci-base: consolidate network.js data acquisition
The new luci-rpc/getNetworkDevices procedure offers netdev enumeration
with included IPv4 and IPv6 address information as well as 64bit traffic
counters, so we can remove the calls to network.device/status and
luci/getIfaddrs now as we're able to obtain all info from a single source.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-11-01 12:03:33 +01:00
Jo-Philipp Wich
cc1cbdaf32 luci-base: migrate luci/getNetworkDevices to C plugin
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-11-01 12:03:33 +01:00
Jo-Philipp Wich
a96e7a664f luci-base: migrate luci/getWirelessDevices to C plugin
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-11-01 12:03:33 +01:00
Jo-Philipp Wich
37b6092aef luci-base, luci-mod-network, luci-app-firewall: migrate luci/getHostHints
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-11-01 12:03:33 +01:00
Jo-Philipp Wich
d21ebcfbbc luci-base: migrate luci/getBoardJSON to C plugin
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-11-01 12:03:33 +01:00
Jo-Philipp Wich
199428a9c3 luci-base: network.js: implement Protocol.getGateway6Addr()
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-10-22 22:38:29 +02:00
Jo-Philipp Wich
2b7ca79118 luci-base: ui.js: prevent race condition in tab initialization
Fixes: #3150
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-10-22 15:51:51 +02:00
Jo-Philipp Wich
77a89299f4 luci.base: fs.js: expose mode param in fs.write()
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-10-21 08:42:41 +02:00
Jo-Philipp Wich
d5ffab23b6 luci-base: network.js: simplify rpc error handling
Use L.resolveDefault() catch unexpected RPC replies and rename declared
rpc functions in a consistent manner.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-10-18 11:49:13 +02:00
Jo-Philipp Wich
51b519e55e luci-base: network.js: prefer netifd traffic stats over getifaddrs() ones
Overwrite the traffic statistics reported by getifaddrs() with the ones
reported by the network.device/status procedure if available as the
getifaddr() stats are limited to 32bit counters.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-10-17 09:21:04 +02:00
Jo-Philipp Wich
120ece921d luci-base: static.js: make IPv6 assignment hint optional
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-10-15 09:14:56 +02:00
Richard Yu
02a0291d14
luci-base: widgets.js: add user and group select
Signed-off-by: Richard Yu <yurichard3839@gmail.com>
2019-10-11 01:05:08 +08:00
Jo-Philipp Wich
e7ca163d7c luci-base: form.js: fix anonymous section table titles
When no section title is defined, the table renderer is supposed to use
the uci section id as fallback when the table section is not declared
to be anonymous.

Fixes: #3147
Fixes: a90bf384b ("luci-base: form.js: harmonize title property handling")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-10-07 19:49:58 +02:00
Jo-Philipp Wich
5cfad8d65b luci-base: form.js: treat inactive options as optional
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-10-07 19:44:22 +02:00
Jo-Philipp Wich
f3ef2ca2eb luci-base: ui.js: add pingDevice() and awaitReconnect() functions
Import these functions from the flash.js for use with other views that
might trigger a device reboot.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-10-07 11:53:39 +02:00
Jo-Philipp Wich
df8078d542 luci-base: ui.js: use common fs.js class for filebrowser operations
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-10-07 11:53:39 +02:00
Jo-Philipp Wich
8776e423d9 luci-base: introduce common fs.js helper class
Introduce a new fs.js helper class to gather filesystem related RPC
operations in a single file.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-10-07 11:53:35 +02:00
Jo-Philipp Wich
1154e755f1 luci-base: luci.js: add resolveDefault() helper
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-10-07 11:48:33 +02:00
Jo-Philipp Wich
b2809cebd8 luci-base: luci.js, rpc.js, uci.js, network.js: add JSDoc annotations
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-10-02 08:59:41 +02:00
Jo-Philipp Wich
948ca3712f luci-base: network.js: implement getMeshID() getter
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-30 12:39:33 +02:00
Jo-Philipp Wich
809f16d4ce luci-base: network.js: fix deleteNetwork() implementation
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-24 08:02:57 +02:00
Jo-Philipp Wich
186ddfa044 luci-base: form.js: do not inherit map tabbing to nested sections
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-24 08:01:04 +02:00
Jo-Philipp Wich
0068c3bd49 luci-base: form.js: allow overriding remove action in Table/GridSections
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-24 07:59:04 +02:00
Jo-Philipp Wich
158515d5bd luci-base: form.js: do not add title attributes for untitled options
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-22 22:26:36 +02:00
Jo-Philipp Wich
6dba41cadc luci-base: tie cached system features to user session
Store the cached system feature flags keyed by the current session id,
this ensures that the features are refreshed on login.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-21 10:55:54 +02:00
Jo-Philipp Wich
119c6319cb luci-base: network.js: don't batch wireless scan requests
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-21 10:23:37 +02:00
Jo-Philipp Wich
21d1266c53 luci-base: rpc.js: increase default timeout to 20s, allow batch prevention
Support a new option "nobatch: true" in rpc.declare() which prevents the
underlying RPC call from being batched with other calls.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-21 10:23:37 +02:00
Jo-Philipp Wich
afeacdc7df luci-base: luci.js: improve XHR issue diagnostics
Differentiate between request timeouts and other error reasons.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-21 10:23:37 +02:00
Jo-Philipp Wich
d10575dfee luci-base: form.js: only update option default if cfgvalue is null
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-20 09:58:31 +02:00
Jo-Philipp Wich
25e0b966c7 luci-base: form.js: add support for dynamic default values
Many uci options have different implicit defaults, depending on the
values of other related options. A prominent example is the wireless
ieee80211w option which defaults to 2, 1 or 0 depending on whether
the encryption is set to wpa3-sae, wpa2/wpa2 mixed or any other mode
respectively.

Add the ability to specify a dictionary of default values and their
corresponding dependencies in order to be able to express such
configurations.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-19 15:40:57 +02:00
Jo-Philipp Wich
4dfa657f77 luci-base: ui.js: mark user-changed widgets
Set a `data-changed=true` attribute on the widget element when the user
did any change to the default value.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-19 15:39:46 +02:00
Jo-Philipp Wich
53ac685092 luci-base: form.js: fix default click action of button options
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-18 15:08:19 +02:00
Jo-Philipp Wich
934fa275b2 luci-base: ensure that button labels are properly html escaped
Fixes: #3067
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-18 13:51:16 +02:00
Jo-Philipp Wich
fd9182b21a luci-base: network.js: filter invalid mac addresses
Only consider valid ethernet mac addresses when building the device state
from raw getifaddrs() information.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-18 07:46:33 +02:00
Jo-Philipp Wich
10880b565f luci-base: network.js: get low level device details from getifaddr() info
Fixes: #3078
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-18 07:19:18 +02:00