bkruse: branch 2.0 r3681 - in /branches/2.0/config: ./ js/

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Tue Aug 19 13:08:10 CDT 2008


Author: bkruse
Date: Tue Aug 19 13:08:09 2008
New Revision: 3681

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=3681
Log:
Fixed a bug in welcome.html (where we did not have
the _$() function yet, so we use good old getElementById).

Added a new feature: Channel Management.

View all channels and their current states, hang them
up, or transfer them to users.

Added:
    branches/2.0/config/status.html   (with props)
Modified:
    branches/2.0/config/index.html
    branches/2.0/config/js/astman.js
    branches/2.0/config/js/pbx.js
    branches/2.0/config/js/tooltip.js
    branches/2.0/config/welcome.html

Modified: branches/2.0/config/index.html
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/index.html?view=diff&rev=3681&r1=3680&r2=3681
==============================================================================
--- branches/2.0/config/index.html (original)
+++ branches/2.0/config/index.html Tue Aug 19 13:08:09 2008
@@ -167,6 +167,11 @@
 			<div class="ui-accordion-link">Follow Me <sup><font color=#fffc31><b>beta</b></font></sup></div>
 			<div class="ui-accordion-desc"></div>
 		</div>
+		<div page='status.html'>
+			<div class="ui-accordion-link">Active Channels <sup><font color=#fffc31><b>beta</b></font></sup></div>
+			<div class="ui-accordion-desc">Displays current Active Channels on the PBX, with the options to Hangup or Transfer.</div>
+		</div>
+
 		<div page='directory.html'>
 			<div class="ui-accordion-link">Directory</div>
 			<div class="ui-accordion-desc">Preferences for 'Dialing by Name Directory'</div>

Modified: branches/2.0/config/js/astman.js
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/js/astman.js?view=diff&rev=3681&r1=3680&r2=3681
==============================================================================
--- branches/2.0/config/js/astman.js (original)
+++ branches/2.0/config/js/astman.js Tue Aug 19 13:08:09 2008
@@ -364,6 +364,16 @@
 	cliCommand : function(cmd) {
 		ASTGUI.debugLog("Executing manager command : '" + cmd + "'" , 'manager');
 		return makeSyncRequest ( { action :'command', command: cmd } );
+	},
+
+	doTransfer : function(from, to) {
+		ASTGUI.debugLog("About to transfer " + from + " to " + to, 'manager');
+		return makeSyncRequest ( { action :'redirect', channel :from, exten :to, context :'default', priority :'1' } );
+	},
+
+	doHangup : function(chan) {
+		ASTGUI.debugLog("Executing hangup on channel : '" + chan + "'" , 'manager');
+		return makeSyncRequest ( { action :'hangup', channel: chan } );
 	},
 
 	cookies: {

Modified: branches/2.0/config/js/pbx.js
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/js/pbx.js?view=diff&rev=3681&r1=3680&r2=3681
==============================================================================
--- branches/2.0/config/js/pbx.js (original)
+++ branches/2.0/config/js/pbx.js Tue Aug 19 13:08:09 2008
@@ -687,6 +687,21 @@
 		return ( sessionData.pbxinfo.users && sessionData.pbxinfo.users.getOwnProperties && sessionData.pbxinfo.users.getOwnProperties() ) || [];
 	},
 
+	listOfChannels: function() { // returns an array of current active channels
+		var raw_chan_output = ASTGUI.cliCommand('core show channels');	
+		try {
+			raw_chan_output = raw_chan_output.split('\n'); /* Split into each individual line  */
+			raw_chan_output.splice(0,3); /* Get rid of headers */
+			raw_chan_output = raw_chan_output.reverse(); /* reverse array */
+			raw_chan_output.splice(0,5); /* get rid of the ---end command--- footer */
+			raw_chan_output = raw_chan_output.reverse(); /* back to the top */ 
+		} catch(e) {
+			ASTGUI.debugLog("Error listOfChannels: " + e);
+			return false;
+		}
+		return raw_chan_output;
+	},
+
 	getUserDetails: function(user){ // returns an object with the specified user details, if the specified user is not found returns null ;
 		return sessionData.pbxinfo.users[user] || null ;
 	},

Modified: branches/2.0/config/js/tooltip.js
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/js/tooltip.js?view=diff&rev=3681&r1=3680&r2=3681
==============================================================================
--- branches/2.0/config/js/tooltip.js (original)
+++ branches/2.0/config/js/tooltip.js Tue Aug 19 13:08:09 2008
@@ -470,3 +470,7 @@
 // Tooltips for "Call Parking" in english
 	tooltips['parking'] = { en: [] };
 	tooltips['parking'].en[0] = "<B>Max Parking Time: </B> How many seconds that a call can be parked for before it is reconnected by ringing the phone that parked the call, or disconnecting the call if it is not answered and moving on with the next calling rule that is defined in this context.";
+
+// Tooltips for "Active Channels" in english
+	tooltips['channels'] = { en: [] };
+	tooltips['channels'].en[0] = "<B>User: </B> A user on the PBX to transfer the call to.";

