Skip to content

Commit

Permalink
Added panel for showing currently available space in menu bar.
Browse files Browse the repository at this point in the history
  • Loading branch information
maubreville committed Nov 15, 2024
1 parent 7d1ebed commit fd6294f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
17 changes: 17 additions & 0 deletions exact/exact/base/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -20,15 +25,27 @@ 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 {
'IMPRINT_URL': settings.IMPRINT_URL,
'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,
Expand Down
15 changes: 14 additions & 1 deletion exact/exact/base/templates/base/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

{% endblock %}
<title>EXACT Label Server</title>

</head>

<body>
Expand All @@ -39,7 +40,17 @@

<div id="navbar" class="navbar-collapse collapse">
{% endif %}
<ul class="nav navbar-nav ml-auto">


{% if SHOW_AVAILABLE_SPACE %}
<div id="spaceNotifier" class="badge {% if warn_memory %} bg-danger {% else %} bg-secondary {% endif %}ml-auto">
<div>Used: {{ used_tb }} TB</div>
<div>Free: {{ free_tb }} TB</div>
</div>
{% endif %}


<ul class="nav navbar-nav ml-auto">
<li class="nav-item"><a href="{% url 'images:index' %}" class="nav-link">Home</a>
</li>
{% block navblock %}{% endblock %}
Expand Down Expand Up @@ -68,6 +79,8 @@
{% endif %}




<li class="nav-item dropdown">
<a href="#" class="dropdown-toggle nav-link" data-toggle="dropdown" role="button"
aria-haspopup="true" aria-expanded="false" id="administrationNavbarDropdown">
Expand Down
2 changes: 2 additions & 0 deletions exact/exact/settings_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@
MEDIA_ROOT= os.path.join(BASE_DIR, 'media')
MEDIA_URL= "/media/"

SHOW_AVAILABLE_SPACE = True # Show how much space is still available on main drive

SHOW_DEMO_DATASETS = False

SHOW_PROCESSING_PANEL = False
Expand Down

0 comments on commit fd6294f

Please sign in to comment.