Skip to content

Commit

Permalink
small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhbir-singh committed Aug 1, 2018
1 parent 6e3822f commit b8d58ec
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 30 deletions.
48 changes: 24 additions & 24 deletions app/assets/javascripts/rsnapshot_backups.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,21 @@ $(document).on('click', '.add-source-path', function(event) {
$(document).on('ajax:success', '#backup_destination_form_id', function(event, results) {
// show message temporary
var messages_span = this.querySelector("#dest_update_messages");
messages_span.innerHTML = results["message"];

if(results["success"]){
messages_span.innerHTML = "Succesfully Updated !!";
messages_span.style.color="green";
var fixed_span = this.parentElement.previousSibling;
var edit_text = this.querySelector("#destination_path");
fixed_span.innerHTML=results["set_path"];
edit_text.value=results["set_path"];
fixed_span.innerHTML = results["set_path"];
edit_text.value = results["set_path"];
}else{
messages_span.innerHTML = results["message"];
messages_span.style.color="#a44";
}

messages_span.style.display="inline-block";
messages_span.style.display = "inline-block";
messages_span.style.width = "100%";

var that=this;
setTimeout(function() {
messages_span.style.display="none";
Expand All @@ -123,11 +127,13 @@ function getBackupElement(path){

$(document).on('ajax:success', '#backup_source_form_id', function(event, results) {
var messages_span = this.querySelector("#source_update_messages");
messages_span.innerHTML = results["message"];

if(results["success"]){
messages_span.innerHTML = "Succesfully Updated !!";
messages_span.style.color="green";
}else{
messages_span.style.color="#a44";
messages_span.style.width="100%";
messages_span.innerHTML = results["message"];
}

messages_span.style.display="inline-block";
Expand Down Expand Up @@ -167,23 +173,11 @@ $(document).on('ajax:success', '#backup_source_form_id', function(event, results
spinner.style.display="none";
});

$(document).on('ajax:success', '#set_interval_form_id', function(event, results) {
var messages_span = this.querySelector("#interval_update_messages");
messages_span.innerHTML = "Automatic Backups Started !!";
messages_span.style.display="inline-block";

setTimeout(function(){
window.location.reload();
}, 4000);

var spinner = this.querySelector(".start_cron_spinner");
spinner.style.display="none";
});

$(document).on('ajax:success', '#stop_backup_form_id', function(event, results) {
var messages_span = this.querySelector("#stop_cron_messages");
messages_span.innerHTML = "Automatic Backups Stopped !!";
messages_span.style.display="inline-block";
var messages_span = this.querySelector("#stop_cron_messages");
messages_span.innerHTML = results["message"];
messages_span.style.display="inline-block";
messages_span.style.color="green";

setTimeout(function(){
window.location.reload();
Expand All @@ -209,7 +203,7 @@ $(document).ready(function() {
});

$(document).on('click', '#start_backups_button', function(event) {
if (confirm('This will start the automatic backups of the folders entered, with the periodicity selected above. Are you sure you want to continue?')) {
if (confirm('This will start the automatic backups of the folders entered, with the periodicity selected. Are you sure you want to continue?')) {
var current = event.target;
current.previousSibling.style.display = "";
var submit_btn=document.getElementById("start_backups");
Expand All @@ -235,6 +229,12 @@ $(document).on('ajax:success', '#start_backups_form_id', function(event, results
messages_span.innerHTML = results["message"]
messages_span.style.display="inline-block";

if(results["success"]){
messages_span.style.color="green";
}else{
messages_span.style.color="#a44";
}

setTimeout(function(){
if(results["success"]){
window.location.reload();
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/rsnapshot_backups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def update_backup_directory
dest_path = RsnapshotHelper.formatted_path(params[:destination_path])
if RsnapshotHelper.check_if_path_exists(dest_path)
RsnapshotHelper.update_conf("snapshot_root", dest_path)
render :json => {success: true, set_path: dest_path}
render :json => {success: true, set_path: dest_path, message: "Updated"}
else
render :json => {success: false, message: "Error: Path '#{dest_path}' do not exist."}
end
Expand All @@ -45,7 +45,7 @@ def update_backup_sources
RsnapshotHelper.add_conf("backup", [source, "./"])
end

render :json => {success: true, message: "Backup Paths Set Successfully.", sources: sources}
render :json => {success: true, message: "Updated", sources: sources}
else
render :json => {success: false, message: "Error: One or more paths do not exist."}
end
Expand All @@ -57,13 +57,13 @@ def start_backups
render :json => {success: false, message: "Error: Select atleast one 'Repeat Duration' to start backups"}
else
CronTabHelper.add_crons(intervals)
render :json => {success: true, message: "Backups Started Successfully !!"}
render :json => {success: true, message: "Backups Scheduled"}
end
end

def stop_backups
CronTabHelper.remove_all_crons
render :json => {success: true, message: "Backups Stopped Successfully !!"}
render :json => {success: true, message: "Backups Stopped"}
end

def update_interval
Expand All @@ -74,7 +74,7 @@ def update_interval
else
CronTabHelper.remove_cron(interval)
end
render :json => {success: true, message: "Successfully Updated !!",
render :json => {success: true, message: "Updated",
interval: interval, type: type}
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/rsnapshot_backups/settings.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ css:
:id => 'backup_destination_form_id' do |f|
= text_field_tag 'destination_path', "#{@dest_path[0][0]}", :placeholder => 'Select Destination Path', :class=>'form-control input-sm increase-length-40', :style=>'display: inline-block; margin-right: 8px; '
= spinner "dest_update_spinner"
input#backup_destination_submit type="submit" style="cursor:pointer"
input#backup_destination_submit type="submit" value="Save" style="cursor:pointer"
= link_to t('cancel'), '#', :class => 'close-backup-destination-form cancel-link cancel-btn-style btn-sm'
br
span#dest_update_messages.messages style="display: none"
Expand Down
2 changes: 2 additions & 0 deletions lib/rsnapshot_backups/rsnapshot_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def formatted_path(paths)
if paths.class == Array
new_paths = []
paths.each do |path|
next if path.size == 0
path = "/"+path if path[0]!="/"
path = path+"/" if path[-1]!="/"
new_paths << path
Expand All @@ -195,6 +196,7 @@ def formatted_path(paths)
def check_if_path_exists(paths)
if paths.class == Array
paths.each do |path|
return false if path.size == 0
return false unless File.exists?(path)
end
return true
Expand Down

0 comments on commit b8d58ec

Please sign in to comment.