mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Disable Backups when no path
This commit is contained in:
parent
12b0f8326d
commit
ec6421b62c
@ -762,6 +762,8 @@ class Server:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def backup_server(self):
|
def backup_server(self):
|
||||||
|
if self.settings["backup_path"] is "":
|
||||||
|
return
|
||||||
backup_thread = threading.Thread(
|
backup_thread = threading.Thread(
|
||||||
target=self.a_backup_server, daemon=True, name=f"backup_{self.name}"
|
target=self.a_backup_server, daemon=True, name=f"backup_{self.name}"
|
||||||
)
|
)
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h4 class="page-title">
|
<h4 class="page-title">
|
||||||
{{ translate('serverDetails', 'serverDetails', data['lang']) }} - {{ data['server_stats']['server_id']['server_name'] }}
|
{{ translate('serverDetails', 'serverDetails', data['lang']) }} - {{
|
||||||
|
data['server_stats']['server_id']['server_name'] }}
|
||||||
<br />
|
<br />
|
||||||
<small>UUID: {{ data['server_stats']['server_id']['server_uuid'] }}</small>
|
<small>UUID: {{ data['server_stats']['server_id']['server_uuid'] }}</small>
|
||||||
</h4>
|
</h4>
|
||||||
@ -45,7 +46,10 @@
|
|||||||
|
|
||||||
{% if data['backing_up'] %}
|
{% if data['backing_up'] %}
|
||||||
<div class="progress" style="height: 15px;">
|
<div class="progress" style="height: 15px;">
|
||||||
<div class="progress-bar progress-bar-striped progress-bar-animated" id="backup_progress_bar" role="progressbar" style="width:{{data['backup_stats']['percent']}}%;" aria-valuenow="{{data['backup_stats']['percent']}}" aria-valuemin="0" aria-valuemax="100">{{ data['backup_stats']['percent'] }}%</div>
|
<div class="progress-bar progress-bar-striped progress-bar-animated" id="backup_progress_bar"
|
||||||
|
role="progressbar" style="width:{{data['backup_stats']['percent']}}%;"
|
||||||
|
aria-valuenow="{{data['backup_stats']['percent']}}" aria-valuemin="0" aria-valuemax="100">{{
|
||||||
|
data['backup_stats']['percent'] }}%</div>
|
||||||
</div>
|
</div>
|
||||||
<p>Backing up <span id="total_files">{{data['backup_stats']['total_files']}}</span> Files</p>
|
<p>Backing up <span id="total_files">{{data['backup_stats']['total_files']}}</span> Files</p>
|
||||||
{% end %}
|
{% end %}
|
||||||
@ -53,47 +57,63 @@
|
|||||||
<br>
|
<br>
|
||||||
{% if not data['backing_up'] %}
|
{% if not data['backing_up'] %}
|
||||||
<div id="backup_button" class="form-group">
|
<div id="backup_button" class="form-group">
|
||||||
<button class="btn btn-primary" id="backup_now_button">{{ translate('serverBackups', 'backupNow', data['lang']) }}</button>
|
<button class="btn btn-primary" id="backup_now_button">{{ translate('serverBackups', 'backupNow',
|
||||||
|
data['lang']) }}</button>
|
||||||
</div>
|
</div>
|
||||||
{% end %}
|
{% end %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{% if data['super_user'] %}
|
{% if data['super_user'] %}
|
||||||
<label for="server_name">{{ translate('serverBackups', 'storageLocation', data['lang']) }} <small class="text-muted ml-1"> - {{ translate('serverBackups', 'storageLocationDesc', data['lang']) }}</small> </label>
|
<label for="server_name">{{ translate('serverBackups', 'storageLocation', data['lang']) }} <small
|
||||||
<input type="text" class="form-control" name="backup_path" id="backup_path" value="{{ data['server_stats']['server_id']['backup_path'] }}" placeholder="{{ translate('serverBackups', 'storageLocation', data['lang']) }}" >
|
class="text-muted ml-1"> - {{ translate('serverBackups', 'storageLocationDesc', data['lang'])
|
||||||
|
}}</small> </label>
|
||||||
|
<input type="text" class="form-control" name="backup_path" id="backup_path"
|
||||||
|
value="{{ data['server_stats']['server_id']['backup_path'] }}"
|
||||||
|
placeholder="{{ translate('serverBackups', 'storageLocation', data['lang']) }}">
|
||||||
{% end %}
|
{% end %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="server_path">{{ translate('serverBackups', 'maxBackups', data['lang']) }} <small class="text-muted ml-1"> - {{ translate('serverBackups', 'maxBackupsDesc', data['lang']) }}</small> </label>
|
<label for="server_path">{{ translate('serverBackups', 'maxBackups', data['lang']) }} <small
|
||||||
<input type="text" class="form-control" name="max_backups" id="max_backups" value="{{ data['backup_config']['max_backups'] }}" placeholder="{{ translate('serverBackups', 'maxBackups', data['lang']) }}" >
|
class="text-muted ml-1"> - {{ translate('serverBackups', 'maxBackupsDesc', data['lang'])
|
||||||
|
}}</small> </label>
|
||||||
|
<input type="text" class="form-control" name="max_backups" id="max_backups"
|
||||||
|
value="{{ data['backup_config']['max_backups'] }}"
|
||||||
|
placeholder="{{ translate('serverBackups', 'maxBackups', data['lang']) }}">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="compress" class="form-check-label ml-4 mb-4"></label>
|
<label for="compress" class="form-check-label ml-4 mb-4"></label>
|
||||||
{% if data['backup_config']['compress'] %}
|
{% if data['backup_config']['compress'] %}
|
||||||
<input type="checkbox" class="form-check-input" id="compress" name="compress"
|
<input type="checkbox" class="form-check-input" id="compress" name="compress" checked=""
|
||||||
checked="" value="True">{{ translate('serverBackups', 'compress', data['lang']) }}
|
|
||||||
{% else %}
|
|
||||||
<input type="checkbox" class="form-check-input" id="compress" name="compress"
|
|
||||||
value="True">{{ translate('serverBackups', 'compress', data['lang']) }}
|
value="True">{{ translate('serverBackups', 'compress', data['lang']) }}
|
||||||
|
{% else %}
|
||||||
|
<input type="checkbox" class="form-check-input" id="compress" name="compress" value="True">{{
|
||||||
|
translate('serverBackups', 'compress', data['lang']) }}
|
||||||
{% end %}
|
{% end %}
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="server">{{ translate('serverBackups', 'exclusionsTitle', data['lang']) }} <small> - {{ translate('serverBackups', 'excludedChoose', data['lang']) }}</small></label>
|
<label for="server">{{ translate('serverBackups', 'exclusionsTitle', data['lang']) }} <small> - {{
|
||||||
|
translate('serverBackups', 'excludedChoose', data['lang']) }}</small></label>
|
||||||
<br>
|
<br>
|
||||||
<button class="btn btn-primary mr-2" id="root_files_button" data-server_path="{{ data['server_stats']['server_id']['path']}}" type="button">{{ translate('serverBackups', 'clickExclude', data['lang']) }}</button>
|
<button class="btn btn-primary mr-2" id="root_files_button"
|
||||||
|
data-server_path="{{ data['server_stats']['server_id']['path']}}" type="button">{{
|
||||||
|
translate('serverBackups', 'clickExclude', data['lang']) }}</button>
|
||||||
</div>
|
</div>
|
||||||
<input type="number" class="form-control" name="changed" id="changed" value="0" style="visibility: hidden;"></input>
|
<input type="number" class="form-control" name="changed" id="changed" value="0"
|
||||||
<div class="modal fade" id="dir_select" tabindex="-1" role="dialog" aria-labelledby="dir_select" aria-hidden="true">
|
style="visibility: hidden;"></input>
|
||||||
|
<div class="modal fade" id="dir_select" tabindex="-1" role="dialog" aria-labelledby="dir_select"
|
||||||
|
aria-hidden="true">
|
||||||
<div class="modal-dialog" role="document">
|
<div class="modal-dialog" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title" id="exampleModalLongTitle">{{ translate('serverBackups', 'excludedChoose', data['lang']) }}</h5>
|
<h5 class="modal-title" id="exampleModalLongTitle">{{ translate('serverBackups',
|
||||||
|
'excludedChoose', data['lang']) }}</h5>
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
<span aria-hidden="true">×</span>
|
<span aria-hidden="true">×</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="tree-ctx-item" id="main-tree-div" data-path="" style="overflow: scroll; max-height:75%;">
|
<div class="tree-ctx-item" id="main-tree-div" data-path=""
|
||||||
|
style="overflow: scroll; max-height:75%;">
|
||||||
<input type="checkbox" id="main-tree-input" name="root_path" value="" disabled>
|
<input type="checkbox" id="main-tree-input" name="root_path" value="" disabled>
|
||||||
<span id="main-tree" class="files-tree-title tree-caret-down root-dir" data-path="">
|
<span id="main-tree" class="files-tree-title tree-caret-down root-dir" data-path="">
|
||||||
<i class="far fa-folder"></i>
|
<i class="far fa-folder"></i>
|
||||||
@ -104,15 +124,19 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" id="modal-cancel" class="btn btn-secondary" data-dismiss="modal">{{ translate('serverBackups', 'cancel', data['lang']) }}</button>
|
<button type="button" id="modal-cancel" class="btn btn-secondary" data-dismiss="modal">{{
|
||||||
<button type="button" id="modal-okay" data-dismiss="modal" class="btn btn-primary">{{ translate('serverWizard', 'save', data['lang']) }}</button>
|
translate('serverBackups', 'cancel', data['lang']) }}</button>
|
||||||
|
<button type="button" id="modal-okay" data-dismiss="modal" class="btn btn-primary">{{
|
||||||
|
translate('serverWizard', 'save', data['lang']) }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="submit" class="btn btn-success mr-2">{{ translate('serverBackups', 'save', data['lang']) }}</button>
|
<button type="submit" class="btn btn-success mr-2">{{ translate('serverBackups', 'save', data['lang'])
|
||||||
<button type="reset" class="btn btn-light">{{ translate('serverBackups', 'cancel', data['lang']) }}</button>
|
}}</button>
|
||||||
|
<button type="reset" class="btn btn-light">{{ translate('serverBackups', 'cancel', data['lang'])
|
||||||
|
}}</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -132,13 +156,15 @@
|
|||||||
{% for backup in data['backup_list'] %}
|
{% for backup in data['backup_list'] %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="/panel/download_backup?file={{ backup['path'] }}&id={{ data['server_stats']['server_id']['server_id'] }}" class="btn btn-primary">
|
<a href="/panel/download_backup?file={{ backup['path'] }}&id={{ data['server_stats']['server_id']['server_id'] }}"
|
||||||
|
class="btn btn-primary">
|
||||||
<i class="fas fa-download" aria-hidden="true"></i>
|
<i class="fas fa-download" aria-hidden="true"></i>
|
||||||
{{ translate('serverBackups', 'download', data['lang']) }}
|
{{ translate('serverBackups', 'download', data['lang']) }}
|
||||||
</a>
|
</a>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<button data-file="{{ backup['path'] }}" data-backup_path="{{ data['backup_path'] }}" class="btn btn-danger del_button">
|
<button data-file="{{ backup['path'] }}" data-backup_path="{{ data['backup_path'] }}"
|
||||||
|
class="btn btn-danger del_button">
|
||||||
<i class="fas fa-trash" aria-hidden="true"></i>
|
<i class="fas fa-trash" aria-hidden="true"></i>
|
||||||
{{ translate('serverBackups', 'delete', data['lang']) }}
|
{{ translate('serverBackups', 'delete', data['lang']) }}
|
||||||
</button>
|
</button>
|
||||||
@ -162,7 +188,8 @@
|
|||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<div class="card-header header-sm d-flex justify-content-between align-items-center">
|
<div class="card-header header-sm d-flex justify-content-between align-items-center">
|
||||||
<h4 class="card-title"><i class="fas fa-server"></i> {{ translate('serverBackups', 'excludedBackups', data['lang']) }} <small class="text-muted ml-1"></small> </h4>
|
<h4 class="card-title"><i class="fas fa-server"></i> {{ translate('serverBackups', 'excludedBackups',
|
||||||
|
data['lang']) }} <small class="text-muted ml-1"></small> </h4>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
<ul>
|
<ul>
|
||||||
@ -195,13 +222,15 @@
|
|||||||
.tree-item,
|
.tree-item,
|
||||||
.files-tree-title {
|
.files-tree-title {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
user-select: none; /* Prevent text selection */
|
user-select: none;
|
||||||
|
/* Prevent text selection */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the caret/arrow with a unicode, and style it */
|
/* Create the caret/arrow with a unicode, and style it */
|
||||||
.tree-caret .fa-folder {
|
.tree-caret .fa-folder {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tree-caret .fa-folder-open {
|
.tree-caret .fa-folder-open {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@ -210,6 +239,7 @@
|
|||||||
.tree-caret-down .fa-folder {
|
.tree-caret-down .fa-folder {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tree-caret-down .fa-folder-open {
|
.tree-caret-down .fa-folder-open {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
@ -226,7 +256,7 @@
|
|||||||
{% block js %}
|
{% block js %}
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
const server_id = new URLSearchParams(document.location.search).get('id')
|
const server_id = new URLSearchParams(document.location.search).get('id')
|
||||||
|
|
||||||
|
|
||||||
//used to get cookies from browser - this is part of tornados xsrf protection - it's for extra security
|
//used to get cookies from browser - this is part of tornados xsrf protection - it's for extra security
|
||||||
@ -244,34 +274,34 @@ const server_id = new URLSearchParams(document.location.search).get('id')
|
|||||||
});
|
});
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
headers: {'X-XSRFToken': token},
|
headers: { 'X-XSRFToken': token },
|
||||||
url: '/ajax/backup_now?id='+server_id,
|
url: '/ajax/backup_now?id=' + server_id,
|
||||||
success: function(data) {
|
success: function (data) {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function del_backup(filename, id){
|
function del_backup(filename, id) {
|
||||||
var token = getCookie("_xsrf")
|
var token = getCookie("_xsrf")
|
||||||
|
|
||||||
data_to_send = { file_name :filename}
|
data_to_send = { file_name: filename }
|
||||||
|
|
||||||
console.log('Sending Command to delete backup: ' + filename)
|
console.log('Sending Command to delete backup: ' + filename)
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "DELETE",
|
type: "DELETE",
|
||||||
headers: {'X-XSRFToken': token},
|
headers: { 'X-XSRFToken': token },
|
||||||
url: '/ajax/del_backup?server_id='+id,
|
url: '/ajax/del_backup?server_id=' + id,
|
||||||
data: {
|
data: {
|
||||||
file_path: filename,
|
file_path: filename,
|
||||||
id: id
|
id: id
|
||||||
},
|
},
|
||||||
success: function(data) {
|
success: function (data) {
|
||||||
location.reload();
|
location.reload();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function restore_backup(filename, id){
|
function restore_backup(filename, id) {
|
||||||
var token = getCookie("_xsrf")
|
var token = getCookie("_xsrf")
|
||||||
var dialog = bootbox.dialog({
|
var dialog = bootbox.dialog({
|
||||||
message: '<i class="fa fa-spin fa-spinner"></i> {{ translate('serverBackups', 'restoring', data['lang']) }}',
|
message: '<i class="fa fa-spin fa-spinner"></i> {{ translate('serverBackups', 'restoring', data['lang']) }}',
|
||||||
@ -281,23 +311,41 @@ const server_id = new URLSearchParams(document.location.search).get('id')
|
|||||||
console.log('Sending Command to restore backup: ' + filename)
|
console.log('Sending Command to restore backup: ' + filename)
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
headers: {'X-XSRFToken': token},
|
headers: { 'X-XSRFToken': token },
|
||||||
url: '/ajax/restore_backup?server_id='+id,
|
url: '/ajax/restore_backup?server_id=' + id,
|
||||||
data: {
|
data: {
|
||||||
zip_file: filename,
|
zip_file: filename,
|
||||||
id: id
|
id: id
|
||||||
},
|
},
|
||||||
success: function(data) {
|
success: function (data) {
|
||||||
setTimeout(function(){
|
setTimeout(function () {
|
||||||
location.href=('/panel/dashboard');
|
location.href = ('/panel/dashboard');
|
||||||
}, 15000);
|
}, 15000);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$( document ).ready(function() {
|
$(document).ready(function () {
|
||||||
console.log( "ready!" );
|
try {
|
||||||
|
if ($('#backup_path').val() == '') {
|
||||||
|
console.log('true')
|
||||||
|
try {
|
||||||
|
document.getElementById('backup_now_button').disabled = true;
|
||||||
|
} catch {
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
document.getElementById('backup_now_button').disabled = false;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
try {
|
||||||
|
document.getElementById('backup_now_button').disabled = false;
|
||||||
|
} catch {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log("ready!");
|
||||||
$("#backup_config_box").hide();
|
$("#backup_config_box").hide();
|
||||||
$("#backup_save_note").hide();
|
$("#backup_save_note").hide();
|
||||||
|
|
||||||
@ -309,8 +357,8 @@ const server_id = new URLSearchParams(document.location.search).get('id')
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#backup_table').DataTable({
|
$('#backup_table').DataTable({
|
||||||
"order": [[ 1, "desc" ]],
|
"order": [[1, "desc"]],
|
||||||
"paging":true,
|
"paging": true,
|
||||||
"lengthChange": false,
|
"lengthChange": false,
|
||||||
"searching": true,
|
"searching": true,
|
||||||
"ordering": true,
|
"ordering": true,
|
||||||
@ -319,7 +367,7 @@ const server_id = new URLSearchParams(document.location.search).get('id')
|
|||||||
"responsive": true,
|
"responsive": true,
|
||||||
});
|
});
|
||||||
|
|
||||||
$( ".del_button" ).click(function() {
|
$(".del_button").click(function () {
|
||||||
var file_to_del = $(this).data("file");
|
var file_to_del = $(this).data("file");
|
||||||
var backup_path = $(this).data('backup_path');
|
var backup_path = $(this).data('backup_path');
|
||||||
|
|
||||||
@ -346,12 +394,12 @@ const server_id = new URLSearchParams(document.location.search).get('id')
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$( ".restore_button" ).click(function() {
|
$(".restore_button").click(function () {
|
||||||
var file_to_restore = $(this).data("file");
|
var file_to_restore = $(this).data("file");
|
||||||
|
|
||||||
|
|
||||||
bootbox.confirm({
|
bootbox.confirm({
|
||||||
title: "{{ translate('serverBackups', 'restore', data['lang']) }} "+file_to_restore,
|
title: "{{ translate('serverBackups', 'restore', data['lang']) }} " + file_to_restore,
|
||||||
message: "{{ translate('serverBackups', 'confirmRestore', data['lang']) }}",
|
message: "{{ translate('serverBackups', 'confirmRestore', data['lang']) }}",
|
||||||
buttons: {
|
buttons: {
|
||||||
cancel: {
|
cancel: {
|
||||||
@ -370,23 +418,23 @@ const server_id = new URLSearchParams(document.location.search).get('id')
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$( "#backup_now_button" ).click(function() {
|
$("#backup_now_button").click(function () {
|
||||||
backup_started();
|
backup_started();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById("modal-cancel").addEventListener("click", function(){
|
document.getElementById("modal-cancel").addEventListener("click", function () {
|
||||||
document.getElementById("root_files_button").classList.remove('clicked');
|
document.getElementById("root_files_button").classList.remove('clicked');
|
||||||
document.getElementById("main-tree-div").innerHTML = '<input type="checkbox" id="main-tree-input" name="root_path" value="" disabled><span id="main-tree" class="files-tree-title tree-caret-down root-dir" data-path=""><i class="far fa-folder"></i><i class="far fa-folder-open"></i>{{ translate("serverFiles", "files", data["lang"]) }}</span></input>'
|
document.getElementById("main-tree-div").innerHTML = '<input type="checkbox" id="main-tree-input" name="root_path" value="" disabled><span id="main-tree" class="files-tree-title tree-caret-down root-dir" data-path=""><i class="far fa-folder"></i><i class="far fa-folder-open"></i>{{ translate("serverFiles", "files", data["lang"]) }}</span></input>'
|
||||||
})
|
})
|
||||||
|
|
||||||
document.getElementById("root_files_button").addEventListener("click", function(){
|
document.getElementById("root_files_button").addEventListener("click", function () {
|
||||||
if($("#root_files_button").data('server_path') != ""){
|
if ($("#root_files_button").data('server_path') != "") {
|
||||||
if(document.getElementById('root_files_button').classList.contains('clicked')){
|
if (document.getElementById('root_files_button').classList.contains('clicked')) {
|
||||||
show_file_tree();
|
show_file_tree();
|
||||||
return;
|
return;
|
||||||
}else{
|
} else {
|
||||||
document.getElementById('root_files_button').classList.add('clicked');
|
document.getElementById('root_files_button').classList.add('clicked');
|
||||||
document.getElementById("changed").value = 1;
|
document.getElementById("changed").value = 1;
|
||||||
}
|
}
|
||||||
@ -400,16 +448,16 @@ document.getElementById("modal-cancel").addEventListener("click", function(){
|
|||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
headers: {'X-XSRFToken': token},
|
headers: { 'X-XSRFToken': token },
|
||||||
url: '/ajax/backup_select?id='+server_id+'&path='+path,
|
url: '/ajax/backup_select?id=' + server_id + '&path=' + path,
|
||||||
});
|
});
|
||||||
}else{
|
} else {
|
||||||
bootbox.alert("You must input a path before selecting this button");
|
bootbox.alert("You must input a path before selecting this button");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (webSocket) {
|
if (webSocket) {
|
||||||
webSocket.on('send_temp_path', function (data) {
|
webSocket.on('send_temp_path', function (data) {
|
||||||
setTimeout(function(){
|
setTimeout(function () {
|
||||||
var x = document.querySelector('.bootbox');
|
var x = document.querySelector('.bootbox');
|
||||||
if (x) {
|
if (x) {
|
||||||
x.remove()
|
x.remove()
|
||||||
@ -427,14 +475,14 @@ document.getElementById("modal-cancel").addEventListener("click", function(){
|
|||||||
}
|
}
|
||||||
if (webSocket) {
|
if (webSocket) {
|
||||||
webSocket.on('backup_status', function (backup) {
|
webSocket.on('backup_status', function (backup) {
|
||||||
if(backup.percent >= 100){
|
if (backup.percent >= 100) {
|
||||||
document.getElementById('backup_progress_bar').innerHTML = '100%';
|
document.getElementById('backup_progress_bar').innerHTML = '100%';
|
||||||
document.getElementById('backup_progress_bar').style.width = '100%';
|
document.getElementById('backup_progress_bar').style.width = '100%';
|
||||||
setTimeout(function(){
|
setTimeout(function () {
|
||||||
window.location.reload(1);
|
window.location.reload(1);
|
||||||
}, 5000);
|
}, 5000);
|
||||||
}else{
|
} else {
|
||||||
document.getElementById('backup_progress_bar').innerHTML = backup.percent +'%';
|
document.getElementById('backup_progress_bar').innerHTML = backup.percent + '%';
|
||||||
document.getElementById('backup_progress_bar').style.width = backup.percent + '%';
|
document.getElementById('backup_progress_bar').style.width = backup.percent + '%';
|
||||||
document.getElementById('total_files').innerHTML = backup.total_files;
|
document.getElementById('total_files').innerHTML = backup.total_files;
|
||||||
}
|
}
|
||||||
@ -451,9 +499,9 @@ document.getElementById("modal-cancel").addEventListener("click", function(){
|
|||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: '/ajax/get_backup_tree?id='+server_id+'&path='+path,
|
url: '/ajax/get_backup_tree?id=' + server_id + '&path=' + path,
|
||||||
dataType: 'text',
|
dataType: 'text',
|
||||||
success: function(data){
|
success: function (data) {
|
||||||
console.log("got response:");
|
console.log("got response:");
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
||||||
@ -461,10 +509,10 @@ document.getElementById("modal-cancel").addEventListener("click", function(){
|
|||||||
serverDir = dataArr.shift(); // Remove & return first element (server directory)
|
serverDir = dataArr.shift(); // Remove & return first element (server directory)
|
||||||
text = dataArr.join('\n');
|
text = dataArr.join('\n');
|
||||||
|
|
||||||
try{
|
try {
|
||||||
document.getElementById('main-tree-div').innerHTML += text;
|
document.getElementById('main-tree-div').innerHTML += text;
|
||||||
document.getElementById('main-tree').parentElement.classList.add("clicked");
|
document.getElementById('main-tree').parentElement.classList.add("clicked");
|
||||||
}catch{
|
} catch {
|
||||||
document.getElementById('files-tree').innerHTML = text;
|
document.getElementById('files-tree').innerHTML = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,56 +526,56 @@ document.getElementById("modal-cancel").addEventListener("click", function(){
|
|||||||
function getToggleMain(event) {
|
function getToggleMain(event) {
|
||||||
path = event.target.parentElement.getAttribute('data-path');
|
path = event.target.parentElement.getAttribute('data-path');
|
||||||
document.getElementById("files-tree").classList.toggle("d-block");
|
document.getElementById("files-tree").classList.toggle("d-block");
|
||||||
document.getElementById(path+"span").classList.toggle("tree-caret-down");
|
document.getElementById(path + "span").classList.toggle("tree-caret-down");
|
||||||
document.getElementById(path+"span").classList.toggle("tree-caret");
|
document.getElementById(path + "span").classList.toggle("tree-caret");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getDirView(event) {
|
function getDirView(event) {
|
||||||
path = event.target.parentElement.getAttribute('data-path');
|
path = event.target.parentElement.getAttribute('data-path');
|
||||||
|
|
||||||
if (document.getElementById(path).classList.contains('clicked')){
|
if (document.getElementById(path).classList.contains('clicked')) {
|
||||||
|
|
||||||
var toggler = document.getElementById(path+"span");
|
var toggler = document.getElementById(path + "span");
|
||||||
|
|
||||||
if (toggler.classList.contains('files-tree-title')){
|
if (toggler.classList.contains('files-tree-title')) {
|
||||||
document.getElementById(path+"ul").classList.toggle("d-block");
|
document.getElementById(path + "ul").classList.toggle("d-block");
|
||||||
document.getElementById(path+"span").classList.toggle("tree-caret-down");
|
document.getElementById(path + "span").classList.toggle("tree-caret-down");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}else{
|
} else {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: '/ajax/get_backup_dir?id='+server_id+'&path='+path,
|
url: '/ajax/get_backup_dir?id=' + server_id + '&path=' + path,
|
||||||
dataType: 'text',
|
dataType: 'text',
|
||||||
success: function(data){
|
success: function (data) {
|
||||||
console.log("got response:");
|
console.log("got response:");
|
||||||
|
|
||||||
dataArr = data.split('\n');
|
dataArr = data.split('\n');
|
||||||
serverDir = dataArr.shift(); // Remove & return first element (server directory)
|
serverDir = dataArr.shift(); // Remove & return first element (server directory)
|
||||||
text = dataArr.join('\n');
|
text = dataArr.join('\n');
|
||||||
|
|
||||||
try{
|
try {
|
||||||
document.getElementById(path+"span").classList.add('tree-caret-down');
|
document.getElementById(path + "span").classList.add('tree-caret-down');
|
||||||
document.getElementById(path).innerHTML += text;
|
document.getElementById(path).innerHTML += text;
|
||||||
document.getElementById(path).classList.add("clicked");
|
document.getElementById(path).classList.add("clicked");
|
||||||
}catch{
|
} catch {
|
||||||
console.log("Bad")
|
console.log("Bad")
|
||||||
}
|
}
|
||||||
|
|
||||||
var toggler = document.getElementById(path);
|
var toggler = document.getElementById(path);
|
||||||
|
|
||||||
if (toggler.classList.contains('files-tree-title')){
|
if (toggler.classList.contains('files-tree-title')) {
|
||||||
document.getElementById(path+"span").addEventListener("click", function caretListener() {
|
document.getElementById(path + "span").addEventListener("click", function caretListener() {
|
||||||
document.getElementById(path+"ul").classList.toggle("d-block");
|
document.getElementById(path + "ul").classList.toggle("d-block");
|
||||||
document.getElementById(path+"span").classList.toggle("tree-caret-down");
|
document.getElementById(path + "span").classList.toggle("tree-caret-down");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function show_file_tree(){
|
function show_file_tree() {
|
||||||
$("#dir_select").modal();
|
$("#dir_select").modal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user