Commit 59cf294e authored by Efthymia Bika's avatar Efthymia Bika

Save current settings as Template

parent 83c801b2
......@@ -29,7 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
if(disable) {
$("#save_button").attr("onclick", "");
} else {
$("#save_button").attr("onclick", "if(check_fields()) save_backup_set();");
$("#save_button").attr("onclick", "if(check_fields()) save_backup_set(false);");
}
}
}
......@@ -147,9 +147,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
templates = new Object();
}
}
$("#template_list").empty();
var ul = $("<ul></ul>")
.attr("class", "no-bullet template-list");
var li = $("<li>Load Template :</li>")
var li = $("<li>Load Template:</li>")
.attr("class", "template-list-title");
ul.append(li);
......@@ -386,7 +387,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</div>
<div class="small-6 columns">
<a id="save_button" class="button radius right small success"
onclick="if(check_fields()) save_backup_set();">
onclick="if(check_fields()) save_backup_set(false);">
<i class="fa fa-floppy-o"></i>&nbsp;Save</a>
</div>
<div class="small-3 columns">
......@@ -395,6 +396,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<i class="fa fa-cloud-download"></i>&nbsp;Restore</a>
</div>
</div>
<div class="clearfix">
<div class="small-8 columns">
</div>
<div class="small-4 columns">
<a id="save_template_button" class="button radius right small success"
onclick="if(check_backup_name() && check_cloud()) save_backup_set(true);">
<i class="fa fa-floppy-o"></i>&nbsp;Save as Template</a>
</div>
</div>
</form>
</div>
<div class="content" id="status"><pre id="status_contents"></pre></div>
......
......@@ -117,7 +117,7 @@ function show_alert_box(msg, alert_type, hide) {
}
}
function save_backup_set() {
function save_backup_set(is_template) {
var backup_name = $("#backup-name").val().replace(/^\s+|\s+$/gm,'');
var directory = $("#directory").html();
var cloud = $("#cloud").val();
......@@ -135,23 +135,39 @@ function save_backup_set() {
container = backup_set.container;
backup_set.exclude = exclude;
backup_set.include = include;
if(typeof backups[cloud + "/" + backup_name] != 'undefined') {
if(typeof backups[cloud + "/" + backup_name].first_backup != 'undefined') {
backup_set.first_backup = backups[cloud + "/" + backup_name].first_backup;
if(!is_template) {
if(typeof backups[cloud + "/" + backup_name] != 'undefined') {
if(typeof backups[cloud + "/" + backup_name].first_backup != 'undefined') {
backup_set.first_backup = backups[cloud + "/" + backup_name].first_backup;
}
if(typeof backups[cloud + "/" + backup_name].last_backup != 'undefined') {
backup_set.last_backup = backups[cloud + "/" + backup_name].last_backup;
}
if(typeof backups[cloud + "/" + backup_name].last_status != 'undefined') {
backup_set.last_status = backups[cloud + "/" + backup_name].last_status;
}
}
if(typeof backups[cloud + "/" + backup_name].last_backup != 'undefined') {
backup_set.last_backup = backups[cloud + "/" + backup_name].last_backup;
}
if(typeof backups[cloud + "/" + backup_name].last_status != 'undefined') {
backup_set.last_status = backups[cloud + "/" + backup_name].last_status;
}
}
backups[cloud + "/" + backup_name] = backup_set;
selected_backup = cloud + "/" + backup_name;
render_backup_sets("");
backups[cloud + "/" + backup_name] = backup_set;
selected_backup = cloud + "/" + backup_name;
render_backup_sets("");
show_alert_box("Successfully saved backup set", "success", true);
write_conf_file(BACKUP_CONF_FILE, backups);
show_alert_box("Successfully saved backup set", "success", true);
write_conf_file(BACKUP_CONF_FILE, backups);
} else {
var template = {};
template.name = backup_name;
template.local_dir = directory;
template.cloud = cloud;
template.container = container;
template.exclude = exclude;
template.include = include;
templates[cloud + "/" + backup_name] = template;
populate_template_list("");
show_alert_box("Successfully saved template", "success", true);
write_conf_file(TEMPLATES_FILE, templates);
}
}
function delete_backup(backup) {
......
......@@ -19,7 +19,7 @@ function backup(restore) {
$("#loader").show();
if($("#error-alert")) $("#error-alert").hide();
if(!restore) {
save_backup_set();
save_backup_set(false);
disable_form(true);
disable_actions(true);
disable_buttons(true);
......
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