Commit graph

374 commits

Author SHA1 Message Date
Jo-Philipp Wich
616d2a61e4 luci-base: luci.js: get rid of global L references in internal classes
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-16 13:30:35 +02:00
Jo-Philipp Wich
930f28b606 luci-base: ui.js: add LuCI.ui.menu helper class
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-16 13:30:35 +02:00
Jo-Philipp Wich
51186355ea luci-base: ui.js: use session data api to persist tab selection state
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-16 13:30:35 +02:00
Jo-Philipp Wich
adeb0f3aa6 luci-base: luci.js: disable page action buttons on readonly views
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-16 13:30:35 +02:00
Jo-Philipp Wich
b739fc17ea luci-base: luci.js: add hasViewPermission() helper
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-16 13:30:35 +02:00
Jo-Philipp Wich
06af541c37 luci-base: luci.js: fix JSdoc markup issues
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-16 13:30:35 +02:00
Jo-Philipp Wich
b0c8221926 luci-base: luci.js: convert various probe* functions to session data api
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-16 13:30:35 +02:00
Jo-Philipp Wich
ef718246b1 luci-base: luci.js: add LuCI.session class
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-16 13:30:35 +02:00
Jo-Philipp Wich
e385640505 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>
2020-04-16 10:49:05 +02:00
Jo-Philipp Wich
0e22d4d87e luci-base: network.js: don't fail loading network config on missing wireless
Fixes: #3914
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-15 09:29:29 +02:00
Jo-Philipp Wich
b9dda90716 Revert "build: luci.mk: gracefully handle missing or unversioned po subdirectories"
This reverts commit e6f77d5d72.
Commit contained unrelated changes.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-14 18:42:36 +02:00
Jo-Philipp Wich
e6f77d5d72 build: luci.mk: gracefully handle missing or unversioned po subdirectories
Fixes: #3911
Fixes: 9d8e99f9b build: gracefully handle non-Git source trees
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-14 18:29:13 +02:00
Jo-Philipp Wich
5c22340f43 luci-base: form.js: make map readonly on insufficient uci permissions
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-14 17:13:19 +02:00
Jo-Philipp Wich
c89fd0a7f3 luci-base: tools/widgets.js: honour map readonly property too
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-14 17:12:47 +02:00
Jo-Philipp Wich
b6e93d54a0 luci-base: ui.js: use standard indicator framework to display uci changes
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-14 17:10:06 +02:00
Jo-Philipp Wich
0f8e5b2536 luci-base: tools/widgets.js: honour readonly property
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-14 17:09:12 +02:00
Jo-Philipp Wich
9279448148 luci-base: form.js: implement readonly property for forms and options
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-14 17:08:36 +02:00
Jo-Philipp Wich
86c797041a luci-base: ui.js: add disabled property to widgets
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-14 17:07:34 +02:00
Jo-Philipp Wich
68b2ce84ec luci-base: luci.js: use standard indicator framework for poll status
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-14 17:06:34 +02:00
Jo-Philipp Wich
6ae1cd8fdb 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)
2020-04-14 17:03:43 +02:00
Jo-Philipp Wich
55cb5a753b 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>
2020-04-13 12:22:13 +02:00
Jo-Philipp Wich
0d0ad80fd1 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>
2020-04-12 23:55:36 +02:00
Jo-Philipp Wich
fde144c9be 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>
2020-04-12 22:51:28 +02:00
Jo-Philipp Wich
65d673f467 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>
2020-04-11 21:26:16 +02:00
Jo-Philipp Wich
65d28a4ac9 luci-base: uci.js: let internal RPC functions reject on errors
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-10 22:52:52 +02:00
Jo-Philipp Wich
bd713f870a 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>
2020-04-10 22:50:41 +02:00
Jo-Philipp Wich
2dfcca23e4 luci-base: form.js: improve save error handling
Fixes: #3552
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-10 20:38:58 +02:00
Jo-Philipp Wich
e331e32b2c
Merge pull request #3749 from Ansuel/fix_relayd
luci-base: fix error 404 on missing relay protocol
2020-04-08 09:15:38 +02:00
Jo-Philipp Wich
698c8ff843 luci-base: form.js: add documentation
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-07 16:35:15 +02:00
Jo-Philipp Wich
249b5bb8c6 luci-base: reintroduce accidentally lost isCreateable() function
Fixes: FS#2976
Fixes: 711f75927 ("luci-base: harmonize JS class naming and requesting")
Ref: https://bugs.openwrt.org/index.php?do=details&task_id=2976
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-06 20:49:44 +02:00
Jo-Philipp Wich
d9e9cf92d1 luci-base: ui.js: add instantiateView() helper
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-03 13:26:44 +02:00
Jo-Philipp Wich
711f759278 luci-base: harmonize JS class naming and requesting
- Make builtin classes available via `require` to allow view code to
   request external and internal classes in a consistent manner without
   having to know which classes are builtin and which not

 - Make base classes request any used class explicitely instead of
   relying on implicitly set up L.{dom,view,Poll,Request,Class} aliases

 - Consistently convert class names to lower case in JSdoc to match
   the names used in `require` statements

 - Deprecate L.{dom,view,Poll,Request,Class} aliases

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-02 21:51:20 +02:00
Jo-Philipp Wich
f1aa3f8f6e luci-base: ui.js: properly handle null choices in dropdown constructor
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-01 18:45:18 +02:00
Jo-Philipp Wich
4250f99d7f luci-base: ui.js: add generic indicator handling functions
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-03-31 21:31:04 +02:00
Jo-Philipp Wich
1bb2717729 luci-base: ui.js: add documentation
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-03-31 21:31:04 +02:00
Jo-Philipp Wich
a63cea83bd luci-base: network.js: fix JSDoc syntax error
Fixes: 506dc5a90 ("luci-base: extended network.js for check if new interface is createable")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-03-30 17:36:29 +02:00
Jo-Philipp Wich
4c55e8226d luci-base: firewall.js: fix Firewall.removeZone()
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-03-26 19:12:38 +01:00
Jo-Philipp Wich
0fb2f8f1d1 luci-base: ui.js: improve mobile dropdown scroll behaviour
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-03-25 12:35:15 +01:00
Jo-Philipp Wich
82fb5a67d3 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)
2020-03-24 22:14:18 +01:00
Jo-Philipp Wich
5d8970d76c form.js: use CSS .btn class for drag handles
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-03-23 21:47:35 +01:00
Jo-Philipp Wich
7c3b3018b3 luci-base: luci.js: tweak CSS classes
- use .btn CSS class for Save & Apply button
 - use .control-group CSS class for page action buttons

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-03-23 21:41:16 +01:00
Jo-Philipp Wich
993b4f7950 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>
2020-03-23 21:36:59 +01:00
Ansuel Smith
3d70d3e5d7
luci-base: fix error 404 on missing relay protocol
Currently relay.js is included in any case even if
the router doesn't have the needed package to use it.
Fix this by checking if the system has this feature.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
2020-03-12 16:46:53 +01:00
Jo-Philipp Wich
fc94ff1881
Merge pull request #3712 from TDT-AG/pr/20200303-luci-base
luci-base: extended network.js for check if new interface is createable
2020-03-04 20:26:57 +01:00
Jo-Philipp Wich
d5f30d335f luci-base: network.js: gracefully handle deleteConfiguration() rejects
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-03-03 21:30:32 +01:00
Jo-Philipp Wich
a22aba2fed luci-base: network.js: add Protocol.deleteConfiguration() callback
Add a new Protocol.deleteConfiguration() callback function which can be
overridden by protocol handler to perform additional cleanup tasks, such
as unsetting related uci entries which are not part of the interface
configuration itself.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-03-03 21:22:44 +01:00
Helge Mader
506dc5a903 luci-base: extended network.js for check if new interface is createable
Signed-off-by: Helge Mader <ma@dev.tdt.de>
2020-03-03 13:53:09 +01:00
Jo-Philipp Wich
4052436d82 luci-base: firewall.js: don't treat zone name as network fallback
Drop obsolete extra logic which treats the zone name as covered network
name in case the network list is unset. This behaviour applied to the
pre-fw3 uci firewall, but is not supported since fw3 anymore.

Ref: https://forum.openwrt.org/t/luci-zone-creation-bug/55921
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-03-02 10:10:27 +01:00
Jo-Philipp Wich
9ae1f47896 luci-base: cbi.js: avoid double-initialization of dropdowns
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-02-14 08:43:28 +01:00
Jo-Philipp Wich
5258080ce3 luci-base: cbi.js: handle translation contexts in _()
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-02-14 08:42:04 +01:00