Commit graph

55 commits

Author SHA1 Message Date
Jo-Philipp Wich
28ab21dd8d luci-base: handle application/json replies with charset specification
On my router, the response header Content-Type is
`application/json; charset=UTF-8` instead of `application/json`, so
almost every feature is broken.

Fixes: #2851
Suggested-by: zhanhb <6323014+zhanhb@users.noreply.github.com>
[reword commit subject]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-07-26 12:46:39 +02:00
Jo-Philipp Wich
f1a5b179dd luci-base: fix cbi dropdown quirks with MS Edge
On MS Edge, the behaviour of "value" attributes on "li" elements is
unreliable, so use the "data-" prefix to circumvent the problem.

Ref: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/19320991/
Fixes: #2224
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 9e6949849d)
2019-01-20 12:00:37 +01:00
Jo-Philipp Wich
64e3fe9f6b luci-base: xhr.js: decode JSON for POST requests as well
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 98217f8f8d)
2018-07-28 17:14:22 +02:00
Jo-Philipp Wich
97b3e5773d luci-base: cbi.js: fade to-be-deleted section when hovering delete button
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 590d1cc74f)
2018-07-26 20:31:05 +02:00
Jo-Philipp Wich
6cf7d11e15 luci-base: cbi.js: use adjacent button dynlist add/remove buttons
Change the cbi.js code to create  a div based button element instead of an
image button.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 875b561875)
2018-07-26 20:30:44 +02:00
Jo-Philipp Wich
392fd02383 luci-base: cbi.js: add cbi_submit() helper
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 7b43e81c9b)
2018-07-20 07:56:12 +02:00
Jo-Philipp Wich
94b6aa2a8e luci-base: remove unused icons
- The wifi_big.png / wifi_big_disabled.png icons were used on the wireless
   overview page which now uses badges with normal sized icons
 - The encryption.png / encryption_disabled.png icons were never used at all

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 92360f2d5b)
2018-07-17 20:52:24 +02:00
Jo-Philipp Wich
b38306dcee luci-base: xhr: increase poll request timeout
Some status requests can take quite some time to finish, the LuCI DSL
status information in particular.

Since the polling loop code already takes care of not relaunching
requests which are already running, increase the per iteration timeout
to up to five times the poll interval.

This should be sufficient to let most operations complete.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-13 16:55:47 +02:00
Jo-Philipp Wich
85bc16605d luci-base: add icons for alias interfaces
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-12 18:10:59 +02:00
Jo-Philipp Wich
674b090d34 luci-base: xhr.js: use JSON.parse() and pass request duration to callbacks
JSON.parse() is supported on all modern browsers and a far better
solution than the hakish and potentially dangerous eval().

Also calculate the duration of request and pass it as 3rd argument to the
callback function, this makes it easier to calculate request delays or
poll intervals in code using XHR.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-12 18:10:10 +02:00
Jo-Philipp Wich
6cda8e6dab luci-base: cbi.js: avoid setting empty cell title attributes
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-09 11:51:43 +02:00
Jo-Philipp Wich
260d2cc44e luci-base: cbi.js: add NodeList.forEach() polyfill for IE 11
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-09 11:51:43 +02:00
Jo-Philipp Wich
c4bd6fb7b9 luci-base: cbi.js: add tooltip handling and responsive table helper code
- make findParent() globally available
 - add code for initializing rich cbi tooltips
 - introduce cbi_update_table() helper to auto-assign responsive attributes
   to table markup

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-22 15:14:40 +02:00
Jo-Philipp Wich
69782ccbcc luci-base: xhr.js: defer starting poll queue
Defer the start of the queue poll loop until the document has been loaded.

