feature/90-implement-public-website-for-device #17

Merged
cayop merged 32 commits from feature/90-implement-public-website-for-device into main 2024-10-30 15:02:18 +00:00
4 changed files with 293 additions and 194 deletions
Showing only changes of commit 2636e80ece - Show all commits

View File

@ -1,4 +1,4 @@
{% extends "base.html" %} {% extends 'base.html' %}
{% load i18n %} {% load i18n %}
{% block content %} {% block content %}
@ -30,13 +30,12 @@
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#evidences">Evidences</button> <button class="nav-link" data-bs-toggle="tab" data-bs-target="#evidences">Evidences</button>
</li> </li>
<li class="nav-items"> <li class="nav-items">
<a class="nav-link" href="">Web</a> <a class="nav-link" href="{% url 'device:device_web' object.id %}">Web</a>
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>
<div class="tab-content pt-2"> <div class="tab-content pt-2">
<div class="tab-pane fade show active" id="details"> <div class="tab-pane fade show active" id="details">
<h5 class="card-title">Details</h5> <h5 class="card-title">Details</h5>
<div class="row mb-3"> <div class="row mb-3">
@ -53,23 +52,23 @@
{% for k, v in object.last_user_evidence %} {% for k, v in object.last_user_evidence %}
<div class="row"> <div class="row">
<div class="col-lg-3 col-md-4 label">{{ k }}</div> <div class="col-lg-3 col-md-4 label">{{ k }}</div>
<div class="col-lg-9 col-md-8">{{ v|default:"" }}</div> <div class="col-lg-9 col-md-8">{{ v|default:'' }}</div>
</div> </div>
{% endfor %} {% endfor %}
{% else %} {% else %}
<div class="row"> <div class="row">
<div class="col-lg-3 col-md-4 label">Manufacturer</div> <div class="col-lg-3 col-md-4 label">Manufacturer</div>
<div class="col-lg-9 col-md-8">{{ object.manufacturer|default:"" }}</div> <div class="col-lg-9 col-md-8">{{ object.manufacturer|default:'' }}</div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-lg-3 col-md-4 label">Model</div> <div class="col-lg-3 col-md-4 label">Model</div>
<div class="col-lg-9 col-md-8">{{ object.model|default:"" }}</div> <div class="col-lg-9 col-md-8">{{ object.model|default:'' }}</div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-lg-3 col-md-4 label">Serial Number</div> <div class="col-lg-3 col-md-4 label">Serial Number</div>
<div class="col-lg-9 col-md-8">{{ object.last_evidence.doc.device.serialNumber|default:"" }}</div> <div class="col-lg-9 col-md-8">{{ object.last_evidence.doc.device.serialNumber|default:'' }}</div>
</div> </div>
{% endif %} {% endif %}
<div class="row"> <div class="row">
@ -77,7 +76,7 @@
</div> </div>
{% for chid in object.hids %} {% for chid in object.hids %}
<div class="row"> <div class="row">
<div class="col">{{ chid |default:"" }}</div> <div class="col">{{ chid|default:'' }}</div>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
@ -112,12 +111,10 @@
<td></td> <td></td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</div> </div>
<div class="tab-pane fade profile-overview" id="lots"> <div class="tab-pane fade profile-overview" id="lots">
{% for tag in lot_tags %} {% for tag in lot_tags %}
<h5 class="card-title">{{ tag }}</h5> <h5 class="card-title">{{ tag }}</h5>
@ -137,7 +134,6 @@
<div class="tab-pane fade profile-overview" id="documents"> <div class="tab-pane fade profile-overview" id="documents">
<div class="btn-group dropdown ml-1 mt-1" uib-dropdown=""> <div class="btn-group dropdown ml-1 mt-1" uib-dropdown="">
<a href="{% url 'device:add_document' object.pk %}" class="btn btn-primary"> <a href="{% url 'device:add_document' object.pk %}" class="btn btn-primary">
<i class="bi bi-plus"></i> <i class="bi bi-plus"></i>
Add new document Add new document
<span class="caret"></span> <span class="caret"></span>
@ -165,7 +161,6 @@
<td></td> <td></td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</div> </div>
@ -184,8 +179,7 @@
{{ c.model }}<br /> {{ c.model }}<br />
{{ c.serialNumber }}<br /> {{ c.serialNumber }}<br />
</p> </p>
<small class="text-muted"> <small class="text-muted"></small>
</small>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
@ -203,8 +197,7 @@
<p class="mb-1"> <p class="mb-1">
<a href="{% url 'evidence:details' snap.uuid %}">{{ snap.uuid }}</a> <a href="{% url 'evidence:details' snap.uuid %}">{{ snap.uuid }}</a>
</p> </p>
<small class="text-muted"> <small class="text-muted"></small>
</small>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>

