pari: branch aadk r832 - in /branches/aadk/config: ./ scripts/

asterisk-gui-commits at lists.digium.com asterisk-gui-commits at lists.digium.com
Mon Apr 30 15:08:41 MST 2007


Author: pari
Date: Mon Apr 30 17:08:40 2007
New Revision: 832

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=832
Log:
Show actual Flash update Result based on /var/lib/asterisk/stic-http/flashresult

Modified:
    branches/aadk/config/flashupdate.html
    branches/aadk/config/scripts/astman.js
    branches/aadk/config/upload2.html

Modified: branches/aadk/config/flashupdate.html
URL: http://svn.digium.com/view/asterisk-gui/branches/aadk/config/flashupdate.html?view=diff&rev=832&r1=831&r2=832
==============================================================================
--- branches/aadk/config/flashupdate.html (original)
+++ branches/aadk/config/flashupdate.html Mon Apr 30 17:08:40 2007
@@ -26,22 +26,67 @@
 <script>
 var uImage_filename;
 var uimage_uploadpath = "/ramfs/var/lib/asterisk/sounds/uploads";
-
-function execute_applyuimage(){
+var flashresult_path = "/var/lib/asterisk/static-http/flashresult";
+
+function execute_applyuimage(a){
+	var b;
 	gui_feedback('Upgrading firmware','blue', 30000 );
+	_$('message_text').innerHTML ="&nbsp;&nbsp;Upgrading Firmware ... ";
 	_$('status_message').style.display = "";
 
-	parent.astmanEngine.run_tool(asterisk_guiapplyUimage + " " + asterisk_guiUploads_path_appliance + uImage_filename , onSuccess = function() {
-			_$('status_message').style.display = "none";
-			gui_feedback('Firmware upgraded','green', 5000 );
-			var f= "Finished upgrading firmware <BR> note: new firmware will be loaded on reboot";
-			gui_alert(f);
-			_$('fstatus').innerHTML = f; 
+	if(a=="http"){
+
+		b = asterisk_guiapplyUimage +" " + _$('httpurl').value ;
+
+	}else if(a == "file"){
+
+		b = asterisk_guiapplyUimage +" file " + asterisk_guiUploads_path_appliance + uImage_filename ;
+
+	}else if(a == "tftp"){
+
+		if( _$('tftp_filename').value.length ){
+			var fname = " " + _$('tftp_filename').value ;
+		}else{
+			var fname = "" ;
 		}
-	);
-}
-
-
+		b = asterisk_guiapplyUimage +" tftp " + _$('tftpurl').value + fname ;
+
+	}
+
+	parent.astmanEngine.run_tool( "rm -f " + flashresult_path , onSuccess = function(){
+		parent.astmanEngine.run_tool( b, onSuccess = function(){ check_flashupdateresult();} );
+	});
+}
+
+
+function check_flashupdateresult(){
+	var opt = {
+		method: 'get',
+		asynchronous: true,
+		onComplete: function (originalRequest){
+			if ( originalRequest.responseText.match("FAIL: ") ) {
+				_$('status_message').style.display = "none";
+				gui_feedback('Firmware upgraded FAILED','default', 5000 );
+				alert("Firmware Update FAILED" + "\n"+originalRequest.responseText);
+				return ;
+			}
+			if ( originalRequest.responseText.match("PASS: ") ) {
+				flashupdate_success();
+			}
+		}
+	};
+	opt.parameters="" ;
+	var tmp = new Ajax.Request("../flashresult", opt);
+}
+
+
+function flashupdate_success(){
+	_$('status_message').style.display = "none";
+	gui_feedback('Firmware upgraded','green', 5000 );
+	var f= "Finished upgrading firmware <BR> note: new firmware will be loaded on reboot";
+	gui_alert(f);
+	_$('fstatus').innerHTML = f; 
+}
 
 function localajaxinit(){
 	_$('updatetype_http').checked = true;
@@ -107,28 +152,13 @@
 		return false;
 	}
 
-        _$('status_message').style.display = "";
-	gui_feedback('Please do not reboot .. firmware update in progress','blue', 180000 ); // will be soon replaced by a countdown
-
 	if( h.checked ){ 
-		parent.astmanEngine.run_tool("flashupdate " + hu.value , onSuccess = function() {
-				gui_alert("Done .. You Can reboot");
-			}
-		);
+		execute_applyuimage("http");
 		return;
 	}
 
 	if( t.checked ){
-		if( _$('tftp_filename').value.length ){
-			var fname = " " + _$('tftp_filename').value ;
-		}else{
-			var fname = "" ;
-		}
-
-		parent.astmanEngine.run_tool("flashupdate tftp " + tu.value + fname, onSuccess = function() {
-				gui_alert("Done .. You Can reboot");
-			}
-		);
+		execute_applyuimage("tftp");
 		return;
 	}
 }

Modified: branches/aadk/config/scripts/astman.js
URL: http://svn.digium.com/view/asterisk-gui/branches/aadk/config/scripts/astman.js?view=diff&rev=832&r1=831&r2=832
==============================================================================
--- branches/aadk/config/scripts/astman.js (original)
+++ branches/aadk/config/scripts/astman.js Mon Apr 30 17:08:40 2007
@@ -36,7 +36,7 @@
 var asterisk_rawmanPath = "../../rawman" ;
 var asterisk_guiConfigFile = "guipreferences.conf"; // will be created in asterisk_configfolder, if the file does not exist 
 var asterisk_configfolder = "/etc/asterisk/";
-var asterisk_guiapplyUimage = "flashupdate file " ;
+var asterisk_guiapplyUimage = "flashupdate" ;
 var asterisk_guiUploads_path_appliance = "/var/lib/asterisk/sounds/uploads/" ;
 var asterisk_scriptsFolder = "/var/lib/asterisk/scripts/" ; /* Directory for gui scripts (graphs.sh, for example) */
 var asterisk_guiListFiles = "sh " + asterisk_scriptsFolder + "listfiles" ;

Modified: branches/aadk/config/upload2.html
URL: http://svn.digium.com/view/asterisk-gui/branches/aadk/config/upload2.html?view=diff&rev=832&r1=831&r2=832
==============================================================================
--- branches/aadk/config/upload2.html (original)
+++ branches/aadk/config/upload2.html Mon Apr 30 17:08:40 2007
@@ -27,7 +27,7 @@
         parent._$('uploadiframe').style.display="none";
         parent._$('status_message').style.display = "none";
         parent.gui_feedback("File Uploaded");
-	parent.execute_applyuimage();
+	parent.execute_applyuimage("file");
 }
 
 </script>



More information about the asterisk-gui-commits mailing list