pari: branch 2.0 r3699 - in /branches/2.0/config: js/pbx.js status.html

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Sat Aug 23 12:36:02 CDT 2008


Author: pari
Date: Sat Aug 23 12:36:01 2008
New Revision: 3699

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=3699
Log:

  More improvements to 'Active Calls' - return each channel as an object instead of as a string

 


Modified:
    branches/2.0/config/js/pbx.js
    branches/2.0/config/status.html

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=3699&r1=3698&r2=3699
==============================================================================
--- branches/2.0/config/js/pbx.js (original)
+++ branches/2.0/config/js/pbx.js Sat Aug 23 12:36:01 2008
@@ -688,15 +688,14 @@
 	},
 
 	listOfChannels: function() { // returns an array of current active channels
-		var raw_chan_staus = makeSyncRequest ( { action :'status' } );
+		var raw_chan_status = makeSyncRequest ( { action :'status' } );
 		var to_return = [];
 		try {
-			raw_chan_staus = raw_chan_staus.replace(/Response: Success/, "");
-			raw_chan_staus = raw_chan_staus.replace(/Message: Channel status will follow/, "");
-			raw_chan_staus = raw_chan_staus.replace(/Event: StatusComplete/, "");
-
-			raw_chan_staus = raw_chan_staus.trim();
-			var chunks = raw_chan_staus.split('Event: Status');
+			raw_chan_status = raw_chan_status.replace(/Response: Success/, "");
+			raw_chan_status = raw_chan_status.replace(/Message: Channel status will follow/, "");
+			raw_chan_status = raw_chan_status.replace(/Event: StatusComplete/, "");
+			raw_chan_status = raw_chan_status.trim();
+			var chunks = raw_chan_status.split('Event: Status');
 
 			chunks.each( function(this_chunk){
 				// Privilege: Call
@@ -711,36 +710,18 @@
 				// Priority: 1
 				// Seconds: 66
 				// Uniqueid: 1219466028.58
+				this_chunk = this_chunk.trim();
 				if( !this_chunk.contains('Channel:') ){ return; }
 				var this_chunk_lines = this_chunk.split('\n');
-				var tmp_Channel = '', tmp_state = '', tmp_application='', tmp_Location ='', tmp_context = '', tmp_extension = '', tmp_priority = '';
-
+
+				var this_chan_data = {};
 				for ( var r =0 ; r < this_chunk_lines.length ; r++ ){
-
 					var this_chunk_line = this_chunk_lines[r];
-					//console.log(this_chunk_line);
-					if(this_chunk_line.contains('Channel:')){
-						tmp_Channel = this_chunk_line.afterStr('Channel:').trim(); continue;
-					}
-
-					if(this_chunk_line.contains('Context:')){
-						tmp_context = this_chunk_line.afterStr('Context:').trim();continue;
-					}
-
-					if(this_chunk_line.contains('Extension:')){
-						tmp_extension = this_chunk_line.afterStr('Extension:').trim();continue;
-					}
-
-					if(this_chunk_line.contains('Priority:')){
-						tmp_priority = this_chunk_line.afterStr('Priority:').trim();continue;
-					}
-					if(this_chunk_line.contains('State:')){
-						tmp_state = this_chunk_line.afterStr('State:').trim(); continue;
-					}
-				}
-
-				var tmp_line = tmp_Channel + '   ' +  tmp_extension + '@' + tmp_context + ':' + tmp_priority + '   ' + tmp_state + '   ' + 'VoiceMailMain(@default)' ;
-				to_return.push(tmp_line);
+					this_chunk_line = this_chunk_line.trim();
+					this_chan_data[this_chunk_line.beforeChar(':').trim()] = this_chunk_line.afterChar(':').trim();
+				}
+
+				to_return.push(this_chan_data);
 			});
 
 		} catch(e) {

Modified: branches/2.0/config/status.html
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/status.html?view=diff&rev=3699&r1=3698&r2=3699
==============================================================================
--- branches/2.0/config/status.html (original)
+++ branches/2.0/config/status.html Sat Aug 23 12:36:01 2008
@@ -164,31 +164,31 @@
 		newRow.className = "frow";
 		addCell( newRow , { html:'Channel'});
 		addCell( newRow , { html:'State'});
+		addCell( newRow , { html:'Seconds'});
 		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 */
-
+	ul.each( function(chan){ // list each channel in table
 		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>' });
+		addCell( newRow , { html: chan.Channel });
+		if ( chan.State == "Up" ){
+			addCell( newRow , { html: '<font color=green><b>Up</b></font>' });
 		}else{
-			addCell( newRow , { html: '<font color=red><b>' + cur_state + '<b></font>' });
+			addCell( newRow , { html: '<font color=red><b>' + chan.State + '<b></font>' });
 		}
+		addCell( newRow , { html: chan.Seconds });
 		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>' });
+		tmp_a[0] = "<span class='guiButton' onclick=\"show_Edit_ChannelDirection('" + chan.Channel +"')\">Transfer</span>&nbsp;" ;
+		tmp_a[1] = "<span class='guiButton' onclick=\"show_Edit_ChannelHangup('" + chan.Channel +"')\">Hangup</span>&nbsp;" ;
+
+		var tmp_app = 'PlaceHolder AppName'; // We need to figure out how to get the app name
+		// one suggestion by bkruse is that we can lookup in extensions.conf using 'chan.Extension, chan.Context, chan.Priority'
+
+		addCell( newRow , { html: '<i>' + tmp_app + '</i>' });
 		addCell( newRow , { html: tmp_a[0] , align:'center' });
 		addCell( newRow , { html: tmp_a[1] , align:'center' });
 	});




More information about the asterisk-gui-commits mailing list