Commit c5da8e01 authored by Efthymia Bika's avatar Efthymia Bika

Add cleanup functionality

parent 9ebcb427
......@@ -202,7 +202,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
$("#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) { $("#backup_details").hide() });
$("#cleanup_link").click(function(e) { load_cleanup(); });
}
}
......@@ -220,6 +220,26 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
g_timestamp = "";
$("#restore-tab-link").trigger("click");
}
function load_cleanup() {
$("#backup_details").hide();
$("#cleanup-msg").html("");
$("#cleanup-msg").removeClass("panel");
$("#remove-all-button").show();
$("#force-delete").hide();
}
function check_remove_all() {
var remove_all_time = $("#remove-all").val();
if(!remove_all_time) {
$('#remove-all-error small').text(errors.remove_all_time_empty);
$('#remove-all-error small').show();
return false;
} else {
$('#remove-all-error small').hide();
}
return true;
}
</script>
<div class="row">
......@@ -435,8 +455,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<div class="content" id="cleanup">
<div class="clearfix">
<div class="small-3 columns">
<label id="remove-all-label" for="remove-all" class="right inline">
Remove older than&nbsp;<i class="fa fa-info-circle green-info"
<label id="remove-all-label" for="remove-all" class="right">
Remove backup sets<br>older than&nbsp;<i class="fa fa-info-circle green-info"
onclick="$('#remove-all-help').slideDown();"></i>
</label>
</div>
......@@ -461,12 +481,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
which indicates midnight on the day in question, relative to the current time zone settings.
</div>
</div>
<div class="row">
<div class="small-1 columns"></div>
<pre id="cleanup-msg" class="small-11 columns"></pre>
</div>
<div class="clearfix">
<div class="small-8 columns">&nbsp;</div>
<div class="small-4 columns">
<a id="remove-all-button" class="button radius right small"
onclick="remove_all()">
<i class="fa fa-cloud-download"></i>&nbsp;Remove All</a>
onclick="if(check_remove_all()) {
remove_all($('#remove-all').val(), false);
$(this).hide()}">
<i class="fa fa-trash-o"></i>&nbsp;Remove All</a>
</div>
<div class="small-4 columns hide" id="force-delete">
<a id="remove-all-button-force" class="button radius right small alert"
onclick="if(check_remove_all()) remove_all($('#remove-all').val(), true)">
<i class="fa fa-trash-o"></i>&nbsp;Force Delete</a>
</div>
</div>
</div>
......
......@@ -24,7 +24,8 @@ var errors = {
res_file_illegal: 'Invalid Entry. Provide a valid file name',
path_empty: 'Provide a path',
passphrase_empty: 'Provide a Passphrase',
passphrase_wrong: 'Wrong Passphrase'
passphrase_wrong: 'Wrong Passphrase',
remove_all_time_empty: 'Provide a valid timestamp'
};
......@@ -53,6 +54,7 @@ function hide_error_divs() {
$('#timestamp-error small').hide();
$('#time-head-error small').hide();
$('#remove-all-error small').hide();
$('#remove-inc-error small').hide();
}
function load_backup(backup) {
......
......@@ -283,3 +283,45 @@ function load_status() {
exec(dup_cmd, {maxBuffer: 1000*1024} , puts);
}
}
function remove_all(time, force) {
$("#loader").show();
function puts(error, stdout, stderr) {
$("#msg").html("");
$("#msg").removeClass("panel");
if(error) {
$("#cleanup-msg").html(stderr);
$("#cleanup-msg").addClass("panel");
$("#force-delete").hide();
} else {
$("#cleanup-msg").addClass("panel");
$("#cleanup-msg").html(stdout);
if(!force) {
$("#force-delete").show();
} else {
$("#force-delete").hide();
}
var nothing_to_del = new RegExp("No old backup sets found, nothing deleted").exec(stdout);
if(nothing_to_del) {
$("#force-delete").hide();
}
}
$("#loader").hide();
}
var force_arg = "";
if(force) {
force_arg = " --force ";
}
var dup_cmd = DUPLICITY_PATH + " remove-older-than " +
time + force_arg + " swift://" + container;
if(process.platform == 'win32') {
var cmd = build_win_commands();
exec(CYGWIN_BASH + " -c '" + cmd + dup_cmd + "'", puts);
} else {
set_envs();
exec(dup_cmd, {maxBuffer: 1000*1024} , puts);
}
}
......@@ -84,7 +84,7 @@ body .tabs {
body legend, .template-list-title {
color: gray;
}
#msg {
#msg, #cleanup-msg {
word-break: break-word;
margin-right: 15px;
}
......
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