This allows all XHR.poll() invocations on the page to register their
handlers before the first batch of requests is made.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-22 09:42:15 +02:00
Jo-Philipp Wich
9d48490729 luci-base: add markup, JS and CSS for new dropdown
This commit introduces the required code for a new, markup based dropdown
widget which can be used as a styleable alternative to select boxes or
radio/checkbox button groups.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-08 08:14:36 +02:00
Jo-Philipp Wich
c3da1fc232 luci-base: cbi.js: remove unused serialize functions
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-30 16:04:07 +02:00
Jo-Philipp Wich
d1df5a6b7d luci-base: cbi.js: fix cbi_row_swap() after recent table markup changes
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-30 15:59:52 +02:00
Jo-Philipp Wich
79c82237e3 luci-base: add element creation helper to cbi.js
Add a new helper function `E()` to cbi.js which can be used to conveniently
build HTML markup.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-28 15:18:45 +02:00
Jo-Philipp Wich
34821b15a5 luci-base: xhr.js: fix timeout setting with IE 11
Internet Explorer 11 requires the timeout to be applied after the open()
call, otherwise an invlaid state exception will be raised

Fixes aa6c97154 ("luci-base: extend xhr.js")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-05 21:16:53 +02:00
Jo-Philipp Wich
aa6c97154e luci-base: extend xhr.js
Add timeout options to get() and post() and introduce XHR.stop() to support
stopping a poll operation.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-26 09:40:17 +02:00
Jo-Philipp Wich
70ffbe65a0 luci-base: add a strict flag to the hostname validator
Some applications, e.g. dnsmasq, do not allow hostnames starting with an
underscore, therefor extend the existing hostname datatype validator with
a `strict` which disallows a leading underscore.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-04 23:21:53 +02:00
Jo-Philipp Wich
de4f1c9046 luci-base: rework client side IP validation types and support "hostid" type
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-02-16 17:05:48 +01:00
Jo-Philipp Wich
fbe7f90eed luci-base: fix client side "host" datatype validator
Fixes #1413.

Reported-by: Wojciech Jowsa <wojciech.jowsa@gmail.com>
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2017-10-25 14:23:47 +02:00
Yousong Zhou
3809bd6ffb luci-base: datatypes: add cidr, ipnet validator type
- Rewrite ipmask to use these subtypes
- Add ip{4,6}prefix validators to cbi.js

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2017-08-22 20:19:49 +08:00
Jo-Philipp Wich
bf407f087c Merge pull request #1245 from danweller18/feature_js_headers
luci-base: Remove request headers that are set automatically by browser
2017-08-02 10:34:59 +02:00
Jo-Philipp Wich
4c9ae3f615 luci-base: cbi.js: fix handling of inverse-depends, combobox validation
- Properly handle logic for evaluating inverted dependencies means
   when depending on another field *not* having a given value

 - Perform datatype validation *after* populating combobox choices to
   avoid triggering a false-positive when validating an .rmempty = false
   combobox during form instantiation

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2017-07-28 16:14:53 +02:00
Daniel W
adb6209503 remove request headers that are set automatically by browser 2017-07-22 12:11:14 -04:00
Yousong Zhou
c759500d49 luci-base: fix loading fold.gif for filebrowser
cbi_init() needs to be called at the end of the page to initialize
cbi_strings with "[data-strings]" while cbi_browser_init() happened
before that.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2017-07-21 20:34:46 +08:00
Jo-Philipp Wich
e4b1bb3156 luci-base: ipmask, ipmask4 and ipmask6 validators
These validators accept IP address specifications in the form

 - address
 - address/bits
 - address/netmask

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2017-01-23 16:15:22 +01:00
Jian Chang
260a24aadb luci-base:adjust the code order
The `cbi_validate_field` should be after data initialized.

