tick and cross icons, sped up network indication by checking dns first
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 4 Jan 2010 09:35:22 +0000 (09:35 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 4 Jan 2010 09:35:22 +0000 (09:35 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@93 01035d8c-6547-0410-b346-abe4f91aad63

easy-asterisk-gui/Makefile
easy-asterisk-gui/check_network.sh [new file with mode: 0644]
easy-asterisk-gui/cross.png [new file with mode: 0644]
easy-asterisk-gui/dashboard.js
easy-asterisk-gui/dashboard.sh
easy-asterisk-gui/menu.html
easy-asterisk-gui/network.js
easy-asterisk-gui/network.sh
easy-asterisk-gui/set_network.sh
easy-asterisk-gui/tick.png [new file with mode: 0644]

index d74d6568da7f448239e97c68b49b15f178a12afc..e34e6d0ab85624de28ea6a8382bae980a6499aa4 100644 (file)
@@ -9,4 +9,4 @@ TESTIP=192.168.1.150
 #      rcp index.html root@$(TESTIP):/var/lib/asterisk/static-http/
 
 test:
-       rcp banner.html menu.html check_loggedin.sh logout.sh login.sh dashboard.sh dashboard.js network.sh network.js set_network.sh tooltip.js tooltip.css root@$(TESTIP):/www/cgi-bin
+       rcp check_network.sh tick.png cross.png banner.html menu.html check_loggedin.sh logout.sh login.sh dashboard.sh dashboard.js network.sh network.js set_network.sh tooltip.js tooltip.css root@$(TESTIP):/www/cgi-bin
diff --git a/easy-asterisk-gui/check_network.sh b/easy-asterisk-gui/check_network.sh
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/easy-asterisk-gui/cross.png b/easy-asterisk-gui/cross.png
new file mode 100644 (file)
index 0000000..05baecd
Binary files /dev/null and b/easy-asterisk-gui/cross.png differ
index de163c23666ac7fad5fe19e97bd2c487535ca963..74d6eaf1bb5ad05e5f1cee5bdf6f08950807d404 100644 (file)
@@ -1,4 +1,7 @@
 function localInit() {
-    $('internet').innerHTML = init_internet;    
+    if (init_internet == "yes")
+       $('internet').innerHTML = '<img src="tick.png" alt="tick" />';
+    else
+        $('internet').innerHTML = '<img src="cross.png" alt="tick" />';
 }
 
index d1ea69445e5ea700d97eccf4accc59fa4f90283b..db8d3b696673318b00687d8b157145b03d93dd5a 100644 (file)
@@ -3,13 +3,12 @@
 # David Rowe 4 Jan 2010
 # CGI for Easy Asterisk dashboard GUI
 
-# See if we have Internet connectivity
+# See if we have Internet connectivity, unlike network.sh we don't check dns first
 
+internet="no";
 packet_loss=`ping google.com -c 1 -q | sed -n 's/.*received, \(.*\)% packet loss/\1/p'`
 if [ $packet_loss == "0" ]; then
-  internet="Good";
-else
-  internet="Not Available";
+  internet="yes";
 fi
 
 # Construct the web page -------------------------------
@@ -46,7 +45,7 @@ cat <<EOF
     <form action="/cgi-bin/set_network.sh" onsubmit="return validate_form(this)" method="get">
     <table align="right" width=600>
     <tr>
-      <tr><td colspan="2" align="left"><h2>Dashboard</h2></td>
+      <tr><td colspan="2" align="left" valign="top" ><h2>Dashboard</h2></td>
       <tr onMouseOver="popUp(event,'t1')" onmouseout="popUp(event,'t1')">
          <td>Internet Connection:</td>
          <td><div id="internet" >
index c8340175926a8ec8f4a875b34592f2b272b970f2..4f3a5e47c7caed7d3e4c1f7a984cacf3150ddd09 100644 (file)
@@ -1,14 +1,22 @@
+    <div id="admin_tip" class="tip">Change your password</div>
     <div id="dashboard_tip" class="tip">Monitor the status of your phone system</div>
-    <div id="network_tip" class="tip">Set up the network and connect to the Internet</div>
+    <div id="network_tip" class="tip">Connect the phone system to your network and the Internet</div>
+    <div id="phone_tip" class="tip">Set up your phones and phone calls</div>
     <td valign="top" >
        <table align="right" width=200>
        <tr><td><h2>&nbsp;</h2></td></tr>
+       <tr onMouseOver="popUp(event,'admin_tip')" onmouseout="popUp(event,'admin_tip')">
+         <td><a href="admin.sh">Admin</a></td>
+       </tr>
        <tr onMouseOver="popUp(event,'dashboard_tip')" onmouseout="popUp(event,'dashboard_tip')">
          <td><a href="dashboard.sh">Dashboard</a></td>
        </tr>
        <tr onMouseOver="popUp(event,'network_tip')" onmouseout="popUp(event,'network_tip')">
          <td><a href="network.sh">Network</a></td>
        </tr>
+       <tr onMouseOver="popUp(event,'phone_tip')" onmouseout="popUp(event,'phone_tip')">
+         <td><a href="phone.sh">Phones</a></td>
+       </tr>
        <tr>
          <td><a href="logout.sh">Logout</a></td>
        </tr>
index c49dc88dc081c671beeacd68d9d8c00bbef8e2d5..108bf01b81bd5c19173d9af85444e791f1d6a714 100644 (file)
@@ -57,7 +57,12 @@ function localInit() {
     $('netmask').value = init_netmask;
     $('gateway').value = init_gateway;
     $('dns').value = init_dns;
-    $('internet').innerHTML = init_internet;    
+    $('backdoor').value = init_backdoor;    
+    if (init_internet == "yes")
+       $('internet').innerHTML = '<img src="tick.png" alt="tick" />';
+    else
+        $('internet').innerHTML = '<img src="cross.png" alt="tick" />';
+
 }
 
 function validate_form(form)
index bb93c28c34f7ba9c81d7b4edac16915fbafb16c4..d4c0ee86f5dba5b545d09ce665ed751f5670c8a6 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/sh -x
 # network.sh
 # David Rowe 4 Jan 2010
 # CGI for Easy Asterisk network GUI
@@ -22,13 +22,19 @@ then
   dns=`sed -n 's/DNS="\(.*\)"/\1/p' /etc/init.d/network-static`
 fi
 
-# See if we have Internet connectivity
+if [ -f /etc/rc.d/S05network-backdoor ]; then
+  backdoor=`sed -n 's/IPADDRESS="\(.*\)"/\1/p' /etc/init.d/network-backdoor`
+fi
+
+# See if we have Internet connectivity, first check dns as time outs can be very slow
 
-packet_loss=`ping google.com -c 1 -q | sed -n 's/.*received, \(.*\)% packet loss/\1/p'`
-if [ $packet_loss == "0" ]; then
-  internet="Good";
-else
-  internet="Not Available";
+dns_packet_loss=`ping $dns -c 1 -q | sed -n 's/.*received, \(.*\)% packet loss/\1/p'`
+internet="no";
+if [ $dns_packet_loss == "0" ]; then
+  packet_loss=`ping google.com -c 1 -q | sed -n 's/.*received, \(.*\)% packet loss/\1/p'`
+  if [ $packet_loss == "0" ]; then
+    internet="yes";
+  fi
 fi
 
 # Construct the web page -------------------------------
@@ -48,6 +54,7 @@ echo 'var init_ipaddress="'$ipaddress'";'
 echo 'var init_netmask="'$netmask'";'
 echo 'var init_gateway="'$gateway'";'
 echo 'var init_dns="'$dns'";'
+echo 'var init_backdoor="'$backdoor'";'
 echo 'var init_internet="'$internet'";'
 cat network.js
 echo "</script>"
@@ -56,7 +63,12 @@ cat << EOF
 <html>
 <title>Easy Asterisk - Network</title>
 <body onload="localInit()">
-<div id="t1" class="tip">Tells you if I can reach the Internet.  If not "Good" check your network settings, in particular Gateway and DNS.</div>
+<div id="t1" class="tip">A tick means I can reach the Internet.  You need the Internet for VOIP calls.  
+                         If you have a problem reaching the Internet check your Network settings, in 
+                         particular Gateway and DNS.</div>
+<div id="t2" class="tip">Emergency backdoor IP. Useful if you get locked out of the main network connection, for 
+                         example due to DHCP problems on your network or a configuration mistake.  
+                         Write this number down somewhere!</div>
 
 <table align="center" width=800>
 EOF
@@ -70,7 +82,7 @@ cat <<EOF
     <form action="/cgi-bin/set_network.sh" onsubmit="return validate_form(this)" method="get">
     <table align="center" width=600>
     <tr>
-      <tr><td colspan="2" align="left"><h2>Network</h2></td>
+      <tr><td colspan="2" align="left" valign="top"><h2>Network</h2></td>
       <tr>
         <td><input type="radio" id="static" name="dhcp" value="no" onClick="doStatic()">Static</td>
         <td><input type="radio" id="dhcp"   name="dhcp" value="yes" onClick="doDHCP()">DHCP</td>
@@ -79,6 +91,9 @@ cat <<EOF
       <tr><td>Netmask:</td><td><input type="text" name="netmask" id="netmask" onBlur="isIP(this)"></td></tr>
       <tr><td>Gateway:</td><td><input type="text" name="gateway" id="gateway" onBlur="isIP(this)"></td></tr>
       <tr><td>DNS:</td><td><input type="text" name="dns" id="dns" onBlur="isIP(this)"></td></tr>
+      <tr onMouseOver="popUp(event,'t2')" onmouseout="popUp(event,'t2')">
+          <td>Emergency IP:</td><td><input type="text" name="backdoor" id="backdoor" onBlur="isIP(this)"></td>
+      </tr>
       <tr onMouseOver="popUp(event,'t1')" onmouseout="popUp(event,'t1')">
          <td>Internet Connection:</td>
          <td><div id="internet" >
index 7ad68c6eb69ae86609eb218d906ae5a7cefda203..dddb65af41424be200e30e5bf7455f1b4df6ffc9 100755 (executable)
@@ -20,8 +20,9 @@ ipaddress=`echo "$QUERY_STRING" | grep -oe "ipaddress=[^&?]*" | sed -n "s/ipaddr
 netmask=`echo "$QUERY_STRING" | grep -oe "netmask=[^&?]*" | sed -n "s/netmask=//p"`
 gateway=`echo "$QUERY_STRING" | grep -oe "gateway=[^&?]*" | sed -n "s/gateway=//p"`
 dns=`echo "$QUERY_STRING" | grep -oe "dns=[^&?]*" | sed -n "s/dns=//p"`
+backdoor=`echo "$QUERY_STRING" | grep -oe "backdoor=[^&?]*" | sed -n "s/backdoor=//p"`
 
-echo `date` " set_network.sh $dhcp $ipaddress $netmask $gateway $dns" >> /tmp/easy_gui.log
+echo `date` " set_network.sh $dhcp $ipaddress $netmask $gateway $dns $backdoor" >> /tmp/easy_gui.log
 
 if [ $dhcp == "yes" ]; then
 
@@ -57,3 +58,9 @@ if [ $dhcp == "no" ]; then
   /etc/init.d/network-static stop
   /etc/init.d/network-static start
 fi
+
+if [ -f /etc/rc.d/S05network-backdoor ]; then
+  sed -i "s/IPADDRESS=.*/IPADDRESS=\"$backdoor\"/g" /etc/init.d/network-backdoor
+  /etc/init.d/network-backdoor stop
+  /etc/init.d/network-backdoor start
+fi
diff --git a/easy-asterisk-gui/tick.png b/easy-asterisk-gui/tick.png
new file mode 100644 (file)
index 0000000..c155dff
Binary files /dev/null and b/easy-asterisk-gui/tick.png differ