luci/applications/luci-app-example
Hosted Weblate 5ef203a46e Translated using Weblate (Chinese (Simplified))
Currently translated at 29.5% (26 of 88 strings)

Translation: OpenWrt/LuCI/applications/mosquitto
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsmosquitto/zh_Hans/

Translated using Weblate (Lithuanian)

Currently translated at 84.0% (163 of 194 strings)

Translated using Weblate (Persian)

Currently translated at 99.6% (279 of 280 strings)

Translated using Weblate (Persian)

Currently translated at 100.0% (66 of 66 strings)

Translation: OpenWrt/LuCI/applications/attendedsysupgrade
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsattendedsysupgrade/fa/

Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (38 of 38 strings)

Translation: OpenWrt/LuCI/applications/advanced-reboot
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsadvanced-reboot/zh_Hans/

Translated using Weblate (Chinese (Simplified))

Currently translated at 99.4% (2358 of 2370 strings)

Translation: OpenWrt/LuCI/modules/luci-base
Translate-URL: https://hosted.weblate.org/projects/openwrt/luci/zh_Hans/

Translated using Weblate (Ukrainian)

Currently translated at 9.8% (8 of 81 strings)

Translation: OpenWrt/LuCI/applications/email
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsemail/uk/

Translated using Weblate (Georgian)

Currently translated at 55.0% (154 of 280 strings)

Translated using Weblate (Lithuanian)

Currently translated at 72.6% (141 of 194 strings)

Translated using Weblate (Ukrainian)

Currently translated at 12.5% (16 of 127 strings)

Translation: OpenWrt/LuCI/applications/pbr
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationspbr/uk/

Translated using Weblate (Ukrainian)

Currently translated at 80.6% (50 of 62 strings)

Translation: OpenWrt/LuCI/applications/acme
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsacme/uk/

Translated using Weblate (Ukrainian)

Currently translated at 31.8% (14 of 44 strings)

Translation: OpenWrt/LuCI/applications/ser2net
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsser2net/uk/

Translated using Weblate (Ukrainian)

Currently translated at 55.5% (10 of 18 strings)

Translation: OpenWrt/LuCI/applications/nextdns
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsnextdns/uk/

Translated using Weblate (Ukrainian)

Currently translated at 8.0% (15 of 186 strings)

Translation: OpenWrt/LuCI/applications/unbound
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsunbound/uk/

Translated using Weblate (Ukrainian)

Currently translated at 100.0% (17 of 17 strings)

Translation: OpenWrt/LuCI/applications/udpxy
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsudpxy/uk/

Translated using Weblate (Ukrainian)

Currently translated at 18.2% (15 of 82 strings)

Translation: OpenWrt/LuCI/applications/shadowsocks-libev
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsshadowsocks-libev/uk/

Translated using Weblate (Ukrainian)

Currently translated at 8.8% (11 of 125 strings)

Translation: OpenWrt/LuCI/applications/privoxy
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsprivoxy/uk/

Translated using Weblate (Ukrainian)

Currently translated at 21.1% (36 of 170 strings)

Translation: OpenWrt/LuCI/applications/mwan3
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsmwan3/uk/

Translated using Weblate (Ukrainian)

Currently translated at 18.3% (9 of 49 strings)

Translation: OpenWrt/LuCI/applications/mjpg-streamer
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsmjpg-streamer/uk/

Translated using Weblate (Ukrainian)

Currently translated at 48.3% (15 of 31 strings)

Translation: OpenWrt/LuCI/applications/dynapoint
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsdynapoint/uk/

Translated using Weblate (Ukrainian)

Currently translated at 7.1% (4 of 56 strings)

Translation: OpenWrt/LuCI/applications/dump1090
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsdump1090/uk/

Translated using Weblate (Ukrainian)

Currently translated at 10.6% (26 of 244 strings)

Translation: OpenWrt/LuCI/applications/banip
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsbanip/uk/

Translated using Weblate (Ukrainian)

Currently translated at 18.4% (31 of 168 strings)

Translation: OpenWrt/LuCI/applications/aria2
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsaria2/uk/

Translated using Weblate (Ukrainian)

Currently translated at 100.0% (177 of 177 strings)

Translation: OpenWrt/LuCI/applications/adblock
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsadblock/uk/

Translated using Weblate (Ukrainian)

Currently translated at 32.9% (65 of 197 strings)

Translation: OpenWrt/LuCI/applications/ddns
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsddns/uk/

Translated using Weblate (Ukrainian)

Currently translated at 13.6% (6 of 44 strings)

Translated using Weblate (Ukrainian)

Currently translated at 15.6% (16 of 102 strings)

Translated using Weblate (Ukrainian)

Currently translated at 16.3% (30 of 183 strings)

