rbrindley: branch 2.0 r4701 - in /branches/2.0/config/js: pbx2.js trunks_voip.js

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Thu Apr 2 13:11:42 CDT 2009


Author: rbrindley
Date: Thu Apr  2 13:11:38 2009
New Revision: 4701

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

- fixed two major issues with pbx.trunks OOPS!
- (1) Adding a trunk had some errors, disallowing addition completion
- (2) Deleting a trunk had some major errors, removing undesired info from extensions.conf


Modified:
    branches/2.0/config/js/pbx2.js
    branches/2.0/config/js/trunks_voip.js

Modified: branches/2.0/config/js/pbx2.js
URL: http://svn.digium.com/svn-view/asterisk-gui/branches/2.0/config/js/pbx2.js?view=diff&rev=4701&r1=4700&r2=4701
==============================================================================
--- branches/2.0/config/js/pbx2.js (original)
+++ branches/2.0/config/js/pbx2.js Thu Apr  2 13:11:38 2009
@@ -1138,7 +1138,8 @@
  * Trunks object.
  */
 pbx.trunks = {
-	trunk_types: ['analog', 'bri', 'iax', 'pri', 'providers', 'sip']
+	trunk_types: ['analog', 'bri', 'iax', 'pri', 'providers', 'sip'],
+	tech: {analog: 'DAHDI', bri: 'DAHDI', iax: 'IAX2', pri:'DAHDI', sip: 'SIP'}
 };
 
 /**
@@ -1154,6 +1155,7 @@
 	var ct = '';
 	var group = '';
 	var name = trunk.username;
+	var tech = this.tech[type];
 
 	/* The first thing we must do is verify required vars and
 	 * do some general prep work depending on type */
@@ -1210,12 +1212,12 @@
 	trunk.group = group || null;
 	//DahdiChannelString ???
 	trunk.hasexten = 'no';
-	trunk.hasiax = trunk.hasiax || 'no';
-	trunk.hassip = trunk.hassip || 'no';
-	trunk.registeriax = trunk.hasiax || 'no';	/* same conditions as hasiax */
-	trunk.registersip = (trunk.host === 'dynamic' && trunk.hassip) ? 'no' : 'yes';
-	trunk.trunkname = (trunk.trunkname) ? trunk.trunkname.guiMetaData() : '';
-	trunk.trunkstyle = (type === 'analog') ? type.guiMetaData() : 'voip'.guiMetaData();
+	trunk.hasiax = (type === 'iax') ? 'yes' : 'no';
+	trunk.hassip = (type === 'sip') ? 'yes' : 'no';
+	trunk.registeriax = (type === 'iax') ? 'yes' : 'no';	/* same conditions as hasiax */
+	trunk.reigstersip = (trunk.host === 'dynamic' && type === 'sip') ? 'yes' : 'no';
+	trunk.trunkname = trunk.trunkname || '';
+	trunk.trunkstyle = (type === 'analog') ? type : 'voip';
 
 	/* Initializing astman interactions */
 	var users_conf = new listOfActions();
@@ -1225,24 +1227,22 @@
 	users_conf.new_action('newcat', name, '', '');
 
 	/* now, lets iterate thru and append to the trunk context! */
