summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/luasrc
AgeCommit message (Collapse)Author
2018-07-28luci-base: fix footer templateJo-Philipp Wich
Move the apply widget markup before the final </html> tag to avoid XHTML errors with the OpenWrt theme. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-27treewide: rework rollback/apply workflowJo-Philipp Wich
Rework the apply confirmation mechanism to be session agnostic in order to circumvent cross domain restrictions which prevent the JS code from issuing apply confirm requests in some cases, e.g. when changing the LAN IP. Confirmation calls may now be done from unauthenticated pages, as long as a matching confirmation token is sent along with the request. The reasoning behind this is that there is little security impact in confirming pending apply sessions, especially since those sessions can only be initiated while being authenticated. After this change, LuCI will now launch a confirmation process on every rendered page when a rollback is pending. The confirmation will happen regardless of whether the user is logged in or not, or if the current page is a CBI form or static template. A confirmation request now also requires a random one-time token which is rendered along with the confirmation JavaScript code in order to succeed. This token is not meant to provide security but to ensure that the confirm was triggered from an interactive browser session and not some background HTTP requests that happened to end up in the admin ui. As a consequence, the different apply/confirm/rollback code paths in CBI maps and the UCI change/revert pages have been consolidated into one common implementation residing in the common global theme agnostic footer template. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-27luci-base: utils: support multiple return values in util.ubus()Jo-Philipp Wich
This is needed to deal with ubus methods that return multiple results, e.g. session/list Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-23luci-base: strip superfluous space in additional field markupJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-23luci-base: rework reveal/hide CBI password template buttonJo-Philipp Wich
Also add a hidden type password field to prevent browser autocompleters from entering the login passwords into fields liek the wireless WPA key field. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-22luci-base: add description annotations to tblsection cellsJo-Philipp Wich
Add a "data-description" attribute to CBI fields which have a description set, this allows responsive design themes to render a field description when decomposing the table grid. Also reuse the precalculated "typename" property if it exists, instead of deriving it from the template name yet again. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-20luci-base: fix bad CSS class names in table section templateJo-Philipp Wich
The previous refactoring of the template caused the row stripying CSS classes to be interpolated in such a way, that a separating space to previous CSS classes was missing, leading to not rendered row names and other side effects. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-18luci-base: rework CBI footer templateJo-Philipp Wich
- Make sure that hitting enter in the form hits the CBI save action and not apply or cancel - Hide action panel if no actions are available - CLeanup code Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-18luci-base: rework tblsection templateJo-Philipp Wich
- Hide empty title and description rows - Correct row striping offset - Cleanup code Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-18luci-base: rework simpleform templateJo-Philipp Wich
- Ensure that pressing enter in the form triggers the submit action and not a cbi skip or cancel - Hide page actions when empty - Cleanup code Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-16luci-base: fix field section add button/input field namesJo-Philipp Wich
Some CBI map models, mainly the Network -> VLAN page, expect a valid previous section ID in their Section:create() callback. Previous refactoring of the tblsection markup broke this behaviour as the "section" loop variable was accidentally localized, causing it to be undefined outside of the loop body which caused the section add button and name input fields to get rendered with a wrong "name" attribute. Fix this by moving the "section" variable declaration out of the loop and by readding references to it in the non-anonymous section add case. Fixes FS#1657 Fixes 002c4d1d5 ("luci-base: add "Name" label to autogenerated title column") Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-15luci-base: fix handling alias interfaces in ifacelist widgetJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-15luci-base: luci.model.network: recognize alias interfacesJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-13luci-base: tweak tblsection markupJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-12luci-base: add error reporting and basic support for dynamic interfacesJo-Philipp Wich
This allows exposing virtual ubus-based network interfaces in LuCI. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-12luci-base: apply_widget: various fixesJo-Philipp Wich
- Fix button styles in failure message - Pause XHR polling during apply/rollback sessions - Throttle confirm requests to 1 request/second Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-09luci-base: fix placement of CBI stringsJo-Philipp Wich
Commit c0de036b3 ("treewide: always include cbi.js") improperly removed the cbi.js script include from header.htm, leaving behind the string dictionary. Move the JSON dictionary to the parent <form> element and delete the leftover </script> element. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-09treewide: always include cbi.jsJo-Philipp Wich
Include cbi.js in the main header template like it is done for xhr.js and remove the page specific includes. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-02luci-base: rework "in request" flagging logic for menu nodesJo-Philipp Wich
The previous implementation failed to mark active nodes under some circumstances. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-28luci-base: luci.tools.status: add host_hints to DHCPv6 leasesJo-Philipp Wich
Attempt to derive a MAC from the DHCPv6 lease DUID and use it to look up a host hint. If a hint is found, add it to the lease information. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-25luci-base: add "Name" label to autogenerated title columnJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-25luci-base: annotate tblsection description row as wellJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-25luci-base, luci-mod-admin-full: unify wifi assoclist codeJo-Philipp Wich
Merge the assoclist code of the status overview and wireless overview pages into a single shared partial template. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-23luci-base: globally cleanup markupJo-Philipp Wich
- add responsive attributes to partial cbi templates - unify and fix button style classes - fix styling of sysauth dialog - rework firewall_zoneforwards widget Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-08treewide: switch firewall zone, network and iface lists to dropdown codeJo-Philipp Wich
Also switch the weekday and monthday lists in the firewall rule details to cbi dropdowns, vastly uncluttering the form. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-08luci-base: add markup, JS and CSS for new dropdownJo-Philipp Wich
This commit introduces the required code for a new, markup based dropdown widget which can be used as a styleable alternative to select boxes or radio/checkbox button groups. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-08luci-base: support option aliases in luci.cbiJo-Philipp Wich
AbstractValue descendants may now specify a new optional property `alias` which refers to a uci option to read/write/remove that differs from the option name itself. This is mainly useful for widgets that are toggled based on dependencies, e.g. for alternating between SingleValue and MultiValue, but which are intented to write into the same uci option. Such a setup was previously possible already by overriding the .cfgvalue(), .write() and .remove() callbacks with custom implementations, but that required a lot of boiler plate code and was rather fragile. With the `alias` property, CBI now takes care of the details and tracks aliased fields within a section accordingly. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-06luci-base: fix some minor luci.model.uci issuesJo-Philipp Wich
- Properly serialize option delete changelogs - Do not perform a section create if a nil value is passed to set() Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-03luci-base: cbi: atomically reorder uci sectionsJo-Philipp Wich
Since the switch to ubus uci operations we do not have a local application- side cursor cache anymore, instead uci operations happen synchronously in the rpcd backend server. This may cause cbi section reorder operations involving multiple elements to fail, because anonymous section hashes may change due to rehashing between consecutive ubus uci reorder calls. In order to avoid that problem, use the ubus uci batch reorder extension, which allows to pass a complete (or partial) list of section ids in the desired order in one call, bypassing the volatile section id problem. Fixes #1844. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-31luci-base: use common alert message markupJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-31luci-base: update coxpcall() implementation, fix runtime error reportingJo-Philipp Wich
Sync our coxpcall() implementation to the newest upstream version in order to get access to the inner backtrace information and propagate these traces to the browser in luci.dispatcher.dispatch(). This should make tracking down runtime errors much easier. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-31luci-base: add full page overlay during applyJo-Philipp Wich
After applying uci configuration, a full map reload is required in many cases as the anonymous section identifiers might have been rehashed, causing the rendered map to go out of sync. To avoid that, add both a full page overlay preventing further page interaction and let the apply widget forcibly reload the current view once the operation is complete. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-28treewide: convert HTML tables to divJo-Philipp Wich
Mostly convert HTML tables to div based markup to allow for easier styling in the future. Also change JS accessor code accordingly. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-23luci-base: fix dispacher failAnsuel Smith
http.getenv("SCRIPT_NAME") fail if it's not provided. This can happen in the login screen when we don't have any script to load. Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
2018-05-19luci-base: handle potential crash in luci.model.network.interface.get_i18n()Jo-Philipp Wich
Should prevent the crash mentioned in #1779. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-19luci-base: break circular luci.config <> luci.model.uci dependencyJo-Philipp Wich
On certain environments, mainly with the embedded uhttpd interpreter, the luci.config class cannot be loaded due to a circular dependency with the luci.model.uci class. Break up the dependency by deferring the loading of luci.config in luci.model.uci until it is actually needed. Fixes #1803, FS#1553. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-18Merge pull request #1769 from jow-/masterJo-Philipp Wich
UCI apply/rollback workflow
2018-05-18luci-base: raise maximum POST value size to 100KBJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-18Merge pull request #1748 from hnyman/wifidataHannu Nyman
luci-base: show wifi chip identification on overview
2018-05-13luci-base: harden cookie sysauth=Yousong Zhou
A simple scan of the code indicates that currently no code in the repo is accessing the sysauth= cookie Closes openwrt/luci#1555 Signed-off-by: Florian Eckert <fe@dev.tdt.de> Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2018-05-05treewide: rework uci apply workflowJo-Philipp Wich
Switch to rpcd based uci apply/rollback workflow which helps to avoid soft- bricking devices by requiring an explicit confirmation call after config apply. When a user now clicks "Save & Apply", LuCI first issues a call to uci apply which commits and reloads configuration, then goes into a polling countdown mode where it repeatedly attempts to call uci confirm. If the committed configuration is sane, the confirm call will go through and cancel rpcd's pending rollback timer. If the configuration change leads to a loss of connectivity (e.g. due to bad firewall rules or similar), the rollback mechanism will kick in after the timeout and revert configuration files and pending changes to the pre-apply state. In order to cover such rare cases where a lost of connectivity is expected and desired, the user is offered an "unchecked" apply option after timing out, which allows committing and applying the changes anyway, without the extra safety checks. As a consequence of this change, the luci-reload mechanism is now completely unsused since rpcd uses ubus config reload signals to reload affected services, which means that only procd-enabled services will receive proper reload treatment with the new workflow. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-05luci-base: enable uci session isolationJo-Philipp Wich
Switch to per-session save directories to decouple LuCI configuration changes from system wide ones. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-05luci-base: show wifi chip identification on overviewHannu Nyman
Show the correct wifi chip identification in case iwinfo recognises the chip. So far the wifidev.get_i18n function has practically always returned just "Generic", but use iwinfo.hardware_name to fetch the name. In case iwinfo returns the default "Generic MAC80211", there is a double 80211 in the final string, which is a cosmetic bug. Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2018-05-03luci-base: support hiding the "Back to Overview" button in cbi mapsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-03Revert "luci-base: support hiding the "Back to Overview" button in cbi maps"Jo-Philipp Wich
This reverts commit 52cf265c9d12537d5f37043350328d30ca11bab4. I accidentally committed unrelated changes. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-03luci-base: support hiding the "Back to Overview" button in cbi mapsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-26luci-base: add simple CORS handling to luci.dispatcherJo-Philipp Wich
Support a new boolean property `cors` which - if set to true - causes the dispatcher to positively answer CORS OPTIONS requests after authentication without actually running the dispatching target. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-26luci-base: handle bodies of non-POST requests as wellJo-Philipp Wich
Decode the HTTP message bodies of any request carrying a Content-Length header, not just those in POST requests. This allows handling parameters in other methods, OPTIONS in particular. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-24luci-base: additionally return error code strings in luci.util.ubus()Jo-Philipp Wich
Add a 3rd return value to luci.util.ubus() containing the string value of the error return value. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-24luci-base: ensure that file upload values have lengthJo-Philipp Wich
Ensure that the (table) length of a file upload value has nonzero length by initializing the first table index with the file name. This fixes tests in the form x = luci.http.formvalue(...) if x and #x > 0 then ... end Fixes #1763. Signed-off-by: Jo-Philipp Wich <jo@mein.io>