Commit graph

402 commits

Author SHA1 Message Date
Anton Kikin
c00d0d9473 luci-base: ui.js: fix function declaration in nested statement
Fix "SyntaxError: Strict mode does not allow function declarations
in a lexically nested statement" error that may occur in some old
browsers (detected on QtWebKit 5.212).

Signed-off-by: Anton Kikin <a.kikin@tano-systems.com>
2020-05-24 02:12:20 +03:00
Florian Eckert
aac1a8d512
Merge pull request #4053 from TDT-AG/pr/20200515-luci-base
luci-base: fix host validation function
2020-05-19 14:06:07 +02:00
Florian Eckert
c8d24f04de luci-base: fix host validation function
Allow only ipv4 or ipv6 addresses without IP mask.
A host IP with mask does not make sense in this context.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2020-05-19 14:05:26 +02:00
Jo-Philipp Wich
9a41673488 luci-base: validation.js: count byte- instead of character length of strings
Fixes: #4055
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-05-17 21:40:27 +02:00
Jo-Philipp Wich
f8cf115d9b luci-base: optimize some PNG files
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-05-07 20:05:52 +02:00
Jo-Philipp Wich
102124115d luci-base: move old cbi icons to luci-compat
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-05-07 19:40:29 +02:00
Jo-Philipp Wich
b34b7fc504 luci-base: replace filebrowser icons with SVG variants
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-05-07 19:39:32 +02:00
Jo-Philipp Wich
f0a0d28fdd 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>
2020-05-04 21:34:12 +02:00
Jo-Philipp Wich
915e446c07 luci-base: ui.js: fix UITextfield.setValue()
Fixes: d02c26772 ("luci-base: ui.js: rework password input handling")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-05-04 21:31:38 +02:00
Jo-Philipp Wich
28cf5cd576 luci-base: firewall.js: fix Zone.addRule()
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-05-04 21:29:01 +02:00
Jo-Philipp Wich
4df3a90b3d luci-base: ui.js: reset scroll position when opening modal overlay
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-05-02 23:53:03 +02:00
Jo-Philipp Wich
e3ef463ccd 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>
2020-05-02 23:53:03 +02:00
Jo-Philipp Wich
d02c26772b luci-base: ui.js: rework password input handling
- Get rid of dummy element
 - Render password field as text input initially and later transform
   it to a password field
 - Use .control-group markup to allow better styling

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-05-02 23:53:02 +02:00
Jo-Philipp Wich
81effc1112 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>
2020-04-28 15:37:02 +02:00
Jo-Philipp Wich
428e3bd6dc luci-base: form.js: toggle inactive CSS class on unsatisfied field cells
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-28 09:51:54 +02:00
Jo-Philipp Wich
daa318c1b2 luci-base: form.js: ListValue: support widget and orientation properties
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-28 09:50:28 +02:00
Jo-Philipp Wich
2fb55e1ab5 luci-base: ui.js: fixes for radio widget type of select element
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-28 09:48:34 +02:00
Jo-Philipp Wich
17ffc84a29 luci-base: form.js: allow secondary configs to fail loading
Ref: https://forum.openwrt.org/t/luci-rpc-error/61760
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-28 09:47:08 +02:00
Jo-Philipp Wich
a8d85ed71a luci-base: firewall.js: gracefully handle missing uci configuration
Ref: https://forum.openwrt.org/t/luci-rpc-error/61760
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-28 09:47:08 +02:00
Jo-Philipp Wich
551d839f90 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>
2020-04-26 18:45:58 +02:00
Jo-Philipp Wich
49c6a810e9 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>
2020-04-26 18:45:58 +02:00
Jo-Philipp Wich
acae1378a8 luci-base: ui.js: fix textarea width
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-20 09:44:14 +02:00
Anton Kikin
7585e5c95a 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>
2020-04-19 13:56:24 +03:00
Anton Kikin
da0e974db5 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>
2020-04-19 13:56:24 +03:00
Jo-Philipp Wich
7882f3ebdd luci-base: ui.js: hide unsatisfied firstchild menu nodes
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-18 23:25:22 +02:00
Jo-Philipp Wich
01d8283ece luci-base: ui.js: order indicators by ID value
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-17 09:30:54 +02:00
Jo-Philipp Wich
90a51ab3b9 luci-base: ui.js: add LuCI.ui.menu.flushCache() function
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-16 15:13:26 +02:00
Jo-Philipp Wich
46d31efc73 luci-base: ui.js: apply disabled attribute to toplevel dynlist node
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-16 13:30:35 +02:00
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