OpenWrt Forum Archive

Topic: [LuCI] Making GUI for mwan3 multiwan package

The content of this topic has been archived on 1 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

The GUI is now a package which may be downloaded with mwan3. View the main mwan3 topic to download:
https://forum.openwrt.org/viewtopic.php … 52&p=1

old post:

My mwan3 LuCI page worklog is here. My issues are now resolved and I am finishing the status page which will have a real-time interface status tab, troubleshooting tab and instructions tab. This should be in version 1.4

Version 1.3.1:
link removed

Screenshots:
http://imageshack.us/a/img96/7404/rulesconfig.png
http://imageshack.us/a/img210/8463/rulesxz.png
http://imageshack.us/a/img822/2214/policiesconfig.png
http://imageshack.us/a/img193/9592/policies.png
http://imageshack.us/a/img13/1345/membersconfig.png
http://imageshack.us/a/img715/49/memberswj.png
http://imageshack.us/a/img38/905/interfacesconfig.png
http://imageshack.us/a/img210/4857/interfaces.png

Changelog:
1.3.1

1. Fixed bug where adding an interface without a test IP or adding a policy without a member would cause the pages to error

1.3.0

1. Fixed duplicate entry name in policy configuration page so values save correctly
2. Policies page now shows "Members assigned" rather than "use_member"

HELP NEEDED:
1. I'm trying to find a way if possible to have a dropdown that displays the names of config sections. For example on the policies edit page I would like to have a dropdown that lets you select from the names of members. Haven't been having any luck finding a way to do this and I don't even know if it's really possible. LMK if you have a solution!

old issues:

1. [Fixed] https://forum.openwrt.org/viewtopic.php … 79#p178679

The issue is when I type in a name for any of the 4 sections and click Add to make the entry I get the below error. If you click back you see that it added the entry and you can then edit it but I need it to take you to the edit page when you click Add. If anyone could shed some light on this one piece I can take it from there and finish what I need to do.

You will find the tab on Network->Multiwan

/usr/lib/lua/luci/dispatcher.lua:448: Failed to execute function dispatcher target for entry '/admin/network/multiwan'.
The called action terminated with an exception:
/usr/lib/lua/luci/dispatcher.lua:448: Failed to execute arcombine dispatcher target for entry '/admin/network/multiwan/rule'.
The called action terminated with an exception:
/usr/lib/lua/luci/dispatcher.lua:67: attempt to index local 'p' (a boolean value)
stack traceback:
    [C]: in function 'assert'
    /usr/lib/lua/luci/dispatcher.lua:448: in function 'dispatch'
    /usr/lib/lua/luci/dispatcher.lua:195: in function </usr/lib/lua/luci/dispatcher.lua:194>

2. [Fixed] https://forum.openwrt.org/viewtopic.php … 02#p178902

mwan3 changed the track_ip option to be a list option so there could be more than one.

I've been messing with the lua code and with the below section on mwan_interface.lua it now displays the multiple test IPs but they are all on one line separated by a space and I can't figure out how to put in a new line so they are each on their own line. Any help would be appreciated.

track_ip = mwan_interface:option(DummyValue, "track_ip", translate("Test IP"))                
function track_ip.cfgvalue(self, s)                                            
        local str = ""                                                         
        local tab = self.map:get(s, "track_ip")                                
        for k,v in pairs(tab) do                                            
                str = str .. v .. "\n"                                      
        end                                                                 
        return str                                                          
end

(Last edited by arfett on 15 Apr 2013, 07:11)

I mean the problem is in the create function, because i comment out the 'luci.http.redirect...' line in the mwan_rule.lua script, and the error disappeared. But not opens the newly created rule...

The create() function must return the name of the newly created section. So simply replace the "return" with "return created".

jow wrote:

The create() function must return the name of the newly created section. So simply replace the "return" with "return created".

function mwan_interface.create(self, section)
    local created = TypedSection.create(self, section)
    m30.uci:save("mwan3")
    luci.http.redirect(ds.build_url("admin", "network", "multiwan", "interface", created))
    return created
