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,17 +965,18 @@ 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):
output += f"""<li class="tree-item" data-path="{dpath}"> if filename not in self.ignored_names:
\n<div id="{dpath}" data-path="{dpath}" data-name="{filename}" class="tree-caret tree-ctx-item tree-folder"> output += f"""<li class="tree-item" data-path="{dpath}">
<span id="{dpath}span" class="files-tree-title" data-path="{dpath}" data-name="{filename}" onclick="getDirView(event)"> \n<div id="{dpath}" data-path="{dpath}" data-name="{filename}" class="tree-caret tree-ctx-item tree-folder">
<i style="color: var(--info);" class="far fa-folder"></i> <span id="{dpath}span" class="files-tree-title" data-path="{dpath}" data-name="{filename}" onclick="getDirView(event)">
<i style="color: var(--info);" class="far fa-folder-open"></i> <i style="color: var(--info);" class="far fa-folder"></i>
{filename} <i style="color: var(--info);" class="far fa-folder-open"></i>
</span> {filename}
</div><li> </span>
\n""" </div><li>
\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,16 +1004,17 @@ 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):
output += f"""<li class="tree-item" data-path="{dpath}"> if filename not in self.ignored_names:
\n<div id="{dpath}" data-path="{dpath}" data-name="{filename}" class="tree-caret tree-ctx-item tree-folder"> output += f"""<li class="tree-item" data-path="{dpath}">
<span id="{dpath}span" class="files-tree-title" data-path="{dpath}" data-name="{filename}" onclick="getDirView(event)"> \n<div id="{dpath}" data-path="{dpath}" data-name="{filename}" class="tree-caret tree-ctx-item tree-folder">
<i style="color: var(--info);" class="far fa-folder"></i> <span id="{dpath}span" class="files-tree-title" data-path="{dpath}" data-name="{filename}" onclick="getDirView(event)">
<i style="color: var(--info);" class="far fa-folder-open"></i> <i style="color: var(--info);" class="far fa-folder"></i>
{filename} <i style="color: var(--info);" class="far fa-folder-open"></i>
</span> {filename}
</div><li>""" </span>
</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()