Translated using Weblate (Ukrainian)

Currently translated at 17.8% (67 of 376 strings)

Translated using Weblate (Spanish)

Currently translated at 5.4% (4 of 74 strings)

Translation: OpenWrt/LuCI/applications/xinetd
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsxinetd/es/

Translated using Weblate (Spanish)

Currently translated at 21.7% (10 of 46 strings)

Translation: OpenWrt/LuCI/applications/xfrpc
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsxfrpc/es/

Translated using Weblate (Spanish)

Currently translated at 90.9% (60 of 66 strings)

Translation: OpenWrt/LuCI/applications/sshtunnel
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationssshtunnel/es/

Translated using Weblate (Lithuanian)

Currently translated at 65.4% (127 of 194 strings)

Translated using Weblate (Spanish)

Currently translated at 85.4% (41 of 48 strings)

Translation: OpenWrt/LuCI/applications/openwisp
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsopenwisp/es/

Translated using Weblate (Spanish)

Currently translated at 100.0% (40 of 40 strings)

Translation: OpenWrt/LuCI/applications/example
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsexample/es/

Translated using Weblate (Spanish)

Currently translated at 71.2% (141 of 198 strings)

Translation: OpenWrt/LuCI/applications/smartdns
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationssmartdns/es/

Translated using Weblate (Spanish)

Currently translated at 100.0% (62 of 62 strings)

Translation: OpenWrt/LuCI/applications/acme
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsacme/es/

Translated using Weblate (Spanish)

Currently translated at 100.0% (89 of 89 strings)

Translation: OpenWrt/LuCI/applications/frpc
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsfrpc/es/

Translated using Weblate (Spanish)

Currently translated at 100.0% (25 of 25 strings)

Translation: OpenWrt/LuCI/applications/ksmbd
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsksmbd/es/

Translated using Weblate (Spanish)

Currently translated at 100.0% (177 of 177 strings)

Translation: OpenWrt/LuCI/applications/adblock
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsadblock/es/

Translated using Weblate (Spanish)

Currently translated at 100.0% (82 of 82 strings)

Translation: OpenWrt/LuCI/applications/shadowsocks-libev
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsshadowsocks-libev/es/

Translated using Weblate (Spanish)

Currently translated at 100.0% (7 of 7 strings)

Translation: OpenWrt/LuCI/applications/squid
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationssquid/es/

Translated using Weblate (Spanish)

Currently translated at 100.0% (40 of 40 strings)

Translation: OpenWrt/LuCI/applications/clamav
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsclamav/es/

Translated using Weblate (Spanish)

Currently translated at 33.6% (82 of 244 strings)

Translation: OpenWrt/LuCI/applications/banip
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsbanip/es/

Translated using Weblate (Spanish)

Currently translated at 100.0% (26 of 26 strings)

Translation: OpenWrt/LuCI/applications/dcwapd
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsdcwapd/es/

Translated using Weblate (Spanish)

Currently translated at 100.0% (170 of 170 strings)

Translation: OpenWrt/LuCI/applications/mwan3
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsmwan3/es/

Translated using Weblate (Spanish)

Currently translated at 100.0% (195 of 195 strings)

Translation: OpenWrt/LuCI/applications/travelmate
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationstravelmate/es/

Translated using Weblate (Spanish)

Currently translated at 100.0% (197 of 197 strings)

Translation: OpenWrt/LuCI/applications/ddns
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsddns/es/

Translated using Weblate (Spanish)

Currently translated at 100.0% (124 of 124 strings)

Translation: OpenWrt/LuCI/applications/nlbwmon
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsnlbwmon/es/

Translated using Weblate (Spanish)

Currently translated at 100.0% (62 of 62 strings)

Translation: OpenWrt/LuCI/applications/ocserv
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsocserv/es/

Translated using Weblate (Spanish)