end

Is this what you mean? It still shows the same error.

Thanks for the assistance.

(Last edited by arfett on 18 Sep 2012, 20:06)

Ok so the issue is as follows: if you pass a section name to TypedSection.create() it does not return the name of the new section (which is guaranteed to be the one you passed in) but a boolean which indicates whether the creation was successful (it could for example fail if something with the same name already exists).

The error quoted above happens when a boolean or numeric value is passed to build_url() instead of a string.
To solve the problem you should rewrite your create callback as shown below:

function mwan_interface.create(self, section)
    if TypedSection.create(self, section) then
        m30.uci:save("mwan3")
        luci.http.redirect(ds.build_url("admin", "network", "multiwan", "interface", section))
        return true
    else
        m30.message = translatef("There already is a section named %q", section)
        return false
    end
end
jow wrote:

Ok so the issue is as follows: if you pass a section name to TypedSection.create() it does not return the name of the new section (which is guaranteed to be the one you passed in) but a boolean which indicates whether the creation was successful (it could for example fail if something with the same name already exists).

The error quoted above happens when a boolean or numeric value is passed to build_url() instead of a string.
To solve the problem you should rewrite your create callback as shown below:

Thanks jow. That if/else function doesn't just limit it to that type of config. For example if there was an interface section named wan2 you can not add a member named wan2. Is there any way to have the duplicate checking only apply to that config type?

(Last edited by arfett on 19 Sep 2012, 00:25)

No, its uci limitation. You cannot have two sections of the same name - even if they're of different types. Names must be globally unique.

jow wrote:

No, its uci limitation. You cannot have two sections of the same name - even if they're of different types. Names must be globally unique.

Got it.

Only other thing is that when you try to add a section with a duplicate name it doesn't show "There is already an entry named %q" anywhere on the page. I thought maybe there was a typo with "translatef" but it doesn't work as "translate" either. I'm not nearly skilled enough to know how to fix that.

(Last edited by arfett on 20 Sep 2012, 18:06)

Issue 2 fixed with:

track_ip = mwan_interface:option(DummyValue, "track_ip", translate("Test IP"))
track_ip.rawhtml = true               
function track_ip.cfgvalue(self, s)                                           
        local str = ""                                                         
        local tab = self.map:get(s, "track_ip")                               
        for k,v in pairs(tab) do                                           
                str = str .. v .. "<br />"                                     
        end                                                                 
        return str                                                         
end

Hmm...  Can you also make the "Status | Overview | Network" section show "IPv4 WAN Status" for each active MWAN connection?  Currently, I only see one connection on this key status page even though multiple MWAN connections are active.

One other thing: I would recommend making it very easy to setup a router with 1 LAN port(old WAN) and 4 WAN ports.  This configuration should be a very common one.   Then you can hook up any number (up to 4) WAN modems and the LAN port to your switch.

(Last edited by Sorbe on 23 Sep 2012, 17:41)

Sorbe wrote:

Hmm...  Can you also make the "Status | Overview | Network" section show "IPv4 WAN Status" for each active MWAN connection?  Currently, I only see one connection on this key status page even though multiple MWAN connections are active.

One other thing: I would recommend making it very easy to setup a router with 1 LAN port(old WAN) and 4 WAN ports.  This configuration should be a very common one.   Then you can hook up any number (up to 4) WAN modems and the LAN port to your switch.

I will see if we can do that. I currently have our intern who is better at HTML than I assisting with the status page. As far as the configuration goes you should bring this up in the mwan3 thread here: https://forum.openwrt.org/viewtopic.php … 52&p=1

While I am helping Adze work on this project with the GUI and some script files he is the main guy for mwan3.

(Last edited by arfett on 24 Sep 2012, 19:14)

Hi,

I tried to install luci-mwan3 and I can not see it on luci web interface it not exists in opkg install packages.
How to install your mwan3 in the luci package ?

Regards,
RL

The discussion might have continued from here.