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

asterisk-gui-commits at lists.digium.com asterisk-gui-commits at lists.digium.com
Mon Jan 15 17:04:13 MST 2007


Author: pari
Date: Mon Jan 15 18:04:11 2007
New Revision: 254

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=254
Log:
** Major Change in Trunks Naming convention** Trunk names in users.conf no longer needs to be in trunk_x format -- in order to facilitate user defined trunk names, which are help ful while setting up DIDs. Each trunk has an associated [asterisk_guiTDPrefix + trunkname] as context 

Modified:
    trunk/config/incoming.html
    trunk/config/meetme.html
    trunk/config/menus.html
    trunk/config/numberplan.html
    trunk/config/queues.html
    trunk/config/record.html
    trunk/config/scripts/astman.js
    trunk/config/trunks.html
    trunk/config/users.html
    trunk/config/voicemail.html

Modified: trunk/config/incoming.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/incoming.html?view=diff&rev=254&r1=253&r2=254
==============================================================================
--- trunk/config/incoming.html (original)
+++ trunk/config/incoming.html Mon Jan 15 18:04:11 2007
@@ -32,6 +32,13 @@
 var  edit_pattern, edit_DIDtrunk, edit_action, edit_priority ;
 
 user_callbacks.format = function(t, x) {
+	var tmp = asterisk_guiTDPrefix + t.name ; 
+	if ( ( t.fieldbyname['context'] == tmp ) && x == undefined ) {
+		didtrunks[tmp] = new Object();
+		didtrunks[tmp].trunkname = t.fieldbyname['trunkname'] ; 
+		return t.name;
+	}
+	/*
 	var tmp = 'DID_' + t.name;
 	if ( t.name.substring(0,6) == 'trunk_' && x == undefined){
 		didtrunks[tmp] = new Object();
@@ -40,6 +47,7 @@
 	if ( t.name.substring(0,6) == 'trunk_'  && t.names[x]=='trunkname' ){
 		didtrunks[tmp].trunkname = t.fields[x];
 	}
+	*/
 	return false;
 }
 
@@ -52,14 +60,14 @@
 // parse all contexts in extensions.conf that look like [DID_trunk_x]
 // and show each entry in the table
 numplan_callbacks.format = function(t, x) {
-	if (t.name.substring(0,10) == 'DID_trunk_' && x == undefined){
+	if (		( t.name.substring(0,asterisk_guiTDPrefix.length) == asterisk_guiTDPrefix ) && x == undefined){
 		if(typeof didtrunks[t.name] == "undefined"){
 			didtrunks[t.name] = new Object();
 			didtrunks[t.name].trunkname = t.name;
 		}
 		return t.name;
 	}
-	if (t.name.substring(0,10) == 'DID_trunk_' && t.names[x]=='exten' ){
+	if ( ( t.name.substring(0,asterisk_guiTDPrefix.length) == asterisk_guiTDPrefix ) && t.names[x]=='exten' ){
 		//get pattern & action
 		var temp = t.fields[x].split(',');
 		didtrunks[t.name][temp[0]] = new Object();

Modified: trunk/config/meetme.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/meetme.html?view=diff&rev=254&r1=253&r2=254
==============================================================================
--- trunk/config/meetme.html (original)
+++ trunk/config/meetme.html Mon Jan 15 18:04:11 2007
@@ -214,8 +214,13 @@
 			}
 			return null;
 		}
-		if (t.name.substring(0,6) == 'trunk_')
+
+		//if (t.name.substring(0,6) == 'trunk_')
+		//	return null;
+		if ( t.fieldbyname['context'] == asterisk_guiTDPrefix + t.name ) {
 			return null;
+		}
+
 		if (t.fieldbyname['fullname'] && t.fieldbyname['fullname'].length) {
 			return t.name + " -- " + t.fieldbyname['fullname'];
 		} else

Modified: trunk/config/menus.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/menus.html?view=diff&rev=254&r1=253&r2=254
==============================================================================
--- trunk/config/menus.html (original)
+++ trunk/config/menus.html Mon Jan 15 18:04:11 2007
@@ -977,10 +977,14 @@
 			}
 			return null;
 		}
