Commit graph

71 commits

Author SHA1 Message Date
Jo-Philipp Wich
5ce7daacda luci-base: ui.js: add LuCI.ui.menu helper class
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 930f28b606)
2020-05-07 19:40:50 +02:00
Jo-Philipp Wich
8daa236263 luci-base: ui.js: use standard indicator framework to display uci changes
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit b6e93d54a0)
2020-05-07 19:40:50 +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
a60ea6915c luci-base: ui.js: add instantiateView() helper
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit d9e9cf92d1)
2020-05-07 19:40:49 +02:00
Jo-Philipp Wich
28489b12eb 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>
(backported from commit 711f759278)
2020-05-07 19:40:48 +02:00
Kevin Darbyshire-Bryant
9705b53322 luci-base: Improve change application message
As a native English speaker the luci message displayed when clicking
'Save & Apply' has a somewhat uncomfortable English phrasing of "Waiting
for configuration to get applied".  It could be improved by replacing
'get' with 'be' but once you've got that far you might as well replace
this with the shorter & simpler "Applying configuration changes".  This
is also technically more correct since luci/openwrt should only be
updating/restarting processes that are related to the changed areas, not
changing the entire configuration.

As a result of that, change both the 'success' and 'rolled back'
messages to "Configuration changes have been applied" & "Configuration
changes have been rolled back"

Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
(cherry picked from commit 9b266d11c6)
2020-05-07 19:40:48 +02:00
Jo-Philipp Wich
c7c78291f1 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>
(cherry picked from commit bf774e4c2a)
2020-05-07 19:40:48 +02:00
Jo-Philipp Wich
ce4d8c5a9a luci-base: ui.js: allow custom validation in Dropdown and DynamicList
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 90a161018c)
2020-05-07 19:40:48 +02:00
Jo-Philipp Wich
f68a32d294 luci-base: ui.js: add documentation
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 1bb2717729)
2020-05-07 19:40:48 +02:00
Jo-Philipp Wich
50c9be16b9 luci-base: ui.js: properly handle null choices in dropdown constructor
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit f1aa3f8f6e)
2020-04-01 18:45:46 +02:00
Ansuel Smith
c1fd6f5222 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>
(cherry picked from commit 5e6ec8562f)
2020-03-04 08:50:21 +01:00
Jo-Philipp Wich
2d286c76b7 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>
(cherry picked from commit 136b965b25)
2020-01-20 19:41:49 +01:00
Jo-Philipp Wich
ae2243cb60 luci-base: ui.js: support clearChoices()/addChoices() for DynLists
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit cc123a03ce)
2020-01-19 20:15:52 +01:00
Jo-Philipp Wich
f1d10ca9ab luci-base: ui.js: use placeholder as select placeholder in DynLists
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 9733a182e8)
2020-01-19 20:15:52 +01:00
Jo-Philipp Wich
b3815b00e2 luci-base: ui.js: properly handle rich choices in Dropdowns, DynLists
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 4c52718dea)
2020-01-19 20:15:52 +01:00
Jo-Philipp Wich
b440eafb69 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>
(cherry picked from commit b0836b037e)
2019-12-30 14:52:27 +01:00
Jo-Philipp Wich
bb07c50f5e luci-base: ui.js: expose UIElement class as AbstractElement
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 0d0a3f4d0d)
2019-12-30 14:52:27 +01:00
Jo-Philipp Wich
9ca48ecc93 luci-base: ui.js: ensure that select choice labels are properly escaped
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 71d370a964)
2019-12-04 18:07:26 +01:00
Jo-Philipp Wich
4193a20d5e 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>
(cherry picked from commit ee36066947)
2019-12-04 16:09:52 +01:00
Jo-Philipp Wich
4b72056f9b luci-base: ui.js: add ComboButton widget
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 97a3bef84b)
2019-11-22 09:20:29 +01:00
Jo-Philipp Wich
f78cc97925 luci-base: ui.js: show filename after selecting upload file
Fixes: #3286
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 4cc7772ed5)
2019-11-11 10:15:48 +01:00
Jo-Philipp Wich
33346dadf4 luci-base, luci-mod-system: move file upload handling to ui.js
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-11-01 12:03:33 +01:00
Jo-Philipp Wich
2b7ca79118 luci-base: ui.js: prevent race condition in tab initialization
Fixes: #3150
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-10-22 15:51:51 +02:00
Jo-Philipp Wich
f3ef2ca2eb luci-base: ui.js: add pingDevice() and awaitReconnect() functions
Import these functions from the flash.js for use with other views that
might trigger a device reboot.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-10-07 11:53:39 +02:00
Jo-Philipp Wich
df8078d542 luci-base: ui.js: use common fs.js class for filebrowser operations
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-10-07 11:53:39 +02:00
Jo-Philipp Wich
4dfa657f77 luci-base: ui.js: mark user-changed widgets
Set a `data-changed=true` attribute on the widget element when the user
did any change to the default value.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-19 15:39:46 +02:00
Jo-Philipp Wich
934fa275b2 luci-base: ensure that button labels are properly html escaped
Fixes: #3067
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-18 13:51:16 +02:00
Jo-Philipp Wich
94a9f600d3 luci-base: ui.js: implement addNotification() helper
The L.ui.addNotification() function pushes a dismissable banner message to
the top of the view.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-11 09:22:13 +02:00
Jo-Philipp Wich
3f93650901 luci-base: use cgi-io and rpcd-mod-file to handle file upload and browsing
Remove the old server side support for file browsing and file uploading
and switch to a client side widget instead which uses XMLHTTPRequests to
upload files via cgi-io and RPC calls for file listing and status queries.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-10 15:28:16 +02:00
Jo-Philipp Wich
d905dacf97 luci-base: ui.js: update tabs after initial render
This ensures that the error badges are properly set.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-10 15:28:16 +02:00
Jo-Philipp Wich
b0dde567ca luci-base: ui.js: also handle failed promises in createHandlerFn()
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-10 15:28:16 +02:00
Jo-Philipp Wich
3500562d5e luci-base: ui.js: ignore description when checking for empty tab panes
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-10 15:28:16 +02:00
Jo-Philipp Wich
afd361e368 luci-base: ui.js: implement Textarea widget
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-08-19 15:04:16 +02:00
Jo-Philipp Wich
7179d2e6dd luci-base: ui.js: add createHandlerFn() helper
The createHandlerFn() helper function is useful to construct onclick
or similar event handling functions. It will add a "spinning" CSS
class on the event target element and disable the element, wrap the
given function with Promise.resolv() and re-enable the target element
once the promise is settled.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-08-14 22:58:15 +02:00
Jo-Philipp Wich
c2eba00a10 luci-base: ui.js: rework tab state handling
Properly preserve the selection state of nested tabs.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-08-14 22:58:15 +02:00
Jo-Philipp Wich
43a8c12f04 luci-base: ui.js: UISelect: fix check for empty choices
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-08-14 22:58:15 +02:00
Jo-Philipp Wich
d1e9841e86 luci-base: ui.js: do not forcibly sort synamic list items
Ref: https://forum.openwrt.org/t/cannot-save-certain-fields/42738/2
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-08-14 22:46:19 +02:00
Jo-Philipp Wich
89bcae20d0 luci-base: ui.js: tabs: fix empty pane checking, allow alternative query root
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-08-01 16:47:19 +02:00