mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Remove unnecessary logs, update logs to have more information, add resizing to file editor
This commit is contained in:
parent
509c801436
commit
6b2ef2c451
@ -471,9 +471,7 @@ class Helpers:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def generate_tree(folder, output=""):
|
def generate_tree(folder, output=""):
|
||||||
for raw_filename in os.listdir(folder):
|
for raw_filename in os.listdir(folder):
|
||||||
print(raw_filename)
|
|
||||||
filename = html.escape(raw_filename)
|
filename = html.escape(raw_filename)
|
||||||
print(filename)
|
|
||||||
rel = os.path.join(folder, raw_filename)
|
rel = os.path.join(folder, raw_filename)
|
||||||
if os.path.isdir(rel):
|
if os.path.isdir(rel):
|
||||||
output += \
|
output += \
|
||||||
@ -485,7 +483,6 @@ class Helpers:
|
|||||||
output += helper.generate_tree(rel)
|
output += helper.generate_tree(rel)
|
||||||
output += '</ul>\n</li>'
|
output += '</ul>\n</li>'
|
||||||
else:
|
else:
|
||||||
console.debug('os.path.isdir(rel): "{}", rel: "{}"'.format(os.path.isdir(rel), rel))
|
|
||||||
output += """<li
|
output += """<li
|
||||||
class="tree-item tree-ctx-item tree-file"
|
class="tree-item tree-ctx-item tree-file"
|
||||||
data-path="{}"
|
data-path="{}"
|
||||||
|
@ -57,7 +57,7 @@ class AjaxHandler(BaseHandler):
|
|||||||
self.redirect("/panel/error?error=Server ID Not Found")
|
self.redirect("/panel/error?error=Server ID Not Found")
|
||||||
|
|
||||||
if server_data['log_path']:
|
if server_data['log_path']:
|
||||||
logger.warning("Server ID not found in server_log ajax call")
|
logger.warning("Server ID not found in server_log ajax call ({})".format(server_id))
|
||||||
|
|
||||||
if full_log:
|
if full_log:
|
||||||
log_lines = helper.get_setting('max_log_lines')
|
log_lines = helper.get_setting('max_log_lines')
|
||||||
@ -94,21 +94,20 @@ class AjaxHandler(BaseHandler):
|
|||||||
|
|
||||||
# does this server id exist?
|
# does this server id exist?
|
||||||
if not db_helper.server_id_exists(server_id):
|
if not db_helper.server_id_exists(server_id):
|
||||||
logger.warning("Server ID not found in get_file ajax call")
|
logger.warning("Server ID not found in get_file ajax call ({})".format(server_id))
|
||||||
console.warning("Server ID not found in get_file ajax call")
|
console.warning("Server ID not found in get_file ajax call ({})".format(server_id))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not helper.in_path(db_helper.get_server_data_by_id(server_id)['path'], file_path)\
|
if not helper.in_path(db_helper.get_server_data_by_id(server_id)['path'], file_path)\
|
||||||
or not helper.check_file_exists(os.path.abspath(file_path)):
|
or not helper.check_file_exists(os.path.abspath(file_path)):
|
||||||
logger.warning("Invalid path in get_file ajax call")
|
logger.warning("Invalid path in get_file ajax call ({})".format(file_path))
|
||||||
console.warning("Invalid path in get_file ajax call")
|
console.warning("Invalid path in get_file ajax call ({})".format(file_path))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
file = open(file_path)
|
file = open(file_path)
|
||||||
file_contents = file.read()
|
file_contents = file.read()
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
console.debug("Send file contents")
|
|
||||||
self.write(file_contents)
|
self.write(file_contents)
|
||||||
self.finish()
|
self.finish()
|
||||||
|
|
||||||
@ -124,8 +123,8 @@ class AjaxHandler(BaseHandler):
|
|||||||
|
|
||||||
# does this server id exist?
|
# does this server id exist?
|
||||||
if not db_helper.server_id_exists(server_id):
|
if not db_helper.server_id_exists(server_id):
|
||||||
logger.warning("Server ID not found in get_file ajax call")
|
logger.warning("Server ID not found in get_file ajax call ({})".format(server_id))
|
||||||
console.warning("Server ID not found in get_file ajax call")
|
console.warning("Server ID not found in get_file ajax call ({})".format(server_id))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.write(db_helper.get_server_data_by_id(server_id)['path'] + '\n' +
|
self.write(db_helper.get_server_data_by_id(server_id)['path'] + '\n' +
|
||||||
@ -172,14 +171,14 @@ class AjaxHandler(BaseHandler):
|
|||||||
|
|
||||||
# does this server id exist?
|
# does this server id exist?
|
||||||
if not db_helper.server_id_exists(server_id):
|
if not db_helper.server_id_exists(server_id):
|
||||||
logger.warning("Server ID not found in create_file ajax call")
|
logger.warning("Server ID not found in create_file ajax call ({})".format(server_id))
|
||||||
console.warning("Server ID not found in create_file ajax call")
|
console.warning("Server ID not found in create_file ajax call ({})".format(server_id))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not helper.in_path(db_helper.get_server_data_by_id(server_id)['path'], file_path) \
|
if not helper.in_path(db_helper.get_server_data_by_id(server_id)['path'], file_path) \
|
||||||
or helper.check_file_exists(os.path.abspath(file_path)):
|
or helper.check_file_exists(os.path.abspath(file_path)):
|
||||||
logger.warning("Invalid path in create_file ajax call")
|
logger.warning("Invalid path in create_file ajax call ({})".format(file_path))
|
||||||
console.warning("Invalid path in create_file ajax call")
|
console.warning("Invalid path in create_file ajax call ({})".format(file_path))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Create the file by opening it
|
# Create the file by opening it
|
||||||
@ -202,14 +201,14 @@ class AjaxHandler(BaseHandler):
|
|||||||
|
|
||||||
# does this server id exist?
|
# does this server id exist?
|
||||||
if not db_helper.server_id_exists(server_id):
|
if not db_helper.server_id_exists(server_id):
|
||||||
logger.warning("Server ID not found in create_dir ajax call")
|
logger.warning("Server ID not found in create_dir ajax call ({})".format(server_id))
|
||||||
console.warning("Server ID not found in create_dir ajax call")
|
console.warning("Server ID not found in create_dir ajax call ({})".format(server_id))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not helper.in_path(db_helper.get_server_data_by_id(server_id)['path'], dir_path) \
|
if not helper.in_path(db_helper.get_server_data_by_id(server_id)['path'], dir_path) \
|
||||||
or helper.check_path_exists(os.path.abspath(dir_path)):
|
or helper.check_path_exists(os.path.abspath(dir_path)):
|
||||||
logger.warning("Invalid path in create_dir ajax call")
|
logger.warning("Invalid path in create_dir ajax call ({})".format(dir_path))
|
||||||
console.warning("Invalid path in create_dir ajax call")
|
console.warning("Invalid path in create_dir ajax call ({})".format(dir_path))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Create the directory
|
# Create the directory
|
||||||
@ -231,14 +230,14 @@ class AjaxHandler(BaseHandler):
|
|||||||
|
|
||||||
# does this server id exist?
|
# does this server id exist?
|
||||||
if not db_helper.server_id_exists(server_id):
|
if not db_helper.server_id_exists(server_id):
|
||||||
logger.warning("Server ID not found in del_file ajax call")
|
logger.warning("Server ID not found in del_file ajax call ({})".format(server_id))
|
||||||
console.warning("Server ID not found in del_file ajax call")
|
console.warning("Server ID not found in del_file ajax call ({})".format(server_id))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not helper.in_path(db_helper.get_server_data_by_id(server_id)['path'], file_path) \
|
if not helper.in_path(db_helper.get_server_data_by_id(server_id)['path'], file_path) \
|
||||||
or not helper.check_file_exists(os.path.abspath(file_path)):
|
or not helper.check_file_exists(os.path.abspath(file_path)):
|
||||||
logger.warning("Invalid path in del_file ajax call")
|
logger.warning("Invalid path in del_file ajax call ({})".format(file_path))
|
||||||
console.warning("Invalid path in del_file ajax call")
|
console.warning("Invalid path in del_file ajax call ({})".format(file_path))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Delete the file
|
# Delete the file
|
||||||
@ -258,14 +257,14 @@ class AjaxHandler(BaseHandler):
|
|||||||
|
|
||||||
# does this server id exist?
|
# does this server id exist?
|
||||||
if not db_helper.server_id_exists(server_id):
|
if not db_helper.server_id_exists(server_id):
|
||||||
logger.warning("Server ID not found in del_file ajax call")
|
logger.warning("Server ID not found in del_file ajax call ({})".format(server_id))
|
||||||
console.warning("Server ID not found in del_file ajax call")
|
console.warning("Server ID not found in del_file ajax call ({})".format(server_id))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not helper.in_path(db_helper.get_server_data_by_id(server_id)['path'], dir_path) \
|
if not helper.in_path(db_helper.get_server_data_by_id(server_id)['path'], dir_path) \
|
||||||
or not helper.check_path_exists(os.path.abspath(dir_path)):
|
or not helper.check_path_exists(os.path.abspath(dir_path)):
|
||||||
logger.warning("Invalid path in del_file ajax call")
|
logger.warning("Invalid path in del_file ajax call ({})".format(dir_path))
|
||||||
console.warning("Invalid path in del_file ajax call")
|
console.warning("Invalid path in del_file ajax call ({})".format(dir_path))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Delete the file
|
# Delete the file
|
||||||
@ -291,14 +290,14 @@ class AjaxHandler(BaseHandler):
|
|||||||
|
|
||||||
# does this server id exist?
|
# does this server id exist?
|
||||||
if not db_helper.server_id_exists(server_id):
|
if not db_helper.server_id_exists(server_id):
|
||||||
logger.warning("Server ID not found in save_file ajax call")
|
logger.warning("Server ID not found in save_file ajax call ({})".format(server_id))
|
||||||
console.warning("Server ID not found in save_file ajax call")
|
console.warning("Server ID not found in save_file ajax call ({})".format(server_id))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not helper.in_path(db_helper.get_server_data_by_id(server_id)['path'], file_path)\
|
if not helper.in_path(db_helper.get_server_data_by_id(server_id)['path'], file_path)\
|
||||||
or not helper.check_file_exists(os.path.abspath(file_path)):
|
or not helper.check_file_exists(os.path.abspath(file_path)):
|
||||||
logger.warning("Invalid path in save_file ajax call")
|
logger.warning("Invalid path in save_file ajax call ({})".format(file_path))
|
||||||
console.warning("Invalid path in save_file ajax call")
|
console.warning("Invalid path in save_file ajax call ({})".format(file_path))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Open the file in write mode and store the content in file_object
|
# Open the file in write mode and store the content in file_object
|
||||||
@ -312,35 +311,35 @@ class AjaxHandler(BaseHandler):
|
|||||||
print(server_id)
|
print(server_id)
|
||||||
|
|
||||||
if server_id is None:
|
if server_id is None:
|
||||||
logger.warning("Server ID not found in rename_item ajax call")
|
logger.warning("Server ID not found in rename_item ajax call ({})".format(server_id))
|
||||||
console.warning("Server ID not found in rename_item ajax call")
|
console.warning("Server ID not found in rename_item ajax call ({})".format(server_id))
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
server_id = bleach.clean(server_id)
|
server_id = bleach.clean(server_id)
|
||||||
|
|
||||||
# does this server id exist?
|
# does this server id exist?
|
||||||
if not db_helper.server_id_exists(server_id):
|
if not db_helper.server_id_exists(server_id):
|
||||||
logger.warning("Server ID not found in rename_item ajax call (1)")
|
logger.warning("Server ID not found in rename_item ajax call ({})".format(server_id))
|
||||||
console.warning("Server ID not found in rename_item ajax call (1)")
|
console.warning("Server ID not found in rename_item ajax call ({})".format(server_id))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if item_path is None or new_item_name is None:
|
if item_path is None or new_item_name is None:
|
||||||
logger.warning("Invalid path in rename_item ajax call (2)")
|
logger.warning("Invalid path in rename_item ajax call")
|
||||||
console.warning("Invalid path in rename_item ajax call (2)")
|
console.warning("Invalid path in rename_item ajax call")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not helper.in_path(db_helper.get_server_data_by_id(server_id)['path'], item_path) \
|
if not helper.in_path(db_helper.get_server_data_by_id(server_id)['path'], item_path) \
|
||||||
or not helper.check_path_exists(os.path.abspath(item_path)):
|
or not helper.check_path_exists(os.path.abspath(item_path)):
|
||||||
logger.warning("Invalid path in rename_item ajax call (3)")
|
logger.warning("Invalid path in rename_item ajax call ({})".format(server_id))
|
||||||
console.warning("Invalid path in rename_item ajax call (3)")
|
console.warning("Invalid path in rename_item ajax call ({})".format(server_id))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
new_item_path = os.path.join(os.path.split(item_path)[0], new_item_name)
|
new_item_path = os.path.join(os.path.split(item_path)[0], new_item_name)
|
||||||
|
|
||||||
if not helper.in_path(db_helper.get_server_data_by_id(server_id)['path'], new_item_path) \
|
if not helper.in_path(db_helper.get_server_data_by_id(server_id)['path'], new_item_path) \
|
||||||
or helper.check_path_exists(os.path.abspath(new_item_path)):
|
or helper.check_path_exists(os.path.abspath(new_item_path)):
|
||||||
logger.warning("Invalid path 2 in rename_item ajax call")
|
logger.warning("Invalid path 2 in rename_item ajax call ({})".format(server_id))
|
||||||
console.warning("Invalid path 2 in rename_item ajax call")
|
console.warning("Invalid path 2 in rename_item ajax call ({})".format(server_id))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# RENAME
|
# RENAME
|
||||||
|
@ -182,7 +182,7 @@
|
|||||||
</style>
|
</style>
|
||||||
<div class="col-md-6 col-sm-12">
|
<div class="col-md-6 col-sm-12">
|
||||||
Editing file <span id="editingFile"></span>
|
Editing file <span id="editingFile"></span>
|
||||||
<div id="editor">file_contents</div>
|
<div id="editor" style="resize: both;">file_contents</div>
|
||||||
<h3 id="file_warn"></h3>
|
<h3 id="file_warn"></h3>
|
||||||
<button class="btn btn-success" onclick="save()">Save</button>
|
<button class="btn btn-success" onclick="save()">Save</button>
|
||||||
</div>
|
</div>
|
||||||
@ -217,6 +217,11 @@
|
|||||||
editor.setTheme('ace/theme/dracula');
|
editor.setTheme('ace/theme/dracula');
|
||||||
editor.session.setUseSoftTabs(true);
|
editor.session.setUseSoftTabs(true);
|
||||||
|
|
||||||
|
// mouseup = css resize end
|
||||||
|
document.addEventListener("mouseup", function(e){
|
||||||
|
editor.resize();
|
||||||
|
});
|
||||||
|
|
||||||
let extensionChanges = [
|
let extensionChanges = [
|
||||||
{
|
{
|
||||||
regex: /^js$/,
|
regex: /^js$/,
|
||||||
|
Loading…
Reference in New Issue
Block a user