Commit f8ebc34c authored by Efthymia Bika's avatar Efthymia Bika

Pop-up window to request passphrase when needed

parent 700dc143
......@@ -16,6 +16,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<script type="text/javascript">
g_tab_clicked = "";
g_value = "";
function disable_buttons(disable) {
$("#backup_button").attr("disabled", disable);
if(disable) {
......@@ -179,8 +182,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
} else {
$("#backup_detais_link").click(function(e) { load_backup(); });
$("#status_link").click(function(e) { load_status(); });
$("#timeview_link").click(function(e) { load_timeview(); });
$("#cleanup_link").click(function(e) { load_cleanup(); });
$("#timeview_link").click(function(e) {
if(check_empty_passphrase()) {
load_timeview();
} else {
g_tab_clicked = "load_timeview";
}
});
$("#cleanup_link").click(function(e) {
if(check_empty_passphrase()) {
load_cleanup();
} else {
g_tab_clicked = "load_cleanup";
}
});
}
}
......@@ -306,6 +321,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
get_quotas, handle_err);
}
}
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);
}
window[g_tab_clicked](g_value);
}
</script>
<div class="row">
......@@ -438,19 +463,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<label id="passphrase_label" for="passphrase"
class="right inline">Passphrase</label>
</div>
<div class="small-6 columns error"
<div class="small-5 columns error"
id="passphrase-error">
<input type="password" id="passphrase"
placeholder="Passphrase">
<small class="error"></small>
</div>
<div class="small-3 columns">
<label for="save_passphrase" class="left">
Save&nbsp;
<input id="save_passphrase"
type="checkbox" class="right">
<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">
......@@ -696,6 +723,38 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<div class="small-1 columns"></div>
<pre id="msg" class="small-11 columns hide"></pre>
</div>
<div id="passphrase-modal" class="reveal-modal" data-reveal
aria-labelledby="firstModalTitle" aria-hidden="true" role="dialog">
<div class="small-3 columns">
<label id="passphrase_m_label" for="passphrase_m"
class="right inline">Passphrase</label>
</div>
<div class="small-6 columns error"
id="passphrase-m-error">
<input type="password" id="passphrase_m"
placeholder="Passphrase">
<small class="error"></small>
</div>
<div class="small-8 columns">
<input id="save_passphrase_m" type="checkbox">
<label for="save_passphrase_m">
Save passphrase and never ask me again
</label>
</div>
<div class="clearfix">
<div class="small-8 columns">
</div>
<div class="small-4 columns">
<a id="submit_passphrase"
class="button radius right small success"
onclick="submit_passphrase()">
&nbsp;Submit
</a>
</div>
</div>
<a class="close-reveal-modal" aria-label="Close">&#215;</a>
</div>
<script type="text/javascript">
$(document).foundation();
</script>
......@@ -86,6 +86,7 @@ function hide_error_divs() {
$('#res-cloud-error small').hide();
$('#passphrase-error small').hide();
$('#res-passphrase-error small').hide();
$('#passphrase-m-error small').hide();
$('#exclude-error small').hide();
$('#include-error small').hide();
$('#res-file-error small').hide();
......@@ -250,3 +251,20 @@ function toggle_settings(hDiv, moreIcon, more_label, less_label) {
$("#" + moreIcon).addClass("fa fa-plus-square-o");
}
}
function show_passphrase_modal(error) {
if(error) {
$("#passphrase-m-error small").text(errors.passphrase_wrong);
$("#passphrase-m-error small").show();
}
$("#passphrase-modal").foundation("reveal", "open");
}
function check_empty_passphrase() {
var passphrase = $("#passphrase").val();
if(!passphrase) {
show_passphrase_modal(false);
return false;
}
return true;
}
......@@ -128,6 +128,8 @@ function load_status() {
function remove_all(force) {
$("#loader").show();
toggle_msgs(false, "msg", false);
g_value = force;
g_tab_clicked = "remove_all";
call_duplicity("remove", get_backup_set(), force);
}
......@@ -268,6 +270,7 @@ function spawn_dup_process(args, backup_set, backup_name, mode) {
var wProcess = spawn(ENV_CMD, args, {env: make_env()});
running_processes.push([wProcess, backup_name]);
var force = (args.indexOf("--force") > -1) ? true : false;
var output_str = "";
function dup_call_out(data) {
if(mode == "status") {
......@@ -351,6 +354,13 @@ function spawn_dup_process(args, backup_set, backup_name, mode) {
} else if(code == DUP_ERR_CODES.CONNECTION_FAILED) {
show_cloud_error();
}
} else if(mode == "remove") {
if(code == DUP_ERR_CODES.CONNECTION_FAILED) {
show_cloud_error();
} else if(code == DUP_ERR_CODES.GPG_FAILED) {
toggle_msgs("", "cleanup-msg", false);
show_passphrase_modal(true);
}
} else {
if(code == DUP_ERR_CODES.CONNECTION_FAILED) show_cloud_error();
}
......
......@@ -31,7 +31,6 @@ function escape_illegal_chars(s) {
}
function show_contents_by_date(error, stdout, stderr) {
toggle_msgs(stderr, "msg", false);
$("#time-contents").empty();
if(!error) {
......@@ -78,6 +77,13 @@ function show_contents_by_date(error, stdout, stderr) {
});
$("#time-contents").append(ul);
} else {
var bad_key = new RegExp("decryption failed: bad key").exec(stderr);
if(bad_key) {
show_passphrase_modal(true);
} else {
toggle_msgs(stderr, "msg", false);
}
}
$("#loader").hide();
}
......@@ -172,6 +178,8 @@ function get_contents_by_date(value) {
"swift://" + container, cert, BAAS_ARCHIVE_DIR,
GPG_DIR, log_file_g, backup_name, "get", value, time_path];
execFile(ENV_CMD, args, {env: make_env()}, show_contents_by_date);
g_tab_clicked = "get_contents_by_date";
g_value = value;
}
function parse_collection_status(data, log_file) {
......
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