pari: trunk r255 - in /trunk/config/setup: 4.html 5.html 7.html

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


Author: pari
Date: Mon Jan 15 18:53:11 2007
New Revision: 255

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=255
Log:
** Setup wizard changes needed due to previous commit **

Modified:
    trunk/config/setup/4.html
    trunk/config/setup/5.html
    trunk/config/setup/7.html

Modified: trunk/config/setup/4.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/setup/4.html?view=diff&rev=255&r1=254&r2=255
==============================================================================
--- trunk/config/setup/4.html (original)
+++ trunk/config/setup/4.html Mon Jan 15 18:53:11 2007
@@ -23,9 +23,11 @@
 			
 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 = {
@@ -41,8 +43,25 @@
 		var tmp = new Ajax.Request(rawman_url, 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',
@@ -94,6 +113,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;
@@ -126,11 +148,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(){
@@ -194,14 +223,25 @@
 	}
 
 	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;
@@ -217,10 +257,18 @@
 			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;
 	}
@@ -230,6 +278,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!");
@@ -309,7 +358,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;
@@ -366,7 +415,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 = "";
@@ -654,7 +703,12 @@
 				<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'>
 				</font>
+
 <!-- Provider type -->
 </td>
 <td>

Modified: trunk/config/setup/5.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/setup/5.html?view=diff&rev=255&r1=254&r2=255
==============================================================================
--- trunk/config/setup/5.html (original)
+++ trunk/config/setup/5.html Mon Jan 15 18:53:11 2007
@@ -84,8 +84,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/setup/7.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/setup/7.html?view=diff&rev=255&r1=254&r2=255
==============================================================================
--- trunk/config/setup/7.html (original)
+++ trunk/config/setup/7.html Mon Jan 15 18:53:11 2007
@@ -20,7 +20,8 @@
 callbacks.format = function(t) {
 	if ((t.name == 'general'))
 		return null;
-	if (t.name.substring(0,6) == 'trunk_')
+	//if (t.name.substring(0,6) == 'trunk_')
+	if ( t.fieldbyname['context'] == asterisk_guiTDPrefix + t.name )
 		return null;
 	if (t.fieldbyname['fullname'] && t.fieldbyname['fullname'].length) {
 		return t.name + " -- " + t.fieldbyname['fullname'];



More information about the asterisk-gui-commits mailing list