Commit 3af6f9e1 authored by Efthymia Bika's avatar Efthymia Bika

Add error/success alerts when backing up

parent d69bd737
......@@ -244,12 +244,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</ul>
<div class="tabs-content">
<div class="content" id="backup_details">
<div id="save-alert" class="hide">
<div data-alert class="alert-box success radius">
Successfully saved backup set.
<a href="#" class="close">&times;</a>
</div>
</div>
<form>
<fieldset>
<legend>From</legend>
......@@ -375,6 +369,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</div>
</fieldset>
<div class="clearfix">
<div id="success-alert" class="hide">
<div data-alert class="alert-box success radius"
id="success-msg">
</div>
</div>
<div id="error-alert" class="hide">
<div data-alert class="alert-box alert radius"
id="error-msg">
</div>
</div>
<div class="small-6 columns">
<a id="backup_button" class="button radius left small"
onclick="if(check_fields()) backup(false);">
......
......@@ -103,6 +103,20 @@ function load_backup(backup) {
$("#backup_details").show();
}
function show_alert_box(msg, alert_type, hide) {
$("#" + alert_type + "-alert").show();
$("#" + alert_type + "-msg").html(msg + "<a href='#' class='close'>&times;</a>");
if(hide) {
$("#" + alert_type + "-alert").delay(800).fadeOut(400);
}
if(alert_type == "error") {
$("html,body").animate({
scrollTop: $("#msg").offset().top},
"slow"
);
}
}
function save_backup_set() {
var backup_name = $("#backup-name").val().replace(/^\s+|\s+$/gm,'');
var directory = $("#directory").html();
......@@ -135,9 +149,8 @@ function save_backup_set() {
backups[cloud + "/" + backup_name] = backup_set;
render_backup_sets("");
show_alert_box("Successfully saved backup set", "success", true);
write_conf_file(BACKUP_CONF_FILE, backups);
$("#save-alert").show();
setTimeout( function() {$("#save-alert").fadeOut()}, 1000);
}
function delete_backup(backup) {
......
......@@ -18,6 +18,7 @@ var dup_verbosity = " -v8 ";
function backup(restore) {
$("#loader").show();
if(!restore) {
if($("#error-alert")) $("#error-alert").hide();
save_backup_set();
disable_form(true);
disable_actions(true);
......@@ -170,6 +171,7 @@ function run_duplicity(restore, force) {
$("#msg").addClass("panel");
$("#loader").hide();
if(!restore) {
show_alert_box("There was a problem uploading backup set", "error", false);
disable_form(false);
disable_actions(true);
backups[cloud + "/" + container_name].last_status = "Failed";
......@@ -209,6 +211,7 @@ function run_duplicity(restore, force) {
$("#msg").html("");
$("#msg").removeClass("panel");
if(!restore) {
show_alert_box("Successfully completed", "success", true);
backups[cloud + "/" + container_name].last_status = "Completed";
backups[cloud + "/" + container_name].last_backup = new Date();
if(typeof backups[cloud + "/" + container_name].first_backup == 'undefined') {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment