luci-app-mwan3: refactoring detail status view and controller
authorFlorian Eckert <fe@dev.tdt.de>
Thu, 18 Jan 2018 12:42:21 +0000 (13:42 +0100)
committerFlorian Eckert <fe@dev.tdt.de>
Thu, 18 Jan 2018 14:10:05 +0000 (15:10 +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_detail.htm

index e7e8dc93c81d6026af31f326c6f198f87c721a5a..69e72b7fdc0c6d8b96517d63c4007779df52f2dc 100644 (file)
@@ -68,16 +68,13 @@ function mwan_Status()
 end
 
 function detailedStatus()
-       local mArray = {}
-
-       -- detailed mwan status
-       local detailStatusInfo = ut.trim(sys.exec("/usr/sbin/mwan3 status"))
-       if detailStatusInfo ~= "" then
-               mArray.mwandetail = { detailStatusInfo }
+       local statusInfo = ut.trim(sys.exec("/usr/sbin/mwan3 status"))
+       luci.http.prepare_content("text/plain")
+       if statusInfo ~= "" then
+               luci.http.write(statusInfo)
+       else
+               luci.http.write("Unable to get status information")
        end
-
-       luci.http.prepare_content("application/json")
-       luci.http.write_json(mArray)
 end
 
 function diagnosticsData(interface, task)
index 0ff2824ed28b8405818586654f359278c59931e7..4cb65dd2b1693df84d6fcf00ef38704936a7a3c1 100644 (file)
 <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
 <script type="text/javascript">//<![CDATA[
        XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "status", "mwan", "detailed_status")%>', null,
-               function(x, mArray)
+               function(x)
                {
-                       var status = document.getElementById('mwan_detail_text');
-                       if (mArray.mwandetail)
-                       {
-                               status.innerHTML = String.format('<pre>%s</pre>', mArray.mwandetail[0]);
-                       }
-                       else
-                       {
-                               status.innerHTML = '<strong><%:No detailed status information available%></strong>';
-                       }
+                       var legend = document.getElementById('diag-rc-legend');
+                       var output = document.getElementById('diag-rc-output');
+                       legend.style.display = 'none';
+                       output.innerHTML = String.format('<pre>%h</pre>', x.responseText);
                }
        );
 //]]></script>
 
-<div id="mwan_detail_status">
+<div>
        <fieldset class="cbi-section">
-               <legend><%:MWAN Detailed Status%></legend>
-               <div id="mwan_detail_text"><img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /><%:Collecting data...%></div>
+               <legend id="diag-rc-legend"><%:Collecting data...%></legend>
+               <span id="diag-rc-output">
+                       <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align: middle;" />
+               </span>
        </fieldset>
 </div>
 
-<style type="text/css">
-  #mwan_detail_text {
-       padding: 20px;
-       text-align: left;
-  }
-</style>
-
 <%+footer%>