Changeset 2307


Ignore:
Timestamp:
Sep 2, 2013, 4:24:59 PM (6 years ago)
Author:
matthijs
Message:

luci: Add "probe" button to 3G page

This allows letting the udiald program probe a device to see what kind
of commands it supports etc. This feature is only enabled in dev mode.

Location:
trunk/luci/modules/admin-fon/luasrc
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/luci/modules/admin-fon/luasrc/controller/fon_admin/fon_devices.lua

    r2277 r2307  
    9696        page.leaf = true
    9797
     98        local page  = node("fon_devices", "fon_umts", "probe")
     99        page.target = call("umts_probe", false)
     100
    98101        local page  = node("fon_devices", "fon_admin")
    99102        page.target = call("action_admin")
     
    108111        http.redirect(dsp.build_url("fon_admin"))
    109112end
     113
     114function umts_probe()
     115        device_id = luci.http.formvalue('device_id')
     116        local probe_output = luci.util.exec("udiald --probe --device-id " ..  device_id .. " 2>&1")
     117        luci.http.prepare_content("text/html")
     118        luci.template.render("fon_umtsd/probe", {probe_output=probe_output})
     119end
  • trunk/luci/modules/admin-fon/luasrc/view/fon_umtsd/device_list.htm

    r2277 r2307  
    33local state = luci.model.uci.cursor_state()
    44local mode = uci:get("fon", "wan", "mode")
     5local dev = uci:get("registered", "fonreg", "dev") == "1"
    56local selected_device = nil
    67if mode == "umts" then
     
    6667                        <td>Unknown</td>
    6768                        <td><%:umts_state_disconnected Disconnected %></td>
    68                         <td><input type="submit" name="connect_<%=device.id%>" value="Connect"/></td>
     69                        <td><input type="submit" name="connect_<%=device.id%>" value="Connect"/>
     70                            <% if dev then %>
     71                            <input type="button" onclick="do_probe('<%=device.id%>')" value="Probe"/>
     72                            <% end %>
     73                        </td>
    6974                <% end %>
    7075        </tr>
     
    7277</tbody>
    7378</table>
     79
     80<div id="probeResults">
     81</div>
     82
     83<script type="text/javascript">
     84function do_probe(device_id) {
     85        var url = '<%=luci.dispatcher.build_url("fon_devices", "fon_umts", "probe")%>';
     86        url += '?device_id=' + device_id;
     87
     88        fon_xhr_load(url, 'probeResults');
     89
     90        var txt = new Element("p");
     91        txt.update("Probing device. This may take a long time (up to a minute), so please be patient.");
     92        $("probeResults").appendChild(txt);
     93}
     94</script>
Note: See TracChangeset for help on using the changeset viewer.