summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/htdocs/luci-static/resources/luci.js
AgeCommit message (Collapse)Author
2023-08-11luci-base: grammar fixesPaul Dee
Login (n) -> Log (v) in Logout (n) -> Log (v) out Signed-off-by: Paul Dee <itsascambutmailmeanyway@gmail.com>
2022-07-27luci-base: luci.js: add array sort utilitiesJo-Philipp Wich
Add two new utility functions L.naturalCompare() and L.sortedArray() to simplify sorting arrays naturally. Ref: #5899 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-05-16luci-base: luci.js: remove wrong CSS class from page footerJo-Philipp Wich
The `control-group` class is meant for gapless grouping of inputs with buttons, while the page actions are just distinct buttons in a row. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-02-21luci-base: properly handle promise targets in Request.request()Jo-Philipp Wich
Under some circumstances, ubus RPC requests may be initiated while LuCI is still resolving the `rpcBaseURL` value. In this situation, the `target` argument of the `request()` call will be a pending promise object which results in an invalid URL when serialized by `expandURL()`, leading to an `Failed to execute 'open' on 'XMLHttpRequest': Invalid URL` exception. This commonly occured on the index status page which immediately initiates ubus RPC calls on load to discover existing status page partials. Solve the issue by filtering the given `target` argument through `Promise.resolve()` before expanding the URL and initiating the actual request. Fixes: #3747 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-12-23luci.js: remove unsafe fallback code from dom.parse()Jo-Philipp Wich
Do not fallback to .innerHTML if DOMParser() failed for whatever reason. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-11-16luci-base: luci.js: fix undefined variable access in Request.request()Jo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-08-09luci-base: fix request timeout docstringPaul Spooren
The `timeout` is defined in milliseconds, not seconds. Signed-off-by: Paul Spooren <mail@aparcar.org>
2021-02-10luci-base: luci.js: fix sortedKeys() orderingJo-Philipp Wich
Chrome does not properly sort arrays when the sort function returns boolean results, in contrast to Firefox which does. Fix the issue by returning a numerical result instead. Fixes: #4792 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-01-20treewide: minor fixes to typos, whitespace, and indentationGiovanni Giacobbi
Signed-off-by: Giovanni Giacobbi <giovanni@giacobbi.net>
2021-01-19luci-base: luci.js: fix `LuCI.request.poll.add()` exception handlingGiovanni Giacobbi
The try/catch is meant for the `res.json()` call and should apply to that. As it was before, an exception inside the poll callback would cause the callback to be reinvoked without the JSON parameter, which is an odd behaviour. Moreover, it makes it hard to debug because it is completely hidden from the browser console. We now differentiate between exceptions thrown due to bad JSON in `responseText` from exceptions generated inside the callback itself, which are let through for browser console logging. Signed-off-by: Giovanni Giacobbi <giovanni@giacobbi.net>
2020-09-15luci-base: use actual JSON-RPC for verifying ubus RPC URLRafał Miłecki
Sending GET request to the main RPC base URL and expecting HTTP response code 400 had two flaws: 1. It was not verifying actual JSON-RPC interface availability 2. It did not allow implementing support for new requests Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Acked-by: Jo-Philipp Wich <jo@mein.io>
2020-05-29luci-base: luci.js: properly skip comments when finding require tokensJo-Philipp Wich
Fixes: #4020, #4022, #4111 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-26luci-base: luci.js: add LuCI.session.getToken()Jo-Philipp Wich
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-16luci-base: luci.js: get rid of global `L` references in internal classesJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-16luci-base: luci.js: disable page action buttons on readonly viewsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-16luci-base: luci.js: add hasViewPermission() helperJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-16luci-base: luci.js: fix JSdoc markup issuesJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-16luci-base: luci.js: convert various probe* functions to session data apiJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-16luci-base: luci.js: add LuCI.session classJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-16luci-base: luci.js: share environment object among LuCI base classesJo-Philipp Wich
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-14Revert "build: luci.mk: gracefully handle missing or unversioned po ↵Jo-Philipp Wich
subdirectories" This reverts commit e6f77d5d72c0e13ed3eb370419abab52c4920a32. Commit contained unrelated changes. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-14build: luci.mk: gracefully handle missing or unversioned po subdirectoriesJo-Philipp Wich
Fixes: #3911 Fixes: 9d8e99f9b build: gracefully handle non-Git source trees Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-14luci-base: luci.js: use standard indicator framework for poll statusJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-12luci-base: luci.js: add ability to add "preload" classesJo-Philipp Wich
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-12luci-base: luci.js: add LuCI.fspath() helperJo-Philipp Wich
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-02luci-base: harmonize JS class naming and requestingJo-Philipp Wich
- 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-03-23luci-base: luci.js: tweak CSS classesJo-Philipp Wich
- 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-02-14luci-base: luci.js: L.dom.data(): gracefully handle non-node argumentJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-01-30luci-base: luci.js: allow overriding response type for requestsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-01-28luci-base: add L.media() URL construction helperJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-01-16Merge pull request #3511 from Ansuel/no-hardJo-Philipp Wich
luci-base: remove hardcoded cgi-bin path
2020-01-16luci-base: make rpc webserver path configurableAnsuel Smith
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-16luci-base: remove hardcoded cgi-bin pathAnsuel Smith
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>
2019-11-26luci-base: luci.js: further nested Class.super() call fixesJo-Philipp Wich
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-26luci-base: luci.js: properly handle nested Class.super() callsJo-Philipp Wich
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-10luci-base: luci.js: add optional apply unchecked actionJo-Philipp Wich
Turn the "Save & Apply" button into a combo button which allows to toggle between apply with rollback and unchecked apply modes. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-10-07luci-base: luci.js: add resolveDefault() helperJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-10-02luci-base: luci.js, rpc.js, uci.js, network.js: add JSDoc annotationsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-21luci-base: tie cached system features to user sessionJo-Philipp Wich
Store the cached system feature flags keyed by the current session id, this ensures that the features are refreshed on login. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-21luci-base: luci.js: improve XHR issue diagnosticsJo-Philipp Wich
Differentiate between request timeouts and other error reasons. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-18luci-base: ensure that button labels are properly html escapedJo-Philipp Wich
Fixes: #3067 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-17luci-base: luci.js: render view buttons depending on available functionsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-14luci-base: luci.js: append version when dynamically loading classesJo-Philipp Wich
This allows for some naive cache busting when the LuCI version changes, to avoid loading outdated classes from cache. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-11luci-base: luci.js: register rpc interceptor to catch expired sessionsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-11luci-base: luci.js: rework error handlingJo-Philipp Wich
- Capture stack trace in L.raise() if passed type is not an Error instance - Use L.ui.addNotification in L.error() to render the error message - Prevent duplicate error reporting in the ui Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-10luci-base: luci.js: use createHandlerFn() for page actionsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-10luci-base: luci.js: support passing FormData as request payloadJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-10luci-base: luci.js: support registering request progress handlersJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-10luci-base: luci.js: fix L.Poll.remove()Jo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-10luci-base: luci.js: support custom filter function in dom.isEmpty()Jo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>