http://www.cnblogs.com/dwayne/archive/2012/04/21/2460830.html

Through the introduction of the last article , We should know Lua Language in OpenWrt Web The basic function design method of configuration page . This article will take a page as an example , To illustrate Lua Language how to implement page controls and how to make the input or operation options effective in the system .

The page is as shown in the figure :

First , We will be having System Create pagination under column "Test by Wayne", Use cbi Module implementation , Modify the catalog lua\luci\controller\admin Under the system.lua file .

stay function index() Add a statement to :

entry({"admin", "system", "test"}, cbi("admin_system/test"), "Test by Wayne", 30).dependent=false

The next thing we need to do is lua\luci\model\cbi\admin_system Created in test.lua File and complete the control element editing .

As I said in the last article , All the controls are created by Map Start , Here I'm testing the network settings , The statement is as follows :

m = Map("network", translate("Test Page by Wayne (~_~)"), translate("On this page we can learn how the .lua works."))

Then you need to create chunks ”Network Configuration”. establish section Before , Need to be in etc/config In the catalog network Add a configuration to the file , Just call it netset Well ,network The documents are as follows :

config 'interface' 'loopback'
        option 'ifname' 'lo'
        option 'proto' 'static'
                   ……
config 'interface' 'lan'
        option 'ifname' 'eth0'
        option 'type' 'bridge'
        option 'proto' 'static'
                   ……
config 'netset'

After modifying the configuration file , Use the following statement to create section:

s = m:section(TypedSection, "netset", translate("Network Configuration"))

The first control ”address” Belong to cbi Type of Value type , And define the input type as ip4addr, The implementation is as follows :

ipaddr1 = s:taboption("wan1", Value, "ipaddr1", translate("address"))
ipaddr1.datatype = "ip4addr"

Control ”netmask” Here it is ListValue The effect of , But here to have custom Custom options , The type of setting is Value, The implementation is as follows :

netmask1 = s:taboption("wan1", Value, "netmask1", translate("netmask"))
netmask1.datatype = "ip4addr"
netmask1:value("255.255.255.0")
netmask1:value("255.255.0.0")
netmask1:value("255.0.0.0")

Come here , Controls can be added and displayed , The rest of the work is to enter values like IP How to get the address and gateway information .

Editing Save & Apply after , And on again etc/config/network file , The contents of the document are as follows :

config 'interface' 'loopback'
        option 'ifname' 'lo'
        option 'proto' 'static'
                   ……
config 'interface' 'lan'
        option 'ifname' 'eth0'
        option 'type' 'bridge'
        option 'proto' 'static'
                   ……
config 'netset'
        option 'ipaddr1' '192.168.1.30'
        option 'netmask1' '255.255.255.0'
        option 'gateway1' '192.168.1.5'

That is to say, all the operation contents are automatically saved in the configuration file , There are many ways to get the values in the configuration file , We can use uci The command to get .

Usage: uci [<options>] <command> [<arguments>]
 
Commands:
        batch
        export     [<config>]
        import     [<config>]
        changes    [<config>]
        commit     [<config>]
        add        <config> <section-type>
        add_list   <config>.<section>.<option>=<string>
        show       [<config>[.<section>[.<option>]]]
        get        <config>.<section>[.<option>]
        set        <config>.<section>[.<option>]=<value>
        delete     <config>[.<section[.<option>]]
        rename     <config>.<section>[.<option>]=<name>
        revert     <config>[.<section>[.<option>]]
        reorder    <config>.<section>=<position>

such , The customization of a page and the realization of its functions are completed .