Currently translated at 100.0% (113 of 113 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (46 of 46 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (51 of 51 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (183 of 183 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (37 of 37 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (33 of 33 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (62 of 62 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (280 of 280 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (58 of 58 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (37 of 37 strings)

Translated using Weblate (Polish)

Currently translated at 100.0% (2370 of 2370 strings)

Translation: OpenWrt/LuCI/modules/luci-base
Translate-URL: https://hosted.weblate.org/projects/openwrt/luci/pl/

Translated using Weblate (Spanish)

Currently translated at 94.9% (2250 of 2370 strings)

Translation: OpenWrt/LuCI/modules/luci-base
Translate-URL: https://hosted.weblate.org/projects/openwrt/luci/es/

Translated using Weblate (Russian)

Currently translated at 100.0% (2370 of 2370 strings)

Translation: OpenWrt/LuCI/modules/luci-base
Translate-URL: https://hosted.weblate.org/projects/openwrt/luci/ru/

Translated using Weblate (Spanish)

Currently translated at 100.0% (164 of 164 strings)

Translation: OpenWrt/LuCI/applications/adblock-fast
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsadblock-fast/es/

Translated using Weblate (Lithuanian)

Currently translated at 47.2% (35 of 74 strings)

Translated using Weblate (Lithuanian)

Currently translated at 56.8% (33 of 58 strings)

Translated using Weblate (Lithuanian)

Currently translated at 98.6% (371 of 376 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (51 of 51 strings)

Translated using Weblate (Spanish)

Currently translated at 97.2% (36 of 37 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (194 of 194 strings)

Translated using Weblate (Spanish)

Currently translated at 99.6% (279 of 280 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (83 of 83 strings)

Translated using Weblate (Spanish)

Currently translated at 96.2% (362 of 376 strings)

Translated using Weblate (Polish)

Currently translated at 100.0% (2370 of 2370 strings)

Translation: OpenWrt/LuCI/modules/luci-base
Translate-URL: https://hosted.weblate.org/projects/openwrt/luci/pl/

Translated using Weblate (Spanish)

Currently translated at 94.9% (2250 of 2370 strings)

Translation: OpenWrt/LuCI/modules/luci-base
Translate-URL: https://hosted.weblate.org/projects/openwrt/luci/es/

Translated using Weblate (Spanish)

Currently translated at 94.9% (2250 of 2370 strings)

Translation: OpenWrt/LuCI/modules/luci-base
Translate-URL: https://hosted.weblate.org/projects/openwrt/luci/es/

Co-authored-by: Danial Behzadi <dani.behzi@ubuntu.com>
Co-authored-by: Džiugas J <dziugas1959@hotmail.com>
Co-authored-by: Franco Castillo <castillofrancodamian@gmail.com>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Matthaiks <kitynska@gmail.com>
Co-authored-by: Salvador Peña <salvadorp74@hotmail.com>
Co-authored-by: Temuri Doghonadze <temuri.doghonadze@gmail.com>
Co-authored-by: gallegonovato <fran-carro@hotmail.es>
Co-authored-by: huang207 <huang207a@outlook.com>
Co-authored-by: st7105 <st7105@gmail.com>
Co-authored-by: try496 <pinghejk@gmail.com>
Co-authored-by: Єгор Филенко <efilenko74@gmail.com>
Signed-off-by: Danial Behzadi <dani.behzi@ubuntu.com>
Signed-off-by: Franco Castillo <castillofrancodamian@gmail.com>
Signed-off-by: Matthaiks <kitynska@gmail.com>
Signed-off-by: Salvador Peña <salvadorp74@hotmail.com>
Signed-off-by: gallegonovato <fran-carro@hotmail.es>
Signed-off-by: huang207 <huang207a@outlook.com>
Signed-off-by: st7105 <st7105@gmail.com>
Signed-off-by: try496 <pinghejk@gmail.com>
Signed-off-by: Єгор Филенко <efilenko74@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsahcp/es/
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsfirewall/es/
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsfirewall/fa/
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsfirewall/ka/
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsfwknopd/uk/
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsminidlna/es/
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsolsr/es/
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsolsr/uk/
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsopenvpn/es/
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsopenvpn/lt/
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsopkg/es/
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationspolipo/es/
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationspolipo/lt/
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsradicale2/es/
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationssamba4/es/
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsstatistics/es/
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsstatistics/lt/
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsstatistics/uk/
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationstinyproxy/lt/
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationstransmission/uk/
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsuhttpd/es/
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationsupnp/es/
Translate-URL: https://hosted.weblate.org/projects/openwrt/luciapplicationswatchcat/es/
Translation: OpenWrt/LuCI/applications/ahcp
Translation: OpenWrt/LuCI/applications/firewall
Translation: OpenWrt/LuCI/applications/fwknopd
Translation: OpenWrt/LuCI/applications/minidlna
Translation: OpenWrt/LuCI/applications/olsr
Translation: OpenWrt/LuCI/applications/openvpn
Translation: OpenWrt/LuCI/applications/opkg
Translation: OpenWrt/LuCI/applications/polipo
Translation: OpenWrt/LuCI/applications/radicale2
Translation: OpenWrt/LuCI/applications/samba4
Translation: OpenWrt/LuCI/applications/statistics
Translation: OpenWrt/LuCI/applications/tinyproxy
Translation: OpenWrt/LuCI/applications/transmission
Translation: OpenWrt/LuCI/applications/uhttpd
Translation: OpenWrt/LuCI/applications/upnp
Translation: OpenWrt/LuCI/applications/watchcat
2024-02-20 19:03:36 +02:00
..
htdocs/luci-static/resources/view/example luci-app-example: Update with more documentation, more examples (#6503) 2023-12-04 22:12:28 +01:00
po Translated using Weblate (Chinese (Simplified)) 2024-02-20 19:03:36 +02:00
root luci-app-example: Update with more documentation, more examples (#6503) 2023-12-04 22:12:28 +01:00
BUILDING.md luci-app-example: improve docs formatting 2024-01-23 09:29:12 +02:00
Makefile luci-app-example: Update with more documentation, more examples (#6503) 2023-12-04 22:12:28 +01:00
README.md luci-app-example: improve docs formatting 2024-01-23 09:29:12 +02:00
structure.md luci-app-example: replace NBSP with a space 2024-01-23 09:29:12 +02:00
YAML.md luci-app-example: improve docs formatting 2024-01-23 09:29:12 +02:00

Example app for js based Luci

This app is meant to be a starting point for developing new LuCI apps using the modern JavaScript client-rendered approach. Previously the LuCI used a Lua server-side render approach which id deprecated now.

Installation

In all cases, you'll want to log out of the web interface and back in to force a cache refresh after installing the new package.

From git

To install the luci-app-example to your OpenWrt instance (assuming your OpenWRT instance is on 192.168.1.1):

scp -r root/* root@192.168.1.1:/
scp -r htdocs/* root@192.168.1.1:/www/
# execute the UCI defaults script to create the /etc/config/example
ssh root@192.168.1.1 "sh /etc/uci-defaults/80_example"

From packages

Install the app on your OpenWrt installation. This can be an actual router/device, or something like a QEMU virtual machine.

opkg install luci-app-example

Visit the web UI for the device/virtual machine where the package was installed. Log in to OpenWrt, and Example should be present in the navigation menu.

Application structure

See structure.md for details on how to lay out a LuCI application.

Code format

The LuCI Javascript code should be indented with tabs. js-beautify/jsbeautifier can help with this. The examples in this application were formatted with:

js-beautify -t -a -j -w 110 -r <filename>

Editing the code

You can either do direct editing on the device/virtual machine, or use something like sshfs to have remote access from your development computer.

By default, the code is minified by the build process, which makes editing it non-trivial. You can either change the build process, or just copy the file content from the git repository and replace the content on disk.

Javascript code can be found on the device/virtual machine in /www/luci-static/resources/view/example/.

form.js

This is a JS view that uses the form.Map approach to providing a form that can change the configuration. It relies on UCI access, and the relevant ACL declarations are in root/usr/share/rpcd/acl.d/luci-app-example.json.

The declarations are luci-app-example > read > uci and luci-app-example > write > uci. Note that for both permissions, the node name "example" is provided as a list argument to the interface type (uci); this maps to /etc/config/example.

Since form.Map and form.JSONMap create Promises, you cannot embed them inside a E()-built structure.

htmlview.js

This is a read-only view that uses E() to create DOM nodes.

Data is fetched via the function defined in load() - these loads are done as Promises, with the promise results stored in an array. Multiple load functions results are available in the array, and can be accessed via a single argument passed to the render() function.

This code relies on the same ACL grants as form.js.

The signature for E() is E(node_type, {node attributes}, [child nodes]).

rpc.js

The RPC JS page is read-only, and demonstrates using RPC calls to get data. It also demonstrates using the JSONMap form object for mapping a configuration to a form, but makes the form read-only for display purposes.

The configuration is stored in /etc/config/example. The file must exist and created on device boot by UCI defaults script in /root/etc/uci-defaults/80_example. The developer guide has more details about UCI defaults.

The RPCd script is stored as /usr/libexec/rpcd/luci.example, and can be called via ubus.

It relies on RPC access, and the relevant ACL declarations are in root/usr/share/rpcd/acl.d/luci-app-example.json.

The declaration is luci-app-example > read > ubus > luci.example; the list of names under this key is the list of APIs that can be called.

ACLs

ACLs are global for the entire web UI - the declaration of luci-app-example in a file called acl.d/luci-app-example is just a naming convention. Nothing enforces that only the code in luci-app-example is mutating /etc/config/example. Once the ACL is defined to allow reads/writes to a UCI node, any code running from the web UI can make changes to that node.

YAML

You may wish to work with YAML data. See YAML.md for details on how to integrate YAML read support.

Translations

For a real world application (or changes to this example one that you wish to submit upstream), translations should be kept up to date.

To rebuild the translations file, from the root of the repository execute ./build/i18n-scan.pl applications/luci-app-example > applications/luci-app-example/po/templates/example.pot

If the scan command fails with an error about being unable to open/find msguniq, install the GNU gettext package for your operating system.