+	sessionData.pbxinfo.trunks[type][name] = {};
 	for (var v in trunk) {
-		if (!trunk.hasOwnProperty(v)) {
+		if (!trunk.hasOwnProperty(v) || v === 'allow' || v === 'disallow') {
 			continue;
 		}
 
 		sessionData.pbxinfo.trunks[type][name][v] = trunk[v];
 		users_conf.new_action('append', name, v, trunk[v]);
 	}
-
-	var resp = users_conf.callActions();
-
-	/* Not good! an error!! */
-	if (!resp.contains('Response: Success')) {
-		top.log.error('pbx.trunks.add: error adding trunk to users.conf');
-		top.log.error(resp);
-		delete sessionData.pbxinfo.trunks[type][name];
-		return false;
-	}
+	sessionData.pbxinfo.trunks[type][name]['allow'] = trunk['allow'];
+	users_conf.new_action('append', name, 'allow', trunk['allow']);
+	sessionData.pbxinfo.trunks[type][name]['disallow'] = trunk['disallow'];
+	users_conf.new_action('append', name, 'disallow', trunk['disallow']);
+
+	/* TODO: get listOfActions to return a response so we know everythings ok! */
+	users_conf.callActions(function(){});
 
 	/* users.conf changes down, now to add to extensions.conf */
 	var ext_conf = new listOfSynActions('extensions.conf');
@@ -1252,7 +1252,8 @@
 	ext_conf.new_action('delcat', ct + ASTGUI.contexts.TrunkDefaultSuffix, '' ,'');
 	ext_conf.new_action('newcat', ct + ASTGUI.contexts.TrunkDefaultSuffix, '', '');
 	ext_conf.new_action('append', ct, 'include', ct + ASTGUI.contexts.TrunkDefaultSuffix);
-	ext_conf.new_action('update', 'globals', trunk, this.technology[type] + '/' + name);
+	/* not going to work for analog vv */
+	ext_conf.new_action('update', 'globals', name, tech + '/' + name);
 
 	resp = '';
 	resp = ext_conf.callActions();
@@ -1272,6 +1273,7 @@
 	}
 
 	callback();
+	return true;
 };
 
 /**
@@ -1462,7 +1464,7 @@
 		}
 	});
 
-	return (!x.length) ? 'trunk_1' : 'trunk_' + numbers.firstAvailable();
+	return (!numbers.length) ? 'trunk_1' : 'trunk_' + numbers.firstAvailable();
 };
 
 /**
@@ -1479,12 +1481,12 @@
 	var actions = new listOfSynActions('extensions.conf');
 	actions.new_action('delete', 'globals', trunk, '');
 
-	for (var trunk in exts) {
-		if (!exts.hasOwnProperty(trunk)) {
+	for (var ext in exts) {
+		if (!exts.hasOwnProperty(ext) || !ext.contains(ASTGUI.contexts.TrunkDIDPrefix + trunk)) {
 			continue;
 		}
 
-		actions.new_action('delcat', trunk, '', '');
+		actions.new_action('delcat', ext, '', '');
 	}
 	actions.callActions();
 

Modified: branches/2.0/config/js/trunks_voip.js
URL: http://svn.digium.com/svn-view/asterisk-gui/branches/2.0/config/js/trunks_voip.js?view=diff&rev=4701&r1=4700&r2=4701
==============================================================================
--- branches/2.0/config/js/trunks_voip.js (original)
+++ branches/2.0/config/js/trunks_voip.js Thu Apr  2 13:11:38 2009
@@ -199,10 +199,17 @@
 			window.location.reload();
 		};
 
-		if(ttv =='SIP'){ parent.pbx.trunks.add('sip', trp , cbf,
-						DOM_edit_VOIPTrunk_Context_Basis.value ) ; }
-		if(ttv =='IAX'){ parent.pbx.trunks.add('iax', trp , cbf,
-						DOM_edit_VOIPTrunk_Context_Basis.value ) ; }
+		if (ttv =='SIP') { 
+			var retval = parent.pbx.trunks.add('sip', trp, cbf, DOM_edit_VOIPTrunk_Context_Basis.value);
+		} else if (ttv =='IAX') { 
+			var retval = parent.pbx.trunks.add('iax', trp, cbf, DOM_edit_VOIPTrunk_Context_Basis.value);
+		}
+
+		if (retval) {
+			ASTGUI.feedback( { msg:'added voip trunk ' + tmp_username, showfor: 5, color:'red', bgcolor:'#ffffff' } );
+			window.location.reload();
+		}
+
 
 	}else if(isNewTrunk == false){
 	// Edit Existing Trunk




More information about the asterisk-gui-commits mailing list