Commit 857b13be authored by Efthymia Bika's avatar Efthymia Bika

Use spawn for timeview section

parent c6996c6e
...@@ -145,6 +145,12 @@ function remove_all(force) { ...@@ -145,6 +145,12 @@ function remove_all(force) {
} }
function load_timeview() {
$('#backup_details').hide();
$("#loader").show();
call_duplicity("timeview", get_backup_set(), false);
}
function call_duplicity(mode, backup_set, force) { function call_duplicity(mode, backup_set, force) {
var win_cmd = ""; var win_cmd = "";
if(process.platform == 'win32') { if(process.platform == 'win32') {
...@@ -192,6 +198,7 @@ function call_duplicity(mode, backup_set, force) { ...@@ -192,6 +198,7 @@ function call_duplicity(mode, backup_set, force) {
break; break;
case "status": case "status":
case "timeview":
args = ["collection-status", "swift://" + backup_set.container]; args = ["collection-status", "swift://" + backup_set.container];
break; break;
case "remove": case "remove":
...@@ -217,6 +224,7 @@ function call_duplicity(mode, backup_set, force) { ...@@ -217,6 +224,7 @@ function call_duplicity(mode, backup_set, force) {
// call duplicity // call duplicity
var wProcess = spawn(DUPLICITY_PATH, args); var wProcess = spawn(DUPLICITY_PATH, args);
var output_str = "";
function dup_call_out(data) { function dup_call_out(data) {
if(mode == "status") { if(mode == "status") {
toggle_msgs(data, "status_contents"); toggle_msgs(data, "status_contents");
...@@ -234,6 +242,8 @@ function call_duplicity(mode, backup_set, force) { ...@@ -234,6 +242,8 @@ function call_duplicity(mode, backup_set, force) {
$("#force-delete").hide(); $("#force-delete").hide();
} }
} }
} else if(mode == "timeview") {
output_str += data.toString();
} else { } else {
toggle_msgs(data, "msg"); toggle_msgs(data, "msg");
if(mode == "backup") { if(mode == "backup") {
...@@ -288,13 +298,21 @@ function call_duplicity(mode, backup_set, force) { ...@@ -288,13 +298,21 @@ function call_duplicity(mode, backup_set, force) {
} else { } else {
check_restore_errors(code); check_restore_errors(code);
} }
} else if(mode == "timeview") {
if(code == 0) {
parse_collection_status(output_str);
} else if(code == DUP_ERR_CODES.CONNECTION_FAILED) {
show_cloud_error();
}
} else { } else {
if(code == DUP_ERR_CODES.CONNECTION_FAILED) show_cloud_error(); if(code == DUP_ERR_CODES.CONNECTION_FAILED) show_cloud_error();
} }
} }
// bind listeners // bind listeners
wProcess.stdout.setEncoding("utf8");
wProcess.stdout.on('data', dup_call_out); wProcess.stdout.on('data', dup_call_out);
wProcess.stderr.setEncoding('utf8');
wProcess.stderr.on('data', dup_call_err); wProcess.stderr.on('data', dup_call_err);
wProcess.on('exit', dup_call_exit); wProcess.on('exit', dup_call_exit);
......
...@@ -170,41 +170,21 @@ function get_contents_by_date(value) { ...@@ -170,41 +170,21 @@ function get_contents_by_date(value) {
} }
} }
function load_timeview() { function parse_collection_status(data) {
$("#backup_details").hide();
$("#loader").show(); var datetime_reg = /\d{4}-\d{2}-\d{2}.\d{2}:\d{2}:\d{2}\s+\d+/g;
var dates = data.match(datetime_reg);
function puts(error, stdout, stderr) { var dates_list = "";
$("#loader").hide(); if(dates) {
toggle_error(error, stderr); dates = dates.sort();
if(!error) { $.each(dates, function(i, value) {
var datetime_reg = /\d{4}-\d{2}-\d{2}.\d{2}:\d{2}:\d{2}\s+\d+/g; value = value.substring(0, 19);
var dates = stdout.match(datetime_reg); var iso_time = value.replace('.', 'T');
var dates_list = ""; dates_list += "<a href='#' onclick='get_contents_by_date(\""
if(dates) { + iso_time + "\")' id='" + iso_time + "'>" +
dates = dates.sort(); value.replace('.', ' ') + "</a><br>";
$.each(dates, function(i, value) { });
value = value.substring(0, 19);
var iso_time = value.replace('.', 'T');
dates_list += "<a href='#' onclick='get_contents_by_date(\""
+ iso_time + "\")' id='" + iso_time + "'>" +
value.replace('.', ' ') + "</a><br>";
});
}
$("#time-dates").html(dates_list);
}
}
var cacert_arg = " --ssl-cacert-file " +
clouds[$("#cloud").val()].cert;
var dup_cmd = DUPLICITY_PATH + cacert_arg +
" collection-status swift://" + container;
if(process.platform == 'win32') {
var cmd = build_win_commands();
var args = ["-c", cmd + dup_cmd];
execFile(CYGWIN_BASH, args, puts);
} else {
set_envs();
exec(dup_cmd, {maxBuffer: 1000*1024} , puts);
} }
$("#time-dates").html(dates_list);
} }
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