add details of one entry snapshot log
This commit is contained in:
parent
744b14f286
commit
6ecbd4e09d
|
@ -534,9 +534,7 @@ class SnapshotListView(GenericMixin):
|
|||
'sid': snap.sid,
|
||||
'snapshot_uuid': snap.snapshot_uuid,
|
||||
'version': snap.version,
|
||||
'device': snap.snapshot.device.devicehub_id
|
||||
if snap.snapshot
|
||||
else '',
|
||||
'device': snap.get_device(),
|
||||
'status': snap.get_status(),
|
||||
'severity': snap.severity,
|
||||
'created': snap.created,
|
||||
|
@ -556,6 +554,29 @@ class SnapshotListView(GenericMixin):
|
|||
return result
|
||||
|
||||
|
||||
class SnapshotDetailView(GenericMixin):
|
||||
template_name = 'inventory/snapshot_detail.html'
|
||||
|
||||
def dispatch_request(self, snapshot_uuid):
|
||||
self.snapshot_uuid = snapshot_uuid
|
||||
self.get_context()
|
||||
self.context['page_title'] = "Snapshot Detail"
|
||||
self.context['snapshots_log'] = self.get_snapshots_log()
|
||||
self.context['snapshot_uuid'] = snapshot_uuid
|
||||
self.context['snapshot_sid'] = ''
|
||||
if self.context['snapshots_log'].count():
|
||||
self.context['snapshot_sid'] = self.context['snapshots_log'][0].sid
|
||||
|
||||
return flask.render_template(self.template_name, **self.context)
|
||||
|
||||
def get_snapshots_log(self):
|
||||
return (
|
||||
SnapshotsLog.query.filter(SnapshotsLog.owner == g.user)
|
||||
.filter(SnapshotsLog.snapshot_uuid == self.snapshot_uuid)
|
||||
.order_by(SnapshotsLog.created.desc())
|
||||
)
|
||||
|
||||
|
||||
devices.add_url_rule('/action/add/', view_func=NewActionView.as_view('action_add'))
|
||||
devices.add_url_rule('/action/trade/add/', view_func=NewTradeView.as_view('trade_add'))
|
||||
devices.add_url_rule(
|
||||
|
@ -603,3 +624,7 @@ devices.add_url_rule(
|
|||
'/export/<string:export_id>/', view_func=ExportsView.as_view('export')
|
||||
)
|
||||
devices.add_url_rule('/snapshots/', view_func=SnapshotListView.as_view('snapshotslist'))
|
||||
devices.add_url_rule(
|
||||
'/snapshots/<string:snapshot_uuid>/',
|
||||
view_func=SnapshotDetailView.as_view('snapshot_detail'),
|
||||
)
|
||||
|
|
|
@ -40,3 +40,9 @@ class SnapshotsLog(Thing):
|
|||
return Severity(self.severity)
|
||||
|
||||
return ''
|
||||
|
||||
def get_device(self):
|
||||
if self.snapshot:
|
||||
return self.snapshot.device.devicehub_id
|
||||
|
||||
return ''
|
||||
|
|
54
ereuse_devicehub/templates/inventory/snapshot_detail.html
Normal file
54
ereuse_devicehub/templates/inventory/snapshot_detail.html
Normal file
|
@ -0,0 +1,54 @@
|
|||
{% extends "ereuse_devicehub/base_site.html" %}
|
||||
{% block main %}
|
||||
|
||||
<div class="pagetitle">
|
||||
<h1>Inventory</h1>
|
||||
<nav>
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{{ url_for('inventory.devicelist')}}">Inventory</a></li>
|
||||
<li class="breadcrumb-item active">{{ page_title }}</li>
|
||||
</ol>
|
||||
</nav>
|
||||
</div><!-- End Page Title -->
|
||||
|
||||
<section class="section profile">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-xl-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body pt-3">
|
||||
<h3>{{ snapshot_sid }} | {{ snapshot_uuid }}</h3>
|
||||
<!-- Bordered Tabs -->
|
||||
<div class="tab-content pt-2">
|
||||
|
||||
<div class="tab-pane fade show active">
|
||||
<h5 class="card-title">Traceability log Details</h5>
|
||||
<div class="list-group col-6">
|
||||
{% for log in snapshots_log %}
|
||||
<div class="list-group-item">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<h5 class="mb-1">{{ log.get_status() }}</h5>
|
||||
<small class="text-muted">{{ log.created.strftime('%H:%M %d-%m-%Y') }}</small>
|
||||
</div>
|
||||
<p class="mb-1">
|
||||
Device:
|
||||
{{ log.get_device() }}<br />
|
||||
Version: {{ log.version }}<br />
|
||||
</p>
|
||||
<p>
|
||||
<small class="text-muted">
|
||||
{{ log.description }}
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% endblock main %}
|
|
@ -37,10 +37,16 @@
|
|||
{% for snap in snapshots_log %}
|
||||
<tr>
|
||||
<td>
|
||||
{% if snap.sid %}
|
||||
<a href="{{ url_for('inventory.snapshot_detail', snapshot_uuid=snap.snapshot_uuid) }}">
|
||||
{{ snap.sid }}
|
||||
</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ url_for('inventory.snapshot_detail', snapshot_uuid=snap.snapshot_uuid) }}">
|
||||
{{ snap.snapshot_uuid }}
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ snap.version }}
|
||||
|
|
Reference in a new issue