luci-app-mwan3: remove diagnostics service section
authorFlorian Eckert <fe@dev.tdt.de>
Tue, 16 Jan 2018 15:09:33 +0000 (16:09 +0100)
committerFlorian Eckert <fe@dev.tdt.de>
Thu, 18 Jan 2018 14:09:17 +0000 (15:09 +0100)
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
applications/luci-app-mwan3/luasrc/controller/mwan3.lua
applications/luci-app-mwan3/luasrc/view/mwan/status_diagnostics.htm

index 62e888c9214166758e1ce2a56fb1c24930de4749..5d4ddfbdaf1205391a84981aa6a5ecd61175f4cc 100644 (file)
@@ -96,69 +96,58 @@ function diagnosticsData(interface, tool, task)
        local mArray = {}
 
        local results = ""
-       if tool == "service" then
-               os.execute("/usr/sbin/mwan3 " .. task)
-               if task == "restart" then
-                       results = "MWAN3 restarted"
-               elseif task == "stop" then
-                       results = "MWAN3 stopped"
-               else
-                       results = "MWAN3 started"
-               end
-       else
-               local interfaceDevice = ut.trim(sys.exec("uci -q -p /var/state get network." .. interface .. ".ifname"))
-               if interfaceDevice ~= "" then
-                       if tool == "ping" then
-                               local gateway = ut.trim(sys.exec("route -n | awk '{if ($8 == \"" .. interfaceDevice .. "\" && $1 == \"0.0.0.0\" && $3 == \"0.0.0.0\") print $2}'"))
-                               if gateway ~= "" then
-                                       if task == "gateway" then
-                                               local pingCommand = "ping -c 3 -W 2 -I " .. interfaceDevice .. " " .. gateway
-                                               results = pingCommand .. "\n\n" .. sys.exec(pingCommand)
-                                       else
-                                               local tracked = ut.trim(sys.exec("uci -q -p /var/state get mwan3." .. interface .. ".track_ip"))
-                                               if tracked ~= "" then
-                                                       for z in tracked:gmatch("[^ ]+") do
-                                                               local pingCommand = "ping -c 3 -W 2 -I " .. interfaceDevice .. " " .. z
-                                                               results = results .. pingCommand .. "\n\n" .. sys.exec(pingCommand) .. "\n\n"
-                                                       end
-                                               else
-                                                       results = "No tracking IP addresses configured on " .. interface
+       local interfaceDevice = ut.trim(sys.exec("uci -q -p /var/state get network." .. interface .. ".ifname"))
+       if interfaceDevice ~= "" then
+               if tool == "ping" then
+                       local gateway = ut.trim(sys.exec("route -n | awk '{if ($8 == \"" .. interfaceDevice .. "\" && $1 == \"0.0.0.0\" && $3 == \"0.0.0.0\") print $2}'"))
+                       if gateway ~= "" then
+                               if task == "gateway" then
+                                       local pingCommand = "ping -c 3 -W 2 -I " .. interfaceDevice .. " " .. gateway
+                                       results = pingCommand .. "\n\n" .. sys.exec(pingCommand)
+                               else
+                                       local tracked = ut.trim(sys.exec("uci -q -p /var/state get mwan3." .. interface .. ".track_ip"))
+                                       if tracked ~= "" then
+                                               for z in tracked:gmatch("[^ ]+") do
+                                                       local pingCommand = "ping -c 3 -W 2 -I " .. interfaceDevice .. " " .. z
+                                                       results = results .. pingCommand .. "\n\n" .. sys.exec(pingCommand) .. "\n\n"
                                                end
+                                       else
+                                               results = "No tracking IP addresses configured on " .. interface
                                        end
-                               else
-                                       results = "No default gateway for " .. interface .. " found. Default route does not exist or is configured incorrectly"
-                               end
-                       elseif tool == "rulechk" then
-                               getInterfaceNumber()
-                               local rule1 = sys.exec(ip .. "rule | grep $(echo $((" .. interfaceNumber .. " + 1000)))")
-                               local rule2 = sys.exec(ip .. "rule | grep $(echo $((" .. interfaceNumber .. " + 2000)))")
-                               if rule1 ~= "" and rule2 ~= "" then
-                                       results = "All required interface IP rules found:\n\n" .. rule1 .. rule2
-                               elseif rule1 ~= "" or rule2 ~= "" then
-                                       results = "Missing 1 of the 2 required interface IP rules\n\n\nRules found:\n\n" .. rule1 .. rule2
-                               else
-                                       results = "Missing both of the required interface IP rules"
-                               end
-                       elseif tool == "routechk" then
-                               getInterfaceNumber()
-                               local routeTable = sys.exec(ip .. "route list table " .. interfaceNumber)
-                               if routeTable ~= "" then
-                                       results = "Interface routing table " .. interfaceNumber .. " was found:\n\n" .. routeTable
-                               else
-                                       results = "Missing required interface routing table " .. interfaceNumber
-                               end
-                       elseif tool == "hotplug" then
-                               if task == "ifup" then
-                                       os.execute("/usr/sbin/mwan3 ifup " .. interface)
-                                       results = "Hotplug ifup sent to interface " .. interface .. "..."
-                               else
-                                       os.execute("/usr/sbin/mwan3 ifdown " .. interface)
-                                       results = "Hotplug ifdown sent to interface " .. interface .. "..."
                                end
