2021-03-22 04:02:18 +00:00
|
|
|
{% extends ../base.html %}
|
|
|
|
|
|
|
|
{% block meta %}
|
|
|
|
{% end %}
|
|
|
|
|
2021-09-29 02:25:47 +00:00
|
|
|
{% block title %}Crafty Controller - {{ translate('serverDetails', 'serverDetails', data['lang']) }}{% end %}
|
2021-03-22 04:02:18 +00:00
|
|
|
|
|
|
|
{% block content %}
|
|
|
|
|
|
|
|
<div class="content-wrapper">
|
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
<!-- Page Title Header Starts-->
|
2021-03-22 04:02:18 +00:00
|
|
|
<div class="row page-title-header">
|
|
|
|
<div class="col-12">
|
|
|
|
<div class="page-header">
|
|
|
|
<h4 class="page-title">
|
2022-06-20 19:26:21 +00:00
|
|
|
{{ translate('serverDetails', 'serverDetails', data['lang']) }} - {{
|
|
|
|
data['server_stats']['server_id']['server_name'] }}
|
2022-03-26 22:37:08 +00:00
|
|
|
<br />
|
|
|
|
<small>UUID: {{ data['server_stats']['server_id']['server_uuid'] }}</small>
|
2021-03-22 04:02:18 +00:00
|
|
|
</h4>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<!-- Page Title Header Ends-->
|
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
{% include "parts/details_stats.html %}
|
2021-03-22 04:02:18 +00:00
|
|
|
|
|
|
|
<div class="row">
|
|
|
|
|
|
|
|
<div class="col-sm-12 grid-margin">
|
|
|
|
<div class="card">
|
|
|
|
<div class="card-body pt-0">
|
2022-03-26 22:37:08 +00:00
|
|
|
|
|
|
|
<span class="d-none d-sm-block">
|
2021-08-21 08:44:03 +00:00
|
|
|
{% include "parts/server_controls_list.html %}
|
2022-03-26 22:37:08 +00:00
|
|
|
</span>
|
|
|
|
<span class="d-block d-sm-none">
|
|
|
|
{% include "parts/m_server_controls_list.html %}
|
|
|
|
</span>
|
2021-03-22 04:02:18 +00:00
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-6 col-sm-12">
|
|
|
|
<br>
|
|
|
|
<br>
|
|
|
|
<form class="forms-sample" method="post" action="/panel/server_backup">
|
|
|
|
{% raw xsrf_form_html() %}
|
|
|
|
<input type="hidden" name="id" value="{{ data['server_stats']['server_id']['server_id'] }}">
|
|
|
|
<input type="hidden" name="subpage" value="backup">
|
2021-03-22 04:02:18 +00:00
|
|
|
|
2022-03-11 05:19:05 +00:00
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
{% if data['backing_up'] %}
|
|
|
|
<div class="progress" style="height: 15px;">
|
2022-06-20 19:26:21 +00:00
|
|
|
<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>
|
2022-03-26 22:37:08 +00:00
|
|
|
</div>
|
2022-06-20 19:26:21 +00:00
|
|
|
<p>Backing up <i class="fas fa-spin fa-spinner"></i> <span
|
|
|
|
id="total_files">{{data['server_stats']['world_size']}}</span></p>
|
2022-03-26 22:37:08 +00:00
|
|
|
{% end %}
|
2022-03-11 05:19:05 +00:00
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
<br>
|
|
|
|
{% if not data['backing_up'] %}
|
|
|
|
<div id="backup_button" class="form-group">
|
2022-06-20 19:26:21 +00:00
|
|
|
<button class="btn btn-primary" id="backup_now_button">{{ translate('serverBackups', 'backupNow',
|
|
|
|
data['lang']) }}</button>
|
2022-03-26 22:37:08 +00:00
|
|
|
</div>
|
|
|
|
{% end %}
|
|
|
|
<div class="form-group">
|
|
|
|
{% if data['super_user'] %}
|
2022-06-20 19:26:21 +00:00
|
|
|
<label for="server_name">{{ translate('serverBackups', 'storageLocation', data['lang']) }} <small
|
|
|
|
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']) }}">
|
2022-03-26 22:37:08 +00:00
|
|
|
{% end %}
|
|
|
|
</div>
|
2021-03-22 04:02:18 +00:00
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
<div class="form-group">
|
2022-06-20 19:26:21 +00:00
|
|
|
<label for="server_path">{{ translate('serverBackups', 'maxBackups', data['lang']) }} <small
|
|
|
|
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']) }}">
|
2022-03-26 22:37:08 +00:00
|
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="compress" class="form-check-label ml-4 mb-4"></label>
|
|
|
|
{% if data['backup_config']['compress'] %}
|
2022-06-20 19:26:21 +00:00
|
|
|
<input type="checkbox" class="form-check-input" id="compress" name="compress" checked=""
|
|
|
|
value="True">{{ translate('serverBackups', 'compress', data['lang']) }}
|
2022-03-26 22:37:08 +00:00
|
|
|
{% else %}
|
2022-06-20 19:26:21 +00:00
|
|
|
<input type="checkbox" class="form-check-input" id="compress" name="compress" value="True">{{
|
|
|
|
translate('serverBackups', 'compress', data['lang']) }}
|
2022-03-26 22:37:08 +00:00
|
|
|
{% end %}
|
|
|
|
</div>
|
2022-06-20 21:16:56 +00:00
|
|
|
<div class="form-group">
|
|
|
|
<label for="shutdown" class="form-check-label ml-4 mb-4"></label>
|
|
|
|
{% if data['backup_config']['shutdown'] %}
|
|
|
|
<input type="checkbox" class="form-check-input" id="shutdown" name="shutdown" checked=""
|
|
|
|
value="True">{{ translate('serverBackups', 'shutdown', data['lang']) }}
|
|
|
|
{% else %}
|
|
|
|
<input type="checkbox" class="form-check-input" id="shutdown" name="shutdown" value="True">{{
|
|
|
|
translate('serverBackups', 'shutdown', data['lang']) }}
|
|
|
|
{% end %}
|
|
|
|
</div>
|
2022-03-26 22:37:08 +00:00
|
|
|
<div class="form-group">
|
2022-06-20 19:26:21 +00:00
|
|
|
<label for="server">{{ translate('serverBackups', 'exclusionsTitle', data['lang']) }} <small> - {{
|
|
|
|
translate('serverBackups', 'excludedChoose', data['lang']) }}</small></label>
|
2022-03-26 22:37:08 +00:00
|
|
|
<br>
|
2022-06-20 19:26:21 +00:00
|
|
|
<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>
|
2022-03-26 22:37:08 +00:00
|
|
|
</div>
|
2022-06-20 19:26:21 +00:00
|
|
|
<input type="number" class="form-control" name="changed" id="changed" value="0"
|
|
|
|
style="visibility: hidden;"></input>
|
|
|
|
<div class="modal fade" id="dir_select" tabindex="-1" role="dialog" aria-labelledby="dir_select"
|
|
|
|
aria-hidden="true">
|
2022-03-26 22:37:08 +00:00
|
|
|
<div class="modal-dialog" role="document">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
2022-06-20 19:26:21 +00:00
|
|
|
<h5 class="modal-title" id="exampleModalLongTitle">{{ translate('serverBackups',
|
|
|
|
'excludedChoose', data['lang']) }}</h5>
|
2022-03-26 22:37:08 +00:00
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
|
|
<span aria-hidden="true">×</span>
|
|
|
|
</button>
|
2021-03-22 04:02:18 +00:00
|
|
|
</div>
|
2022-03-26 22:37:08 +00:00
|
|
|
<div class="modal-body">
|
2022-06-20 19:26:21 +00:00
|
|
|
<div class="tree-ctx-item" id="main-tree-div" data-path=""
|
|
|
|
style="overflow: scroll; max-height:75%;">
|
2022-03-26 22:37:08 +00:00
|
|
|
<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>
|
2022-03-01 01:02:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-03-26 22:37:08 +00:00
|
|
|
<div class="modal-footer">
|
2022-06-20 19:26:21 +00:00
|
|
|
<button type="button" id="modal-cancel" class="btn btn-secondary" data-dismiss="modal">{{
|
|
|
|
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>
|
2022-03-26 22:37:08 +00:00
|
|
|
</div>
|
2021-03-22 04:02:18 +00:00
|
|
|
</div>
|
2022-03-26 22:37:08 +00:00
|
|
|
</div>
|
2021-03-22 04:02:18 +00:00
|
|
|
</div>
|
2022-03-26 22:37:08 +00:00
|
|
|
|
2022-06-20 19:26:21 +00:00
|
|
|
<button type="submit" class="btn btn-success mr-2">{{ translate('serverBackups', 'save', data['lang'])
|
|
|
|
}}</button>
|
|
|
|
<button type="reset" class="btn btn-light">{{ translate('serverBackups', 'cancel', data['lang'])
|
|
|
|
}}</button>
|
2022-03-26 22:37:08 +00:00
|
|
|
</form>
|
2021-03-22 04:02:18 +00:00
|
|
|
</div>
|
2022-03-26 22:37:08 +00:00
|
|
|
|
|
|
|
<div class="col-md-6 col-sm-12">
|
|
|
|
<div class="text-center">
|
|
|
|
|
|
|
|
<table class="table table-responsive dataTable" id="backup_table">
|
|
|
|
<h4 class="card-title">{{ translate('serverBackups', 'currentBackups', data['lang']) }}</h4>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th width="10%">{{ translate('serverBackups', 'options', data['lang']) }}</th>
|
|
|
|
<th>{{ translate('serverBackups', 'path', data['lang']) }}</th>
|
|
|
|
<th width="20%">{{ translate('serverBackups', 'size', data['lang']) }}</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for backup in data['backup_list'] %}
|
|
|
|
<tr>
|
|
|
|
<td>
|
2022-06-20 19:26:21 +00:00
|
|
|
<a href="/panel/download_backup?file={{ backup['path'] }}&id={{ data['server_stats']['server_id']['server_id'] }}"
|
|
|
|
class="btn btn-primary">
|
2022-03-26 22:37:08 +00:00
|
|
|
<i class="fas fa-download" aria-hidden="true"></i>
|
|
|
|
{{ translate('serverBackups', 'download', data['lang']) }}
|
|
|
|
</a>
|
|
|
|
<br>
|
|
|
|
<br>
|
2022-06-20 19:26:21 +00:00
|
|
|
<button data-file="{{ backup['path'] }}" data-backup_path="{{ data['backup_path'] }}"
|
|
|
|
class="btn btn-danger del_button">
|
2022-03-26 22:37:08 +00:00
|
|
|
<i class="fas fa-trash" aria-hidden="true"></i>
|
|
|
|
{{ translate('serverBackups', 'delete', data['lang']) }}
|
|
|
|
</button>
|
|
|
|
<button data-file="{{ backup['path'] }}" class="btn btn-warning restore_button">
|
|
|
|
<i class="fas fa-undo-alt" aria-hidden="true"></i>
|
|
|
|
{{ translate('serverBackups', 'restore', data['lang']) }}
|
|
|
|
</button>
|
|
|
|
</td>
|
|
|
|
<td>{{ backup['path'] }}</td>
|
|
|
|
<td>{{ backup['size'] }}</td>
|
|
|
|
</tr>
|
|
|
|
{% end %}
|
|
|
|
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
2022-03-01 01:02:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-03-26 22:37:08 +00:00
|
|
|
</div>
|
|
|
|
<div class="col-md-12 col-sm-12">
|
|
|
|
<br>
|
|
|
|
<br>
|
|
|
|
<div class="card-header header-sm d-flex justify-content-between align-items-center">
|
2022-06-20 19:26:21 +00:00
|
|
|
<h4 class="card-title"><i class="fas fa-server"></i> {{ translate('serverBackups', 'excludedBackups',
|
|
|
|
data['lang']) }} <small class="text-muted ml-1"></small> </h4>
|
2022-03-26 22:37:08 +00:00
|
|
|
</div>
|
|
|
|
<br>
|
|
|
|
<ul>
|
|
|
|
{% for item in data['exclusions'] %}
|
|
|
|
<li>{{item}}</li>
|
|
|
|
<br>
|
|
|
|
{% end %}
|
|
|
|
</ul>
|
|
|
|
</div>
|
2021-03-22 04:02:18 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
2022-03-01 01:02:30 +00:00
|
|
|
<style>
|
|
|
|
/* Remove default bullets */
|
2022-03-26 22:37:08 +00:00
|
|
|
.tree-view,
|
|
|
|
.tree-nested {
|
|
|
|
list-style-type: none;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
margin-left: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Style the items */
|
|
|
|
.tree-item,
|
|
|
|
.files-tree-title {
|
|
|
|
cursor: pointer;
|
|
|
|
user-select: none;
|
|
|
|
/* Prevent text selection */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the caret/arrow with a unicode, and style it */
|
|
|
|
.tree-caret .fa-folder {
|
|
|
|
display: inline-block;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tree-caret .fa-folder-open {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Rotate the caret/arrow icon when clicked on (using JavaScript) */
|
|
|
|
.tree-caret-down .fa-folder {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tree-caret-down .fa-folder-open {
|
|
|
|
display: inline-block;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Hide the nested list */
|
|
|
|
.tree-nested {
|
|
|
|
display: none;
|
|
|
|
}
|
2022-03-01 01:02:30 +00:00
|
|
|
</style>
|
2021-03-22 04:02:18 +00:00
|
|
|
<!-- content-wrapper ends -->
|
|
|
|
|
|
|
|
{% end %}
|
|
|
|
|
|
|
|
{% block js %}
|
|
|
|
<script>
|
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
const server_id = new URLSearchParams(document.location.search).get('id')
|
2021-03-22 04:02:18 +00:00
|
|
|
|
2022-02-27 17:26:54 +00:00
|
|
|
|
|
|
|
//used to get cookies from browser - this is part of tornados xsrf protection - it's for extra security
|
|
|
|
function getCookie(name) {
|
|
|
|
var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
|
|
|
|
return r ? r[1] : undefined;
|
|
|
|
}
|
|
|
|
|
2022-03-11 05:19:05 +00:00
|
|
|
function backup_started() {
|
|
|
|
var token = getCookie("_xsrf")
|
|
|
|
document.getElementById('backup_button').style.visibility = 'hidden';
|
|
|
|
var dialog = bootbox.dialog({
|
2022-02-27 17:26:54 +00:00
|
|
|
message: "{{ translate('serverBackups', 'backupTask', data['lang']) }}",
|
2022-03-11 05:19:05 +00:00
|
|
|
closeButton: false
|
2022-03-26 22:37:08 +00:00
|
|
|
});
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
headers: { 'X-XSRFToken': token },
|
|
|
|
url: '/ajax/backup_now?id=' + server_id,
|
|
|
|
success: function (data) {
|
2022-10-21 20:48:51 +00:00
|
|
|
return;
|
2022-03-26 22:37:08 +00:00
|
|
|
},
|
|
|
|
});
|
2022-10-21 20:48:51 +00:00
|
|
|
return;
|
2022-03-26 22:37:08 +00:00
|
|
|
}
|
2022-02-27 17:26:54 +00:00
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
function del_backup(filename, id) {
|
2022-02-27 17:26:54 +00:00
|
|
|
var token = getCookie("_xsrf")
|
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
data_to_send = { file_name: filename }
|
2022-02-27 17:26:54 +00:00
|
|
|
|
|
|
|
console.log('Sending Command to delete backup: ' + filename)
|
|
|
|
$.ajax({
|
|
|
|
type: "DELETE",
|
2022-03-26 22:37:08 +00:00
|
|
|
headers: { 'X-XSRFToken': token },
|
|
|
|
url: '/ajax/del_backup?server_id=' + id,
|
2022-02-27 17:26:54 +00:00
|
|
|
data: {
|
2022-03-26 22:37:08 +00:00
|
|
|
file_path: filename,
|
|
|
|
id: id
|
2022-02-27 17:26:54 +00:00
|
|
|
},
|
2022-03-26 22:37:08 +00:00
|
|
|
success: function (data) {
|
2022-02-27 17:26:54 +00:00
|
|
|
location.reload();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
function restore_backup(filename, id) {
|
2022-02-27 17:26:54 +00:00
|
|
|
var token = getCookie("_xsrf")
|
2022-03-08 02:46:42 +00:00
|
|
|
var dialog = bootbox.dialog({
|
2022-06-08 22:11:21 +00:00
|
|
|
message: "<i class='fa fa-spin fa-spinner'></i> {{ translate('serverBackups', 'restoring', data['lang']) }}",
|
2022-03-26 22:37:08 +00:00
|
|
|
closeButton: false
|
|
|
|
});
|
2022-02-27 17:26:54 +00:00
|
|
|
|
|
|
|
console.log('Sending Command to restore backup: ' + filename)
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
2022-03-26 22:37:08 +00:00
|
|
|
headers: { 'X-XSRFToken': token },
|
|
|
|
url: '/ajax/restore_backup?server_id=' + id,
|
2022-02-27 17:26:54 +00:00
|
|
|
data: {
|
2022-03-26 22:37:08 +00:00
|
|
|
zip_file: filename,
|
|
|
|
id: id
|
2022-02-27 17:26:54 +00:00
|
|
|
},
|
2022-03-26 22:37:08 +00:00
|
|
|
success: function (data) {
|
|
|
|
setTimeout(function () {
|
|
|
|
location.href = ('/panel/dashboard');
|
|
|
|
}, 15000);
|
2022-02-27 17:26:54 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
$(document).ready(function () {
|
2022-04-12 21:37:20 +00:00
|
|
|
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 {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2022-03-26 22:37:08 +00:00
|
|
|
console.log("ready!");
|
2022-02-27 17:26:54 +00:00
|
|
|
$("#backup_config_box").hide();
|
|
|
|
$("#backup_save_note").hide();
|
|
|
|
|
|
|
|
$("#show_config").click(function () {
|
|
|
|
$("#backup_config_box").toggle();
|
|
|
|
$('#backup_button').hide();
|
|
|
|
$('#backup_save_note').show();
|
|
|
|
$('#backup_data').hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#backup_table').DataTable({
|
2022-03-26 22:37:08 +00:00
|
|
|
"order": [[1, "desc"]],
|
2022-06-22 03:18:17 +00:00
|
|
|
"paging": false,
|
2022-02-27 17:26:54 +00:00
|
|
|
"lengthChange": false,
|
|
|
|
"searching": true,
|
|
|
|
"ordering": true,
|
|
|
|
"info": true,
|
|
|
|
"autoWidth": false,
|
|
|
|
"responsive": true,
|
|
|
|
});
|
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
$(".del_button").click(function () {
|
2022-02-27 17:26:54 +00:00
|
|
|
var file_to_del = $(this).data("file");
|
2022-02-27 19:36:33 +00:00
|
|
|
var backup_path = $(this).data('backup_path');
|
2022-02-27 17:26:54 +00:00
|
|
|
|
|
|
|
console.log("file to delete is" + file_to_del);
|
|
|
|
|
|
|
|
bootbox.confirm({
|
|
|
|
title: "{% raw translate('serverBackups', 'destroyBackup', data['lang']) %}",
|
|
|
|
message: "{{ translate('serverBackups', 'confirmDelete', data['lang']) }}",
|
|
|
|
buttons: {
|
|
|
|
cancel: {
|
|
|
|
label: '<i class="fas fa-times"></i> {{ translate("serverBackups", "cancel", data['lang']) }}'
|
2021-03-22 04:02:18 +00:00
|
|
|
},
|
2022-02-27 17:26:54 +00:00
|
|
|
confirm: {
|
|
|
|
label: '<i class="fas fa-check"></i> {{ translate("serverBackups", "confirm", data['lang']) }}'
|
|
|
|
}
|
2021-11-29 21:22:46 +00:00
|
|
|
},
|
2022-02-27 17:26:54 +00:00
|
|
|
callback: function (result) {
|
|
|
|
console.log(result);
|
|
|
|
if (result == true) {
|
2022-02-27 19:36:33 +00:00
|
|
|
var full_path = backup_path + '/' + file_to_del;
|
2022-03-01 01:02:30 +00:00
|
|
|
del_backup(full_path, server_id);
|
2022-02-27 17:26:54 +00:00
|
|
|
}
|
|
|
|
}
|
2021-11-29 21:22:46 +00:00
|
|
|
});
|
2022-02-27 17:26:54 +00:00
|
|
|
});
|
2021-11-29 21:22:46 +00:00
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
$(".restore_button").click(function () {
|
2022-02-27 17:26:54 +00:00
|
|
|
var file_to_restore = $(this).data("file");
|
2021-11-29 21:22:46 +00:00
|
|
|
|
|
|
|
|
2022-02-27 17:26:54 +00:00
|
|
|
bootbox.confirm({
|
2022-03-26 22:37:08 +00:00
|
|
|
title: "{{ translate('serverBackups', 'restore', data['lang']) }} " + file_to_restore,
|
2022-02-27 17:26:54 +00:00
|
|
|
message: "{{ translate('serverBackups', 'confirmRestore', data['lang']) }}",
|
|
|
|
buttons: {
|
|
|
|
cancel: {
|
|
|
|
label: '<i class="fas fa-times"></i> {{ translate("serverBackups", "cancel", data['lang']) }}'
|
|
|
|
},
|
|
|
|
confirm: {
|
2022-03-01 01:02:30 +00:00
|
|
|
label: '<i class="fas fa-check"></i> {{ translate("serverBackups", "restore", data['lang']) }}',
|
2022-03-26 22:37:08 +00:00
|
|
|
className: 'btn-outline-danger'
|
2022-02-27 17:26:54 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
callback: function (result) {
|
|
|
|
console.log(result);
|
|
|
|
if (result == true) {
|
2022-03-01 01:02:30 +00:00
|
|
|
restore_backup(file_to_restore, server_id);
|
2022-02-27 17:26:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2021-03-22 04:02:18 +00:00
|
|
|
});
|
2022-03-26 22:37:08 +00:00
|
|
|
$("#backup_now_button").click(function () {
|
2022-03-11 05:19:05 +00:00
|
|
|
backup_started();
|
|
|
|
});
|
2021-03-22 04:02:18 +00:00
|
|
|
|
2021-11-29 21:22:46 +00:00
|
|
|
});
|
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
document.getElementById("modal-cancel").addEventListener("click", function () {
|
|
|
|
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>'
|
|
|
|
})
|
2022-03-01 01:02:30 +00:00
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
document.getElementById("root_files_button").addEventListener("click", function () {
|
|
|
|
if ($("#root_files_button").data('server_path') != "") {
|
|
|
|
if (document.getElementById('root_files_button').classList.contains('clicked')) {
|
2022-03-01 01:02:30 +00:00
|
|
|
show_file_tree();
|
|
|
|
return;
|
2022-03-26 22:37:08 +00:00
|
|
|
} else {
|
2022-03-01 01:02:30 +00:00
|
|
|
document.getElementById('root_files_button').classList.add('clicked');
|
|
|
|
document.getElementById("changed").value = 1;
|
|
|
|
}
|
2022-03-26 22:37:08 +00:00
|
|
|
path = $("#root_files_button").data('server_path')
|
|
|
|
console.log($("#root_files_button").data('server_path'))
|
|
|
|
var token = getCookie("_xsrf");
|
|
|
|
var dialog = bootbox.dialog({
|
|
|
|
message: '<p class="text-center mb-0"><i class="fa fa-spin fa-cog"></i> Please wait while we gather your files...</p>',
|
|
|
|
closeButton: false
|
|
|
|
});
|
2022-03-01 01:02:30 +00:00
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
headers: { 'X-XSRFToken': token },
|
|
|
|
url: '/ajax/backup_select?id=' + server_id + '&path=' + path,
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
bootbox.alert("You must input a path before selecting this button");
|
|
|
|
}
|
2022-03-01 01:02:30 +00:00
|
|
|
});
|
|
|
|
if (webSocket) {
|
|
|
|
webSocket.on('send_temp_path', function (data) {
|
2022-03-26 22:37:08 +00:00
|
|
|
setTimeout(function () {
|
2022-03-01 01:02:30 +00:00
|
|
|
var x = document.querySelector('.bootbox');
|
|
|
|
if (x) {
|
|
|
|
x.remove()
|
|
|
|
}
|
|
|
|
var x = document.querySelector('.modal-backdrop');
|
|
|
|
if (x) {
|
|
|
|
x.remove()
|
|
|
|
}
|
|
|
|
document.getElementById('main-tree-input').setAttribute('value', data.path)
|
|
|
|
getTreeView(data.path);
|
|
|
|
show_file_tree();
|
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
}, 5000);
|
2022-03-01 01:02:30 +00:00
|
|
|
});
|
|
|
|
}
|
2022-03-11 05:19:05 +00:00
|
|
|
if (webSocket) {
|
|
|
|
webSocket.on('backup_status', function (backup) {
|
2022-03-26 22:37:08 +00:00
|
|
|
if (backup.percent >= 100) {
|
2022-03-11 05:19:05 +00:00
|
|
|
document.getElementById('backup_progress_bar').innerHTML = '100%';
|
|
|
|
document.getElementById('backup_progress_bar').style.width = '100%';
|
2022-03-26 22:37:08 +00:00
|
|
|
setTimeout(function () {
|
2022-03-11 05:19:05 +00:00
|
|
|
window.location.reload(1);
|
2022-03-26 22:37:08 +00:00
|
|
|
}, 5000);
|
|
|
|
} else {
|
|
|
|
document.getElementById('backup_progress_bar').innerHTML = backup.percent + '%';
|
2022-03-11 05:19:05 +00:00
|
|
|
document.getElementById('backup_progress_bar').style.width = backup.percent + '%';
|
|
|
|
document.getElementById('total_files').innerHTML = backup.total_files;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-03-01 01:02:30 +00:00
|
|
|
|
|
|
|
function getTreeView(path) {
|
|
|
|
path = path
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
2022-03-26 22:37:08 +00:00
|
|
|
url: '/ajax/get_backup_tree?id=' + server_id + '&path=' + path,
|
2022-03-01 01:02:30 +00:00
|
|
|
dataType: 'text',
|
2022-03-26 22:37:08 +00:00
|
|
|
success: function (data) {
|
2022-03-01 01:02:30 +00:00
|
|
|
console.log("got response:");
|
|
|
|
console.log(data);
|
|
|
|
|
|
|
|
dataArr = data.split('\n');
|
|
|
|
serverDir = dataArr.shift(); // Remove & return first element (server directory)
|
|
|
|
text = dataArr.join('\n');
|
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
try {
|
2022-03-01 01:02:30 +00:00
|
|
|
document.getElementById('main-tree-div').innerHTML += text;
|
|
|
|
document.getElementById('main-tree').parentElement.classList.add("clicked");
|
2022-03-26 22:37:08 +00:00
|
|
|
} catch {
|
2022-03-01 01:02:30 +00:00
|
|
|
document.getElementById('files-tree').innerHTML = text;
|
|
|
|
}
|
2022-03-26 22:37:08 +00:00
|
|
|
|
2022-03-01 01:02:30 +00:00
|
|
|
|
|
|
|
document.getElementsByClassName('files-tree-title')[0].setAttribute('data-path', serverDir);
|
|
|
|
document.getElementsByClassName('files-tree-title')[0].setAttribute('data-name', 'Files');
|
|
|
|
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function getToggleMain(event) {
|
|
|
|
path = event.target.parentElement.getAttribute('data-path');
|
2022-03-26 22:37:08 +00:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2022-03-01 01:02:30 +00:00
|
|
|
|
|
|
|
function getDirView(event) {
|
2022-03-26 22:37:08 +00:00
|
|
|
path = event.target.parentElement.getAttribute('data-path');
|
2022-03-01 01:02:30 +00:00
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
if (document.getElementById(path).classList.contains('clicked')) {
|
2022-03-01 01:02:30 +00:00
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
var toggler = document.getElementById(path + "span");
|
2022-03-01 01:02:30 +00:00
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
if (toggler.classList.contains('files-tree-title')) {
|
|
|
|
document.getElementById(path + "ul").classList.toggle("d-block");
|
|
|
|
document.getElementById(path + "span").classList.toggle("tree-caret-down");
|
2022-03-01 01:02:30 +00:00
|
|
|
}
|
|
|
|
return;
|
2022-03-26 22:37:08 +00:00
|
|
|
} else {
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
|
|
|
url: '/ajax/get_backup_dir?id=' + server_id + '&path=' + path,
|
|
|
|
dataType: 'text',
|
|
|
|
success: function (data) {
|
|
|
|
console.log("got response:");
|
|
|
|
|
|
|
|
dataArr = data.split('\n');
|
|
|
|
serverDir = dataArr.shift(); // Remove & return first element (server directory)
|
|
|
|
text = dataArr.join('\n');
|
|
|
|
|
|
|
|
try {
|
|
|
|
document.getElementById(path + "span").classList.add('tree-caret-down');
|
|
|
|
document.getElementById(path).innerHTML += text;
|
|
|
|
document.getElementById(path).classList.add("clicked");
|
|
|
|
} catch {
|
|
|
|
console.log("Bad")
|
|
|
|
}
|
2022-03-01 01:02:30 +00:00
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
var toggler = document.getElementById(path);
|
2022-03-01 01:02:30 +00:00
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
if (toggler.classList.contains('files-tree-title')) {
|
|
|
|
document.getElementById(path + "span").addEventListener("click", function caretListener() {
|
|
|
|
document.getElementById(path + "ul").classList.toggle("d-block");
|
|
|
|
document.getElementById(path + "span").classList.toggle("tree-caret-down");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2022-03-01 01:02:30 +00:00
|
|
|
}
|
2022-03-26 22:37:08 +00:00
|
|
|
function show_file_tree() {
|
2022-03-01 01:02:30 +00:00
|
|
|
$("#dir_select").modal();
|
|
|
|
}
|
2022-02-27 21:15:40 +00:00
|
|
|
|
2021-03-22 04:02:18 +00:00
|
|
|
</script>
|
|
|
|
|
2022-03-01 01:02:30 +00:00
|
|
|
{% end %}
|