-		if (t.name.substring(0,6) == 'trunk_')
+
+		//if (t.name.substring(0,6) == 'trunk_')
+		//	return null;
+		if ( t.fieldbyname['context'] == asterisk_guiTDPrefix + t.name ) {
 			return null;
-		else
+		}else{
 			return t.name;
+		}
 }
 
 usercallbacks.identifier = "extension";

Modified: trunk/config/numberplan.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/numberplan.html?view=diff&rev=254&r1=253&r2=254
==============================================================================
--- trunk/config/numberplan.html (original)
+++ trunk/config/numberplan.html Mon Jan 15 18:04:11 2007
@@ -66,8 +66,11 @@
 
 
 trunkcallbacks.format = function(t) {
-	if (t.name.substr(0,6) != 'trunk_')
+	//if (t.name.substr(0,6) != 'trunk_')
+	//	return null;
+	if ( t.fieldbyname['context'] != asterisk_guiTDPrefix + t.name ) {
 		return null;
+	}
 	if (t.fieldbyname['trunkname'] && t.fieldbyname['trunkname'].length) {
 		trunks_desc[t.name] = new Object();
 		trunks_desc[t.name].comment = t.fieldbyname['trunkname'] ;

Modified: trunk/config/queues.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/queues.html?view=diff&rev=254&r1=253&r2=254
==============================================================================
--- trunk/config/queues.html (original)
+++ trunk/config/queues.html Mon Jan 15 18:04:11 2007
@@ -289,8 +289,11 @@
 			if ( t.fieldbyname['userbase'] && t.fieldbyname['userbase'].length){ userbase =  t.fieldbyname['userbase'] ; }
 			return null;
 		}
-		if (t.name.substring(0,6) == 'trunk_')
+		//if (t.name.substring(0,6) == 'trunk_')
+		//	return null;
+		if ( t.fieldbyname['context'] == asterisk_guiTDPrefix + t.name ) {
 			return null;
+		}
 		if (t.fieldbyname['fullname'] && t.fieldbyname['fullname'].length) {
 			return t.name + " -- " + t.fieldbyname['fullname'];
 		} else

Modified: trunk/config/record.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/record.html?view=diff&rev=254&r1=253&r2=254
==============================================================================
--- trunk/config/record.html (original)
+++ trunk/config/record.html Mon Jan 15 18:04:11 2007
@@ -186,8 +186,11 @@
 callbacks.format = function(t) {
 	if ((t.name == 'general'))
 		return null;
-	if (t.name.substring(0,6) == 'trunk_')
-		return null;
+	//if (t.name.substring(0,6) == 'trunk_')
+	//	return null;
+	if ( t.fieldbyname['context'] == asterisk_guiTDPrefix + t.name ) {
+			return null;
+	}
 	if (t.fieldbyname['fullname'] && t.fieldbyname['fullname'].length) {
 		return t.name + " -- " + t.fieldbyname['fullname'];
 	} else

Modified: trunk/config/scripts/astman.js
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/scripts/astman.js?view=diff&rev=254&r1=253&r2=254
==============================================================================
--- trunk/config/scripts/astman.js (original)
+++ trunk/config/scripts/astman.js Mon Jan 15 18:04:11 2007
@@ -25,6 +25,7 @@
  var asterisk_guiversion = "$Revision$";
 var sortbynames = false;
 var dragdata = new Object;
+var asterisk_guiTDPrefix = "DID_";
 
 function startDrag(event, movethis ){
 	dragdata.movethis = movethis ;

Modified: trunk/config/trunks.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/trunks.html?view=diff&rev=254&r1=253&r2=254
==============================================================================
--- trunk/config/trunks.html (original)
+++ trunk/config/trunks.html Mon Jan 15 18:04:11 2007
@@ -42,9 +42,12 @@
 				
 	var provfieldnames = new Array('providerdesc', 'providerlogo');
 	var isnewtrunk;
+	var dids_array = [];
+	var old_trunkname;
+
 
 	function add_didcontext(trunk){
-		var didcontext = "DID_" + trunk ;
+		var didcontext = asterisk_guiTDPrefix + trunk ;
 		var uri = build_action('newcat', 0, didcontext ,"", "");
 		uri += build_action('append', 1, didcontext ,"include", "default"); 
 		var opt = {
@@ -60,8 +63,26 @@
 		var tmp = new Ajax.Request("../../rawman", opt);
 	}
 
+	function update_didcontext(old_trunk, new_trunk){
+		var old_didcontext = asterisk_guiTDPrefix + old_trunk  ;
+		var new_didcontext = asterisk_guiTDPrefix + new_trunk  ;
+		var uri = build_action('renamecat', 0, old_didcontext ,"", new_didcontext );
+		var opt = {
+			method: 'get',
+			asynchronous: true,
+			onSuccess: function(t) { },
+			onFailure: function(t) {
+				alert("Config Error: " + t.status + ": " + t.statusText);
+				alert("Failed to Rename the DID context for " + old_didcontext );
+			}
+		};
+		opt.parameters= "action=updateconfig&reload=yes&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri;
+		var tmp = new Ajax.Request("../../rawman", opt);
+	}
+
+
 	function delete_didcontext(trunk){
-		var didcontext = "DID_" + trunk ;
+		var didcontext = asterisk_guiTDPrefix + trunk ;
 		var uri = build_action('delcat', 0, didcontext ,"", "");
 		var opt = {
 			method: 'get',
@@ -81,6 +102,9 @@
 	}
 	
 	globalvars.format = function(t) {
+		if ( t.name.substring(0,asterisk_guiTDPrefix.length) == asterisk_guiTDPrefix ){
+			dids_array.push( t.name.substring( asterisk_guiTDPrefix.length ) );
+		}
 		if (t.name == "globals")
 			return t.name
 		return null;
@@ -97,11 +121,18 @@
 	}
 	
 	callbacks.format = function(t) {
+		/*
 		if ((t.name == 'general'))
 			return null;
 		if (t.name.substring(0,6) != 'trunk_')
 			return null;
 		return t.fieldbyname['trunkname'];
+		*/
+		// if t.name is found in dids_array
+		if( InArray(dids_array, t.name) ){
+			return t.fieldbyname['trunkname'];
+		}
+		return null;
 	}
 
 	callbacks.cancelnewcategory = function(){
@@ -165,19 +196,31 @@
 	}
 
 	callbacks.beforeSaving = function(){
-				if (	$('trunkstylecustomvoip').checked) {
-						//
-				}
+			if(isnewtrunk ==1){
+				dids_array.push($('name').value );
+			}else{
+					old_trunkname = $('devices').value ;
+					if( $('devices').value != $('name').value){ // if the trunk name is changed , change the name in dids_array
+							for( var i=0 ; i < dids_array.length; i ++	){
+								if( dids_array[i] == $('devices').value) { dids_array[i] = $('name').value;}
+							}
+					}	
+			}
 	}
 
 	callbacks.savechanges = function() {
-		if(isnewtrunk ==1){ //New Trunk created , add [DID_trunk_x] in extensions.conf
-			add_didcontext($('devices').value);
+		if(isnewtrunk == 1){ //New Trunk created , add [DID_trunk_x] in extensions.conf
+			add_didcontext($('name').value);
+		}else{
+			if(old_trunkname != $('name').value ){	 // rename DID if needed
+				update_didcontext(old_trunkname, $('name').value);
+			}
 		}
 		saveSPdetails();
 		var uri;
 		var newvalue;
 		var tmp = $('devices').value.split('_');
+
 		var oldvalue = $('hiddenglobals').stored_config.catbyname['globals'].fieldbyname[$('devices').value];
 		if ($('trunkstylevoip').checked || $('trunkstylecustomvoip').checked) {
 			if ($('devices').stored_config.catbyname[$('devices').value].fieldbyname['hasiax'] == 'yes')
@@ -187,11 +230,20 @@
 		} else {
 			newvalue = "Zap/g"+tmp[1];
 		}
+
 		if (newvalue != oldvalue) {
-			uri = build_action('update', 0, 'globals', $('devices').value, newvalue);
-			apply_uri($('hiddenglobals'), uri);
-			$('hiddenglobals').stored_config.catbyname['globals'].fieldbyname[$('devices').value] = newvalue;
-			return true;
+			if(old_trunkname == $('name').value ){	
+				uri = build_action('update', 0, 'globals', $('devices').value, newvalue);
+				apply_uri($('hiddenglobals'), uri);
+				$('hiddenglobals').stored_config.catbyname['globals'].fieldbyname[$('devices').value] = newvalue;
+				return true;
+			}else{
+				uri = build_action('delete', 0, 'globals', old_trunkname, "","" );
+				uri += build_action('update', 1, 'globals', $('name').value, newvalue);
+				apply_uri($('hiddenglobals'), uri);
+				$('hiddenglobals').stored_config.catbyname['globals'].fieldbyname[$('name').value] = newvalue;
+				return true;
+			}
 		}
 		return false;
 	}
@@ -201,6 +253,7 @@
 		var provider;
 		var count = 0;
 		$('hasexten').value = 'no';
+		$('context').value =  asterisk_guiTDPrefix + $('name').value  ;
 		if ($('trunkstylevoip').checked) {
 							if (!$('username').value.length) {
 								alert("When using VoIP, the username must not be empty!");
@@ -280,7 +333,7 @@
 						$('hassip').value = 'no';
 						$('hasiax').value = 'no';
 						$('callerid').value = 'asreceived';
-						$('group').value = box.value.split('_')[1];
+						$('group').value = $('name').value.split('_')[1];
 		} else if( $('trunkstylecustomvoip').checked ){
 						// Custom VOIP Provider
 						$('trunkname').value = "Custom - " + $('customvoip_name').value;
@@ -337,7 +390,7 @@
 			tmp.name = 'trunk_' + x;
 		}
 		tmp.fieldbyname['hasexten'] = 'no';
-		tmp.fieldbyname['context'] = 'DID_'+tmp.name;
+		tmp.fieldbyname['context'] = asterisk_guiTDPrefix + tmp.name;
 		$('customvoip_name').value = "";
 		$('customvoip_username').value = "";
 		$('customvoip_secret').value = "";
@@ -609,6 +662,10 @@
 				<LABEL FOR="trunkstyleanalog"><input name='trunkstyle' type='radio' id='trunkstyleanalog' onclick='activateanalogvoip()' value='analog'>Analog</LABEL><BR>
 				<LABEL FOR="trunkstylevoip"><input name='trunkstyle' type='radio' id='trunkstylevoip' onclick='activateanalogvoip()' value='voip'>VoIP</LABEL><BR>
 				<LABEL FOR="trunkstylecustomvoip"><input name='trunkstyle' type='radio' id='trunkstylecustomvoip' onclick='activateanalogvoip()' value='customvoip'>Custom VoIP</LABEL>
+
+				<BR><BR>
+				<B>Provider Name:</B><BR>
+				<input id="name" size=10 class='input8'>
 <!-- Provider type -->
 </td>
 <td>
@@ -636,7 +693,6 @@
 				</div>
 				<div id='customvoip' align="center" style='display:none' align="center">
 						<table align="center" cellpadding=2 cellspacing=1>
-									<input id="name" type="hidden">
 									<input id="trunkname" type="hidden">
 									<input id="hasiax" type="hidden">
 									<input id="hassip" type="hidden">

Modified: trunk/config/users.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/users.html?view=diff&rev=254&r1=253&r2=254
==============================================================================
--- trunk/config/users.html (original)
+++ trunk/config/users.html Mon Jan 15 18:04:11 2007
@@ -59,8 +59,11 @@
 				return null;
 			}
 			
-			if (t.name.substring(0,6) == 'trunk_')
+			//if (t.name.substring(0,6) == 'trunk_')
+			//	return null;
+			if ( t.fieldbyname['context'] == asterisk_guiTDPrefix + t.name ) {
 				return null;
+			}
 			
 			if (t.fieldbyname['fullname'] && t.fieldbyname['fullname'].length ) {
 					if(	sortbynames ){

Modified: trunk/config/voicemail.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/voicemail.html?view=diff&rev=254&r1=253&r2=254
==============================================================================
--- trunk/config/voicemail.html (original)
+++ trunk/config/voicemail.html Mon Jan 15 18:04:11 2007
@@ -173,8 +173,11 @@
 			}
 			return null;
 		}
-		if (t.name.substring(0,6) == 'trunk_')
+		//if (t.name.substring(0,6) == 'trunk_')
+		//	return null;
+		if ( t.fieldbyname['context'] == asterisk_guiTDPrefix + t.name ) {
 			return null;
+		}
 		if (t.fieldbyname['fullname'] && t.fieldbyname['fullname'].length) {
 			return t.name + " -- " + t.fieldbyname['fullname'];
 		} else



More information about the asterisk-gui-commits mailing list