Merge branch 'tweak/server-stats-db-hidden' into 'dev'

Hide stats DB directory from files tree

See merge request crafty-controller/crafty-4!530
This commit is contained in:
Iain Powrie 2023-01-29 19:12:18 +00:00
commit dd26569649
3 changed files with 27 additions and 25 deletions

View File

@ -7,6 +7,7 @@
- Fix Schedule Restore | Add Backup Config Preservation. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/533))
- Rework `/public` Route. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/538))
### Tweaks
- Hide stats DB directory from files tree. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/530))
- Added further login screen customisation settings. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/531))
- Set backup filename to use same time as schedule. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/534))
- Move Schedules to from DB to Queue Datatype. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/535))

View File

@ -78,6 +78,7 @@ class Helpers:
self.websocket_helper = WebSocketHelper(self)
self.translation = Translation(self)
self.update_available = False
self.ignored_names = ["crafty_managed.txt", "db_stats"]
@staticmethod
def auto_installer_fix(ex):
@ -947,8 +948,7 @@ class Helpers:
return data
@staticmethod
def generate_tree(folder, output=""):
def generate_tree(self, folder, output=""):
dir_list = []
unsorted_files = []
file_list = os.listdir(folder)
@ -965,6 +965,7 @@ class Helpers:
rel = os.path.join(folder, raw_filename)
dpath = os.path.join(folder, filename)
if os.path.isdir(rel):
if filename not in self.ignored_names:
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">
<span id="{dpath}span" class="files-tree-title" data-path="{dpath}" data-name="{filename}" onclick="getDirView(event)">
@ -975,7 +976,7 @@ class Helpers:
</div><li>
\n"""
else:
if filename != "crafty_managed.txt":
if filename not in self.ignored_names:
output += f"""<li
class="d-block tree-ctx-item tree-file tree-item"
data-path="{dpath}"
@ -984,8 +985,7 @@ class Helpers:
<i class="far fa-file"></i></span>{filename}</li>"""
return output
@staticmethod
def generate_dir(folder, output=""):
def generate_dir(self, folder, output=""):
dir_list = []
unsorted_files = []
@ -1004,6 +1004,7 @@ class Helpers:
dpath = os.path.join(folder, filename)
rel = os.path.join(folder, raw_filename)
if os.path.isdir(rel):
if filename not in self.ignored_names:
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">
<span id="{dpath}span" class="files-tree-title" data-path="{dpath}" data-name="{filename}" onclick="getDirView(event)">
@ -1013,7 +1014,7 @@ class Helpers:
</span>
</div><li>"""
else:
if filename != "crafty_managed.txt":
if filename not in self.ignored_names:
output += f"""<li
class="d-block tree-ctx-item tree-file tree-item"
data-path="{dpath}"

View File

@ -100,7 +100,7 @@ class FileHandler(BaseHandler):
self.write(
Helpers.get_os_understandable_path(path)
+ "\n"
+ Helpers.generate_tree(path)
+ self.helper.generate_tree(path)
)
self.finish()
@ -121,7 +121,7 @@ class FileHandler(BaseHandler):
self.write(
Helpers.get_os_understandable_path(path)
+ "\n"
+ Helpers.generate_dir(path)
+ self.helper.generate_dir(path)
)
self.finish()