Commit graph

340 commits

Author SHA1 Message Date
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
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
Jo-Philipp Wich
308215ca15 luci-base: luci.js: L.dom.data(): gracefully handle non-node argument
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-02-14 08:40:15 +01:00
Jo-Philipp Wich
c1aeb300f6 luci-base: form.js: pass section_id to Button onclick handler
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-02-13 19:26:33 +01:00
Jo-Philipp Wich
311bcd4b5c luci-base: form.js: ButtonValue: pass sid as first onclick argument
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-02-13 19:26:33 +01:00
Jo-Philipp Wich
dc60aaeb77 luci-base: fs.js: exec_direct(): add ability to encode command as latin1
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-02-12 11:59:41 +01:00
Jo-Philipp Wich
9bb78b5cd8 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>
2020-02-12 11:59:41 +01:00
Jo-Philipp Wich
bf774e4c2a luci-base: ui.js: dispatch "cbi-tab-active" event when a tab is selected
This is useful to lazy-load tab contents.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-02-12 11:59:41 +01:00
Jo-Philipp Wich
187bef9f6c luci-base: validation.js: fix integer and float type validation
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-01-31 17:26:57 +01:00
Jo-Philipp Wich
da4b0f0483 luci-base: fs.js: support Blob/JSON in read_direct() and exec_direct()
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-01-30 11:58:15 +01:00
Jo-Philipp Wich
478ed0d886 luci-base: luci.js: allow overriding response type for requests
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-01-30 11:45:46 +01:00
Jo-Philipp Wich
b60b4790d1 luci-base: add L.media() URL construction helper
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-01-28 11:14:42 +01:00
Jo-Philipp Wich
894752610d 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>
2020-01-22 22:02:24 +01:00
Jo-Philipp Wich
136b965b25 luci-base: ui.js: UIFileUpload fixes
- Introduce a new option `initial_directory` which describes the initial
   directory to display when nothing is selected, default to the root
   directory

 - Prevent stray legacy cbi reloads when deselecting files

 - Fix within-root-directory-check for initial rendering

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-01-20 19:40:46 +01:00
Jo-Philipp Wich
601c4ee01e luci-base: form.js: add a new "contains" dependency mode
By tagging option dependencies with `!contains`, dependencies are
considered satisfied when the value is contained in the value of
a related field, instead of being equal to it.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-01-19 16:15:22 +01:00
Jo-Philipp Wich
4670099a20 luci-base: form.js: don't stringify node arguments in CBIValue.value()
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-01-19 16:15:22 +01:00
Jo-Philipp Wich
cc123a03ce luci-base: ui.js: support clearChoices()/addChoices() for DynLists
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-01-19 16:15:22 +01:00
Jo-Philipp Wich
9733a182e8 luci-base: ui.js: use placeholder as select placeholder in DynLists
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-01-19 16:15:22 +01:00
Jo-Philipp Wich
4c52718dea luci-base: ui.js: properly handle rich choices in Dropdowns, DynLists
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-01-19 16:15:22 +01:00
Jo-Philipp Wich
aca2c4ba4e luci-base: cbi.js: collapse whitespace before language string hashing
To mirror the behavior of the Lua runtime, we need to collapse whitepace
in translation source strings before doing the string table lookup.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-01-16 18:17:09 +01:00
Jo-Philipp Wich
b65588ebc6
Merge pull request #3511 from Ansuel/no-hard
luci-base: remove hardcoded cgi-bin path
2020-01-16 15:36:05 +01:00
Ansuel Smith
529bde4408
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>
2020-01-16 15:16:09 +01:00
Ansuel Smith
5e6ec8562f
luci-base: remove hardcoded cgi-bin path
Currently LuCI can be loaded only when placed in the root of the server as the cgi-bin path are hardcoded. Change the index.html to load the cgi-bin path from the current level.
Also add a new entry in the env Object to make the cgi_base path easily accessible.
This variable will be based on the position of /cgi-bin/luci.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
2020-01-16 15:02:14 +01:00
Jo-Philipp Wich
77c2998f32 luci-base: form.js: fix immediate validation of activated options
When form options are activated because their dependencies are satisified,
ensure that an immediate validation is triggered to highlight potential
errors without having the user to activate another form control first.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-01-15 18:52:16 +01:00
Jo-Philipp Wich
9e25917432 luci-base: form.js: implement AbstractValue.getUIElement()
Introduce a new method `getUIElement()` which simplifies obtaining the
underlying per-section UI widget class instance for a from option object.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-12-30 14:51:40 +01:00
Jo-Philipp Wich
b0836b037e luci-base: ui.js: implement UIDropdown.{add,clear}Choices()
The new `addChoices()` and `clearChoices()` functions allow clearing and
adding new options to existing dropdown instances respectively.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-12-30 14:51:40 +01:00
Jo-Philipp Wich
0d0a3f4d0d luci-base: ui.js: expose UIElement class as AbstractElement
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-12-30 14:51:40 +01:00
Jo-Philipp Wich
e884b63916 luci-base: fs.js: properly escape arguments in exec_direct()
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-12-18 21:22:06 +01:00
Jo-Philipp Wich
f3724e46a5 luci-base: fs.js: add read_direct() and exec_direct() functions
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-12-18 21:10:15 +01:00
Balázs Úr
d0bc86bcc3 luci-base: fix typos
Signed-off-by: Balázs Úr <balazs@urbalazs.hu>
2019-12-17 11:41:00 +01:00
Jo-Philipp Wich
90a161018c luci-base: ui.js: allow custom validation in Dropdown and DynamicList
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-12-16 17:46:01 +01:00
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