pari: trunk r131 - in /trunk/config: ./ scripts/

asterisk-gui-commits at lists.digium.com asterisk-gui-commits at lists.digium.com
Fri Nov 17 17:40:27 MST 2006


Author: pari
Date: Fri Nov 17 18:40:27 2006
New Revision: 131

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=131
Log:
FIX: status.html uses the same pollevent as the parent

Modified:
    trunk/config/cfgbasic.html
    trunk/config/home.html
    trunk/config/homeapp.html
    trunk/config/scripts/astman.js
    trunk/config/status.html

Modified: trunk/config/cfgbasic.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/cfgbasic.html?view=diff&rev=131&r1=130&r2=131
==============================================================================
--- trunk/config/cfgbasic.html (original)
+++ trunk/config/cfgbasic.html Fri Nov 17 18:40:27 2006
@@ -43,8 +43,9 @@
 	var tooltip_default = "Move the mouse over to a field to see tooltips";
 
 	eventeater.eventcb = function(msgs) {
-		if (loggedon == 1)
+		if (loggedon == 1){
 			astmanEngine.pollEvents();
+		}
 	}
 
 

Modified: trunk/config/home.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/home.html?view=diff&rev=131&r1=130&r2=131
==============================================================================
--- trunk/config/home.html (original)
+++ trunk/config/home.html Fri Nov 17 18:40:27 2006
@@ -38,7 +38,7 @@
 			$('secret').disabled = 0;
 			$('logoff').disabled = 1;
 			$('login').disabled = 0;
-			$('username').focus();
+			try{ $('username').focus();	}catch(err){ }
 		}
 	}
 	
@@ -46,11 +46,13 @@
 		if ((parent.loggedon == 1) && (localloggedon == 1))
 			return;
 		parent.setLoggedOn(1);
+		parent.loggedon = 1;
 		localloggedon = 1;
 		updateButtons();
 		$('statusbar').innerHTML = "<img src='images/tick.gif'><i>Connected!</i>";
 		parent.document.getElementById('logoutlink').innerHTML = "Logout";
 		parent.document.getElementById('logoutlink').onclick = parent.Logoff ;
+
 		parent.astmanEngine.pollEvents();
 	}
 	

Modified: trunk/config/homeapp.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/homeapp.html?view=diff&rev=131&r1=130&r2=131
==============================================================================
--- trunk/config/homeapp.html (original)
+++ trunk/config/homeapp.html Fri Nov 17 18:40:27 2006
@@ -52,6 +52,7 @@
 		if ((parent.loggedon == 1) && (localloggedon == 1))
 			return;
 		parent.setLoggedOn(1);
+		parent.loggedon = 1;
 		localloggedon = 1;
 		updateButtons();
 		$('statusbar').innerHTML = "<img src='images/tick.gif'><i>Connected!</i>";

Modified: trunk/config/scripts/astman.js
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/scripts/astman.js?view=diff&rev=131&r1=130&r2=131
==============================================================================
--- trunk/config/scripts/astman.js (original)
+++ trunk/config/scripts/astman.js Fri Nov 17 18:40:27 2006
@@ -959,7 +959,6 @@
 		tmp = new Ajax.Request(this.url, opt);
 	}
 
