Commit 85335b0e authored by Efthymia Bika's avatar Efthymia Bika

Remove passphrase field from backup form

Use passphrase pop-up instead, where needed
parent f8ebc34c
......@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
g_tab_clicked = "";
g_value = "";
g_passphrase = "";
function disable_buttons(disable) {
$("#backup_button").attr("disabled", disable);
......@@ -133,26 +134,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
return true;
}
function check_passphrase() {
var passphrase = $("#passphrase").val();
if(!passphrase) {
$('#passphrase-error small').text(errors.passphrase_empty);
$('#passphrase-error small').show();
return false;
} else {
$('#passphrase-error small').hide();
}
return true;
}
function disable_form(disable) {
$("#backup-name").prop("disabled", disable);
$("#choose-dir").prop("disabled", disable);
$("#cloud").prop("disabled", disable);
var save_pass = $("#save_passphrase").is(":checked");
if(save_pass) {
$("#passphrase").prop("disabled", disable);
}
var project = $("#project_div");
if(project) {
$("#project").prop("disabled", disable);
......@@ -202,13 +188,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
function check_fields() {
return(check_directory("directory")
&& check_cloud()
&& check_backup_name()
&& check_passphrase());
&& check_backup_name());
}
function go_to_restore() {
g_res_directory = RESTORE_DEFAULT_DIR;
g_passphrase = $("#passphrase").val();
g_passphrase = $("#passphrase_m").val();
g_res_file = "";
g_timestamp = "";
$("#restore-tab-link").trigger("click");
......@@ -323,14 +308,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
}
function submit_passphrase() {
$('#passphrase').val($('#passphrase_m').val());
$('#passphrase-modal').foundation('reveal', 'close');
if($("#save_passphrase_m").is(":checked")) {
$("#save_passphrase").attr("checked", true);
save_backup_set(false);
if(!$("#passphrase_m").val()) {
$("#passphrase-m-error small").text(errors.passphrase_empty);
$("#passphrase-m-error small").show();
} else {
$('#passphrase-modal').foundation('reveal', 'close');
if($("#save_passphrase_m").is(":checked")) {
if(selected_backup) {
backups[selected_backup].passphrase =
$("#passphrase_m").val();
}
save_backup_set(false);
}
window[g_tab_clicked](g_value);
}
window[g_tab_clicked](g_value);
}
</script>
<div class="row">
......@@ -458,27 +451,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
in your cloud
</div>
</div>
<div class="clearfix">
<div class="small-3 columns">
<label id="passphrase_label" for="passphrase"
class="right inline">Passphrase</label>
</div>
<div class="small-5 columns error"
id="passphrase-error">
<input type="password" id="passphrase"
placeholder="Passphrase">
<small class="error"></small>
</div>
<div class="small-2 columns">
<label for="save_passphrase" class="right inline">
Save
</label>
</div>
<div class="small-2 columns">
<input id="save_passphrase"
type="checkbox">
</div>
</div>
</fieldset>
<div class="clearfix pad-bottom">
<div class="small-3 columns">
......@@ -725,7 +697,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</div>
<div id="passphrase-modal" class="reveal-modal" data-reveal
aria-labelledby="firstModalTitle" aria-hidden="true" role="dialog">
<h5>Use a passphrase to encrypt/decrypt backups</h5>
<div>&nbsp;</div>
<div class="small-3 columns">
<label id="passphrase_m_label" for="passphrase_m"
class="right inline">Passphrase</label>
......@@ -753,7 +726,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</a>
</div>
</div>
<a class="close-reveal-modal" aria-label="Close">&#215;</a>
<a class="close-reveal-modal" aria-label="Close"
onclick="if($('#loader')) $('#loader').hide()">&#215;</a>
</div>
<script type="text/javascript">
$(document).foundation();
......
......@@ -84,7 +84,6 @@ function hide_error_divs() {
$('#cloud-error small').hide();
$('#project-error small').hide();
$('#res-cloud-error small').hide();
$('#passphrase-error small').hide();
$('#res-passphrase-error small').hide();
$('#passphrase-m-error small').hide();
$('#exclude-error small').hide();
......@@ -112,10 +111,8 @@ function load_backup(backup) {
$("#backup-name").val(backup.name);
$("#directory").html(backup.local_dir);
$("#cloud").val(backup.cloud);
$("#passphrase").val(backup.passphrase);
if(backup.passphrase != "") {
$("#save_passphrase").prop("checked", true);
}
$("#passphrase_m").val(backup.passphrase);
if(backup.first_backup) {
disable_form(true);
disable_actions(false);
......@@ -144,7 +141,7 @@ function load_backup(backup) {
$("#cloud").val('');
$("#project").val('');
}
$("#passphrase").val('');
$("#passphrase_m").val('');
$("#exclude").val('');
$("#include").val('');
$("#full").prop("checked", true);
......@@ -158,7 +155,8 @@ function load_backup(backup) {
function show_alert_box(msg, alert_type, hide) {
$("#" + alert_type + "-alert").show();
$("#" + alert_type + "-msg").html(msg + "<a href='#' class='close'>&times;</a>");
$("#" + alert_type + "-msg").html(msg +
"<a href='#' class='close'>&times;</a>");
if(hide) {
$("#" + alert_type + "-alert").delay(1200).fadeOut(400);
}
......@@ -172,8 +170,15 @@ function save_backup_set(is_template) {
var backup_name = $("#backup-name").val().replace(/^\s+|\s+$/gm,'');
var directory = $("#directory").html();
var cloud = $("#cloud").val();
var save_pass = $("#save_passphrase").is(":checked");
var passphrase = (save_pass) ? $("#passphrase").val() : "";
var passphrase = "";
if(typeof backups[cloud + "/" + backup_name] != 'undefined') {
// existing backup
passphrase = backups[cloud + "/" + backup_name].passphrase;
} else {
// new one
passphrase = $("#save_passphrase_m").is(":checked") ?
$("#passphrase_m").val() : "";
}
var exclude = $("#exclude").val();
var include = $("#include").val();
......@@ -261,7 +266,7 @@ function show_passphrase_modal(error) {
}
function check_empty_passphrase() {
var passphrase = $("#passphrase").val();
var passphrase = $("#passphrase_m").val();
if(!passphrase) {
show_passphrase_modal(false);
return false;
......
......@@ -30,12 +30,17 @@ function backup(restore) {
if($("#error-alert")) $("#error-alert").hide();
$("#msg").html("");
if(!restore) {
save_backup_set(false);
disable_form(true);
disable_actions(true);
disable_buttons(true);
if(check_empty_passphrase()) {
save_backup_set(false);
disable_form(true);
disable_actions(true);
disable_buttons(true);
call_duplicity("backup", get_backup_set(), false);
call_duplicity("backup", get_backup_set(), false);
} else {
g_tab_clicked = "backup";
g_value = false;
}
} else {
$('#res-passphrase-error small').hide();
call_duplicity("restore", null, false);
......@@ -43,7 +48,7 @@ function backup(restore) {
}
function get_env_values() {
var sel_pass = $('#passphrase').val() ? $('#passphrase') :
var sel_pass = $('#passphrase_m').val() ? $('#passphrase_m') :
$("#res-passphrase");
var passphrase = sel_pass.val();
......@@ -332,6 +337,9 @@ function spawn_dup_process(args, backup_set, backup_name, mode) {
backup_set.last_status = "Failed";
if(code == DUP_ERR_CODES.CONNECTION_FAILED) {
show_cloud_error();
} else if(code == DUP_ERR_CODES.GPG_FAILED) {
toggle_msgs("", "msg", false);
show_passphrase_modal(true);
} else {
show_alert_box("There was a problem uploading backup set",
"error", false);
......
......@@ -23,7 +23,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
function load_field_values() {
$("#res-backup-name").val(backups[selected_backup].name);
$("#res-cloud").val(backups[selected_backup].cloud);
$("#res-passphrase").val(backups[selected_backup].passphrase);
$("#res-passphrase").val(backups[selected_backup].passphrase ||
g_passphrase);
if(typeof g_res_directory != 'undefined') {
$("#res-directory").html(g_res_directory);
}
......
......@@ -187,3 +187,6 @@ body fieldset {
.wrapper p {
font-size: 0.8rem;
}
.reveal-modal {
max-width: 38.5rem;
}
......@@ -21,6 +21,7 @@ function go_to_restore_single(name) {
g_res_file = time_path + name;
g_timestamp = selected_date;
g_passphrase = $("#passphrase_m").val();
$("#restore-tab-link").trigger("click");
}
......
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