mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Revert "Merge branch 'xithical-fixes' into 'dev'"
This reverts merge request !173
This commit is contained in:
parent
1a0e8176e3
commit
26014d0e86
@ -104,17 +104,5 @@ class Management_Controller:
|
||||
return management_helper.get_backup_config(server_id)
|
||||
|
||||
@staticmethod
|
||||
def set_backup_config(server_id: int, backup_path: str = None, max_backups: int = None, excluded_dirs: list = None):
|
||||
return management_helper.set_backup_config(server_id, backup_path, max_backups, excluded_dirs)
|
||||
|
||||
@staticmethod
|
||||
def get_excluded_backup_dirs(server_id: int):
|
||||
return management_helper.get_excluded_backup_dirs(server_id)
|
||||
|
||||
@staticmethod
|
||||
def add_excluded_backup_dir(server_id: int, dir_to_add: str):
|
||||
management_helper.add_excluded_backup_dir(server_id, dir_to_add)
|
||||
|
||||
@staticmethod
|
||||
def del_excluded_backup_dir(server_id: int, dir_to_del: str):
|
||||
management_helper.del_excluded_backup_dir(server_id, dir_to_del)
|
||||
def set_backup_config(server_id: int, backup_path: str = None, max_backups: int = None):
|
||||
return management_helper.set_backup_config(server_id, backup_path, max_backups)
|
||||
|
@ -125,7 +125,7 @@ class Schedules(Model):
|
||||
# Backups Class
|
||||
#************************************************************************************************
|
||||
class Backups(Model):
|
||||
excluded_dirs = CharField(null=True)
|
||||
directories = CharField(null=True)
|
||||
max_backups = IntegerField()
|
||||
server_id = ForeignKeyField(Servers, backref='backups_server')
|
||||
class Meta:
|
||||
@ -311,37 +311,34 @@ class helpers_management:
|
||||
row = Backups.select().where(Backups.server_id == server_id).join(Servers)[0]
|
||||
conf = {
|
||||
"backup_path": row.server_id.backup_path,
|
||||
"excluded_dirs": row.excluded_dirs,
|
||||
"directories": row.directories,
|
||||
"max_backups": row.max_backups,
|
||||
"server_id": row.server_id.server_id
|
||||
}
|
||||
except IndexError:
|
||||
conf = {
|
||||
"backup_path": None,
|
||||
"excluded_dirs": None,
|
||||
"directories": None,
|
||||
"max_backups": 0,
|
||||
"server_id": server_id
|
||||
}
|
||||
return conf
|
||||
|
||||
@staticmethod
|
||||
def set_backup_config(server_id: int, backup_path: str = None, max_backups: int = None, excluded_dirs: list = None):
|
||||
def set_backup_config(server_id: int, backup_path: str = None, max_backups: int = None):
|
||||
logger.debug(f"Updating server {server_id} backup config with {locals()}")
|
||||
if Backups.select().where(Backups.server_id == server_id).count() != 0:
|
||||
new_row = False
|
||||
conf = {}
|
||||
else:
|
||||
conf = {
|
||||
"excluded_dirs": None,
|
||||
"directories": None,
|
||||
"max_backups": 0,
|
||||
"server_id": server_id
|
||||
}
|
||||
new_row = True
|
||||
if max_backups is not None:
|
||||
conf['max_backups'] = max_backups
|
||||
if excluded_dirs is not None:
|
||||
dirs_to_exclude = ",".join(excluded_dirs)
|
||||
conf['excluded_dirs'] = dirs_to_exclude
|
||||
if not new_row:
|
||||
with database.atomic():
|
||||
if backup_path is not None:
|
||||
@ -358,34 +355,5 @@ class helpers_management:
|
||||
Backups.create(**conf)
|
||||
logger.debug("Creating new backup record.")
|
||||
|
||||
@staticmethod
|
||||
def get_excluded_backup_dirs(server_id: int):
|
||||
excluded_dirs = helpers_management.get_backup_config(server_id)['excluded_dirs']
|
||||
if excluded_dirs is not None:
|
||||
dir_list = excluded_dirs.split(",")
|
||||
else:
|
||||
dir_list = []
|
||||
return dir_list
|
||||
|
||||
@staticmethod
|
||||
def add_excluded_backup_dir(server_id: int, dir_to_add: str):
|
||||
dir_list = management_helper.get_excluded_backup_dirs()
|
||||
if dir_to_add not in dir_list:
|
||||
dir_list.append(dir_to_add)
|
||||
excluded_dirs = ",".join(dir_list)
|
||||
management_helper.set_backup_config(server_id=server_id, excluded_dirs=excluded_dirs)
|
||||
else:
|
||||
logger.debug(f"Not adding {dir_to_add} to excluded directories - already in the excluded directory list for server ID {server_id}")
|
||||
|
||||
@staticmethod
|
||||
def del_excluded_backup_dir(server_id: int, dir_to_del: str):
|
||||
dir_list = management_helper.get_excluded_backup_dirs()
|
||||
if dir_to_del in dir_list:
|
||||
dir_list.remove(dir_to_del)
|
||||
excluded_dirs = ",".join(dir_list)
|
||||
management_helper.set_backup_config(server_id=server_id, excluded_dirs=excluded_dirs)
|
||||
else:
|
||||
logger.debug(f"Not removing {dir_to_del} from excluded directories - not in the excluded directory list for server ID {server_id}")
|
||||
|
||||
|
||||
management_helper = helpers_management()
|
||||
|
@ -773,12 +773,6 @@ class Helpers:
|
||||
websocket_helper.broadcast_user(user_id, 'send_temp_path',{
|
||||
'path': tempDir
|
||||
})
|
||||
@staticmethod
|
||||
def backup_select(path, user_id):
|
||||
if user_id:
|
||||
websocket_helper.broadcast_user(user_id, 'send_temp_path',{
|
||||
'path': path
|
||||
})
|
||||
|
||||
@staticmethod
|
||||
def unzip_backup_archive(backup_path, zip_name):
|
||||
|
@ -8,7 +8,6 @@ import logging.config
|
||||
import shutil
|
||||
import subprocess
|
||||
import html
|
||||
import tempfile
|
||||
from apscheduler.schedulers.background import BackgroundScheduler
|
||||
#TZLocal is set as a hidden import on win pipeline
|
||||
from tzlocal import get_localzone
|
||||
@ -581,36 +580,14 @@ class Server:
|
||||
backup_filename = f"{self.settings['backup_path']}/{datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}"
|
||||
logger.info(f"Creating backup of server '{self.settings['server_name']}'" +
|
||||
f" (ID#{self.server_id}, path={self.server_path}) at '{backup_filename}'")
|
||||
|
||||
tempDir = tempfile.mkdtemp()
|
||||
# pylint: disable=unexpected-keyword-arg
|
||||
shutil.copytree(self.server_path, tempDir, dirs_exist_ok=True)
|
||||
excluded_dirs = management_helper.get_excluded_backup_dirs(self.server_id)
|
||||
server_dir = helper.get_os_understandable_path(self.settings['path'])
|
||||
|
||||
for my_dir in excluded_dirs:
|
||||
# Take the full path of the excluded dir and replace the server path with the temp path
|
||||
# This is so that we're only deleting excluded dirs from the temp path and not the server path
|
||||
excluded_dir = helper.get_os_understandable_path(my_dir).replace(server_dir, helper.get_os_understandable_path(tempDir))
|
||||
# Next, check to see if it is a directory
|
||||
if os.path.isdir(excluded_dir):
|
||||
# If it is a directory, recursively delete the entire directory from the backup
|
||||
shutil.rmtree(excluded_dir)
|
||||
else:
|
||||
# If not, just remove the file
|
||||
os.remove(excluded_dir)
|
||||
|
||||
shutil.make_archive(helper.get_os_understandable_path(backup_filename), 'zip', tempDir)
|
||||
|
||||
shutil.make_archive(helper.get_os_understandable_path(backup_filename), 'zip', self.server_path)
|
||||
while len(self.list_backups()) > conf["max_backups"] and conf["max_backups"] > 0:
|
||||
backup_list = self.list_backups()
|
||||
oldfile = backup_list[0]
|
||||
oldfile_path = f"{conf['backup_path']}/{oldfile['path']}"
|
||||
logger.info(f"Removing old backup '{oldfile['path']}'")
|
||||
os.remove(helper.get_os_understandable_path(oldfile_path))
|
||||
|
||||
self.is_backingup = False
|
||||
shutil.rmtree(tempDir)
|
||||
logger.info(f"Backup of server: {self.name} completed")
|
||||
return
|
||||
except:
|
||||
|
@ -99,141 +99,6 @@ class AjaxHandler(BaseHandler):
|
||||
helper.generate_zip_dir(path))
|
||||
self.finish()
|
||||
|
||||
elif page == "get_backup_tree":
|
||||
server_id = self.get_argument('id', None)
|
||||
folder = self.get_argument('path', None)
|
||||
|
||||
output = ""
|
||||
|
||||
file_list = os.listdir(folder)
|
||||
file_list = sorted(file_list, key=str.casefold)
|
||||
output += \
|
||||
f"""<ul class="tree-nested d-block" id="{folder}ul">"""\
|
||||
|
||||
for raw_filename in file_list:
|
||||
filename = html.escape(raw_filename)
|
||||
rel = os.path.join(folder, raw_filename)
|
||||
dpath = os.path.join(folder, filename)
|
||||
if str(dpath) in self.controller.management.get_excluded_backup_dirs(server_id):
|
||||
if os.path.isdir(rel):
|
||||
output += \
|
||||
f"""<li class="tree-item" data-path="{dpath}">
|
||||
\n<div id="{dpath}" data-path="{dpath}" data-name="{filename}" class="tree-caret tree-ctx-item tree-folder">
|
||||
<input type="checkbox" class="checkBoxClass" name="root_path" value="{dpath}" checked>
|
||||
<span id="{dpath}span" class="files-tree-title" data-path="{dpath}" data-name="{filename}" onclick="getDirView(event)">
|
||||
<i class="far fa-folder"></i>
|
||||
<i class="far fa-folder-open"></i>
|
||||
<strong>{filename}</strong>
|
||||
</span>
|
||||
</input></div><li>
|
||||
\n"""\
|
||||
|
||||
else:
|
||||
output += f"""<li
|
||||
class="tree-item tree-ctx-item tree-file"
|
||||
data-path="{dpath}"
|
||||
data-name="{filename}"
|
||||
onclick=""><input type='checkbox' class="checkBoxClass" name='root_path' value="{dpath}" checked><span style="margin-right: 6px;">
|
||||
<i class="far fa-file"></i></span></input>{filename}</li>"""
|
||||
|
||||
else:
|
||||
if os.path.isdir(rel):
|
||||
output += \
|
||||
f"""<li class="tree-item" data-path="{dpath}">
|
||||
\n<div id="{dpath}" data-path="{dpath}" data-name="{filename}" class="tree-caret tree-ctx-item tree-folder">
|
||||
<input type="checkbox" class="checkBoxClass" name="root_path" value="{dpath}">
|
||||
<span id="{dpath}span" class="files-tree-title" data-path="{dpath}" data-name="{filename}" onclick="getDirView(event)">
|
||||
<i class="far fa-folder"></i>
|
||||
<i class="far fa-folder-open"></i>
|
||||
<strong>{filename}</strong>
|
||||
</span>
|
||||
</input></div><li>
|
||||
\n"""\
|
||||
|
||||
else:
|
||||
output += f"""<li
|
||||
class="tree-item tree-ctx-item tree-file"
|
||||
data-path="{dpath}"
|
||||
data-name="{filename}"
|
||||
onclick=""><input type='checkbox' class="checkBoxClass" name='root_path' value="{dpath}">
|
||||
<span style="margin-right: 6px;"><i class="far fa-file"></i></span></input>{filename}</li>"""
|
||||
self.write(helper.get_os_understandable_path(folder) + '\n' +
|
||||
output)
|
||||
self.finish()
|
||||
|
||||
elif page == "get_backup_dir":
|
||||
server_id = self.get_argument('id', None)
|
||||
folder = self.get_argument('path', None)
|
||||
output = ""
|
||||
|
||||
file_list = os.listdir(folder)
|
||||
file_list = sorted(file_list, key=str.casefold)
|
||||
output += \
|
||||
f"""<ul class="tree-nested d-block" id="{folder}ul">"""\
|
||||
|
||||
for raw_filename in file_list:
|
||||
filename = html.escape(raw_filename)
|
||||
rel = os.path.join(folder, raw_filename)
|
||||
dpath = os.path.join(folder, filename)
|
||||
if str(dpath) in self.controller.management.get_excluded_backup_dirs(server_id):
|
||||
if os.path.isdir(rel):
|
||||
output += \
|
||||
f"""<li class="tree-item" data-path="{dpath}">
|
||||
\n<div id="{dpath}" data-path="{dpath}" data-name="{filename}" class="tree-caret tree-ctx-item tree-folder">
|
||||
<input type="checkbox" name="root_path" value="{dpath}">
|
||||
<span id="{dpath}span" class="files-tree-title" data-path="{dpath}" data-name="{filename}" onclick="getDirView(event)">
|
||||
<i class="far fa-folder"></i>
|
||||
<i class="far fa-folder-open"></i>
|
||||
<strong>{filename}</strong>
|
||||
</span>
|
||||
</input></div><li>"""\
|
||||
|
||||
else:
|
||||
output += f"""<li
|
||||
class="tree-item tree-ctx-item tree-file"
|
||||
data-path="{dpath}"
|
||||
data-name="{filename}"
|
||||
onclick=""><input type='checkbox' name='root_path' value='{dpath}'><span style="margin-right: 6px;">
|
||||
<i class="far fa-file"></i></span></input>{filename}</li>"""
|
||||
|
||||
else:
|
||||
if os.path.isdir(rel):
|
||||
output += \
|
||||
f"""<li class="tree-item" data-path="{dpath}">
|
||||
\n<div id="{dpath}" data-path="{dpath}" data-name="{filename}" class="tree-caret tree-ctx-item tree-folder">
|
||||
<input type="checkbox" name="root_path" value="{dpath}">
|
||||
<span id="{dpath}span" class="files-tree-title" data-path="{dpath}" data-name="{filename}" onclick="getDirView(event)">
|
||||
<i class="far fa-folder"></i>
|
||||
<i class="far fa-folder-open"></i>
|
||||
<strong>{filename}</strong>
|
||||
</span>
|
||||
</input></div><li>"""\
|
||||
|
||||
else:
|
||||
output += f"""<li
|
||||
class="tree-item tree-ctx-item tree-file"
|
||||
data-path="{dpath}"
|
||||
data-name="{filename}"
|
||||
onclick=""><input type='checkbox' name='root_path' value='{dpath}'>
|
||||
<span style="margin-right: 6px;"><i class="far fa-file"></i></span></input>{filename}</li>"""
|
||||
|
||||
self.write(helper.get_os_understandable_path(folder) + '\n' +
|
||||
output)
|
||||
self.finish()
|
||||
|
||||
elif page == "get_dir":
|
||||
server_id = self.get_argument('id', None)
|
||||
path = self.get_argument('path', None)
|
||||
|
||||
if not self.check_server_id(server_id, 'get_tree'):
|
||||
return
|
||||
else:
|
||||
server_id = bleach.clean(server_id)
|
||||
|
||||
if helper.validate_traversal(self.controller.servers.get_server_data_by_id(server_id)['path'], path):
|
||||
self.write(helper.get_os_understandable_path(path) + '\n' +
|
||||
helper.generate_dir(path))
|
||||
self.finish()
|
||||
|
||||
@tornado.web.authenticated
|
||||
def post(self, page):
|
||||
@ -334,11 +199,6 @@ class AjaxHandler(BaseHandler):
|
||||
helper.unzipServer(path, exec_user['user_id'])
|
||||
return
|
||||
|
||||
elif page == "backup_select":
|
||||
path = self.get_argument('path', None)
|
||||
helper.backup_select(path, exec_user['user_id'])
|
||||
return
|
||||
|
||||
|
||||
@tornado.web.authenticated
|
||||
def delete(self, page):
|
||||
|
@ -428,7 +428,6 @@ class PanelHandler(BaseHandler):
|
||||
return
|
||||
server_info = self.controller.servers.get_server_data_by_id(server_id)
|
||||
page_data['backup_config'] = self.controller.management.get_backup_config(server_id)
|
||||
page_data['exclusions'] = self.controller.management.get_excluded_backup_dirs(server_id)
|
||||
self.controller.refresh_server_settings(server_id)
|
||||
try:
|
||||
page_data['backup_list'] = server.list_backups()
|
||||
@ -1028,7 +1027,6 @@ class PanelHandler(BaseHandler):
|
||||
logger.debug(self.request.arguments)
|
||||
server_id = self.get_argument('id', None)
|
||||
server_obj = self.controller.servers.get_server_obj(server_id)
|
||||
checked = self.get_body_arguments('root_path')
|
||||
if superuser:
|
||||
backup_path = bleach.clean(self.get_argument('backup_path', None))
|
||||
if helper.is_os_windows():
|
||||
@ -1054,7 +1052,7 @@ class PanelHandler(BaseHandler):
|
||||
server_obj = self.controller.servers.get_server_obj(server_id)
|
||||
server_obj.backup_path = backup_path
|
||||
self.controller.servers.update_server(server_obj)
|
||||
self.controller.management.set_backup_config(server_id, max_backups=max_backups, excluded_dirs=checked)
|
||||
self.controller.management.set_backup_config(server_id, max_backups=max_backups)
|
||||
|
||||
self.controller.management.add_to_audit_log(exec_user['user_id'],
|
||||
f"Edited server {server_id}: updated backups",
|
||||
|
@ -136,8 +136,15 @@
|
||||
|
||||
/* TODO Update each element */
|
||||
if (server.running){
|
||||
if (server['stats']['waiting_start']){
|
||||
server_status.setAttribute("class", "text-warning");
|
||||
server_status.innerHTML = `{{ translate('serverStats', 'starting', data['lang']) }}`;
|
||||
}
|
||||
else
|
||||
{
|
||||
server_status.setAttribute("class", "text-success");
|
||||
server_status.innerHTML = `{{ translate('serverStats', 'online', data['lang']) }}`;
|
||||
}
|
||||
|
||||
startedUTC = server.started;
|
||||
startedUTC = moment.utc(startedUTC, 'YYYY-MM-DD HH:mm:ss');
|
||||
|
@ -35,8 +35,6 @@
|
||||
|
||||
<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'] }}">
|
||||
@ -56,38 +54,6 @@
|
||||
<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']) }}" >
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="server">{{ translate('serverBackups', 'exclusionsTitle', data['lang']) }} <small> - {{ translate('serverBackups', 'excludedChoose', data['lang']) }}</small></label>
|
||||
<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>
|
||||
</div>
|
||||
<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-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLongTitle">{{ translate('serverBackups', 'excludedChoose', data['lang']) }}</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<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>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
<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-okay" data-dismiss="modal" class="btn btn-primary">{{ translate('serverWizard', 'save', data['lang']) }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
@ -95,10 +61,15 @@
|
||||
</div>
|
||||
|
||||
<div class="col-md-6 col-sm-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">{{ translate('serverBackups', 'currentBackups', data['lang']) }}</h4>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
@ -136,20 +107,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</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">
|
||||
<h4 class="card-title"><i class="fas fa-server"></i> {{ translate('serverBackups', 'excludedBackups', data['lang']) }} <small class="text-muted ml-1"></small> </h4>
|
||||
</div>
|
||||
<br>
|
||||
<ul>
|
||||
{% for item in data['exclusions'] %}
|
||||
<li>{{item}}</li>
|
||||
<br>
|
||||
{% end %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@ -159,44 +116,6 @@
|
||||
|
||||
|
||||
</div>
|
||||
<style>
|
||||
/* Remove default bullets */
|
||||
.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;
|
||||
}
|
||||
</style>
|
||||
<!-- content-wrapper ends -->
|
||||
|
||||
{% end %}
|
||||
@ -204,7 +123,7 @@
|
||||
{% block js %}
|
||||
<script>
|
||||
|
||||
const server_id = new URLSearchParams(document.location.search).get('id')
|
||||
const serverId = 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
|
||||
@ -309,7 +228,7 @@ const server_id = new URLSearchParams(document.location.search).get('id')
|
||||
console.log(result);
|
||||
if (result == true) {
|
||||
var full_path = backup_path + '/' + file_to_del;
|
||||
del_backup(full_path, server_id);
|
||||
del_backup(full_path, serverId);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -327,14 +246,13 @@ const server_id = new URLSearchParams(document.location.search).get('id')
|
||||
label: '<i class="fas fa-times"></i> {{ translate("serverBackups", "cancel", data['lang']) }}'
|
||||
},
|
||||
confirm: {
|
||||
label: '<i class="fas fa-check"></i> {{ translate("serverBackups", "restore", data['lang']) }}',
|
||||
className: 'btn-outline-danger'
|
||||
label: '<i class="fas fa-check"></i> {{ translate("serverBackups", "restore", data['lang']) }}'
|
||||
}
|
||||
},
|
||||
callback: function (result) {
|
||||
console.log(result);
|
||||
if (result == true) {
|
||||
restore_backup(file_to_restore, server_id);
|
||||
restore_backup(file_to_restore, serverId);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -342,139 +260,6 @@ const server_id = new URLSearchParams(document.location.search).get('id')
|
||||
|
||||
});
|
||||
|
||||
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>'
|
||||
})
|
||||
|
||||
document.getElementById("root_files_button").addEventListener("click", function(){
|
||||
if($("#root_files_button").data('server_path') != ""){
|
||||
if(document.getElementById('root_files_button').classList.contains('clicked')){
|
||||
show_file_tree();
|
||||
return;
|
||||
}else{
|
||||
document.getElementById('root_files_button').classList.add('clicked')
|
||||
}
|
||||
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
|
||||
});
|
||||
|
||||
$.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");
|
||||
}
|
||||
});
|
||||
if (webSocket) {
|
||||
webSocket.on('send_temp_path', function (data) {
|
||||
setTimeout(function(){
|
||||
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();
|
||||
|
||||
}, 5000);
|
||||
});
|
||||
}
|
||||
|
||||
function getTreeView(path) {
|
||||
path = path
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: '/ajax/get_backup_tree?id='+server_id+'&path='+path,
|
||||
dataType: 'text',
|
||||
success: function(data){
|
||||
console.log("got response:");
|
||||
console.log(data);
|
||||
|
||||
dataArr = data.split('\n');
|
||||
serverDir = dataArr.shift(); // Remove & return first element (server directory)
|
||||
text = dataArr.join('\n');
|
||||
|
||||
try{
|
||||
document.getElementById('main-tree-div').innerHTML += text;
|
||||
document.getElementById('main-tree').parentElement.classList.add("clicked");
|
||||
}catch{
|
||||
document.getElementById('files-tree').innerHTML = text;
|
||||
}
|
||||
|
||||
|
||||
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');
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
function getDirView(event) {
|
||||
path = event.target.parentElement.getAttribute('data-path');
|
||||
|
||||
if (document.getElementById(path).classList.contains('clicked')){
|
||||
|
||||
var toggler = document.getElementById(path+"span");
|
||||
|
||||
if (toggler.classList.contains('files-tree-title')){
|
||||
document.getElementById(path+"ul").classList.toggle("d-block");
|
||||
document.getElementById(path+"span").classList.toggle("tree-caret-down");
|
||||
}
|
||||
return;
|
||||
}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")
|
||||
}
|
||||
|
||||
var toggler = document.getElementById(path);
|
||||
|
||||
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");
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
function show_file_tree(){
|
||||
$("#dir_select").modal();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
@ -310,6 +310,9 @@
|
||||
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
|
||||
});
|
||||
setTimeout(function(){
|
||||
dialog.modal('hide');
|
||||
}, 5000);
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
headers: {'X-XSRFToken': token},
|
||||
@ -430,20 +433,9 @@ function hide(event) {
|
||||
}
|
||||
if (webSocket) {
|
||||
webSocket.on('send_temp_path', function (data) {
|
||||
setTimeout(function(){
|
||||
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();
|
||||
|
||||
}, 5000);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -437,6 +437,9 @@
|
||||
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
|
||||
});
|
||||
setTimeout(function(){
|
||||
dialog.modal('hide');
|
||||
}, 5000);
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
headers: {'X-XSRFToken': token},
|
||||
@ -584,20 +587,9 @@ function hide(event) {
|
||||
}
|
||||
if (webSocket) {
|
||||
webSocket.on('send_temp_path', function (data) {
|
||||
setTimeout(function(){
|
||||
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();
|
||||
|
||||
}, 5000);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,8 +0,0 @@
|
||||
# Generated by database migrator
|
||||
import peewee
|
||||
|
||||
def migrate(migrator, db):
|
||||
migrator.rename_column('backups', 'directories', 'excluded_dirs')
|
||||
|
||||
def rollback(migrator, db):
|
||||
migrator.rename_column('backups', 'excluded_dirs', 'directories')
|
@ -236,11 +236,7 @@
|
||||
"options": "Options",
|
||||
"restoring": "Restoring Backup. This may take a while. Please be patient.",
|
||||
"restore": "Restore",
|
||||
"confirmRestore": "Are you sure you want to restore from this backup. All current server files will changed to backup state and will be unrecoverable.",
|
||||
"excludedBackups": "Excluded Paths: ",
|
||||
"excludedChoose": "Choose the paths you wish to exclude from your backups",
|
||||
"clickExclude": "Click to select Exclusions",
|
||||
"exclusionsTitle": "Backup Exclusions"
|
||||
"confirmRestore": "Are you sure you want to restore from this backup. All current server files will changed to backup state and will be unrecoverable."
|
||||
},
|
||||
"serverFiles": {
|
||||
"noscript": "The file manager does not work without JavaScript",
|
||||
|
Loading…
Reference in New Issue
Block a user