-
 	this.clickChannel = function(ev) {
 		var target = ev.target;
 		// XXX This is icky, we statically use astmanEngine to call the callback XXX 
@@ -969,8 +968,13 @@
 			target=target.parentNode;
 		me.selecttarget = target.id;
 		target.className = "chanlistselected";
-		me.chancallback(target.id);
-	};
+
+		if(channelsCallback ){
+			channelsCallback (target.id);
+		}
+		//me.chancallback(target.id);
+	};
+
 	this.restoreTarget = function(targetname) {
 		var other;
 		target = $(targetname);
@@ -1492,6 +1496,9 @@
 		me.eventcallback(msgs);
 	};
 	this.eventResponse = function(t) {
+		if( t.responseText.match("Message: Authentication Required") ){
+				parent.window.location.href = parent.window.location.href ;
+		}
 		me.parseResponse(t, me.doEvents);
 	};
 	this.gotConfig = function(t, box) {

Modified: trunk/config/status.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/status.html?view=diff&rev=131&r1=130&r2=131
==============================================================================
--- trunk/config/status.html (original)
+++ trunk/config/status.html Fri Nov 17 18:40:27 2006
@@ -25,171 +25,105 @@
 <link href="stylesheets/rico.css" media="all" rel="Stylesheet" type="text/css" />
 <link href="stylesheets/schwing.css" media="all" rel="Stylesheet" type="text/css" />
 <script>
-	var logins = new Object;
-	var logoffs = new Object;
-	var channels = new Object;
-	var pongs = new Object;
-	var loggedon = -1;
-	var selectedchan = null;
-	var hungupchan = "";
-	var transferedchan = "";
-	
-	var activechannels = new Object;
-	
-	function loggedOn() {
-		if (loggedon == 1)
-			return;
-		loggedon = 1;
-		updateButtons();
-		$('status').innerHTML = "<i>Retrieving channel status...</i>";
-		astmanEngine.pollEvents();
-		astmanEngine.sendRequest('action=status', activechannels.channels);
+var selectedchan = null;
+var transferedchan = "";
+var hungupchan = "";
+
+
+function doHangup() {
+	hungupchan = selectedchan;
+	parent.astmanEngine.sendRequest('action=hangup&channel=' + selectedchan, afterHangup);
+}
+
+function afterHangup(){
+	refreshChannelsList();
+	$('status').innerHTML = "Hungup " + hungupchan;
+}
+
+
+function doTransfer() {
+	var channel = parent.astmanEngine.channelInfo(selectedchan);
+	var exten = prompt("Enter new extension for " + selectedchan);
+	var altchan;
+	if (exten) {
+		if (channel.link) {
+			if (confirm("Transfer " + channel.link + " too?"))
+				altchan = channel.link;
+		}
+		if (altchan) {
+			transferredchan = selectedchan + " and " + altchan + " to " + exten;
+			parent.astmanEngine.sendRequest('action=redirect&channel=' + selectedchan + "&priority=1&extrachannel=" + altchan + "&exten=" + exten, afterTransfer);
+		} else {
+			transferredchan = selectedchan + " to " + exten;
+			parent.astmanEngine.sendRequest('action=redirect&channel=' + selectedchan + "&priority=1&exten=" + exten, afterTransfer);
+		}
+	}
+}
+
+function afterTransfer(){
+	refreshChannelsList();
+	$('status').innerHTML = "Transferred " + transferredchan;
+}
+
+function refreshChannelsList() {
+	selectedchan = null;
+	$('transfer').disabled = 1;
+	$('hangup').disabled = 1;
+	$('status').innerHTML = "<i>Updating channel status...</i>";
+	parent.astmanEngine.channelClear();
+	parent.astmanEngine.sendRequest('action=status', onStatusCheck);
+	updateButtons();
+}	
+
+onStatusCheck = function(msgs) {
+	if (msgs[0].headers['response'] != "Success") {
+		//something went wrong - may be the user is logged out or 500 or 404  or what ever
 	}
 
-	function clearChannelList() {
-		$('channellist').innerHTML = "<i class='light'>Not connected</i>";
+	for (i=1;i<msgs.length - 1;i++) 
+		parent.astmanEngine.channelUpdate(msgs[i]);
+	$('channellist').innerHTML = parent.astmanEngine.channelTable(channelsCallback);
+	$('status').innerHTML = "Ready";
+}
+
+
+function updateButtons(){
+	if ($(selectedchan)) {
+		$('transfer').disabled = 0;
+		$('hangup').disabled = 0;
+	} else {
+		$('transfer').disabled = 1;
+		$('hangup').disabled = 1;
+		selectedchan = null;
 	}
+		$('refresh').disabled = 0;
+}
 
-	function loggedOff() {
-		if (loggedon == 0)
-			return;
-		loggedon = 0;
-		selectedchan = null;
-		updateButtons();
-		astmanEngine.channelClear();
-	 	clearChannelList();
-	}
+channelsCallback = function(target) {
+	selectedchan = target;
+	updateButtons();
+}
 
-	function updateButtons()
-	{
-		if ($(selectedchan)) {
-			$('transfer').disabled = 0;
-			$('hangup').disabled = 0;
-		} else {
-			$('transfer').disabled = 1;
-			$('hangup').disabled = 1;
-			selectedchan = null;
-		}
-		if (loggedon) {
-			$('refresh').disabled = 0;
-		} else {
-			$('refresh').disabled = 1;
-		}
-	}
+parent.eventeater.eventcd = function (msgs) {
+		for (i=1;i<msgs.length - 1;i++) 
+			parent.astmanEngine.channelUpdate(msgs[i]);
+		$('channellist').innerHTML = parent.astmanEngine.channelTable(channelsCallback);
+		parent.astmanEngine.pollEvents();
+}
 
-	activechannels.channelCallback = function(target) {
-		selectedchan = target;
-		updateButtons();
-	}
-	
-	activechannels.channels = function(msgs) {
-		resp = msgs[0].headers['response'];
-		if (resp == "Success") {
-			loggedOn();
-		} else
-			loggedOff();
-
-		for (i=1;i<msgs.length - 1;i++) 
-			astmanEngine.channelUpdate(msgs[i]);
-		$('channellist').innerHTML = astmanEngine.channelTable(activechannels.channelCallback);
-		$('status').innerHTML = "Ready";
-	}
-
-	activechannels.logins = function(msgs) {
-		$('status').innerHTML = msgs[0].headers['message'];
-		resp = msgs[0].headers['response'];
-		if (resp == "Success")
-			loggedOn();
-		else
-			loggedOff();
-	};
-	
-	
-	activechannels.logoffs = function(msgs) {
-		$('status').innerHTML = msgs[0].headers['message'];
-		loggedOff();
-	};
-
-	activechannels.hungup = function(msgs) {
-		$('status').innerHTML = "Hungup " + hungupchan;
-		doStatus();
-	}
-	
-	activechannels.transferred = function(msgs) {
-		$('status').innerHTML = "Transferred " + transferredchan;
-	}
-
-	function doHangup() {
-		hungupchan = selectedchan;
-		astmanEngine.sendRequest('action=hangup&channel=' + selectedchan, activechannels.hungup);
-	}
-
-	function doStatus() {
-		$('status').innerHTML = "<i>Updating channel status...</i>";
-		astmanEngine.channelClear();
-		astmanEngine.sendRequest('action=status', activechannels.channels);
-	}	
-		
-	function doLogin() {
-		$('status').innerHTML = "<i>Logging in...</i>";
-		astmanEngine.sendRequest('action=login&username=' + $('username').value + "&secret=" + $('secret').value, activechannels.logins);
-	}
-	
-	function doTransfer() {
-		var channel = astmanEngine.channelInfo(selectedchan);
-		var exten = prompt("Enter new extension for " + selectedchan);
-		var altchan;
-		if (exten) {
-			if (channel.link) {
-				if (confirm("Transfer " + channel.link + " too?"))
-					altchan = channel.link;
-			}
-			if (altchan) {
-				transferredchan = selectedchan + " and " + altchan + " to " + exten;
-				astmanEngine.sendRequest('action=redirect&channel=' + selectedchan + "&priority=1&extrachannel=" + altchan + "&exten=" + exten, activechannels.transferred);
-			} else {
-				transferredchan = selectedchan + " to " + exten;
-				astmanEngine.sendRequest('action=redirect&channel=' + selectedchan + "&priority=1&exten=" + exten, activechannels.transferred);
-			}
-		}
-	}
-	
-	function doLogoff() {
-		$('status').innerHTML = "<i>Logging off...</i>";
-		astmanEngine.sendRequest('action=logoff', activechannels.logoffs);
-	}
-	
-	activechannels.pongs  = function(msgs) {
-		resp = msgs[0].headers['response'];
-		if (resp == "Pong") {
-			loggedOn();
-		} else {
-			$('status').innerHTML = "<i>Please login...</i>";
-			loggedOff();
-		}
-	}
-	
-	activechannels.eventcb = function(msgs) {
-		var x;
-		if (loggedon) {
-			for (i=1;i<msgs.length - 1;i++) {
-				astmanEngine.channelUpdate(msgs[i]);
-			}
-			$('channellist').innerHTML = astmanEngine.channelTable(activechannels.channelCallback);
-			astmanEngine.pollEvents();
-		}
-		updateButtons();
-	}
 
 function localajaxinit(){
-		astmanEngine.setURL('../../rawman');
-		astmanEngine.setEventCallback(activechannels.eventcb);
-		clearChannelList();
-		astmanEngine.sendRequest('action=ping', activechannels.pongs);
+		refreshChannelsList() ;
+		parent.astmanEngine.setEventCallback(parent.eventeater.eventcd );
 		parent.loadscreen(this);
 }
+
+function localajaxend(){
+		parent.astmanEngine.setEventCallback(parent.eventeater.eventcb );
+}
+
 </script>
-<body id="foo" onload="localajaxinit()"  bgcolor="EFEFEF">
+<body id="foo" onload="localajaxinit()"  bgcolor="EFEFEF" onunload="localajaxend()">
 
 <div class="mainscreenTitleBar">
 	<span style="margin-left: 4px;font-weight:bold">Channels Status</span>
@@ -203,7 +137,7 @@
 	</tr>
 	<tr height=32 valign="middle">
 		<td align="center">
-				<input type="submit" onClick="doStatus()" id="refresh" value="Refresh"  onmouseover="show_tooltip('en', 'status', 1);"  class="buttonbold">
+				<input type="submit" onClick="refreshChannelsList()" id="refresh" value="Refresh"  onmouseover="show_tooltip('en', 'status', 1);"  class="buttonbold">
 				<input type="submit" onClick="doTransfer()" id="transfer" value="Transfer..."  onmouseover="show_tooltip('en', 'status', 2);"  class="buttonbold">
 				<input type="submit" onClick="doHangup()" id="hangup" value="Hangup"  onmouseover="show_tooltip('en', 'status', 3);"  class="buttonbold">
 		</td>



More information about the asterisk-gui-commits mailing list