+                       else
+                               results = "No default gateway for " .. interface .. " found. Default route does not exist or is configured incorrectly"
+                       end
+               elseif tool == "rulechk" then
+                       getInterfaceNumber()
+                       local rule1 = sys.exec(ip .. "rule | grep $(echo $((" .. interfaceNumber .. " + 1000)))")
+                       local rule2 = sys.exec(ip .. "rule | grep $(echo $((" .. interfaceNumber .. " + 2000)))")
+                       if rule1 ~= "" and rule2 ~= "" then
+                               results = "All required interface IP rules found:\n\n" .. rule1 .. rule2
+                       elseif rule1 ~= "" or rule2 ~= "" then
+                               results = "Missing 1 of the 2 required interface IP rules\n\n\nRules found:\n\n" .. rule1 .. rule2
+                       else
+                               results = "Missing both of the required interface IP rules"
+                       end
+               elseif tool == "routechk" then
+                       getInterfaceNumber()
+                       local routeTable = sys.exec(ip .. "route list table " .. interfaceNumber)
+                       if routeTable ~= "" then
+                               results = "Interface routing table " .. interfaceNumber .. " was found:\n\n" .. routeTable
+                       else
+                               results = "Missing required interface routing table " .. interfaceNumber
+                       end
+               elseif tool == "hotplug" then
+                       if task == "ifup" then
+                               os.execute("/usr/sbin/mwan3 ifup " .. interface)
+                               results = "Hotplug ifup sent to interface " .. interface .. "..."
+                       else
+                               os.execute("/usr/sbin/mwan3 ifdown " .. interface)
+                               results = "Hotplug ifdown sent to interface " .. interface .. "..."
                        end
-               else
-                       results = "Unable to perform diagnostic tests on " .. interface .. ". There is no physical or virtual device associated with this interface"
                end
+       else
+               results = "Unable to perform diagnostic tests on " .. interface .. ". There is no physical or virtual device associated with this interface"
        end
        if results ~= "" then
                results = ut.trim(results)
index 19433f4d9f92e82a9905c7af8dad7cecd1b132e0..f7a1ede2e42a24cc5627f3a6a216a39cfd06730f 100644 (file)
                var iface = document.getElementById('mwaniface').value;
                var output = document.getElementById('diag_output');
 
-               if (tool == "service")
-                       {
-                               output.innerHTML =
-                                       '<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="padding: 20px; vertical-align: middle;" /> ' +
-                                       String.format("<%:Waiting for MWAN to %s...%>", task_name)
-                               ;
-                       }
-                       else
-                       {
-                               output.innerHTML =
-                                       '<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="padding: 20px; vertical-align: middle;" /> ' +
-                                       "<%:Waiting for diagnostic results...%>"
-                               ;
-                       }
+               output.innerHTML = '<img src="<%=resource%>/icons/loading.gif" ' +
+                       'alt="<%:Loading%>" ' +
+                       'style="padding: 20px; vertical-align: middle;" />' +
+                       "<%:Waiting for diagnostic results...%>";
 
                output.parentNode.style.display = 'block';
                output.style.display = 'inline';
                        <input type="button" value="<%:Hotplug ifdown%>" class="cbi-button cbi-button-apply" onclick="update_status('hotplug', 'ifdown', null)" />
                </div>
        </fieldset>
-       <fieldset id="diag_select" class="cbi-section">
-               <legend><%:MWAN Service Control%></legend>
-               <div id="buttoncss">
-                       <input type="button" value="<%:Restart MWAN%>" class="cbi-button cbi-button-apply" onclick="update_status('service', 'restart', '<%:restart%>')" />
-                       <input type="button" value="<%:Stop MWAN%>" class="cbi-button cbi-button-apply" onclick="update_status('service', 'stop', '<%:stop%>')" />
-                       <input type="button" value="<%:Start MWAN%>" class="cbi-button cbi-button-apply" onclick="update_status('service', 'start', '<%:start%>')" />
-               </div>
-       </fieldset>
        <fieldset class="cbi-section" style="display:none">
                <legend><%:Diagnostic Results%></legend>
                <div id="diag_output"></div>