Commit graph

12275 commits

Author SHA1 Message Date
Jo-Philipp Wich
2d705b273c luci-base: uci.js: fix section deletion logic
- Process deletions before additions or changes, allowing user code to
   remove and recreate a section with the same name.

 - Only record section deletions when the section to be removed actually
   existed in the original config or when it was staged for creation
   earlier. This avoids stray ubus not found exception when saving.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 49c6a810e9)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
b3c0560a93 luci-base: network.js: don't fail loading network config on missing wireless
Fixes: #3914
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 0e22d4d87e)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
7fc5c4aca6 luci-base: tools/widgets.js: honour map readonly property too
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit c89fd0a7f3)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
58e2200cd8 luci-base: tools/widgets.js: honour readonly property
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 0f8e5b2536)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
30c1e5b260 luci-base: uci.js: do not issue malformed uci/delete requests
Fixes: #3912
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit ec3a202b69b5bf5785c0785b2ac39efbe5cae2b7)
(cherry picked from commit 6ae1cd8fdb)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
96e3a03d8e luci-base: uci.js: fix variable clash
Don't overwrite the `r` variable which is supposed to refer to the reordered
uci sections with temporary data for collecting uci add parameters.

Fixes stray uci/get permission errors caused by an attempt to load
nonsensical uci package names.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 55cb5a753b)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
22b3919b05 luci-base: network.js: gracefully handle missing wireless config
Ref: https://github.com/openwrt/luci/issues/3895
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 65d673f467)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
a149076a3d luci-base: rpc.js: add ability to reject nonzero ubus statuses
Add a new declare option `reject` which makes the generated RPC call
function reject with an error in case the remote ubus call returned
a non-zero status.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit bd713f870a)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
0633974a26 luci-base: cbi.js: handle translation contexts in _()
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 5258080ce3)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
c952ef38d2 luci-base: cbi.js: support plural translations and disambiguation contexts
- Implement `N_(count, "String singular", "String plural" [, "Context"])`
   plural translation function.

 - Extend `_()` to optionally accept a second disambiguation context
   argument.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 894752610d)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
f044d2a4a8 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>
(cherry picked from commit f0a0d28fdd)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
750572d630 luci-base: form.js: toggle inactive CSS class on unsatisfied field cells
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 428e3bd6dc)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
dede2a9187 luci-base: form.js: ListValue: support widget and orientation properties
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit daa318c1b2)
2020-05-07 19:40:49 +02:00
Anton Kikin
8c5a3d37bd luci-base: form.js: allow to disable descriptions row in TableSection
Add 'nodescriptions' property to the TableSection class that allows
to disable displaying table header row with descriptions.

Signed-off-by: Anton Kikin <a.kikin@tano-systems.com>
(cherry picked from commit 7585e5c95a)
2020-05-07 19:40:49 +02:00
Anton Kikin
09fcfebe70 luci-base: form.js: fix TableSection descriptions row rendering
In some cases, a table cell at actions column of a descriptions row
may not be rendered. For example, this happens for GridSection when
sorting is disabled:

    s = m.section(form.GridSection, 'section_type');
    s.sortable = false;

