Commit b484e4be authored by Efthymia Bika's avatar Efthymia Bika

Provide more meaningful message when token expires

parent a0f5def1
......@@ -391,16 +391,6 @@ 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);">
......@@ -496,6 +486,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</div>
</div>
</div>
<div class="clearfix">
<div class="small-2 columns"></div>
<div class="small-10 columns">
<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>
</div>
<div id="loader" class="hide text-center">
<i class="fa fa-spinner fa-pulse fa-2x gray-spin"></i>
</div>
......
......@@ -54,6 +54,25 @@ function build_win_commands() {
"export SWIFT_PREAUTHURL=" + env_values[1] + ";" +
"export SWIFT_PREAUTHTOKEN=" + env_values[2] + ";";
}
function parse_cloud_error(restore, stderr, backup) {
var cloud_error =
new RegExp("AttributeError 'NoneType' object has no attribute 'find'")
.exec(stderr);
if(cloud_error) {
toggle_error(false, "");
show_alert_box("A problem occured.<br>" +
"Please check your <a href='#'" +
" onclick=$('#cloud-settings-link').trigger('click')>cloud settings</a>",
"error", false);
if(!restore && backup) {
backups[backup].last_status = "Failed";
write_conf_file(BACKUP_CONF_FILE, backups);
disable_buttons(false);
}
return true;
}
return false;
}
function run_duplicity(restore, force) {
......@@ -165,39 +184,43 @@ function run_duplicity(restore, force) {
toggle_error(error, stderr);
if(error) {
$("#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";
if(parse_cloud_error(restore, stderr, cloud + "/" + container_name)) {
return;
} else {
var exist_error =
new RegExp("Restore destination directory.* already exists.\nWill not overwrite.")
.exec(stderr);
var gpg_error = new RegExp("GPGError: GPG Failed").exec(stderr);
if(exist_error) {
toggle_error(false, "");
$("#modal-confirm").foundation("reveal", "open");
var i = 0;
$("#modal-confirm").on('close.fndtn.reveal', function(e) {
if(e.namespace !== "fndtn.reveal") return;
i++;
$(this).click(function(event) {
// event is fired more than once so have to check
if(event.target.id == "modal-accept" && i == 1) {
$("#loader").show();
run_duplicity(true, true);
}
});
});
} else if(gpg_error) {
toggle_error(false, "");
$('#res-passphrase-error small').text(errors.passphrase_wrong);
$('#res-passphrase-error small').show();
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";
} else {
$('#res-passphrase-error small').hide();
show_alert_box("A problem occured during restoring", "error", false);
toggle_error(true, stderr);
var exist_error =
new RegExp("Restore destination directory.* already exists.\nWill not overwrite.")
.exec(stderr);
var gpg_error = new RegExp("GPGError: GPG Failed").exec(stderr);
if(exist_error) {
toggle_error(false, "");
$("#modal-confirm").foundation("reveal", "open");
var i = 0;
$("#modal-confirm").on('close.fndtn.reveal', function(e) {
if(e.namespace !== "fndtn.reveal") return;
i++;
$(this).click(function(event) {
// event is fired more than once so have to check
if(event.target.id == "modal-accept" && i == 1) {
$("#loader").show();
run_duplicity(true, true);
}
});
});
} else if(gpg_error) {
toggle_error(false, "");
$('#res-passphrase-error small').text(errors.passphrase_wrong);
$('#res-passphrase-error small').show();
} else {
$('#res-passphrase-error small').hide();
show_alert_box("A problem occured during restoring", "error", false);
toggle_error(true, stderr);
}
}
}
} else {
......@@ -259,6 +282,8 @@ function load_status() {
toggle_error(error, stderr);
if(!error) {
$("#status_contents").html(stdout);
} else {
parse_cloud_error(false, stderr, false);
}
$("#loader").hide();
}
......@@ -278,9 +303,11 @@ function remove_all(time, force) {
function puts(error, stdout, stderr) {
toggle_error(false, "");
if(error) {
$("#cleanup-msg").html(stderr);
$("#cleanup-msg").addClass("panel");
$("#force-delete").hide();
if(!parse_cloud_error(false, stderr, false)) {
$("#cleanup-msg").html(stderr);
$("#cleanup-msg").addClass("panel");
$("#force-delete").hide();
}
} else {
$("#cleanup-msg").addClass("panel");
$("#cleanup-msg").html(stdout);
......
......@@ -163,6 +163,7 @@ function load_timeview() {
$("#loader").show();
function puts(error, stdout, stderr) {
$("#loader").hide();
toggle_error(error, stderr);
if(!error) {
var datetime_reg = /\d{4}-\d{2}-\d{2}.\d{2}:\d{2}:\d{2}\s+\d+/g;
......@@ -178,8 +179,9 @@ function load_timeview() {
});
}
$("#time-dates").html(dates_list);
} else {
parse_cloud_error(false, stderr, false);
}
$("#loader").hide();
}
var dup_cmd = DUPLICITY_PATH + " collection-status swift://" + container;
if(process.platform == 'win32') {
......
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