OpenWrt Web Interface modification and function implementation examples of more related articles

  1. OpenWRT - WEB Interface development ideas and basic methods

    Want to OpenWRT Of WEB Interface (* Hereinafter referred to as the interface ) Make changes . The goal of the revision is : 1. Change the style of the page , Design for the style of the enterprise (stylesheet) 2. Create your own features , Realization After visiting the page , The user can access the configuration file ( That is to say ...

  2. After the last compilation openwrt after , add to web Interface

    The first blog wrote about openwrt Compile environment and compile a default configuration openwrt System . Now I'm doing how to add it web Interface .(hiwooya Self contained luci web) The method is as follows : First, configure... In the compilation environment make m ...

  3. EasyNVR No plug-in live server software how to change their own web Interface ( Customized modification of web pages )

    Background needs A lot of users are using EasyNVR, notice EasyNVR There is such a demand behind its own interface , It just needs to be changed web Some of the styles of the front end , At present EasyhNVR by 3.0 edition ,web Front end in order to increase the front-end efficiency and reduce ...

  4. miscellaneous :zabbix(WEB The interface provides distributed system monitoring and network monitoring functions )

    ylbtech- miscellaneous :zabbix(WEB The interface provides distributed system monitoring and network monitoring functions ) zabbix( The sound is the same as zæbix) It's based on WEB The interface provides enterprise level open source solutions for distributed system monitoring and network monitoring .z ...

  5. zabbix( One is based on WEB The interface provides enterprise level open source solutions for distributed system monitoring and network monitoring )

    zabbix It's based on WEB The interface provides enterprise level open source solutions for distributed system monitoring and network monitoring .zabbix Can monitor all kinds of network parameters , Ensure the safe operation of the server system : And provide a flexible notification mechanism to allow system administrators to quickly locate / solve ...

  6. [ Re posting ]web Security : Easy to understand , Explain the principle of cracking the website and how to protect it with examples ! How to make the website more secure .

    web Security : Easy to understand , Explain the principle of cracking the website and how to protect it with examples ! How to make the website more secure . https://www.cnblogs.com/1996V/p/7458377.html Thank you for what the original author wrote Security ...

  7. CheungSSH Domestic automation operation and maintenance tools are open source Web Interface

    CheungSSH web2.0 Publish documents CheungSSH brief introduction CheungSSH It is a product independently developed by Chinese people Linux Operation and maintenance automation management server software , To reduce operating costs for enterprises , Emancipating the hands of administrators and the concept of automatic production ...

  8. be based on MVC4+EasyUI Of Web Experience summary of development framework (2)- Use EasyUI Tree control construction of Web Interface

    I've spent a lot of time recently refactoring and refining my Web On the development framework , In terms of user experience and interface design , and Winform The development framework is consistent , And in the Web On , I mainly use EasyUI Front end interface processing technology , go MVC Technical route of , In heavy ...

  9. 【 Cloud computing 】Docker Centralization web Interface management platform shipyard

    Docker Centralization web Interface management platform shipyard docker shipyard seanlook                        2015 year 01 month 05 Promulgated by the              ...

Random recommendation

  1. Python data type ( Tuples 、 list 、 character string 、 Dictionaries )

    Tuples tuple: Immutable data type ABC = ('a', 1, x, 'today') list list: Modifiable data types ABC = ['a', 1, x, 'today'] character string set: ABC ...

  2. 【 Problem. 】ECFinal2018 J - Philosophical … Balance——dp

    Link to the original text https://www.cnblogs.com/cly-none/p/ECFINAL2018J.html The question : Give a length of \(n\) String \(s\), Ask for \(s\) Every suffix of \(s[ ...

  3. Tomcat The problem of repeated loading of projects at startup

    Recently, during project development and testing , Find out Tomcat The project loads repeatedly at startup , The problem that causes the resource to be initialized twice   The cause of the problem : Here's the picture : stay Eclipse Lieutenant general Server Locations Set to “Use Tomcat ...

  4. c# Newtonsoft.Json encapsulation

    public static T Deserialize<T>(string content) where T : class, new() { return JsonConvert.Des ...

  5. Unable to execute dex: Multiple dex files defineLcom/google/gson/JsonDeserializer;

    This is an anomaly, as we all know , It's about a android jar The problem of package conflict . Why mention it , It's because it really hurts . Sometimes I don't pay attention ( Hand base ) Import one more package , It's over .(jar If there are too many packages, it's not possible to bring one morning for debugging ) ...

  6. Network in Network Personal understanding

    The key point is 1*1 How to use convolution of , That is to say MLP Convolution . Just look at the data below Input is 224*224*3 Image , The first convolution is 11*11*3*96( That is to say 96 individual 11*11*3 Convolution kernel , And then there's the step size ), Convolution end ...

  7. 20145234 Huang Fei 《Java Programming 》 Experiment 1 —Java Familiarity with development environment (Linux + Eclipse)

    The experimental steps Because of the tight experimental time , Here's just a screenshot of the final result ( One ) At the command line Java Application development ( Two )Eclipse Next Java Application development . debugging ( 3、 ... and ) practice Implementation of positive integers 1-N All prime functions between , And test experiment ...

  8. linux Manually install the configuration mysql5.7

    The original address of this article is   https://www.cnblogs.com/mujingyu/p/7689116.html One . Inspection before installation 1.1 Check linux System version [root@localhost ...

  9. Levenberg-Marquardt

    c++ opencv L-M Source code http://www.shenlejun.cn/article/show.asp?id=97 What is optimization , It can be divided into several categories ? answer :Levenberg-Marquardt ...

  10. use Python I'll show you countries GDP Changes

    Preface The text and pictures of the article come from the Internet , Just for learning . Communication use , Not for any commercial purpose , The copyright belongs to the original author , If you have any questions, please contact us in time for handling . author : Zhou radish Derived from : Radish chowder PS: If necessary Python Learning materials partner ...