pari: branch 2.0 r3661 - in /branches/2.0/config: incoming.html js/astman.js

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Wed Aug 13 16:52:55 CDT 2008


Author: pari
Date: Wed Aug 13 16:52:54 2008
New Revision: 3661

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

	ASTGUI-9 -- Ability to forward incoming rules (DID) by ${EXTEN} basis

 Description: 
	the new old & gui currently allows to define an incoming calling rule based on a pattern
	to be forwarded to a user or a voicemenu or a ring group etc, something like
	_6XXX --to--> extension 6001

	but there is no way in the gui to forward to a range of extensions, something like
	_6XXX --- to --> ${EXTEN} ; OR
	_2564286XXX --- to --> ${EXTEN:-4} 




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

Modified: branches/2.0/config/incoming.html
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/incoming.html?view=diff&rev=3661&r1=3660&r2=3661
==============================================================================
--- branches/2.0/config/incoming.html (original)
+++ branches/2.0/config/incoming.html Wed Aug 13 16:52:54 2008
@@ -94,7 +94,17 @@
 		ASTGUI.updateFieldToValue( 'edit_itrl_tf', tmp_edit_itrl_tf ) ;
 
 		ASTGUI.updateFieldToValue( 'edit_itrl_pattern', ASTGUI.parseContextLine.getExten( EDIT_CONTEXT_IR_LINE ) );
-		ASTGUI.updateFieldToValue( 'edit_itrl_dest', ASTGUI.parseContextLine.getAppWithArgs( EDIT_CONTEXT_IR_LINE ) );
+
+		$('.localext_byDid').hide();
+		if( EDIT_CONTEXT_IR_LINE.contains(',1,Goto(default|${EXTEN') ){
+			$('.localext_byDid').show();
+			ASTGUI.updateFieldToValue( 'edit_itrl_dest', 'ByDID' );
+			var tmp_ldp = EDIT_CONTEXT_IR_LINE.betweenXY('{','}').lChop('EXTEN').lChop(':') ;
+			if( !tmp_ldp.length  ){ tmp_ldp = '0'; }
+			ASTGUI.updateFieldToValue( 'edit_itrl_LocalDest_Pattern', tmp_ldp );
+		}else{
+			ASTGUI.updateFieldToValue( 'edit_itrl_dest', ASTGUI.parseContextLine.getAppWithArgs( EDIT_CONTEXT_IR_LINE ) );
+		}
 
 		incomingRules_MiscFunctions.enableDisablePattern();
 		ASTGUI.feedback( { msg: 'Edit Incoming Rule !', showfor: 2 , color: 'green', bgcolor: '#FFFFFF' } );
@@ -331,6 +341,7 @@
 		isNewIR = true ;
 		ASTGUI.resetTheseFields(['edit_itrl_trunk', 'edit_itrl_tf', 'edit_itrl_pattern', 'edit_itrl_dest' ]);
 		incomingRules_MiscFunctions.enableDisablePattern();
+		$('.localext_byDid').hide();
  		_$('div_ir_edit_title').innerHTML = 'New Incoming Rule';
 		ASTGUI.feedback( { msg: 'New Incoming Rule !', showfor: 2 , color: 'green', bgcolor: '#FFFFFF' } );
 		$('.hideOnEdit').show();
@@ -369,10 +380,22 @@
 		var this_tiName = ASTGUI.getFieldValue('edit_itrl_tf') ;
 		var TMP_NEW_PATTERN = ASTGUI.getFieldValue('edit_itrl_pattern');
 
+		if( ASTGUI.getFieldValue('edit_itrl_dest') == 'ByDID' && parent.astgui_managetrunks.misc.getTrunkType(this_trunk) == 'analog' ){
+			ASTGUI.feedback ({ msg: 'Local Extension by DID is not applicable for Analog Trunks !' , showfor:3,  color:'red' });
+			return ;
+		}
+
 		if( isNewIR == true ){ // create new Incoming Rule
 			ASTGUI.debugLog("create New Incoming Rule" , 'parse');
 			parent.ASTGUI.dialog.waitWhile('Creating Incoming Rule ...');
-			var this_ActualRule = TMP_NEW_PATTERN + ',1,' + ASTGUI.getFieldValue('edit_itrl_dest') ;
+
+			if( ASTGUI.getFieldValue('edit_itrl_dest') == 'ByDID' ){
+				var tmp_didXdigits = ASTGUI.getFieldValue('edit_itrl_LocalDest_Pattern') || '0' ;
+				var this_ActualRule = TMP_NEW_PATTERN + ',1,Goto(default|${EXTEN:'+  tmp_didXdigits + '}|1)';
+			}else{
+				var this_ActualRule = TMP_NEW_PATTERN + ',1,' + ASTGUI.getFieldValue('edit_itrl_dest') ;
+			}
+
 			var x = new listOfActions( 'extensions.conf' );
 			var PREVIOUS = EX_CF[ ASTGUI.contexts.TrunkDIDPrefix + this_trunk ];
 
@@ -453,8 +476,6 @@
 					}else{
 						PREVIOUS_DEFAULT_CONTEXT.push('exten=' + this_ActualRule ); // make sure that the s/_X. would always end up at the bottom of all rules
 					}
