Show
Ignore:
Timestamp:
10/28/11 16:15:27 (20 months ago)
Author:
jow
Message:

luci-0.10: sync with trunk, drop broken and unfinished applications

Location:
luci/branches/luci-0.10/modules/freifunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • luci/branches/luci-0.10/modules/freifunk

    • Property svn:mergeinfo deleted
  • luci/branches/luci-0.10/modules/freifunk/luasrc/view/freifunk

    • Property svn:mergeinfo deleted
  • luci/branches/luci-0.10/modules/freifunk/luasrc/view/freifunk/public_status.htm

    r6982 r7810  
    2626-- update interval 
    2727local bogomips = bogomips or 100 
    28 local interval 
     28local interval = 10 
    2929if bogomips > 350 then 
    30     interval = "5000" 
    31 else 
    32     interval = "10000" 
     30    interval = 5 
    3331end 
    3432 
     
    5250local defroutev6 = sys.net.defaultroute6() 
    5351 
     52if defroutev4 then 
     53    defroutev4.dest = defroutev4.dest:string() 
     54    defroutev4.gateway = defroutev4.gateway:string() 
     55else 
     56    local dr4 = sys.exec("ip r s t olsr-default") 
     57    if dr4 then 
     58        defroutev4 = { } 
     59        defroutev4.dest, defroutev4.gateway, defroutev4.device, defroutev4.metric = dr4:match("^(%w+) via (%d+.%d+.%d+.%d+) dev (%w+) +metric (%d+)") 
     60    end 
     61end 
     62 
     63 
    5464-%> 
    5565 
     
    6070 
    6171<script type="text/javascript">//<![CDATA[ 
    62     var iwxhr = new XHR(); 
    63  
    64     var update_wifi_status = function() { 
    65         iwxhr.get('<%=luci.dispatcher.build_url("freifunk", "status", "public_status_json", table.concat(netlist, ","))%>', null, 
    66             function(x, st) 
     72    XHR.poll(<%=interval%>, '<%=luci.dispatcher.build_url("freifunk", "status", "public_status_json", table.concat(netlist, ","))%>', null, 
     73        function(x, st) 
     74        { 
     75            if (st) 
    6776            { 
    68                 if (st) 
     77                for( var i = 0; i < st.length; i++ ) 
    6978                { 
    70                     for( var i = 0; i < st.length; i++ ) 
    71                     { 
    72                         var iw = st[i]; 
    73                         var is_assoc = (iw.bssid && iw.channel); 
    74                         var p = (100 / iw.quality_max * iw.quality); 
    75                         var q = is_assoc ? p : -1; 
    76  
    77                         var icon; 
    78                         if (q < 0) 
    79                             icon = "<%=resource%>/icons/signal-none.png"; 
    80                         else if (q == 0) 
    81                             icon = "<%=resource%>/icons/signal-0.png"; 
    82                         else if (q < 25) 
    83                             icon = "<%=resource%>/icons/signal-0-25.png"; 
    84                         else if (q < 50) 
    85                             icon = "<%=resource%>/icons/signal-25-50.png"; 
    86                         else if (q < 75) 
    87                             icon = "<%=resource%>/icons/signal-50-75.png"; 
    88                         else 
    89                             icon = "<%=resource%>/icons/signal-75-100.png"; 
    90  
    91                         var power = document.getElementById(iw.id + '-txpower'); 
    92                         if (power) 
    93                             power.innerHTML = String.format('%s dbm', iw.txpower); 
    94  
    95                         var signal = document.getElementById(iw.id + '-signal'); 
    96                         if (signal) 
    97                             signal.innerHTML = String.format( 
    98                                 '<img src="%s" title="Signal: %s db / Noise: %s db" alt="Signal Quality" />', 
    99                                 icon, iw.signal, iw.noise 
    100                             ); 
    101  
    102                         var bitrate = document.getElementById(iw.id + '-bitrate'); 
    103                         if (bitrate) 
    104                             bitrate.innerHTML = String.format('%s Mb/s', iw.bitrate ? iw.bitrate / 1000 : '?'); 
    105  
    106                         var ssid = document.getElementById(iw.id + '-ssid'); 
    107                         if (ssid) 
    108                             ssid.innerHTML = iw.ssid; 
    109  
    110                         var bssid = document.getElementById(iw.id + '-bssid'); 
    111                         if (bssid) 
    112                             bssid.innerHTML = iw.bssid; 
    113  
    114                         var channel = document.getElementById(iw.id + '-channel'); 
    115                         if (channel) 
    116                             channel.innerHTML = iw.channel; 
    117  
    118                         var mode = document.getElementById(iw.id + '-mode'); 
    119                         if (mode) 
    120                         mode.innerHTML = iw.mode; 
    121                     } 
    122  
    123                     i = st.length - 1 
    124                     var u 
    125                      
    126                     if (u = document.getElementById('dynuptime')) 
    127                         u.innerHTML = st[i].uptime; 
    128  
    129                     if (u = document.getElementById('dynload')) 
    130                         u.innerHTML = st[i].load; 
    131  
    132                     if (u = document.getElementById('dynmem')) 
    133                         u.innerHTML = st[i].mem; 
    134  
    135                     if (u = document.getElementById('dyntime')) 
    136                         u.innerHTML = st[i].time; 
    137  
    138                     if (st[i].defroutev4) 
    139                     { 
    140                         if (u = document.getElementById('v4dst')) 
    141                             u.innerHTML = st[i].defroutev4.dest; 
    142  
    143                         if (u = document.getElementById('v4gw')) 
    144                             u.innerHTML = st[i].defroutev4.gateway; 
    145  
    146                         if (u = document.getElementById('v4dev')) 
    147                             u.innerHTML = st[i].defroutev4.dev; 
    148  
    149                         if (u = document.getElementById('v4metr')) 
    150                             u.innerHTML = st[i].defroutev4.metr; 
    151                     } 
    152  
    153                     if (st[i].defroutev6) 
    154                     { 
    155                         if (u = document.getElementById('v6dst')) 
    156                             u.innerHTML = st[i].defroutev6.dest; 
    157  
    158                         if (u = document.getElementById('v6gw')) 
    159                             u.innerHTML = st[i].defroutev6.gateway; 
    160  
    161                         if (u = document.getElementById('v6dev')) 
    162                             u.innerHTML = st[i].defroutev6.dev; 
    163  
    164                         if (u = document.getElementById('v6metr')) 
    165                             u.innerHTML = st[i].defroutev6.metr; 
    166                     } 
     79                    var iw = st[i]; 
     80                    var is_assoc = (iw.bssid && iw.channel); 
     81                    var p = (100 / iw.quality_max * iw.quality); 
     82                    var q = is_assoc ? p : -1; 
     83 
     84                    var icon; 
     85                    if (q < 0) 
     86                        icon = "<%=resource%>/icons/signal-none.png"; 
     87                    else if (q == 0) 
     88                        icon = "<%=resource%>/icons/signal-0.png"; 
     89                    else if (q < 25) 
     90                        icon = "<%=resource%>/icons/signal-0-25.png"; 
     91                    else if (q < 50) 
     92                        icon = "<%=resource%>/icons/signal-25-50.png"; 
     93                    else if (q < 75) 
     94                        icon = "<%=resource%>/icons/signal-50-75.png"; 
     95                    else 
     96                        icon = "<%=resource%>/icons/signal-75-100.png"; 
     97 
     98                    var power = document.getElementById(iw.id + '-txpower'); 
     99                    if (power) 
     100                        power.innerHTML = String.format('%s dbm', iw.txpower); 
     101 
     102                    var signal = document.getElementById(iw.id + '-signal'); 
     103                    if (signal) 
     104                        signal.innerHTML = String.format( 
     105                            '<img src="%s" title="Signal: %s db / Noise: %s db" alt="Signal Quality" />', 
     106                            icon, iw.signal, iw.noise 
     107                        ); 
     108 
     109                    var bitrate = document.getElementById(iw.id + '-bitrate'); 
     110                    if (bitrate) 
     111                        bitrate.innerHTML = String.format('%s Mb/s', iw.bitrate ? iw.bitrate / 1000 : '?'); 
     112 
     113                    var ssid = document.getElementById(iw.id + '-ssid'); 
     114                    if (ssid) 
     115                        ssid.innerHTML = iw.ssid; 
     116 
     117                    var bssid = document.getElementById(iw.id + '-bssid'); 
     118                    if (bssid) 
     119                        bssid.innerHTML = iw.bssid; 
     120 
     121                    var channel = document.getElementById(iw.id + '-channel'); 
     122                    if (channel) 
     123                        channel.innerHTML = iw.channel; 
     124 
     125                    var mode = document.getElementById(iw.id + '-mode'); 
     126                    if (mode) 
     127                    mode.innerHTML = iw.mode; 
    167128                } 
    168129 
    169                 window.setTimeout(update_wifi_status, <%=interval%>); 
     130                i = st.length - 1 
     131                var u 
     132 
     133                if (u = document.getElementById('dynuptime')) 
     134                    u.innerHTML = st[i].uptime; 
     135 
     136                if (u = document.getElementById('dynload')) 
     137                    u.innerHTML = st[i].load; 
     138 
     139                if (u = document.getElementById('dynmem')) 
     140                    u.innerHTML = st[i].mem; 
     141 
     142                if (u = document.getElementById('dyntime')) 
     143                    u.innerHTML = st[i].time; 
     144 
     145                if (st[i].defroutev4) 
     146                { 
     147                    if (u = document.getElementById('v4dst')) 
     148                        u.innerHTML = st[i].defroutev4.dest; 
     149 
     150                    if (u = document.getElementById('v4gw')) 
     151                        u.innerHTML = st[i].defroutev4.gateway; 
     152 
     153                    if (u = document.getElementById('v4dev')) 
     154                        u.innerHTML = st[i].defroutev4.dev; 
     155 
     156                    if (u = document.getElementById('v4metr')) 
     157                        u.innerHTML = st[i].defroutev4.metr; 
     158                } 
     159 
     160                if (st[i].defroutev6) 
     161                { 
     162                    if (u = document.getElementById('v6dst')) 
     163                        u.innerHTML = st[i].defroutev6.dest; 
     164 
     165                    if (u = document.getElementById('v6gw')) 
     166                        u.innerHTML = st[i].defroutev6.gateway; 
     167 
     168                    if (u = document.getElementById('v6dev')) 
     169                        u.innerHTML = st[i].defroutev6.dev; 
     170 
     171                    if (u = document.getElementById('v6metr')) 
     172                        u.innerHTML = st[i].defroutev6.metr; 
     173                } 
    170174            } 
    171         ) 
    172     }; 
    173  
    174     update_wifi_status(); 
     175        } 
     176    ); 
    175177//]]></script> 
    176178 
     
    191193<div class="cbi-map"> 
    192194    <h2><%:Wireless Overview%></h2> 
    193      
     195 
    194196        <% if not has_iwinfo then %> 
    195197            <div class="errorbox"> 
     
    212214                        <th class="cbi-section-table-cell"><%:Interface%></th> 
    213215                    </tr> 
    214     <%  
     216    <% 
    215217    for _, dev in ipairs(devices) do 
    216218    local net 
     
    294296 
    295297                        <tr class="cbi-section-table-row cbi-rowstyle-1"> 
    296                             <td class="cbi-value-field" id="v4dst"><%=defroutev4.dest:string()%></td> 
     298                            <td class="cbi-value-field" id="v4dst"><%=defroutev4.dest%></td> 
    297299                            <td class="cbi-value-field" id="v4dev"><%=defroutev4.device%></td> 
    298                             <td class="cbi-value-field" id="v4gw"><%=defroutev4.gateway:string()%></td> 
     300                            <td class="cbi-value-field" id="v4gw"><%=defroutev4.gateway%></td> 
    299301                            <td class="cbi-value-field" id="v4metr"><%=defroutev4.metric%></td> 
    300302                        </tr>