pari: branch 2.0 r3639 - in /branches/2.0/config/js: astman.js pbx.js

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Fri Aug 8 11:33:16 CDT 2008


Author: pari
Date: Fri Aug  8 11:33:15 2008
New Revision: 3639

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

reverting to r3634

  I realized we can not keep doing these manual checks every time we do an update/delete/delcat,
  as there are so many other places where we have to do the same. 
  Also it would be a nightmare to manually keep doing these variable/category verifications in future.
  
  A better model would be probably to make listOfActions() and listOfSynActions() do these verifications automatically when needed.



Modified:
    branches/2.0/config/js/astman.js
    branches/2.0/config/js/pbx.js

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=3639&r1=3638&r2=3639
==============================================================================
--- branches/2.0/config/js/astman.js (original)
+++ branches/2.0/config/js/astman.js Fri Aug  8 11:33:15 2008
@@ -2205,16 +2205,8 @@
 
 	updateaValue: function(e){
 		// ASTGUI.updateaValue(  {file:'users.conf', context :'6000', variable :'hassip', value :'yes'}   )
-		var cxt = context2json({ filename : e.file , context : e.context , usf : 1 }) ;
-
 		var u = new listOfSynActions(e.file) ;
-
-		if( cxt.hasOwnProperty(e.variable) ){
-			u.new_action('delete', e.context, e.variable , '' , '');
-		}else{
-			u.new_action('append', e.context, e.variable , e.value );
-		}
-
+		u.new_action('update', e.context, e.variable , e.value );
 		var g = u.callActions();
 		return (g.contains('Response: Success')) ? true : false ;
 	},

Modified: branches/2.0/config/js/pbx.js
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/js/pbx.js?view=diff&rev=3639&r1=3638&r2=3639
==============================================================================
--- branches/2.0/config/js/pbx.js (original)
+++ branches/2.0/config/js/pbx.js Fri Aug  8 11:33:15 2008
@@ -49,7 +49,7 @@
 			return;
 		}
 