-
-					
 				}else{
 					PREVIOUS_DEFAULT_CONTEXT.unshift('exten=' + this_ActualRule );
 				}
@@ -481,7 +502,13 @@
 		}else{ // edit/update existing incoming rule
 
 			var pp = ASTGUI.parseContextLine.getPriority(EDIT_CONTEXT_IR_LINE);
-			var this_ActualRule = ASTGUI.getFieldValue('edit_itrl_pattern') + ',' + pp  + ',' + ASTGUI.getFieldValue('edit_itrl_dest') ;
+
+			if( ASTGUI.getFieldValue('edit_itrl_dest') == 'ByDID' ){
+				var tmp_didXdigits = ASTGUI.getFieldValue('edit_itrl_LocalDest_Pattern') || '0' ;
+				var this_ActualRule = ASTGUI.getFieldValue('edit_itrl_pattern') + ',' + pp  + ',Goto(default|${EXTEN:'+ tmp_didXdigits + '}|1)';
+			}else{
+				var this_ActualRule = ASTGUI.getFieldValue('edit_itrl_pattern') + ',' + pp  + ',' + ASTGUI.getFieldValue('edit_itrl_dest') ;
+			}
 
 			var u = new listOfSynActions('extensions.conf') ;
 			u.new_action( 'update' , EDIT_CONTEXT_IR , 'exten' , this_ActualRule , EDIT_CONTEXT_IR_LINE.afterChar('=') );
@@ -503,8 +530,16 @@
 	ASTGUI.selectbox.populateArray( 'edit_itrl_tf', TI_LIST.getOwnProperties() );
 	ASTGUI.selectbox.append( 'edit_itrl_tf' , 'None (no TimeIntervals matched)' , '' );
 	ASTGUI.selectbox.populateArray( 'edit_itrl_dest' ,  parent.miscFunctions.getAllDestinations() );
+	ASTGUI.selectbox.append( 'edit_itrl_dest' , 'Local Extension by DID' , 'ByDID' );
 	ASTGUI.events.add( 'edit_itrl_trunk' , 'click' , incomingRules_MiscFunctions.enableDisablePattern );
 
+	ASTGUI.events.add( 'edit_itrl_dest', 'change' , function(){
+		if( _$('edit_itrl_dest').value == 'ByDID' ){
+			$('.localext_byDid').show();
+		}else{
+			$('.localext_byDid').hide();
+		}
+	});
 	//'edit_itrl_trunk', 'edit_itrl_tf', 'edit_itrl_pattern', 'edit_itrl_dest'
 };
 
@@ -550,6 +585,11 @@
 				<TD><select id='edit_itrl_dest'  required='yes'></select></TD>
 			</TR>
 
+			<TR class='localext_byDid' style='display:none'>
+				<TD align="right"><nobr>Local Extension by DID Pattern :</nobr></TD>
+				<TD>&nbsp;${EXTEN:<input id='edit_itrl_LocalDest_Pattern' size=2>}</TD>
+			</TR>
+
 			<TR>
 				<TD align="right" colspan=2 height=10> </TD>
 			</TR>

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=3661&r1=3660&r2=3661
==============================================================================
--- branches/2.0/config/js/astman.js (original)
+++ branches/2.0/config/js/astman.js Wed Aug 13 16:52:54 2008
@@ -227,7 +227,10 @@
 	};
 
 	String.prototype.lChop = function(c){ // chop a string from the beginning of the string
-		return (this.beginsWith(c) && this.substr(c.length) ) || this;
+		if(this.beginsWith(c)){
+			return this.substr(c.length);
+		}
+		return this;
 	};
 
 	String.prototype.rChop = function(c){ // chop a string from the end of the string




More information about the asterisk-gui-commits mailing list