Signed-off-by: Jian Chang <aa65535@live.com>
2017-01-03 19:00:53 +08:00
Jo-Philipp Wich
6a11f71758 luci-base: cbi.js: handle undefined arguments in formatting
Fix the JavaScript String.format() to not trigger an exception if the argument
for an escaped format like %h or %q is undefined.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2016-08-04 11:45:30 +02:00
Jo-Philipp Wich
3b86fd1d1b luci-base: cbi: fix button handling for dynamic lists
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2016-02-19 17:21:06 +01:00
Jo-Philipp Wich
99f5d4e902 luci-base: cbi.js: properly round down numbers for %u and %d patterns
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2016-02-17 16:33:34 +01:00
Jo-Philipp Wich
a860de860a luci-base: cbi.js: string formatting fixes
* Fix left and right justify/padding in formats
* Do not emit decimal numbers for small values in %m format

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2016-02-15 12:45:42 +01:00
Jo-Philipp Wich
9ce798abd4 luci-base: cbi: properly handle dependant elements without parent
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2016-02-10 19:29:34 +01:00
Jo-Philipp Wich
58e2f557da luci-base: cbi: only spawn dynlist sub-comboboxes if choices are available
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2016-02-10 18:23:39 +01:00
Jo-Philipp Wich
6d126649f0 luci-base: cbi: further refactoring
Eliminate more inline scripts in favor to global initialization, use a global
object for sharing fixed strings instead of passing them to each invocation.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2016-02-10 18:11:49 +01:00
Jo-Philipp Wich
cd85ef388c luci-base: fix dependency handling of optionals (#645)
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2016-02-09 16:12:02 +01:00
Jo-Philipp Wich
7b7783f0ee luci-base: cbi: optimize tab hide logic
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2016-01-19 10:36:54 +01:00
Jo-Philipp Wich
6f688a3265 luci-base: cbi: fix event binding js
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2016-01-19 10:36:54 +01:00
Jo-Philipp Wich
2bd428ad8a luci-base: cbi: prevent unintended focus on combobox init
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2016-01-18 20:14:47 +01:00
Jo-Philipp Wich
5eaf4cc489 luci-base: cbi: refactor event handling js
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2016-01-18 19:34:02 +01:00
Jo-Philipp Wich
808c1b77f9 luci-base: cbi: fix reverse field order after dependency change
When fields got removed and readded due to unsatisfied dependencies, they
got inserted in reverse order into the dom.

Fix this issue by properly passing the element index.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2016-01-18 18:59:19 +01:00
Jo-Philipp Wich
b50471787f luci-base: refactor cbi dependency handling code
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2016-01-18 17:05:36 +01:00
Jo-Philipp Wich
be8dba57a9 luci-base: improve tab hide logic
Do not rely on explicit child counts but inspect the code instead to decide
when to hide tabs or not.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2016-01-18 11:23:11 +01:00
Jo-Philipp Wich
aa12e53333 luci-base: add extra css class for map level tabs, don't track tab child count
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2016-01-18 11:04:15 +01:00
Daniel Dickinson
c481f3f343 validation: Add option ipv4only option to host and hostport datatypes
Some applications only support ipv4 so add ipv4only option
to host and hostport datatypes so that for thos applications
that when an IP address is specified only and ipv4 ip address
gets accepted.
2015-12-15 20:41:01 -05:00
Daniel Dickinson
bbcfad7953 modules/luci-base: Fix ipaddrport validator to support ipv6
The previous versiono of ipaddrport validator only worked for ipv4
due to disallowing colons (:) in ip address which obvious fails for
ipv6.  We now instead allow either ipv4 address or an ipv6 address of
the form [<ipv6address>]:port
2015-12-15 20:40:14 -05:00
Daniel Dickinson
6318f67fd4 luci-base: Add time and data datatypes for use with firewall app
Adding LuCI configuation of the firewall time and data uci options
is in progress and this adds the necessary datatypes for validating
those fields.
2015-12-14 23:26:26 -05:00
Jo-Philipp Wich
9b30357454 luci-base: add hostport and ipaddrport validation types
Add two new types 'hostport' and 'ipaddrport' to validate strings in the form
'sub.example.org:1234' and '0.0.0.0:80'. The 'hostport' accepts hostnames or
IP addresses followed by a colon and a port number while the 'ipaddrport' type
accepts numeric IP addresses only, followed by a colon and a port.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-12-02 11:13:39 +01:00