View File

@ -0,0 +1,81 @@
{% extends 'base.html' %}
{% block content %}
<h1>{{ title }}</h1>
<h5 class="card-title">Details</h5>
<div class="row mb-3">
<div class="col-lg-3 col-md-4 label">Phid</div>
<div class="col-lg-9 col-md-8">{{ object.id }}</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-4 label">Type</div>
<div class="col-lg-9 col-md-8">{{ object.type }}</div>
</div>
{% if object.is_websnapshot %}
{% for k, v in object.last_user_evidence %}
<div class="row">
<div class="col-lg-3 col-md-4 label">{{ k }}</div>
<div class="col-lg-9 col-md-8">{{ v|default:'' }}</div>
</div>
{% endfor %}
{% else %}
<div class="row">
<div class="col-lg-3 col-md-4 label">Manufacturer</div>
<div class="col-lg-9 col-md-8">{{ object.manufacturer|default:'' }}</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-4 label">Model</div>
<div class="col-lg-9 col-md-8">{{ object.model|default:'' }}</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-4 label">Serial Number</div>
<div class="col-lg-9 col-md-8">{{ object.last_evidence.doc.device.serialNumber|default:'' }}</div>
</div>
{% endif %}
<div class="row">
<div class="col-lg-3 col-md-4 label">Identifiers</div>
</div>
{% for chid in object.hids %}
<div class="row">
<div class="col">{{ chid|default:'' }}</div>
</div>
{% endfor %}
{% comment %} <h2>User Anotations</h2> {% endcomment %}
<h2>Components</h2>
<ul>
{% for c in object.last_evidence.doc.components %}
<div class="list-group-item">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">{{ c.type }}</h5>
<small class="text-muted">{{ evidence.created }}</small>
</div>
<p class="mb-1">
{{ c.manufacturer }}<br />
{{ c.model }}<br />
{{ c.serialNumber }}<br />
</p>
<small class="text-muted"></small>
</div>
{% endfor %}
<h2>Last Evidence Snapshot</h2>
<p>{{ snapshot }}</p>
{% comment %} <h2>Lot Tags</h2>
<ul>
{% for tag in lot_tags %}
<li>{{ tag.name }}</li>
{% endfor %}
</ul> {% endcomment %}
{% endblock %}

View File

@ -9,4 +9,6 @@ urlpatterns = [
path("<str:pk>/", views.DetailsView.as_view(), name="details"), path("<str:pk>/", views.DetailsView.as_view(), name="details"),
path("<str:pk>/annotation/add", views.AddAnnotationView.as_view(), name="add_annotation"), path("<str:pk>/annotation/add", views.AddAnnotationView.as_view(), name="add_annotation"),
path("<str:pk>/document/add", views.AddDocumentView.as_view(), name="add_document"), path("<str:pk>/document/add", views.AddDocumentView.as_view(), name="add_document"),
path("<str:pk>/web/", views.DeviceWebView.as_view(), name="device_web"),
] ]

View File

@ -101,6 +101,29 @@ class DetailsView(DashboardView, TemplateView):
return context return context
class DeviceWebView(DashboardView, TemplateView):
template_name = "device_web.html"
title = _("Device Web")
breadcrumb = "Device / Web"
model = Annotation
def get(self, request, *args, **kwargs):
self.pk = kwargs['pk']
self.object = Device(id=self.pk)
return super().get(request, *args, **kwargs)
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
self.object.initial()
lot_tags = LotTag.objects.filter(owner=self.request.user.institution)
context.update({
'object': self.object,
'snapshot': self.object.get_last_evidence(),
'lot_tags': lot_tags,
})
return context
class AddAnnotationView(DashboardView, CreateView): class AddAnnotationView(DashboardView, CreateView):
template_name = "new_annotation.html" template_name = "new_annotation.html"
title = _("New annotation") title = _("New annotation")