From f381562b3b058c22439af82cc599752c089a0091 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Sun, 5 Feb 2023 19:05:20 -0500 Subject: [PATCH] Make monitored mount points user configurable --- app/classes/shared/helpers.py | 1 + app/classes/shared/tasks.py | 1 + app/classes/web/panel_handler.py | 5 + app/frontend/templates/panel/config_json.html | 125 +++++++++++------- app/frontend/templates/panel/dashboard.html | 22 +-- 5 files changed, 97 insertions(+), 57 deletions(-) diff --git a/app/classes/shared/helpers.py b/app/classes/shared/helpers.py index 92226425..1fb09f0a 100644 --- a/app/classes/shared/helpers.py +++ b/app/classes/shared/helpers.py @@ -417,6 +417,7 @@ class Helpers: "allow_nsfw_profile_pictures": False, "enable_user_self_delete": False, "reset_secrets_on_next_boot": False, + "monitored_mounts": [], } def get_all_settings(self): diff --git a/app/classes/shared/tasks.py b/app/classes/shared/tasks.py index c9c1889f..1ba28714 100644 --- a/app/classes/shared/tasks.py +++ b/app/classes/shared/tasks.py @@ -702,6 +702,7 @@ class TasksManager: "disk_usage": json.loads( host_stats.get("disk_json").replace("'", '"') ), + "mounts": self.helper.get_setting("monitored_mounts"), }, ) except: diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index 1f61a702..ff88aad9 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -12,6 +12,7 @@ import bleach import requests import tornado.web import tornado.escape +import psutil from tornado import iostream # TZLocal is set as a hidden import on win pipeline @@ -293,6 +294,7 @@ class PanelHandler(BaseHandler): "background": self.controller.cached_login, "login_opacity": self.controller.management.get_login_opacity(), "serverTZ": tz, + "monitored": self.helper.get_setting("monitored_mounts"), "version_data": self.helper.get_version_string(), "failed_servers": self.controller.servers.failed_servers, "user_data": exec_user, @@ -885,6 +887,9 @@ class PanelHandler(BaseHandler): page_data["config-json"] = data page_data["availables_languages"] = [] page_data["all_languages"] = [] + page_data["all_partitions"] = [] + for item in psutil.disk_partitions(all=False): + page_data["all_partitions"].append(item.mountpoint) for file in sorted( os.listdir( diff --git a/app/frontend/templates/panel/config_json.html b/app/frontend/templates/panel/config_json.html index a5acdcc1..dcea519c 100644 --- a/app/frontend/templates/panel/config_json.html +++ b/app/frontend/templates/panel/config_json.html @@ -6,7 +6,8 @@ {% block title %}Crafty Controller - {{ translate('panelConfig', 'pageTitle', data['lang']) }}{% end %} {% block content %} - +
@@ -50,62 +51,87 @@ {% for item in data['config-json'].items() %} {% if item[0] == "reset_secrets_on_next_boot" %}
- {% else %} -
- {% end %} -
- {% if item[0] == 'language' %} - - {% elif item[0] == 'disabled_language_files' %} -
- - + {% for lang in data['availables_languages'] %} + {% if lang == item[1] %} {% else %} {% end %} {% end %} - + {% elif item[0] == 'disabled_language_files' %} +
+ + + +
+ {% elif item[0] == 'monitored_mounts'%} +
+ + + +
+ {% elif isinstance(item[1], list) %} + + {% elif isinstance(item[1], bool) %} +
+ {% if item[1] == True %} + +  
+ +   + {% else %} + +  
+ +   + {% end %} +
+ {% elif isinstance(item[1], int) %} + + {% else %} + + {% end %}
- {% elif isinstance(item[1], list) %} - - {% elif isinstance(item[1], bool) %} -
- {% if item[1] == True %} - -  
- -   - {% else %} - -  
- -   {% end %} -
- {% elif isinstance(item[1], int) %} - - {% else %} - - {% end %} -
- {% end %} -   +  
@@ -153,6 +179,9 @@ let selected_Lang = $('#lang_select').val(); $('#disabled_lang').val(selected_Lang); + let mounts = $('#mount_select').val(); + $('#monitored_mounts').val(mounts); + let class_list = document.getElementsByClassName("list"); let form_json = convertFormToJSON($("#config-form")); for (let i = 0; i < class_list.length; i++) { diff --git a/app/frontend/templates/panel/dashboard.html b/app/frontend/templates/panel/dashboard.html index ccaed1b0..4493afd5 100644 --- a/app/frontend/templates/panel/dashboard.html +++ b/app/frontend/templates/panel/dashboard.html @@ -109,6 +109,7 @@
@@ -926,24 +928,26 @@ var storage_html = '`; $("#storage_data").html(storage_html);