pari: branch 2.0 r3777 - in /branches/2.0/config: js/astman.js welcome.html

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Sat Sep 6 04:19:47 CDT 2008


Author: pari
Date: Sat Sep  6 04:19:45 2008
New Revision: 3777

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

 Realtime status of Users




Modified:
    branches/2.0/config/js/astman.js
    branches/2.0/config/welcome.html

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=3777&r1=3776&r2=3777
==============================================================================
--- branches/2.0/config/js/astman.js (original)
+++ branches/2.0/config/js/astman.js Sat Sep  6 04:19:45 2008
@@ -905,6 +905,7 @@
 		tr_addCell: function(tr, nc){ // usage :: ASTGUI.domActions.tr_addCell( el, { html:'newCell Text' , align:'center', width:'20px' }  )
 			var ih = nc.html; delete nc.html;
 			var newcell = tr.insertCell( tr.cells.length );
+			if( nc.id ){ newcell.id = nc.id ; delete nc.id; }
 			newcell.innerHTML = ih;
 			if( nc.onclickFunction && typeof nc.onclickFunction == "function" ){
 				ASTGUI.events.add( newcell , 'click' , nc.onclickFunction ) ;

Modified: branches/2.0/config/welcome.html
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/welcome.html?view=diff&rev=3777&r1=3776&r2=3777
==============================================================================
--- branches/2.0/config/welcome.html (original)
+++ branches/2.0/config/welcome.html Sat Sep  6 04:19:45 2008
@@ -74,6 +74,8 @@
 <script>
 var REGISTRY_OUTPUT = { } ;
 var EX_CF;
+var tmp_image = document.createElement('IMG');
+$(tmp_image).attr('border', '0');
 
 var default_IncomingRule_trunk = function(trunk){
 	var cxt = ASTGUI.contexts.TrunkDIDPrefix + trunk + ASTGUI.contexts.TrunkDefaultSuffix ;
@@ -213,7 +215,7 @@
 					var tmp_userstring = '<u>' + user + '</u>' ;
 				}
 
-				addCell( newRow , { html: ASTGUI.getUser_DeviceStatus_Image(user) } );
+				addCell( newRow , { html: ASTGUI.getUser_DeviceStatus_Image(user) , id : 'TD_USER_DEVICE_STATUS_' + user } );
 				addCell( newRow ,
 					{	html: tmp_userstring ,
 						onclickFunction: function(){
@@ -385,7 +387,6 @@
 };
 
 
-
 var localajaxinit = function(){
 	var ST ;
 	var loadIfeverythingParsed = function(){
@@ -413,6 +414,65 @@
 	};
 
 	ST = setInterval( loadIfeverythingParsed , 200 );
+	(function(){
+		var managerEvents = {};
+		managerEvents.updateUserImage = function(user , user_status){
+			var this_td = _$('TD_USER_DEVICE_STATUS_' + user );
+			ASTGUI.domActions.removeAllChilds ( this_td );
+			switch(user_status){
+				case 'F': // No Device is Busy/InUse
+					var IMG_STATUS_GREEN = tmp_image.cloneNode(true);
+					this_td.appendChild(IMG_STATUS_GREEN) ;
+					$(IMG_STATUS_GREEN).attr( 'src', 'images/status_green.png' );
+					break ;
+				case 'B': // Busy
+					var IMG_STATUS_RED = tmp_image.cloneNode(true);
+					this_td.appendChild(IMG_STATUS_RED) ;
+					$(IMG_STATUS_RED).attr( 'src', 'images/status_red.png' );
+					break ;
+				case 'U': // UnAvailable
+					var IMG_STATUS_GRAY = tmp_image.cloneNode(true);
+					this_td.appendChild(IMG_STATUS_GRAY) ;
+					$(IMG_STATUS_GRAY).attr( 'src', 'images/status_gray.png' );
+					break ;
+				case 'R': // Ringing
+					var IMG_STATUS_ORANGE = tmp_image.cloneNode(true);
+					this_td.appendChild(IMG_STATUS_ORANGE) ;
+					$(IMG_STATUS_ORANGE).attr( 'src', 'images/status_orange.png' );
+					break ;
+				case 'H': // Hold
+					var IMG_STATUS_YELLOW = tmp_image.cloneNode(true);
+					this_td.appendChild(IMG_STATUS_YELLOW) ;
+					$(IMG_STATUS_YELLOW).attr( 'src', 'images/status_yellow.png' );
+					break ;
+				default :
+					var IMG_STATUS_GRAY = tmp_image.cloneNode(true);
+					this_td.appendChild(IMG_STATUS_GRAY) ;
+					$(IMG_STATUS_GRAY).attr( 'src', 'images/status_gray.png' );
+					break ;
+			}
+		};
+		
+		managerEvents.parseOutput = function(op){
+			var tmp_chunks = ASTGUI.miscFunctions.getChunksFromManagerOutput(op, 1) ;
+			tmp_chunks.each(function(this_chunk){
+				
+				if(this_chunk.hasOwnProperty('Event') && this_chunk.Event == 'ExtensionStatus' ){
+					var tmp_user = this_chunk.Exten ;
+					var new_status = ASTGUI.getUser_DeviceStatus(tmp_user) ;
+					managerEvents.updateUserImage(tmp_user , new_status);
+				}
+			});
+			
+			this.Watch();
+		},
+		managerEvents.Watch = function(){
+			$.get( ASTGUI.paths.rawman, {action:'waitevent'}, function(op){managerEvents.parseOutput(op); } );
+		};
+		
+		setTimeout( managerEvents.Watch, 2000 );
+	})();
+	
 };
 
 </script>
@@ -422,6 +482,8 @@
 	<span class='refresh_icon' onclick="window.location.reload();" >&nbsp;<img src="images/refresh.png" title=" Refresh " border=0 >&nbsp;</span>
 </div>
 
+<div id='waitevent_Log'></div>
+
 	<div class='lite_Heading'>System Status</div>
 	<div style='width: 100%; text-align:center;' id='firmware_div'></div>
 




More information about the asterisk-gui-commits mailing list