Skip to content

Commit

Permalink
splitting in disk and project distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardKoschicek committed Apr 23, 2024
1 parent d2781d8 commit 3a25900
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 40 deletions.
133 changes: 94 additions & 39 deletions openatlas/templates/file.html
Original file line number Diff line number Diff line change
@@ -1,73 +1,128 @@
<div style="float:left;">
{{ info|display_info|safe }}
{% if disk_space_info %}
<h1>
{{ _('local disk usage') }}
</h1>
<div class="progress">
<div
class="progress-bar bg-primary"
role="progressbar"
style="width: {{ disk_space_info.percent_used - disk_space_info.percent_project }}%"
aria-valuenow="{{ disk_space_info.percent_used - disk_space_info.percent_project }}"
aria-valuemin="0"
aria-valuemax="100">
class="progress-bar bg-primary"
role="progressbar"
style="width: {{ disk_space_info.percent_used - disk_space_info.percent_project }}%"
aria-valuenow="{{ disk_space_info.percent_used - disk_space_info.percent_project }}"
aria-valuemin="0"
aria-valuemax="100">
<b>{{ disk_space_info.percent_used - disk_space_info.percent_project }}%</b>
</div>
<div
class="progress-bar bg-warning"
role="progressbar"
style="width: {{ disk_space_info.percent_project }}%"
aria-valuenow="{{ disk_space_info.percent_project }}"
aria-valuemin="0"
aria-valuemax="100">
class="progress-bar bg-warning"
role="progressbar"
style="width: {{ disk_space_info.percent_project }}%"
aria-valuenow="{{ disk_space_info.percent_project }}"
aria-valuemin="0"
aria-valuemax="100">
<b>{{ disk_space_info.percent_project }}%</b>
</div>
<div
class="progress-bar bg-gray"
role="progressbar"
style="width: {{ 100 - disk_space_info.percent_used }}%"
aria-valuenow="{{ 100 - disk_space_info.percent_used }}"
aria-valuemin="0"
aria-valuemax="100">
class="progress-bar bg-gray"
role="progressbar"
style="width: {{ 100 - disk_space_info.percent_used }}%"
aria-valuenow="{{ 100 - disk_space_info.percent_used }}"
aria-valuemin="0"
aria-valuemax="100">
<b class="text-dark">{{ 100 - disk_space_info.percent_used }}%</b>
</div>
</div>
<div>
<p class="mb-1">
{{ _('total disk space')|uc_first }} <strong>{{ disk_space_info.total }}</strong>
{{ _('total disk space')|uc_first }}
<strong>{{ disk_space_info.total }}</strong>
</p>
<p class="mb-1">
{{ _('non project files')|uc_first }} <strong>{{ disk_space_info.other_files }}</strong>
<span class="bg-primary d-inline-block ml-2 disk-space-legend"></span>
{{ _('non project files')|uc_first }}
<strong>{{ disk_space_info.other_files }}</strong>
</p>
<p class="mb-1">
{{ _('project files')|uc_first }} <strong>{{ disk_space_info.project }}</strong>
<span class="bg-warning d-inline-block ml-2 disk-space-legend"></span>
{{ _('project files')|uc_first }}
<strong>{{ disk_space_info.project }}</strong>
</p>
<p class="mb-1">
{{ _('export')|uc_first }} <strong>{{ disk_space_info.export }}</strong>
<span class="bg-warning d-inline-block ml-2 disk-space-legend"></span>
</p>
<p class="mb-1">
{{ _('upload')|uc_first }} <strong>{{ disk_space_info.upload }}</strong>
<span class="bg-warning d-inline-block ml-2 disk-space-legend"></span>
</p>
<p class="mb-1">
{{ _('processed')|uc_first }} <strong>{{ disk_space_info.processed }}</strong>
<span class="bg-warning d-inline-block ml-2 disk-space-legend"></span>
</p>
<p class="mb-1">
{{ _('iiif')|uc_first }} <strong>{{ disk_space_info.iiif }}</strong>
<span class="bg-warning d-inline-block ml-2 disk-space-legend"></span>
</p>
<p class="mb-1">
{{ _('free disk space')|uc_first }} <strong>{{ disk_space_info.free }}</strong>
<span class="bg-gray d-inline-block ml-2 disk-space-legend"></span>
{{ _('free disk space')|uc_first }}
<strong>{{ disk_space_info.free }}</strong>
</p>
</div>
<h1>
{{ _('distribution of project files') }}
</h1>
<div class="progress">
<div
class="progress-bar bg-danger"
role="progressbar"
style="width: {{ disk_space_info.percent_upload }}%"
aria-valuenow="{{ disk_space_info.percent_upload }}"
aria-valuemin="0"
aria-valuemax="100">
<b>{{ disk_space_info.percent_upload }}%</b>
</div>
<div
class="progress-bar bg-success"
role="progressbar"
style="width: {{ disk_space_info.percent_export }}%"
aria-valuenow="{{ disk_space_info.percent_export }}"
aria-valuemin="0"
aria-valuemax="100">
<b>{{ disk_space_info.percent_export }}%</b>
</div>
<div
class="progress-bar bg-info"
role="progressbar"
style="width: {{ disk_space_info.percent_processed }}%"
aria-valuenow="{{ disk_space_info.percent_processed }}"
aria-valuemin="0"
aria-valuemax="100">
<b class="text-dark">{{ disk_space_info.percent_processed }}%</b>
</div>
<div
class="progress-bar bg-dark"
role="progressbar"
style="width: {{ disk_space_info.percent_iiif }}%"
aria-valuenow="{{ disk_space_info.percent_iiif }}"
aria-valuemin="0"
aria-valuemax="100">
<b>{{ disk_space_info.percent_iiif }}%</b>
</div>
</div>
<div>
<p class="mb-1">
<span class="bg-danger d-inline-block ml-2 disk-space-legend"></span>
{{ _('upload folder')|uc_first }}
<strong>{{ disk_space_info.upload }}</strong>
</p>
<p class="mb-1">
<span class="bg-success d-inline-block ml-2 disk-space-legend"></span>
{{ _('export folder')|uc_first }}
<strong>{{ disk_space_info.export }}</strong>
</p>
<p class="mb-1">
<span class="bg-info d-inline-block ml-2 disk-space-legend"></span>
{{ _('processed images folder')|uc_first }}
<strong>{{ disk_space_info.processed }}</strong>
</p>
<p class="mb-1">
<span class="bg-dark d-inline-block ml-2 disk-space-legend"></span>
{{ _('iiif folder')|uc_first }}
<strong>{{ disk_space_info.iiif }}</strong>
</p>
</div>
{% endif %}
</div>
{% if 'manager'|is_authorized %}
<div style="float:left;margin-left:2em;">
<img src="{{ get_logo|safe }}" id="logo-preview" alt="Logo" style="max-width:400px;"><br>
<img src="{{ get_logo|safe }}" id="logo-preview" alt="Logo"
style="max-width:400px;"><br>
<div class="toolbar">
{% if g.settings.logo_file_id %}
{{ _('remove custom logo')|button(url_for('logo_remove'))|safe }}
Expand Down
10 changes: 9 additions & 1 deletion openatlas/views/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ def admin_delete_orphaned_resized_images() -> Response:


