How to create custom page on openwrt luci

Since I have read the documentation of https://oldwiki.archive.openwrt.org/doc/devel/luci ,I want to create a custom page on Luci without dropdown and that page contain a button for user to click to enable the shell script. Could you please guide me how to do this?

This is the most recent write-up I've seen so far. I was able to use this to get a module added to the dropdown menu. Just a heads up though, for 19.07, due to the use of client-side rendering, you'll need the luci-compat package for the example on the page to work. Hopefully there will be a write-up to add these modules natively without having to rely on a compatibility package.

1 Like

Create a HTML page with button in view folder. register the page and create a function to execute the shell script in corresponding .lua page in controller folder . on button click trigger the luci function using XHR.get().

In Controller --> example.lua
entry({"admin", "page",}, template("pagebutton"), "Page With Button", 5)
entry({"admin", "page", "runshell"}, call("trigger_button"), nil).leaf = false

function trigger_button()
os.execute("Your Shell Script here")
end

in view --> pagebutton.html

Javascript Code (I used jQuery, you can use pure JavaScript Code)
$("#btn").click(function(){
XHR.get('<%=luci.dispatcher.build_url("admin", "page", "runshell")%>', null,
function(x, st){
console.log('Script Triggered')
});

HTML
<button id="btn"></button>

1 Like

help alot.....

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.