-		if( ecnf.hasOwnProperty('general') && ecnf.general.hasOwnProperty('clearglobalvars') && ecnf.general..clearglobalvars != 'yes' ){
+		if( ecnf.hasOwnProperty('general') && ecnf.general.getProperty('clearglobalvars') != 'yes' ){
 			var u = new listOfSynActions('extensions.conf');
 			u.new_action('update', 'general', 'clearglobalvars', 'yes');
 			u.callActions();
@@ -166,9 +166,10 @@
 			var s = $.ajax({ url: ASTGUI.paths.rawman+'?action=getconfig&filename=' + tmp_file , async: false }).responseText;
 			if( s.contains('Response: Error') && s.contains('Message: Config file not found') ){
 				ASTGUI.miscFunctions.createConfig( tmp_file , function(){
-					var u = new listOfSynActions(tmp_file);
+					var u = new listOfSynActions(tmp_file) ;
+					u.new_action('delcat', 'general', "", ""); 
 					u.new_action('newcat', 'general', "", ""); 
-					u.new_action('append', 'general', '#include "../zaptel.conf" ;', ' ;');
+					u.new_action('update', 'general', '#include "../zaptel.conf" ;', ' ;');
 					u.callActions();
 				});
 				return;
@@ -624,13 +625,6 @@
 		// note: 	this function updates sessionData.pbxinfo['users'] before actually making the ajax requests
 		//		we need to address this issue at some point in future
 		userinfo = ASTGUI.toCustomObject(userinfo) ;
-
-		var x = new listOfActions();
-		x.filename('users.conf');
-		if( sessionData.pbxinfo['users'].hasOwnProperty(exten) ){
-			x.new_action('delcat', exten, '', '');
-		}
-
 		var disallow = userinfo.getProperty('disallow') || 'all' ;
 		var allow = userinfo.getProperty('allow') || 'all' ;
 		sessionData.pbxinfo['users'][exten] = userinfo ;
@@ -638,6 +632,9 @@
 		sessionData.pbxinfo['users'][exten]['allow'] = allow ;
 		delete userinfo.disallow ;
 		delete userinfo.allow ;
+		var x = new listOfActions();
+		x.filename('users.conf');
+		x.new_action('delcat', exten, '', '');
 		x.new_action('newcat', exten, '', '');
 		x.new_action('append', exten, 'username', exten );
 		x.new_action('append', exten, 'transfer', 'yes' );
@@ -645,8 +642,11 @@
 		x.new_action('append', exten, 'allow', allow );
 		x.new_action('append', exten, 'mailbox', userinfo.mailbox || exten );
 		sessionData.pbxinfo['users'][exten]['mailbox'] = userinfo.mailbox || exten ;
+
 		x.new_action('append', exten, 'call-limit', '100' );
 		sessionData.pbxinfo['users'][exten]['mailbox'] = '100' ;
+
+
 		if(userinfo.mailbox) delete userinfo.mailbox;
 		for( var d in userinfo ){ if( userinfo.hasOwnProperty(d) ) {
 			x.new_action( 'append', exten, d, userinfo[d] );
@@ -680,11 +680,7 @@
 
 		var EXT_CNF = config2json({filename:'extensions.conf', usf:0 }) ;
 		var v = new listOfSynActions('extensions.conf') ;
-
-		if( EXT_CNF['globals'].indexOfLike( trunk + '=' )  != -1 ){
-			v.new_action('delete', 'globals', trunk , '' );
-		}
-
+		v.new_action('delete', 'globals', trunk , '' );
 		for( var ct in EXT_CNF){ if( EXT_CNF.hasOwnProperty(ct) ){
 			if( ct == ASTGUI.contexts.TrunkDIDPrefix + trunk || ct.beginsWith( ASTGUI.contexts.TrunkDIDPrefix + trunk + '_' ) ){
 				v.new_action('delcat', ct , '' , '' );
@@ -787,12 +783,7 @@
 		// any other patterns are not defined for Analag trunks
 		var x = new listOfActions();
 		x.filename('users.conf');
-
-		var tmp_USCNF = config2json({ filename:'users.conf', usf:1 });
-		if( tmp_USCNF.hasOwnProperty(trunk) ){
-			x.new_action('delcat', trunk , '', ''); // not really needed - but just in case
-		}
-
+		x.new_action('delcat', trunk , '', ''); // not really needed - but just in case
 		x.new_action('newcat', trunk, '', ''); // create new trunk
 		// add some default values for any AnalogTrunk
 			sessionData.pbxinfo.trunks.analog[trunk] = new ASTGUI.customObject; // add new/reset analog trunk info in sessionData
@@ -838,19 +829,13 @@
 		} );
 
 		var cb = function(){
-			var v = new listOfSynActions('extensions.conf');
-			var tmp_EXTNCF = config2json({ filename:'extensions.conf', usf:1 });
-			if( tmp_EXTNCF.hasOwnProperty(ct) ){
-				v.new_action('delcat', ct, '', '');
-			}
-
+			var v = new listOfSynActions('extensions.conf') ;
+			v.new_action('delcat', ct, '', '');
 			v.new_action('newcat', ct, '', ''); // add context
-
-			if( tmp_EXTNCF.hasOwnProperty(ct + ASTGUI.contexts.TrunkDefaultSuffix) ){
-				v.new_action('delcat', ct + ASTGUI.contexts.TrunkDefaultSuffix , '', '');
-			}
+			v.new_action('delcat', ct + ASTGUI.contexts.TrunkDefaultSuffix , '', '');
 			v.new_action('newcat', ct + ASTGUI.contexts.TrunkDefaultSuffix , '', ''); // add context
 			v.new_action('append', ct , 'include', ct + ASTGUI.contexts.TrunkDefaultSuffix );
+
 			v.new_action('append', 'globals', trunk , 'Zap/g' + group);
 
 			var h = v.callActions();
@@ -887,10 +872,7 @@
 		var x = new listOfActions();
 
 		x.filename('users.conf');
-			var tmp_USCNF = config2json({ filename:'users.conf', usf:1 });
-			if( tmp_USCNF.hasOwnProperty(trunk) ){
-				x.new_action('delcat', trunk , '', ''); // not really needed - but just in case
-			}
+		x.new_action('delcat', trunk , '', ''); // not really needed - but just in case
 		x.new_action('newcat', trunk, '', ''); // create new trunk
 
 		x.new_action('append', trunk, 'context', ct);
@@ -906,18 +888,13 @@
 
 		var cb = function(){
 			var v = new listOfSynActions('extensions.conf') ;
-				var tmp_EXTNCF = config2json({ filename:'extensions.conf', usf:1 });
-				if( tmp_EXTNCF.hasOwnProperty(ct) ){
-					v.new_action('delcat', ct, '', '');
-				}
+			v.new_action('delcat', ct, '', '');
 			v.new_action('newcat', ct, '', ''); // add context
-				if( tmp_EXTNCF.hasOwnProperty(ct + ASTGUI.contexts.TrunkDefaultSuffix) ){
-					v.new_action('delcat', ct + ASTGUI.contexts.TrunkDefaultSuffix , '', '');
-				}
+			v.new_action('delcat', ct + ASTGUI.contexts.TrunkDefaultSuffix , '', '');
 			v.new_action('newcat', ct + ASTGUI.contexts.TrunkDefaultSuffix , '', ''); // add context
 			v.new_action('append', ct , 'include', ct + ASTGUI.contexts.TrunkDefaultSuffix );
 
-			v.new_action('append', 'globals', trunk, 'IAX2/' + trunk);
+			v.new_action('update', 'globals', trunk, 'IAX2/' + trunk);
 			var h = v.callActions();
 			if( h.contains('Response: Success') ){
 				cbf();
@@ -947,10 +924,7 @@
 		var x = new listOfActions();
 
 		x.filename('users.conf');
-			var tmp_USCNF = config2json({ filename:'users.conf', usf:1 });
-			if( tmp_USCNF.hasOwnProperty(trunk) ){
-				x.new_action('delcat', trunk , '', ''); // not really needed - but just in case
-			}
+		x.new_action('delcat', trunk , '', ''); // not really needed - but just in case
 		x.new_action('newcat', trunk, '', ''); // create new trunk
 			sessionData.pbxinfo.trunks.sip[trunk] = new ASTGUI.customObject; // add new/reset sip trunk info in sessionData
 		x.new_action('append', trunk, 'context', ct);
@@ -966,19 +940,14 @@
 
 		var cb = function(){
 			var v = new listOfSynActions('extensions.conf') ;
-				var tmp_EXTNCF = config2json({ filename:'extensions.conf', usf:1 });
-				if( tmp_EXTNCF.hasOwnProperty(ct) ){
-					v.new_action('delcat', ct, '', '');
-				}
+			v.new_action('delcat', ct, '', '');
 			v.new_action('newcat', ct, '', ''); // add context
 
-				if( tmp_EXTNCF.hasOwnProperty(ct + ASTGUI.contexts.TrunkDefaultSuffix) ){
-					v.new_action('delcat', ct + ASTGUI.contexts.TrunkDefaultSuffix , '', '');
-				}
+			v.new_action('delcat', ct + ASTGUI.contexts.TrunkDefaultSuffix , '', '');
 			v.new_action('newcat', ct + ASTGUI.contexts.TrunkDefaultSuffix , '', ''); // add context
 			v.new_action('append', ct , 'include', ct + ASTGUI.contexts.TrunkDefaultSuffix );
 
-			v.new_action('append', 'globals', trunk, 'SIP/' + trunk);
+			v.new_action('update', 'globals', trunk, 'SIP/' + trunk);
 			var h = v.callActions();
 
 			if( h.contains('Response: Success') ){ 
@@ -1195,9 +1164,7 @@
 		}
 		var x = new listOfActions();
 		x.filename('extensions.conf');
-		if( sessionData.pbxinfo.callingPlans.hasOwnProperty(dp_name) ){
-			x.new_action('delcat', dp_name, '', '') ;
-		}
+		x.new_action('delcat', dp_name, '', ''); 
 		x.new_action('newcat', dp_name , '', ''); // create new callplan
 		dp.includes.each( function(include_context) {
 			x.new_action( 'append', dp_name , 'include' , include_context );
@@ -1352,10 +1319,7 @@
 	addMenu: function(new_name, new_menu, cbf){ // Creates a New Voicemenu 'new_name' with a standard VoiceMenu structure of 'new_menu'
 		var x = new listOfActions();
 		x.filename('extensions.conf');
-			var tmp_EXTNCF = config2json({ filename:'extensions.conf', usf:1 });
-			if( tmp_EXTNCF.hasOwnProperty(new_name) ){
-				x.new_action('delcat', new_name , '', ''); // not really needed - but just in case
-			}
+		x.new_action('delcat', new_name , '', ''); // not really needed - but just in case
 		x.new_action('newcat', new_name , '', ''); // create new VoiceMenu
 		new_menu.includes.each( function(item) { // usually ['default'] or just [] 
 			x.new_action( 'append', new_name , 'include', item );
@@ -1388,10 +1352,7 @@
 
 	deleteMenu: function(menu_name){ // deletes voicemenu 'menu_name'
 		var v = new listOfSynActions('extensions.conf') ;
-			var tmp_EXTNCF = config2json({ filename:'extensions.conf', usf:1 });
-			if( tmp_EXTNCF.hasOwnProperty(menu_name) ){
-				v.new_action('delcat', menu_name, '', '');
-			}
+		v.new_action('delcat', menu_name, '', ''); 
 		if( sessionData.pbxinfo.voicemenus[menu_name]['alias_exten'] != '' ){
 			var aext = sessionData.pbxinfo.voicemenus[menu_name]['alias_exten'] ;
 			v.new_action('delete', ASTGUI.contexts.VoiceMenuExtensions , 'exten', '', aext);
@@ -1676,9 +1637,12 @@
 		u.new_action('delcat', rgname , '', '');
 		if( sessionData.pbxinfo.ringgroups[rgname].extension ){
 
+
+
 			var f = sessionData.pbxinfo.ringgroups[rgname].extension ;
+
+
 			u.new_action( 'delete', ASTGUI.contexts.RingGroupExtensions , 'exten', '', f + ',1,Goto(' + rgname + '|s|1)' ) ;
-
 			if( sessionData.pbxinfo.ringgroups[rgname].hasOwnProperty('isOLDRG') && sessionData.pbxinfo.ringgroups[rgname].isOLDRG == true ){
 				u.new_action( 'delete', 'default' , 'exten', '', f + ',1,Goto(' + rgname + '|s|1)' ) ;
 			}




More information about the asterisk-gui-commits mailing list