Skip to content

Commit

Permalink
added implementation for individual interval update
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhbir-singh committed Jul 29, 2018
1 parent 1ff20b9 commit 5dd4aae
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 19 deletions.
43 changes: 31 additions & 12 deletions app/assets/javascripts/rsnapshot_backups.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,21 +209,25 @@ $(document).ready(function() {
});

$(document).on('click', '#start_backups_button', function(event) {
var current = event.target;
current.previousSibling.style.display = "";
var submit_btn=document.getElementById("start_backups");
submit_btn.click();
if (confirm('This will start the automatic backups of the folders entered, with the periodicity selected above. Are you sure you want to continue?')) {
var current = event.target;
current.previousSibling.style.display = "";
var submit_btn=document.getElementById("start_backups");
submit_btn.click();
}
});

$(document).on('click', '#stop_backups_button', function(event) {
var current=event.target;
current.previousSibling.style.display = "";
var form=document.getElementById("start_backups_form_id");
var action=form.action;
action=action.replace("start_backups","stop_backups");
form.action=action;
var submit_btn=document.getElementById("start_backups");
submit_btn.click();
if (confirm('This will stop the automatic backups currenly running. Are you sure you want to continue?')) {
var current=event.target;
current.previousSibling.style.display = "";
var form=document.getElementById("start_backups_form_id");
var action=form.action;
action=action.replace("start_backups","stop_backups");
form.action=action;
var submit_btn=document.getElementById("start_backups");
submit_btn.click();
}
});

$(document).on('ajax:success', '#start_backups_form_id', function(event, results) {
Expand All @@ -241,3 +245,18 @@ $(document).on('ajax:success', '#start_backups_form_id', function(event, results
var spinner = document.getElementsByClassName("start_backups_spinner")[0];
spinner.style.display="none";
});

$(document).on('change', '.repeat_duration', function(event, results) {
var stop_btn = document.getElementById("stop_backups_button");
if(stop_btn != null){
var type = event.target.checked;
var interval = event.target.value;
document.getElementById("interval_text").value=interval;
document.getElementById("update_type").value=type;
var submit_btn=document.getElementById("update_interval_btn");
submit_btn.click();

var spinner = event.target.nextSibling.nextSibling;
spinner.style.display="";
}
});
6 changes: 6 additions & 0 deletions app/controllers/rsnapshot_backups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,10 @@ def stop_backups
render :json => {success: true, message: "Backups Stopped Successfully !!"}
end

def update_interval
#params[:interval]
#params[:type]

end

end
31 changes: 25 additions & 6 deletions app/views/rsnapshot_backups/settings.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ css:
vertical-align: top;
}

.interval_spinner{
position: absolute;
margin-top: -8px;
margin-left: 65px;
}

.settings-stretcher
.share-manage.collapsed-div-style
fieldset
Expand Down Expand Up @@ -73,24 +79,37 @@ css:
:id => 'start_backups_form_id',\
:class => 'start_backups_form'
- if @current_intervals.blank? or @current_intervals.include?("daily")
input name="interval[]" value="daily" type="checkbox" checked="checked"
input.repeat_duration name="interval[]" value="daily" type="checkbox" checked="checked"
- else
input name="interval[]" value="daily" type="checkbox"
input.repeat_duration name="interval[]" value="daily" type="checkbox"
span.position-absolute.pl-2 Daily
= spinner "interval_spinner"
br
- if !@current_intervals.blank? and @current_intervals.include?("weekly")
input name="interval[]" value="weekly" type="checkbox" checked="checked"
input.repeat_duration name="interval[]" value="weekly" type="checkbox" checked="checked"
- else
input name="interval[]" value="weekly" type="checkbox"
input.repeat_duration name="interval[]" value="weekly" type="checkbox"
span.position-absolute.pl-2 Weekly
= spinner "interval_spinner"
br
- if !@current_intervals.blank? and @current_intervals.include?("monthly")
input name="interval[]" value="monthly" type="checkbox" checked="checked"
input.repeat_duration name="interval[]" value="monthly" type="checkbox" checked="checked"
- else
input name="interval[]" value="monthly" type="checkbox"
input.repeat_duration name="interval[]" value="monthly" type="checkbox"
span.position-absolute.pl-2 Monthly
= spinner "interval_spinner"

input.p-2.pl-3.pr-3.mt-2#start_backups type="submit" style="display: none;" value="Start Backups"

= form_tag rsnapshot_backups_engine.update_interval_path,\
:method => :post,\
:remote => true,\
:style => 'display: none;',\
:id => 'update_interval_form_id'
input#interval_text type="text" name="interval" value=""
input#update_type type="text" name="type" value=""
input#update_interval_btn type="submit" style="display: none;" value="Update Interval"

div style="margin-left:120px;"
= spinner "start_backups_spinner"
- if @cron_job_status
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
post 'set_interval' => 'rsnapshot_backups#update_interval'
post 'start_backups' => 'rsnapshot_backups#start_backups'
post 'stop_backups' => 'rsnapshot_backups#stop_backups'

post 'update_interval' => 'rsnapshot_backups#update_interval'
end

0 comments on commit 5dd4aae

Please sign in to comment.