Added: branches/2.0/config/status.html
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/status.html?view=auto&rev=3681
==============================================================================
--- branches/2.0/config/status.html (added)
+++ branches/2.0/config/status.html Tue Aug 19 13:08:09 2008
@@ -1,0 +1,232 @@
+<!--
+ * Asterisk-GUI	- an Asterisk configuration interface
+ *
+ * Displays calls in progress - options to transfer, hangup a call
+ *
+ * Copyright (C) 2006-2008, Digium, Inc.
+ *
+ * Brandon Kruse <bkruse at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ *
+-->
+<script src="js/jquery.js"></script>
+<script src="js/astman.js"></script>
+<script src="js/jquery.tooltip.js"></script>
+<link href="stylesheets/schwing.css" media="all" rel="Stylesheet" type="text/css" />
+<style type="text/css">
+	#table_channel_list {
+		border: 1px solid #666666;
+		margin-top: 5px;
+		margin-bottom:10px;
+		width: 96%;
+		text-align: center;
+		padding : 1px;
+	}
+	#table_channel_list tr.frow { background: #6b79a5; color: #CED7EF; }
+	#table_channel_list tr.frow td{ font-weight:bold; }
+	#table_channel_list tr td{ padding : 3px; }
+	#table_channel_list tr.even { background: #DFDFDF; }
+	#table_channel_list tr.odd{ background: #FFFFFF; }
+	#table_channel_list tr.even:hover, #table_channel_list tr.odd:hover {
+		background: #a8b6e5;
+		cursor: default;
+	}
+
+
+	#sqDestinations{
+		height:120px ;
+		background-color:#FFFFFF;
+		padding: 5px;
+		border-width: 1px;
+		border-color: #7E5538;
+		border-style: solid;
+		cursor: default;
+		font: 83%/1.4 arial, helvetica, sans-serif;
+		overflow :auto;
+	}
+	
+	#sqDestinations div {
+		clear :both;
+		padding : 3px 5px 0px 5px;
+		min-height: 20px;
+	}
+	#sqDestinations div:hover {
+		background-color:#DEDEDE;
+	}
+	
+	#sqDestinations div span.step_desc {
+		float: left;
+		/* max-width: 300px; */
+		background: transparent;
+	}
+	#sqDestinations div span.step_desc:hover{
+		background-color:#DEDEDE;
+	}
+	
+	#sqDestinations div span.step_up {
+		float: right;
+		width: 20px;
+		background: transparent url("./images/asterisk-arrow-up.png") no-repeat;
+	}
+	
+	#sqDestinations div span.step_down {
+		float: right;
+		width: 20px;
+		background: transparent url("./images/asterisk-arrow-down.png") no-repeat;
+	}
+	
+	#sqDestinations div span.step_delete {
+		float: right;
+		width: 20px;
+		background: transparent url("./images/delete_circle.png") no-repeat;
+	}
+
+</style>
+
+<script>
+
+var CUR_CHAN;
+var poller;
+
+poller = setInterval('localajaxinit()', 10000);
+
+var show_Edit_ChannelDirection = function(chan) {
+	
+	CUR_CHAN = chan;
+	var ul = parent.astgui_manageusers.listOfUsers();
+	ul.sort();
+
+	ul.each( function(user) {
+		ASTGUI.selectbox.append('USERS', user, user);	
+	});	
+	chan_miscFuncs.reset_Fields();
+	$('#div_activechannel_edit').showWithBg();
+};
+
+var doTransfer = function(to) {
+
+	ASTGUI.doTransfer(CUR_CHAN, to);
+	ASTGUI.feedback({ msg:'Transfered ' + CUR_CHAN + ' to ' + to, showfor: 3, color: 'blue' });	
+}
+
+var show_Edit_ChannelHangup = function(chan) {
+	
+	chan_miscFuncs.reset_Fields();
+	if(confirm("Are you sure you want to hangup " + chan + "?")) {
+		ASTGUI.doHangup(chan);
+		ASTGUI.feedback({ msg:'Hungup Channel ' + chan, showfor: 3, color: 'blue' });	
+	}
+	localajaxinit(); /* Refresh */
+};
+
+var chan_miscFuncs = {
+
+	reset_Fields : function(){ // followMe_MiscFunctions.reset_Fields()
+		ASTGUI.resetTheseFields (['USERS']);
+
+	},
+
+}
+
+function localajaxinit(){
+	var TBL = _$('table_channel_list') ;
+	ASTGUI.domActions.clear_table(TBL);
+	var addCell = ASTGUI.domActions.tr_addCell;
+	/* XXX Move this function to ASTGUI */
+	var ul = parent.astgui_manageusers.listOfChannels();
+	_$('thisPage_lite_Heading').innerHTML = "Active Channels - " + ul.length;
+
+	if(!ul.length){
+		ASTGUI.domActions.clear_table(TBL);
+		var newRow = TBL.insertRow(-1);
+		newRow.className = 'even';
+		addCell( newRow , { html:'No Channels Open !!', align:'center'} );
+		return ;
+	}
+
+	(function(){ // add first row
+		var newRow = TBL.insertRow(-1);
+		newRow.className = "frow";
+		addCell( newRow , { html:'Channel'});
+		addCell( newRow , { html:'State'});
+		addCell( newRow , { html:'Application'});
+		addCell( newRow , { html:''});
+		addCell( newRow , { html:''});
+
+	})();
+
+	ul.each( function(chan){ // list each user in table
+		var tmpsplit = chan.split(/\s+/); /* split by whitespace */
+		var cur_chan = tmpsplit[0]; /* Unique channel ID */ 
+		var cur_location = tmpsplit[1]; /* Location of the call */
+		var cur_state = tmpsplit[2]; /* Channel status */
+		var cur_app = tmpsplit[3]; /* Current application */
+
+		var newRow = TBL.insertRow(-1); 
+		newRow.className = ((TBL.rows.length)%2==1)?'odd':'even';
+		addCell( newRow , { html: cur_chan });
+		if ( cur_state == "Up" ){
+			addCell( newRow , { html: '<font color=green><b>' + cur_state + '</b></font>' });
+		}else{
+			addCell( newRow , { html: '<font color=red><b>' + cur_state + '<b></font>' });
+		}
+		var tmp_a = [];
+		tmp_a[0] = "<span class='guiButton' onclick=\"show_Edit_ChannelDirection('" + cur_chan +"')\">Transfer</span>&nbsp;" ;
+		tmp_a[1] = "<span class='guiButton' onclick=\"show_Edit_ChannelHangup('" + cur_chan +"')\">Hangup</span>&nbsp;" ;
+		addCell( newRow , { html: '<i>' + cur_app + '</i>' });
+		addCell( newRow , { html: tmp_a[0] , align:'center' });
+		addCell( newRow , { html: tmp_a[1] , align:'center' });
+	} );
+};
+
+
+function localajaxend(){
+	parent.astmanEngine.setEventCallback(null);
+	if( navigator.userAgent.indexOf("MSIE") != -1 ){ 
+		try{ purge( document.body ); } catch(e){ }	
+	}
+	clearInterval(poller);
+}
+
+</script>
+<body bgcolor="EFEFEF">
+	<div class="iframeTitleBar"> 
+		Channel Management <span class='refresh_icon' onclick="window.location.reload();" >&nbsp;<img src="images/refresh.png" title=" Refresh " border=0 >&nbsp;</span>
+	</div>
+	<div class='lite_Heading' id='thisPage_lite_Heading'>Active Channels</div>
+	
+	<table id='table_channel_list' cellpadding=0 cellspacing=0 border=0 align=center style='clear:both;'></table>
+
+
+<div id="div_activechannel_edit" STYLE="width:550; display:none;" class='dialog'>
+	<TABLE width="100%" cellpadding=0 cellspacing=0>
+	<TR class="dialog_title_tr">
+		<TD class="dialog_title" onmousedown="ASTGUI.startDrag(event);">
+			<span id="div_activechannel_edit_title"></span></TD>
+		<TD class="dialog_title_X" onclick="ASTGUI.hideDrag(event);"> X </TD>
+	</TR>
+	</TABLE>
+	
+	<TABLE	align=center cellpadding=2 cellspacing=2 border=0 width='100%'>
+		<tr>	<td align=right>User <img src="images/tooltip_info.gif" tip="en,channels,0" class='tooltipinfo'> :</td>
+			<td>	<select id='USERS' required='yes'> </td>
+		</tr>
+
+		<tr>	<td align=center valign=bottom colspan=2 style="padding:15px; background-color: #f4deb7">
+				<span class='guiButtonCancel' onclick='ASTGUI.hideDrag(event);'>Cancel</span>
+				<span class='guiButtonEdit' onclick="doTransfer(_$('USERS').value);">Transfer</span>
+			</td>
+		</tr>
+	</TABLE>
+</div>
+
+</body>

Propchange: branches/2.0/config/status.html
------------------------------------------------------------------------------
    svn:executable = *

Modified: branches/2.0/config/welcome.html
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/welcome.html?view=diff&rev=3681&r1=3680&r2=3681
==============================================================================
--- branches/2.0/config/welcome.html (original)
+++ branches/2.0/config/welcome.html Tue Aug 19 13:08:09 2008
@@ -381,7 +381,7 @@
 		updateTrunkslisting();
 		update_needsConfiguratin_list();
 
-		ASTGUI.systemCmdWithOutput( 'uptime' , function(a){ _$('SYS_status_div').innerHTML = 'Uptime : ' + a.trim() ; } );	
+		ASTGUI.systemCmdWithOutput( 'uptime' , function(a){ document.getElementById('SYS_status_div').innerHTML = 'Uptime : ' + a.trim() ; } );	
 
 	};
 




More information about the asterisk-gui-commits mailing list