device details

This commit is contained in:
Cayo Puigdefabregas 2022-01-13 16:08:55 +01:00
parent 3463d63f31
commit 68269c4b21
3 changed files with 168 additions and 5 deletions

View file

@ -21,7 +21,6 @@ class DeviceListView(View):
lot = None
if id:
lot = lots.filter(Lot.id == id).one()
# import pdb; pdb.set_trace()
devices = [dev for dev in lot.devices if dev.type in filter_types]
devices = sorted(devices, key=lambda x: x.updated, reverse=True)
else:
@ -36,6 +35,20 @@ class DeviceListView(View):
return flask.render_template(self.template_name, **context)
class DeviceDetailsView(View):
decorators = [login_required]
template_name = 'inventory/device_details.html'
def dispatch_request(self, id):
lots = Lot.query.filter(Lot.owner_id == current_user.id)
device = Device.query.filter(
Device.owner_id == current_user.id).filter(Device.devicehub_id == id).one()
context = {'device': device,
'lots': lots}
return flask.render_template(self.template_name, **context)
class LotDeviceAddView(View):
methods = ['POST']
decorators = [login_required]
@ -109,8 +122,8 @@ class LotDeleteView(View):
return flask.redirect(next_url)
devices.add_url_rule('/device/', view_func=DeviceListView.as_view('devicelist'))
devices.add_url_rule('/device/<string:id>/', view_func=DeviceDetailsView.as_view('device_details'))
devices.add_url_rule('/lot/<string:id>/device/', view_func=DeviceListView.as_view('lotdevicelist'))
devices.add_url_rule('/lot/devices/add/', view_func=LotDeviceAddView.as_view('lot_devices_add'))
devices.add_url_rule('/lot/devices/del/', view_func=LotDeviceDeleteView.as_view('lot_devices_del'))

View file

@ -0,0 +1,150 @@
{% extends "ereuse_devicehub/base_site.html" %}
{% block main %}
<link href="https://cdn.jsdelivr.net/npm/simple-datatables@latest/dist/style.css" rel="stylesheet" type="text/css">
<div class="pagetitle">
<h1>Inventory</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('inventory.devices.devicelist')}}">Inventory</a></li>
<li class="breadcrumb-item active">Details device</li>
<li class="breadcrumb-item active">{{ device.devicehub_id }}</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>{{ device.devicehub_id }}</h3>
<!-- Bordered Tabs -->
<ul class="nav nav-tabs nav-tabs-bordered">
<li class="nav-item">
<button class="nav-link active" data-bs-toggle="tab" data-bs-target="#type">Type</button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#status">Status</button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#rate">Rate</button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#traceability">Traceability log</button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#components">Components</button>
</li>
</ul>
<div class="tab-content pt-2">
<div class="tab-pane fade show active" id="type">
<h5 class="card-title">Type Details</h5>
<div class="row">
<div class="col-lg-3 col-md-4 label ">Type</div>
<div class="col-lg-9 col-md-8">{{ device.type }}</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-4 label">Manufacturer</div>
<div class="col-lg-9 col-md-8">{{ device.manufacturer }}</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-4 label">Model</div>
<div class="col-lg-9 col-md-8">{{ device.model }}</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">{{ device.serial_number }}</div>
</div>
</div>
<div class="tab-pane fade profile-overview" id="status">
<h5 class="card-title">Status Details</h5>
<div class="row">
<div class="col-lg-3 col-md-4 label">Physical States</div>
<div class="col-lg-9 col-md-8">{{ device.physical or '' }}</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-4 label">Trading States</div>
<div class="col-lg-9 col-md-8">{{ device.last_action_trading or ''}}</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-4 label">Usage States</div>
<div class="col-lg-9 col-md-8">{{ device.usage or '' }}</div>
</div>
</div>
<div class="tab-pane fade profile-overview" id="rate">
<h5 class="card-title">Rate Details</h5>
<div class="row">
<div class="col-lg-3 col-md-4 label">Rating</div>
<div class="col-lg-9 col-md-8">{{ device.rate or '' }}</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-4 label">Processor</div>
<div class="col-lg-9 col-md-8">{{ device.rate.processor or '' }}</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-4 label">RAM</div>
<div class="col-lg-9 col-md-8">{{ device.rate.ram or '' }}</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-4 label">Data storage</div>
<div class="col-lg-9 col-md-8">{{ device.rate.data_storage or '' }}</div>
</div>
</div>
<div class="tab-pane fade profile-overview" id="traceability">
<h5 class="card-title">Traceability log Details</h5>
<div class="list-group col-6">
{% for action in device.actions %}
<div class="list-group-item d-flex justify-content-between align-items-center">
{{ action.type }} {{ action.severity }}
<small class="text-muted">{{ action.created.strftime('%H:%M %d-%m-%Y') }}</small>
</div>
{% endfor %}
</div>
</div>
<div class="tab-pane fade profile-overview" id="components">
<h5 class="card-title">Components Details</h5>
<div class="list-group col-6">
{% for component in device.components|sort(attribute='type') %}
<div class="list-group-item">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">{{ component.type }}</h5>
<small class="text-muted">{{ component.created.strftime('%H:%M %d-%m-%Y') }}</small>
</div>
<p class="mb-1">
{{ component.manufacturer }}<br />
{{ component.model }}<br />
</p>
<small class="text-muted">
{% if component.type in ['RamModule', 'HardDrive', 'SolidStateDrive'] %}
{{ component.size }}MB
{% endif %}
</small>
</div>
{% endfor %}
</div>
</div>
</div>
</div>
</div>
</div>
</section>
{% endblock main %}

View file

@ -6,7 +6,7 @@
<h1>Inventory</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index.html">Inventory</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('inventory.devices.devicelist')}}">Inventory</a></li>
{% if not lot %}
<li class="breadcrumb-item active">Unassgined</li>
{% elif lot.is_temporary %}
@ -219,8 +219,8 @@
{% for dev in devices %}
<tr>
<td><input type="checkbox" class="deviceSelect" data="{{ dev.id }}"/></td>
<td>{{ dev.type }} {{ dev.manufacturer }} {{ dev.model }}</td>
<td>{{ dev.devicehub_id }}</td>
<td><a href={{ url_for('inventory.devices.device_details', id=dev.devicehub_id)}}>{{ dev.type }} {{ dev.manufacturer }} {{ dev.model }}</a></td>
<td><a href={{ url_for('inventory.devices.device_details', id=dev.devicehub_id)}}>{{ dev.devicehub_id }}</a></td>
<td>
{% for t in dev.tags | sort(attribute="id") %}
{{ t.id }}{% if not loop.last %},{% endif %}