pari: trunk r139 - /trunk/config/backup.html

asterisk-gui-commits at lists.digium.com asterisk-gui-commits at lists.digium.com
Thu Nov 30 20:58:33 MST 2006


Author: pari
Date: Thu Nov 30 21:58:33 2006
New Revision: 139

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=139
Log:
made the 'Download backup Process' simple and easy

Modified:
    trunk/config/backup.html

Modified: trunk/config/backup.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/backup.html?view=diff&rev=139&r1=138&r2=139
==============================================================================
--- trunk/config/backup.html (original)
+++ trunk/config/backup.html Thu Nov 30 21:58:33 2006
@@ -24,129 +24,74 @@
 <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 backups_callbacks = new Object;
 var bkp_path = "/var/lib/asterisk/static-http/config/bkps/";
-var bkpfiles_name = "gui_bkpfiles.conf" ;
+var bkpfile ;
 
-function save_bkpfilename( newbkp_name ){
-		var opt2 = {
-			method: 'get',
-			asynchronous: true,
-			onSuccess: function(t) {	 
-					 addrow_totable(newbkp_name);
-			},
-			onFailure: function(t) {
-				alert("Config Error: " + t.status + ": " + t.statusText);
-			}
-		};
-		var uri = build_action('newcat', 0, newbkp_name,"", ""); 
-		opt2.parameters ="action=updateconfig&reload=yes&srcfilename=" + encodeURIComponent(bkpfiles_name) + "&dstfilename=" + encodeURIComponent(bkpfiles_name) + uri;
-		var tmp2 = new Ajax.Request("../../rawman", opt2);
+function localajaxinit() {
+	parent.loadscreen(this);
+	$('status_message').style.top  = 	100;
+	$('status_message').style.left  = 	100;
 }
 
 
-function backup_new(){
-		if( $('newbkp_name').value == "" ){
-			alert("Please Enter a name for the backup");
-			$('newbkp_name').focus();
-			return true;
-		}
+function addzero(x){
+if ( x < 10)
+	return "0" + x;
+return x;
+}
+
+function removebkpfile(){
+	$('status_message').style.display='none';
+	//remove bkpfile on server 
+			var opt = {
+				method: 'get',
+				asynchronous: true,
+				onSuccess: function(t) { 
+					// file deleted on server
+				},
+				onFailure: function(t) {
+					// file not deleted on server
+				}
+			};
+			opt.parameters="action=originate&channel=" + encodeURIComponent("Local/removefile@" + asterisk_guitools) + "&Variable=var1%3d"+ encodeURIComponent( bkp_path+ bkpfile)+"&application=noop&timeout=60000";
+			var tmp = new Ajax.Request("../../rawman", opt);	
+}
+
+
+function showremovebkpfile(){
+	$('message_text').innerHTML =  "<A href=\"#\" onclick=\"removebkpfile()\">I have downloaded the file</A><BR><BR>" + "<A href=\"./bkps/"+ bkpfile  +"\" onclick=\"showremovebkpfile()\">ReDownload</A>";
+}
+
+
+
+function download_bkp(){
+		$('message_text').innerHTML = "Please wait while the system <BR> Generates a Backup ... ";
+		var today=new Date()
+		var year = today.getFullYear();
+		var month = addzero(today.getMonth() + 1);
+		var day = addzero(today.getDate());
+		var hour =addzero(today.getHours());
+		var minute =addzero(today.getMinutes());
+		var seconds =addzero(today.getSeconds());
+		bkpfile =  "conf_" + year + month + day + hour  + minute +seconds  +".tar";
+
 		$('status_message').style.display="block";
 		var opt = {
 				method: 'get',
 				asynchronous: true,
 				onSuccess: function(t) { 
-							setTimeout("$('status_message').style.display='none'",sc_displaytime);
-							$('status').innerHTML = " <I> Configuration Saved ! </I>";
-							save_bkpfilename( $('newbkp_name').value );
-							$("newbkp_name").value="";
+							$('status').innerHTML = " <I> Finished generating Backup ! </I>";
+							$('message_text').innerHTML = "<A href=\"./bkps/"+ bkpfile  +"\" onclick=\"showremovebkpfile()\">Click Here to Download</A>";
 				},
 				onFailure: function(t) {
 					$('status_message').style.display='none';
 					alert("Config Error: " + t.status + ": " + t.statusText);
 				}
 		};
-		opt.parameters="action=originate&channel=" + encodeURIComponent("Local/takebackup@"+asterisk_guitools) + "&Variable=var1%3d"+ encodeURIComponent( bkp_path + $('newbkp_name').value +".tar" )+"&application=noop&timeout=60000";
+		opt.parameters="action=originate&channel=" + encodeURIComponent("Local/takebackup@"+asterisk_guitools) + "&Variable=var1%3d"+ encodeURIComponent( bkp_path + bkpfile)+"&application=noop&timeout=60000";
 		var tmp = new Ajax.Request("../../rawman", opt);
-}
 
 
-
-
-
-function delete_bkps(filename){
-	var ans = confirm("Delete Backup file "+ filename +" ?");
-	if (ans){
-			var opt = {
-				method: 'get',
-				asynchronous: true,
-				onSuccess: function(t) { 
-						$('status').innerHTML = " <I> Delete Request Successfull ! </I>";
-						// remove file name from stored config file
-						var opt2 = {
-							method: 'get',
-							asynchronous: true,
-							onSuccess: function() { 
-								// Remove this TR
-								var delete_id = "delete_" + filename;
-								var tableRow = $(delete_id).parentNode.parentNode; //gets TR object
-								for( var i=0; i <  $('table_bkpfileslist'). rows.length; i++){
-									if  ( $('table_bkpfileslist'). rows[i].id == tableRow.id){
-										 $('table_bkpfileslist').deleteRow(i);
-										 break;
-									}
-								}
-							},
-							onFailure: function(t) {
-								$('status_message').style.display='none';
-								alert("Config Error: " + t.status + ": " + t.statusText);
-							}
-						};	
-						var uri = build_action('delcat', 0, filename,"", ""); 
-						opt2.parameters = "action=updateconfig&srcfilename=" + encodeURIComponent(bkpfiles_name) + "&dstfilename=" + encodeURIComponent(bkpfiles_name) + uri;
-						var tmp2 = new Ajax.Request('../../rawman', opt2);
-				},
-				onFailure: function(t) {
-					alert("Config Error: " + t.status + ": " + t.statusText);
-				}
-			};
-			opt.parameters="action=originate&channel=" + encodeURIComponent("Local/removefile@" + asterisk_guitools) + "&Variable=var1%3d"+ encodeURIComponent( bkp_path + filename+".tar" )+"&application=noop&timeout=60000";
-			var tmp = new Ajax.Request("../../rawman", opt);
-	}
-	else{
-		//
-	}
-}
-
-
-
-
-function addrow_totable(filename){
-		var newRow = $('table_bkpfileslist').insertRow(-1);
-		newRow.id = "row" + filename; 
-
-		var newCell1 = newRow.insertCell(0);
-		newCell1 .innerHTML = "<A href=\' ./bkps/" + filename +".tar\'>" + filename + "</A>" ;
-
-		var newCell2 = newRow.insertCell(1);
-		newCell2 .innerHTML = "<input type=\"button\" id='delete_" + filename + "' onclick='delete_bkps(\""+ filename + "\")'  value=\"Delete\">" ;
-}
-
-
-backups_callbacks.format = function(t) {
-		return t.name;
-}
-
-backups_callbacks.loaded= function() {
-	for (var i=0; i < $('backups_list').length; i++){
-		addrow_totable($('backups_list').options[i].value);
-	}
-}
-
-function localajaxinit() {
-	parent.astmanEngine.config2list(bkpfiles_name, $('backups_list'), new Array, backups_callbacks);
-	parent.loadscreen(this);
-	$('message_text').innerHTML = "Please wait while the system <BR> Generates a Backup ... ";
 }
 
 </script>
@@ -157,32 +102,18 @@
 </div>
 <div class="mainscreenContentBox" id="userscontent">
 <table class="mainscreenTable" align="center">
-	<tr><td valign="top" align="center">
-			<BR>
-			<table cellpadding=3 cellspacing=0 border=0 width=400 style="border-width: 1px 1px 1px 1px; border-style: solid; border-color: #7E7E7E; ">
-				<tr><td colspan=2 align=center class="field_text"><B>List of Backup Files</B><select id='backups_list' style="display:none"></select></td></tr>
-				<tr bgcolor="#FFFFFF"><td><font color="#2D4E93" width="300">File Name</font></td><td  color="#2D4E93" ></td></tr>
-				<tr><td colspan=2>
-						<div style="height:125px;width=400px; overflow :auto;">
-						<table id="table_bkpfileslist"  cellpadding=3 cellspacing=0 border=0 width="100%"  class="field_text"></table>
-						</div>
-						</td>
-				</tr>
-			</table>
-
-
-
+	<tr>	<td align=center height=30><BR><BR><div id="status"></div></td></tr>
+	<tr>
+		<td valign="top" align="center">
 			<BR><BR>
-			<table cellpadding=2 cellspacing=2 border=0>
-				<tr>	<td colspan=2 height=40 valign=middle align=center class="field_text"><B>Create New Backup</B> </td>	</tr>
-				<tr><td class="field_text">File Name:</td>
-						<td><input id='newbkp_name' size=16 class="input8"></td>
-				</tr>
-				<tr>	<td colspan=2 align=center height=10></td></tr>
-				<tr>	<td colspan=2 align=center><input type="button" id='getbackup' Value="Backup" onclick="backup_new()" class="buttonbold"></td></tr>
-				<tr>	<td colspan=2 align=center height=10><div id="status"></div></td></tr>
-			</table>
-	</td>
+			<A href="#" onclick="download_bkp()"><font size="+1">Download a Configuration backup</font></A>	
+		</td>
+	</tr>
+	<tr>
+		<td valign="top" align="center">
+			<BR><BR>
+			Note: Restoring a configuration backup will be added soon to this section !
+		</td>
 	</tr>
 </table>
 </div>



More information about the asterisk-gui-commits mailing list