add new version of public page

This commit is contained in:
Cayo Puigdefabregas 2023-02-01 13:28:31 +01:00
parent 00c07161e0
commit 6b5db31922
2 changed files with 180 additions and 390 deletions

View File

@ -1,400 +1,181 @@
{% import 'devices/macros.html' as macros %} {% extends "ereuse_devicehub/base.html" %}
<!DOCTYPE html> {% block page_title %}Device {{ device.dhid }}{% endblock %}
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link href="https://stackpath.bootstrapcdn.com/bootswatch/3.3.7/flatly/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-+ENW/yibaokMnme+vBLnHMphUYxHs34h9lpdbSLuAwGkOKFRl4C34WkjazBtb7eT"
crossorigin="anonymous">
<script src="https://use.fontawesome.com/7553aecc27.js"></script>
<title>Devicehub | {{ device.__format__('t') }}</title>
<style>
/*Sticky footer*/
html {
position: relative;
min-height: 100%;
}
body { {% block body %}
margin-bottom: 60px; /* Margin bottom by footer height */ <main>
}
.footer { <section class="container mt-3">
position: absolute; <div class="row">
bottom: 0;
width: 100%;
height: 6em;
}
</style>
</head>
<body>
<nav class="navbar navbar-default" style="background-color: gainsboro; margin: 0 !important"> <div class="col">
<div class="container-fluid"> <div class="col-xl-12">
<a href="https://www.usody.com/" target="_blank">
<h1 align="center">Usody Public Link</h1>
</a>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<div class="page-header col-md-6 col-md-offset-3">
<h1>{% if abstract %}Real device {% endif %}{{ device.__format__('t') or '' }}<br>
<small>{{ device.__format__('s') or '' }}</small>
</h1>
</div>
</div>
<div class="row">
<div class="col-md-3">
</div>
<div class="col-md-6">
<ul>
{% for key, value in device.public_properties.items() %}
<li>{{ key }}: {{ value or '' }}</li>
{% endfor %}
</ul>
{% if isinstance(device, d.Computer) %}
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th></th>
<th>Range</th>
</tr>
</thead>
<tbody>
{% if device.processor_model %}
<tr>
<td>
CPU {{ device.processor_model }}
</td>
<td>
Processor Rate = {% if device.rate %}
{{ device.rate.processor_range }}
({{ device.rate.processor }})
{% endif %}
</td>
</tr>
{% endif %}
{% if device.ram_size %}
<tr>
<td>
RAM {{ device.ram_size // 1000 }} GB
{{ macros.component_type(device.components, 'RamModule') }}
</td>
<td>
RAM Rate = {% if device.rate %}
{{ device.rate.ram_range }}
({{ device.rate.ram }})
{% endif %}
</td>
</tr>
{% endif %}
{% if device.data_storage_size %}
<tr>
<td>
Data Storage {{ device.data_storage_size // 1000 }} GB
{{ macros.component_type(device.components, 'SolidStateDrive') }}
{{ macros.component_type(device.components, 'HardDrive') }}
</td>
<td>
Data Storage Rate = {% if device.rate %}
{{ device.rate.data_storage_range }}
({{ device.rate.data_storage }})
{% endif %}
</td>
</tr>
{% endif %}
{% if device.graphic_card_model %}
<tr>
<td>
Graphics {{ device.graphic_card_model }}
{{ macros.component_type(device.components, 'GraphicCard') }}
</td>
<td></td>
</tr>
{% endif %}
{% if device.network_speeds %}
<tr>
<td>
Network
{% if device.network_speeds[0] %}
Ethernet
{% if device.network_speeds[0] != None %}
max. {{ device.network_speeds[0] }} Mbps
{% endif %}
{% endif %}
{% if device.network_speeds[0] and device.network_speeds[1] %}
+
{% endif %}
{% if device.network_speeds[1] %}
WiFi
{% if device.network_speeds[1] != None %}
max. {{ device.network_speeds[1] }} Mbps
{% endif %}
{% endif %}
{{ macros.component_type(device.components, 'NetworkAdapter') }}
</td>
<td></td>
</tr>
{% endif %}
</tbody>
</table>
</div>
<h4>Actual Status</h4>
<ol>
<li>
<strong>
Lifecycle Status
</strong>
{% if device.status %}
{{ device.status.type }}
{% endif %}
</li>
<li>
<strong>
Allocate Status
</strong>
{% if device.allocated_status %}
{{ device.allocated_status.type }}
{% endif %}
</li>
<li>
<strong>
Physical Status
</strong>
{% if device.physical_status %}
{{ device.physical_status.type }}
{% endif %}
</li>
</ol>
<h4>Public traceability log of the device</h4> <div class="card">
<div class="text-right"> <div class="card-body">
<small>Latest one.</small> <h3 class="nav-link mt-5" style="color: #993365">{{ device_real.type }} - {{ device_real.verbose_name }}</h3>
<div class="row">
<div class="col-6">
<h5 class="card-title">Basic</h5>
<div class="row">
<div class="col">
Usody Identifier (DHID)
</div>
<div class="col">
{{ device_real.dhid }}
</div>
</div>
<div class="row">
<div class="col">
Inventory Identifier (PHID)
</div>
<div class="col">
{{ device_real.phid() }}
</div>
</div>
<div class="row">
<div class="col">
Type
</div>
<div class="col">
{{ device_real.type or '- not detected -' }}
</div>
</div>
<div class="row">
<div class="col">
Manufacturer
</div>
<div class="col">
{{ device_real.manufacturer or '- not detected -' }}
</div>
</div>
<div class="row">
<div class="col">
Model
</div>
<div class="col">
{{ device_real.model or '- not detected -' }}
</div>
</div>
<div class="row">
<div class="col">
Part Number
</div>
<div class="col">
{{ device_real.part_number or '- not detected -' }}
</div>
</div>
<div class="row">
<div class="col">
Serial Number
</div>
<div class="col">
- anonymized -
</div>
</div>
</div> </div>
<ol> <div class="col-1">
{% for action in device.public_actions %}
<li>
<strong>
{{ device.is_status(action) }}
{% if not device.is_status(action) %}
{{ action.type }}
{% endif %}
</strong>
{% if device.is_status(action) %}
{{ action }} {{ action.type }}
{% else %}
{{ action }}
{% endif %}
<br>
<div class="text-muted">
<small>
{{ action._date_str }}
</small>
</div>
{% if action.certificate %}
<a href="{{ action.certificate.to_text() }}">See the certificate</a>
{% endif %}
</li>
{% endfor %}
</ol>
<div class="text-right">
<small>Oldest one.</small>
</div> </div>
{% endif %} <div class="col-5">
</div> <h5 class="card-title">Status</h5>
</div> <div class="row">
{% if abstract %} <div class="col">
<div class="row"> <div class="label"><b>Physical</b></div>
<div class="page-header col-md-6 col-md-offset-3"> <div>{{ device_real.physical_status and device.physical_status.type or '- not status -' }}</div>
<hr /> </div>
<h1>Abstract device {{ abstract.__format__('t') or '' }}<br> </div>
<small>{{ abstract.__format__('s') or '' }}</small> <div class="row">
</h1> <div class="col">
</div> <div class="label"><b>Lifecycle</b></div>
</div> <div>{{ device_real.status and device_real.status.type or '- not status -' }}</div>
<div class="row"> </div>
<div class="col-md-3"> </div>
</div> <div class="row">
<div class="col-md-6"> <div class="col">
<ul> <div class="label"><b>Allocation</b></div>
{% for key, value in abstract.public_properties.items() %} <div>
<li>{{ key }}: {{ value or '' }}</li> {% if device_real.allocated %}
{% endfor %} Allocated
</ul> {% else %}
{% if isinstance(abstract, d.Computer) %} Not allocated
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th></th>
<th>Range</th>
</tr>
</thead>
<tbody>
{% if abstract.processor_model %}
<tr>
<td>
CPU {{ abstract.processor_model }}
</td>
<td>
Processor Rate = {% if abstract.rate %}
{{ abstract.rate.processor_range }}
({{ abstract.rate.processor }})
{% endif %}
</td>
</tr>
{% endif %} {% endif %}
{% if abstract.ram_size %} </div>
<tr> </div>
<td> </div>
RAM {{ abstract.ram_size // 1000 }} GB
{{ macros.component_type(abstract.components, 'RamModule') }}
</td>
<td>
RAM Rate = {% if abstract.rate %}
{{ abstract.rate.ram_range }}
({{ abstract.rate.ram }})
{% endif %}
</td>
</tr>
{% endif %}
{% if abstract.data_storage_size %}
<tr>
<td>
Data Storage {{ abstract.data_storage_size // 1000 }} GB
{{ macros.component_type(abstract.components, 'SolidStateDrive') }}
{{ macros.component_type(abstract.components, 'HardDrive') }}
</td>
<td>
Data Storage Rate = {% if abstract.rate %}
{{ abstract.rate.data_storage_range }}
({{ abstract.rate.data_storage }})
{% endif %}
</td>
</tr>
{% endif %}
{% if abstract.graphic_card_model %}
<tr>
<td>
Graphics {{ abstract.graphic_card_model }}
{{ macros.component_type(abstract.components, 'GraphicCard') }}
</td>
<td></td>
</tr>
{% endif %}
{% if abstract.network_speeds %}
<tr>
<td>
Network
{% if abstract.network_speeds[0] %}
Ethernet
{% if abstract.network_speeds[0] != None %}
max. {{ abstract.network_speeds[0] }} Mbps
{% endif %}
{% endif %}
{% if abstract.network_speeds[0] and abstract.network_speeds[1] %}
+
{% endif %}
{% if abstract.network_speeds[1] %}
WiFi
{% if abstract.network_speeds[1] != None %}
max. {{ abstract.network_speeds[1] }} Mbps
{% endif %}
{% endif %}
{{ macros.component_type(abstract.components, 'NetworkAdapter') }}
</td>
<td></td>
</tr>
{% endif %}
</tbody>
</table>
</div> </div>
<h4>Actual Status</h4> </div>
<ol> <div class="row mt-3">
<li> <div class="col-6">
<strong> <h5 class="card-title">Components</h5>
Lifecycle Status <div class="row">
</strong> {% if placeholder.binding %}
<div class="list-group col">
{% if abstract.status %} {% for component in placeholder.binding.components|sort(attribute='type') %}
{{ abstract.status.type }} <div class="list-group-item">
{% endif %} <div class="d-flex w-100 justify-content-between">
</li> <h5 class="mb-1">{{ component.type }}</h5>
<li> <small class="text-muted">{{ component.created.strftime('%H:%M %d-%m-%Y') }}</small>
<strong> </div>
Allocate Status <p class="mb-1">
</strong> {{ component.manufacturer }}<br />
{{ component.model }}<br />
{% if abstract.allocated_status %} </p>
{{ abstract.allocated_status.type }} <small class="text-muted">
{% endif %} {% if component.type in ['RamModule', 'HardDrive', 'SolidStateDrive'] %}
</li> {{ component.size }}MB
<li> {% endif %}
<strong> </small>
Physical Status </div>
</strong> {% endfor %}
</div>
{% if abstract.physical_status %} {% else %}
{{ abstract.physical_status.type }} <div class="list-group col">
{% endif %} <div class="list-group-item">
</li> - not detected -
</ol> </div>
</div>
{% endif %}
</div>
</div>
<div class="col-6">
<h5 class="card-title">Repair history</h5>
<div class="row">
<div class="list-group col">
{% for action in placeholder.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>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<h4>Public traceability log of the abstract</h4> </main>
<div class="text-right"> <!-- ======= Footer ======= -->
<small>Latest one.</small> <div class="container">
</div> <div class="row">
<ol> <div class="col">
{% for action in abstract.public_actions %} <footer class="footer">
<li> <div class="copyright">
<strong> &copy; Copyright <strong><span>Usody</span></strong>. All Rights Reserved
{{ abstract.is_status(action) }} </div>
{% if not abstract.is_status(action) %} <div class="credits">
{{ action.type }} <a href="https://help.usody.com/en/" target="_blank">Help</a> |
{% endif %} <a href="https://pangea.org/es/politica-de-privacidad/" target="_blank">Privacy</a> |
</strong> <a href="https://pangea.org/aviso-legal/" target="_blank">Terms</a>
</div>
{% if abstract.is_status(action) %} <div class="credits">
{{ action }} {{ action.type }} DeviceHub
{% else %} </div>
{{ action }} </footer><!-- End Footer -->
{% endif %} </div>
<br>
<div class="text-muted">
<small>
{{ action._date_str }}
</small>
</div>
{% if action.certificate %}
<a href="{{ action.certificate.to_text() }}">See the certificate</a>
{% endif %}
</li>
{% endfor %}
</ol>
<div class="text-right">
<small>Oldest one.</small>
</div>
{% endif %}
</div>
</div>
{% endif %}
</div> </div>
<footer class="container-fluid footer">
<div class="row">
<div class="col-md-4">
Page generated by:<br>
<img style="height: 9em"
src="{{ url_for('Device.static', filename='usody-logo-v4.png') }}">
</div>
</div> </div>
</footer> {% endblock body%}
</body>
</html>

View File

@ -148,8 +148,17 @@ class DeviceView(View):
if device.is_abstract() == 'Twin': if device.is_abstract() == 'Twin':
abstract = device.placeholder.binding abstract = device.placeholder.binding
placeholder = device.binding or device.placeholder
device_abstract = placeholder and placeholder.binding or device
device_real = placeholder and placeholder.device or device
return render_template( return render_template(
'devices/layout.html', device=device, states=states, abstract=abstract 'devices/layout.html',
placeholder=placeholder,
device=device,
device_abstract=device_abstract,
device_real=device_real,
states=states,
abstract=abstract
) )
@auth.Auth.requires_auth @auth.Auth.requires_auth