From fd6294ff3cfd4c08bd4bd037ee12bb8a053fee3b Mon Sep 17 00:00:00 2001 From: Marc Aubreville Date: Fri, 15 Nov 2024 16:07:24 +0100 Subject: [PATCH] Added panel for showing currently available space in menu bar. --- exact/exact/base/context_processors.py | 17 +++++++++++++++++ exact/exact/base/templates/base/base.html | 15 ++++++++++++++- exact/exact/settings_base.py | 2 ++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/exact/exact/base/context_processors.py b/exact/exact/base/context_processors.py index 0e9d2855..df1adfb9 100644 --- a/exact/exact/base/context_processors.py +++ b/exact/exact/base/context_processors.py @@ -3,6 +3,11 @@ from exact.processing.models import PluginJob from exact.tagger_messages.models import TeamMessage from django.db.models import Q +from django.core.cache import cache +import shutil + + + def base_data(request): @@ -20,6 +25,13 @@ def base_data(request): unread_message_count = 0 processing_queue = 0 + storage_memory_data = cache.get('storage_memory_data') + if not storage_memory_data: + total,used,free = shutil.disk_usage(settings.IMAGE_PATH) + storage_memory_data = {'used_tb':round(used/1024/1024/1024/1024*10)/10, + 'free_tb':round(free/1024/1024/1024/1024*10)/10, + 'total_tb': 0.1*round(10*total/1024/1024/1024/1024)} + cache.set('storage_memory_data', storage_memory_data, 60) return { @@ -27,8 +39,13 @@ def base_data(request): 'USE_IMPRINT': settings.USE_IMPRINT, 'IMPRINT_NAME': settings.IMPRINT_NAME, 'TOOLS_ENABLED': settings.TOOLS_ENABLED, + 'SHOW_AVAILABLE_SPACE' : settings.SHOW_AVAILABLE_SPACE, 'my_teams': my_teams, 'frontend' : request.user.ui.frontend if hasattr(request.user,'ui') and hasattr(request.user.ui,'frontend') and request.user.ui.frontend else 1, + 'free_tb' : storage_memory_data['free_tb'], + 'used_tb' : storage_memory_data['used_tb'], + 'total_tb' : storage_memory_data['total_tb'], + 'warn_memory' : storage_memory_data['free_tb']/storage_memory_data['total_tb'] < 0.05, 'unread_message_count': unread_message_count, 'processing_queue': processing_queue, 'show_processing_panel' : show_processing_panel, diff --git a/exact/exact/base/templates/base/base.html b/exact/exact/base/templates/base/base.html index fd845945..81ece90b 100644 --- a/exact/exact/base/templates/base/base.html +++ b/exact/exact/base/templates/base/base.html @@ -16,6 +16,7 @@ {% endblock %} EXACT Label Server + @@ -39,7 +40,17 @@