Skip to content

Commit

Permalink
updates in signal processing
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-dvorak committed Apr 5, 2024
1 parent e0a3ba0 commit 4fa5e1c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 14 deletions.
3 changes: 3 additions & 0 deletions DOSPORTAL/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ def __str__(self) -> str:
def description_formatted(self):
return markdownify(self.description)

@property
def formatted_label(self):
return f"""<a class='btn btn-sm btn-info' href='{self.get_absolute_url()}'> <i class='bi bi-cpu-fill'></i> {self.name}</a>"""



Expand Down
3 changes: 2 additions & 1 deletion DOSPORTAL/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ def save_record(sender, instance, created = None, **kwargs):
new_columns = ['time'] + list(range(df_spectrum.shape[1] - 1))
df_spectrum.columns = new_columns

duration = df_spectrum['time'].max()
df_spectrum['time'] = df_spectrum['time'].astype(float)
duration = df_spectrum['time'].max() - df_spectrum['time'].min()
instance.record_duration = datetime.timedelta(seconds=float(duration))

new_name = instance.user_directory_path_data('pk')
Expand Down
21 changes: 12 additions & 9 deletions DOSPORTAL/templates/detectors/detectors_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@
</div>
{%endif%}
<ul>
<li><strong>Serial number:</strong> {{ detector.sn }}</a>
<li><strong>Type:</strong> <a href="/detector_type/{{ detector.type.id }}/">{{ detector.type }}</a>
<li><strong>Advanced metadata:</strong></li>
<li><strong>Serial number:</strong> <span class="btn btn-sm btn-outline-success">{{detector.sn}}</span></a>
<li><strong>Type:</strong> {{ detector.type.formatted_label|safe }}</a>
{% comment %}<li><strong>Advanced metadata:</strong></li> {% endcomment}
<span class="ml-3">{{detector.data}}</span>
<li><strong>Measurements conducted with this detector:</strong>
<ul>
{%for record in detector.records.all %}
<li> <a href="/measurement/{{ record.measurement.id }}/">{{ record.measurement }}</a>
{%endfor%}
</ul>

{% comment %}
<li><strong>Measurements conducted with this detector:</strong>
<ul>
{%for record in detector.records.all %}
<li> <a href="/measurement/{{ record.measurement.id }}/">{{ record.measurement }}</a>
{%endfor%}
</ul>
{% endcomment %}

<li><strong>Records created with this detector:</strong>
<ul>
Expand Down
5 changes: 3 additions & 2 deletions DOSPORTAL/templates/organizations/organization_profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
{% endfor %}
</div>



</div>

<hr>
Expand All @@ -31,6 +29,8 @@ <h2>Detectors</h2>

<a href="{% url 'detector-view' pk=detector.pk %}"> {{detector}}</a> <br>
{% endfor %}

{% comment %}
<hr>
<h2>Maintainer of detectors:</h2>

Expand All @@ -39,6 +39,7 @@ <h2>Maintainer of detectors:</h2>
<h2>Author of measurements</h2>

TODO:
{% endcomment %}



Expand Down
5 changes: 3 additions & 2 deletions DOSPORTAL/templates/records/record_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@
<td class="">{{record.log_original_filename}} ({{ record.log_file | filesize_mb }})</td>
{% if record.description|length > 1 %}<tr>
<td class="w-auto">Description:</td>
<td class=""><div class="callout m-0 p-2">{{record.formatted_markdown | safe }}</div></td>
<td class=""><div class="callout m-0 p-2">{{record.formatted_markdown }}</div></td>
</tr> {% endif %}
</tr>
{% if record.metadata|length > 4 %} <tr>
<td class="w-auto">Advanced metadata:</td>
<td class=""><div class="callout m-0 p-2" style="max-height: 200pt;overflow-y: auto;"><code>{{record.metadata}})</code></div></td>

<td class=""><div class="callout m-0 p-2" style="max-height: 200pt;overflow-y: auto;"><code>{{record.metadata|pretty_json|safe }})</code></div></td>
</tr> {% endif %}
</tbody>
</table>
Expand Down
10 changes: 10 additions & 0 deletions DOSPORTAL/templatetags/filters.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
from django import template
import json

register = template.Library()

@register.filter(name='filesize_mb')
def filesize_mb(value):
"""Převede velikost souboru na megabajty."""
return f"{value.size / (1024 * 1024):.2f} MB"

@register.filter(name='pretty_json')
def pretty_json(value):
val = json.loads(value)
val = json.dumps(val, indent=4, ensure_ascii=False, sort_keys=True)
val = val.replace(' ', '&nbsp;')
val = val.replace('\n', '<br>')

return val

0 comments on commit 4fa5e1c

Please sign in to comment.