Signed-off-by: Anton Kikin <a.kikin@tano-systems.com>
(cherry picked from commit da0e974db5)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
1c935a9963 luci-base: form.js: implement readonly property for forms and options
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 9279448148)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
4447dea2da luci-base: form.js: improve save error handling
Fixes: #3552
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 2dfcca23e4)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
cd64289554 luci-base: form.js: add documentation
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 698c8ff843)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
581ce6d116 form.js: use CSS .btn class for drag handles
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 5d8970d76c)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
3005b14815 luci-base: form.js: rendering fixes for grid sections
- Ensure that last header cell is rendered for grid sections without
   sorting or addremove actions
 - Don't skip header cells for optional options

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 9bb78b5cd8)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
d51e0d807a luci-base: ui.js: reset scroll position when opening modal overlay
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 4df3a90b3d)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
243c6c525d 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>
(cherry picked from commit e3ef463ccd)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
9be5a3df0b 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>
(cherry picked from commit 81effc1112)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
41d2df511b luci-base: ui.js: fixes for radio widget type of select element
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 2fb55e1ab5)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
e5ebf819da luci-base: ui.js: fix textarea width
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit acae1378a8)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
815824b36b luci-base: ui.js: order indicators by ID value
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 01d8283ece)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
791741f0fb luci-base: ui.js: apply disabled attribute to toplevel dynlist node
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 46d31efc73)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
cd29fdde9e luci-base: ui.js: use session data api to persist tab selection state
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 51186355ea)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
b76269ab8c luci-base: ui.js: add disabled property to widgets
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 86c797041a)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
ac4bb729ab luci-base: ui.js: add generic indicator handling functions
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 4250f99d7f)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
67b2a36e53 luci-base: ui.js: improve mobile dropdown scroll behaviour
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 0fb2f8f1d1)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
ceea8b7d5e luci-base: form.js / ui.js: tie form labels to widgets
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 22ba6fc40933bee02c3ea93bbda952bb44bf3af1)
(cherry picked from commit 82fb5a67d3)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
2c2fdaf6ea luci-base: ui.js: various tweaks
- emit checkbox markup suitable for CSS styling
 - use .btn CSS class where appropriate
 - dispatch events when updating uci change indicator
 - use correct target node when handling events in createHandlerFn()

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 993b4f7950)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
85ac64e08c luci-base: luci.js: get rid of global L references in internal classes
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(backported from commit 616d2a61e4)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
bf4dd8e335 luci-base: luci.js: share environment object among LuCI base classes
This allows us to get rid of global `L` references in luci.js itself.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit e385640505)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
bef91474bd luci-base: ensure that ubus path uses trailing slash
Without the trailing slash, probing endpoint availability will fail.

Fixes: 529bde440 ("luci-base: make rpc webserver path configurable")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 38289bc975)
2020-05-07 19:40:49 +02:00
Ansuel Smith
14a81ccb63 luci-base: make rpc webserver path configurable
Currently the ubus path that provide the webserver is hardcoded to be /ubus.
Change this to make it configurable from the luci config file.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
(backported from commit 529bde4408)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
e28f94bf01 luci-base: luci.js: add LuCI.session.getToken()
Since we're already have LuCI.session.getID() we should mirror the same
interface for retrieving the session token.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 551d839f90)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
37d07f52bd luci-base: luci.js: add hasViewPermission() helper
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit b739fc17ea)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
93f9784a04 luci-base: luci.js: fix JSdoc markup issues
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 06af541c37)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
cba0bf708f luci-base: luci.js: convert various probe* functions to session data api
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit b0c8221926)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
a198a32b2d luci-base: luci.js: add LuCI.session class
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit ef718246b1)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
87468c5731 luci-base: luci.js: add ability to add "preload" classes
Extend the LuCI bootstrap procedure to scan for class files in
/www/luci-static/preload/. Any JavaScript file found there will be
required automatically before setting up the view, allowing to stage
code that should run on every page load.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 0d0ad80fd1)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
3c6dd6deec luci-base: luci.js: add LuCI.fspath() helper
The LuCI.fspath() function allows constructing absolute filesystem paths
from path segments relative to the document root.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit fde144c9be)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
2c7645b8e9 luci-base: expose effective dispatched path to client side environment
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(backported from commit 97f27e0d54)
2020-05-07 19:40:49 +02:00
jjm2473
f42af69363 ucitrack: fix bug for exec with params
In file `/etc/config/ucitrack`
```
config fstab
        option exec '/sbin/block mount'
```
`/sbin/block mount` never be called after fstab changed.

Signed-off-by: jjm2473 <1129525450@qq.com>
(cherry picked from commit 97780a9ce1)
2020-05-07 19:40:49 +02:00
David Lam
855264221c luci-base: add system cert bundle detection
Add detection mechanism for system cert CA bundle installed by the
ca-bundle package. Used by LuCI to detect whether the "Use system
certificates" certificate validation option should be enabled.

Signed-off-by: David Lam <david@thedavid.net>
(cherry picked from commit 27b21c2a62)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
20ddfdeb4f luci-base: dispatcher.lua: pass permission state to legacy CBI templates
Ref: https://github.com/openwrt/luci/issues/3937
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit c48a8d5813)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
d122f1278b luci-base: dispatcher.lua: honour acl_depends annotations in Lua controllers
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 760763a7b5)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
9ad6320876 luci-base: dispatcher.lua: add support for handling menu ACL annotations
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 125916f2f4)
2020-05-07 19:40:49 +02:00