def get_disk_space_info() -> Optional[dict[str, Any]]:
export, upload, processed, iiif = 0,0,0,0
export, upload, processed, iiif = 0, 0, 0, 0
if os.name == 'posix':
process = run(
['du', '-sb', app.config['EXPORT_PATH']],
Expand Down Expand Up @@ -852,6 +852,10 @@ def get_disk_space_info() -> Optional[dict[str, Any]]:
stats = shutil.disk_usage(app.config['UPLOAD_PATH'])
percent_free = 100 - math.ceil(stats.free / (stats.total / 100))
percent_files = math.ceil(files_size / (stats.total / 100))
percent_export = math.ceil(export / (files_size / 100))
percent_upload = math.ceil(upload / (files_size / 100))
percent_processed = math.ceil(processed / (files_size / 100))
percent_iiif = math.ceil(iiif / (files_size / 100))
other_files = stats.total - stats.free - files_size
return {
'total': convert_size(stats.total),
Expand All @@ -864,6 +868,10 @@ def get_disk_space_info() -> Optional[dict[str, Any]]:
'free': convert_size(stats.free),
'percent_used': percent_free,
'percent_project': percent_files,
'percent_export': percent_export,
'percent_upload': percent_upload,
'percent_processed': percent_processed,
'percent_iiif': percent_iiif,
'percent_other': 100 - (percent_files + percent_free)}


Expand Down

0 comments on commit 3a25900

Please sign in to comment.