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

View File

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