pari: branch asterisknow r2027 - in /branches/asterisknow/config: ./ scripts/

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Wed Dec 19 22:44:37 CST 2007


Author: pari
Date: Wed Dec 19 22:44:37 2007
New Revision: 2027

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=2027
Log:
save and apply settings

Modified:
    branches/asterisknow/config/provisioning.html
    branches/asterisknow/config/scripts/astman.js

Modified: branches/asterisknow/config/provisioning.html
URL: http://svn.digium.com/view/asterisk-gui/branches/asterisknow/config/provisioning.html?view=diff&rev=2027&r1=2026&r2=2027
==============================================================================
--- branches/asterisknow/config/provisioning.html (original)
+++ branches/asterisknow/config/provisioning.html Wed Dec 19 22:44:37 2007
@@ -21,7 +21,55 @@
 <link href="stylesheets/rico.css" media="all" rel="Stylesheet" type="text/css" />
 <link href="stylesheets/schwing.css" media="all" rel="Stylesheet" type="text/css" />
 <script>
+var network_params = "/etc/asterisk/scripts/network.params";
 var file_storeSettings = 'provisioning.conf';
+// use provisioning.conf  to store and retrieve settings - 
+// note that provisioning.conf is not used by networking.sh or any other script
+// it is just an easy and convinient way for the gui to retrieve the last applied settings
+// for this reason it is possible that the settings in network.params file to be different from those in provisioning.conf 
+// if the user edits any of these files manually
+
+function apply_settings(){
+	// save back to provisioning.conf
+	// also generate a new network.params
+	// update serveriface in phoneprov.conf - touch this file on load (just to make sure it exists when writing)
+	// finally call networking.sh
+
+	var DWP = (_$('DHCP_WAN_PROVISION').checked)? 'on': 'off';
+	var TFTPL = _$('TFTP_LAN').value ;
+	var NTPAD = _$('NTP_ADDRESS').value;
+	var WI = _$('WAN_INTERFACE').value;
+
+	var uri = build_action( 'update', 0 , 'general' , 'DHCP_WAN_PROVISION' , DWP );
+	uri += build_action( 'update', 1 , 'general' , 'TFTP_LAN' , TFTPL );
+	uri += build_action( 'update', 2 , 'general' , 'NTP_ADDRESS' , NTPAD );
+	uri += build_action( 'update', 3 , 'general' , 'WAN_INTERFACE' , WI );
+
+	gui_feedback ( " Applying Settings !! " , 'default') ;
+	_$('thispage_settings').style.display = 'none';
+
+	makerequest('u', file_storeSettings , uri, function(t){ 
+		var uri2 = build_action( 'update', 0 , 'general' , 'serveriface' , WI );
+		makerequest('u', phoneprov.conf , uri2, function(t){ 
+			var cmd1 = "echo \"DHCP_WAN_PROVISION=" + DWP + " TFTP_LAN=" + TFTPL + " NTP_ADDRESS=" + NTPAD + " WAN_INTERFACE=" + WI + "\" > " + network_params;
+			parent.astmanEngine.run_tool( cmd1 , onSuccess = function(){ });
+		});
+	});
+
+	setTimeout( function(){
+			parent.astmanEngine.run_tool( asterisk_guiNetworkSettings, onSuccess = function() { 
+				gui_feedback ( " Done " , 'green' ) ;
+				window.location.reload();
+			});
+	} , 3000 );
+
+}
+
+
+
+
+
+
 
 
 function localajaxinit() {
@@ -29,43 +77,24 @@
 	setWindowTitle("Settings for auto provisioning Polycom phones");
 
 	ASTGUI.events.add( _$('DHCP_WAN_PROVISION') , 'change', function(){ 
-		if(_$('DHCP_WAN_PROVISION').checked){
-			_$('TFTP_LAN').disabled = false;
-			_$('NTP_ADDRESS').disabled = false;
-			_$('WAN_INTERFACE').disabled = false;
-		}else{
-			_$('TFTP_LAN').disabled = true;
-			_$('NTP_ADDRESS').disabled = true;
-			_$('WAN_INTERFACE').disabled = true;
-		}
+		var y = _$('DHCP_WAN_PROVISION').checked;
+		_$('TFTP_LAN').disabled = !y;
+		_$('NTP_ADDRESS').disabled = !y;
+		_$('WAN_INTERFACE').disabled = !y;
 	});
 
 	parent.loadscreen(this);
-	// use provisioning.conf  to store and retrieve settings - 
-	// note that provisioning.conf is not use by networking.sh or any other script
-	// it is just an easy and convinient way for the gui to later retrieve the last applied settings
-	// for this reason it is possible that the setting in network.params file to be different from those in provisioning.conf 
-	// if the user edits any of these file manually
-
-	// basically what we do in this page is 
-		// display the settings from provisioning.conf - is file not found create one with default values
-		// default values -
-		//	TFTP_LAN 		= http://0.0.0.0/phoneprov
-		//	DHCP_WAN_PROVISION	= off
-		//	NTP_ADDRESS		= 
-		//	WAN_INTERFACE		= eth0 ( also save this as serveriface in phoneprov.conf[general] )
-		//
-		//
-		// save back to provisioning.conf
-		// also generate a new network.params
-		// update serveriface in phoneprov.conf - touch this file on load (just to make sure it exists when writing)
-		// finally call networking.sh
-		//
+	// display the settings from provisioning.conf - is file not found create one with default values
+	// default values -
+	//	TFTP_LAN 		= http://0.0.0.0/phoneprov
+	//	DHCP_WAN_PROVISION	= off
+	//	NTP_ADDRESS		= 
+	//	WAN_INTERFACE		= eth0 ( also save this as serveriface in phoneprov.conf[general] )
 	
 	var parseProvisioningConf = function(n){
 		if( n == "ERROR: CONFIG FILE NOT FOUND"){// provisioning.conf not found
 			gui_feedback ( " Creating file " + file_storeSettings , 'default') ;
-			parent.astmanEngine.run_tool('touch /etc/asterisk/' + file_storeSettings ,onSuccess = function() { 
+			parent.astmanEngine.run_tool('echo "[general]" > /etc/asterisk/' + file_storeSettings ,onSuccess = function() { 
 				setTimeout( function(){window.location.reload();} , 1000);
 			});
 			return false ;
@@ -136,8 +165,8 @@
 			</TR>
 			<TR>	<TD colspan=2 align=center>
 					<BR>
-					<input type="button" value="Save" id="save">&nbsp;&nbsp;
-					<input type="button" value="Cancel" id="cancel">
+					<input type="button" value="Save" id="save" onclick='apply_settings();'>&nbsp;&nbsp;
+					<input type="button" value="Cancel" id="cancel" onclick='window.location.reload();'>
 				</TD>
 			</TR>
 		</table>

Modified: branches/asterisknow/config/scripts/astman.js
URL: http://svn.digium.com/view/asterisk-gui/branches/asterisknow/config/scripts/astman.js?view=diff&rev=2027&r1=2026&r2=2027
==============================================================================
--- branches/asterisknow/config/scripts/astman.js (original)
+++ branches/asterisknow/config/scripts/astman.js Wed Dec 19 22:44:37 2007
@@ -27,6 +27,7 @@
 var asterisk_guiversion = "$Revision$";
 var asterisk_guifbt = 3000; // Feedback msg time
 var asterisk_scriptsFolder = "/var/lib/asterisk/scripts/" ; /* Directory for gui scripts (listfiles, for example) */
+var asterisk_guiNetworkSettings = "sh " + asterisk_scriptsFolder + "networking.sh";
 var asterisk_ConfigBkpPath = "/var/lib/asterisk/gui_configbackups/" ;
 var asterisk_Sounds_path = "/var/lib/asterisk/sounds/";
 var asterisk_menusRecord_path = asterisk_Sounds_path + "record/";




More information about the asterisk-gui-commits mailing list