Device-details html modularized into several files
This commit is contained in:
parent
6e952e8643
commit
7c1e0c1804
|
@ -62,361 +62,19 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="tab-content pt-4">
|
||||
<!-- Device Details -->
|
||||
<div class="tab-pane fade show active" id="details">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-lg-6">
|
||||
<h5 class="card-title">{% trans 'Details' %}</h5>
|
||||
<hr>
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Phid' %}</div>
|
||||
<div class="col-sm-8">{{ object.id }}</div>
|
||||
</div>
|
||||
|
||||
{% if object.is_eraseserver %}
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Is an erase server' %}</div>
|
||||
<div class="col-sm-8">{% trans 'Yes' %}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Type' %}</div>
|
||||
<div class="col-sm-8">{{ object.type }}</div>
|
||||
</div>
|
||||
|
||||
{% if object.is_websnapshot and object.last_user_evidence %}
|
||||
{% for k, v in object.last_user_evidence.items %}
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{{ k }}</div>
|
||||
<div class="col-sm-8">{{ v|default:'' }}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Manufacturer' %}</div>
|
||||
<div class="col-sm-8">{{ object.manufacturer|default:'' }}</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Model' %}</div>
|
||||
<div class="col-sm-8">{{ object.model|default:'' }}</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Serial Number' %}</div>
|
||||
<div class="col-sm-8">{{ object.serial_number|default:'' }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Identifiers' %}</div>
|
||||
<div class="col-sm-8">
|
||||
{% for chid in object.hids %}
|
||||
<div>{{ chid|default:'' }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Device Current State -->
|
||||
<div class="col-lg-6">
|
||||
<h5 class="card-title">{% trans 'Current State' %}</h5>
|
||||
<hr>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead class="table">
|
||||
<tr>
|
||||
<th scope="col">{% trans 'State' %}</th>
|
||||
<th scope="col">{% trans 'User' %}</th>
|
||||
<th scope="col">{% trans 'Date' %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if device_states %}
|
||||
<tr class="table-success">
|
||||
<td>{{ device_states.0.state }}</td>
|
||||
<td>{{ device_states.0.user.responsable_person|default:device_states.0.user.username }}</td>
|
||||
<td>{{ device_states.0.date|date:"SHORT_DATETIME_FORMAT" }}</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="3" class="text-center">{% trans 'No state recorded.' %}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% include 'tabs/general_details.html' %}
|
||||
|
||||
<!-- TODO: display last note? -->
|
||||
{% if last_note %}
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Note' %}</div>
|
||||
<div class="col-sm-8">{{ object.last_state.note }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Log Tab TODO: currently only displays states, change when log table is implemented-->
|
||||
{% include 'tabs/log.html' %}
|
||||
|
||||
<div class="tab-pane fade" id="log">
|
||||
<h5 class="card-title mb-3">{% trans 'Log' %}</h5>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead class="table">
|
||||
<tr>
|
||||
<th scope="col">{% trans 'Date' %}</th>
|
||||
<th scope="col">{% trans 'User' %}</th>
|
||||
<th scope="col">{% trans 'State' %}</th>
|
||||
<th scope="col">{% trans 'Actions' %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for state_change in device_states %}
|
||||
<tr {% if forloop.first %}class="table-success"{% endif %}>
|
||||
<td>{{ state_change.date|date:"SHORT_DATETIME_FORMAT" }}</td>
|
||||
<td>{{ state_change.user.responsable_person|default:state_change.user.username }}</td>
|
||||
<td><strong>{{ state_change.state }}</strong></td>
|
||||
<td>
|
||||
{% if state_change.date|timesince < '1 hour' %}
|
||||
<a href="#" data-bs-toggle="modal" data-bs-target="#deleteStateModal{{ state_change.id }}" title="{% trans 'Delete State' %}">
|
||||
<i class="bi bi-trash text-danger"></i>
|
||||
</a>
|
||||
|
||||
<!-- Delete Confirmation Modal -->
|
||||
<div class="modal fade" id="deleteStateModal{{ state_change.id }}" tabindex="-1" aria-labelledby="deleteStateModalLabel{{ state_change.id }}" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="deleteStateModalLabel{{ state_change.id }}">{% trans 'Confirm Delete' %}</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{% trans 'Close' %}"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>{% trans 'Are you sure you want to undo this state?' %}</p>
|
||||
<p><strong>{{ state_change.state }}</strong> - {{ state_change.date|date:"SHORT_DATETIME_FORMAT" }}</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans 'Cancel' %}</button>
|
||||
<form method="post" action="{% url 'action:undo_action' state_change.id %}">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="btn btn-danger">{% trans 'Delete' %}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="4" class="text-center">{% trans 'No state changes recorded.' %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% include 'tabs/user_properties.html' %}
|
||||
|
||||
<div class="tab-pane fade" id="user_properties">
|
||||
<div class="btn-group mt-1 mb-3">
|
||||
<a href="{% url 'device:add_user_property' object.pk %}" class="btn btn-primary">
|
||||
<i class="bi bi-plus"></i>
|
||||
{% trans 'New user property' %}
|
||||
</a>
|
||||
</div>
|
||||
{% include 'tabs/documents.html' %}
|
||||
|
||||
<h5 class="card-title">{% trans 'User properties' %}</h5>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
{% trans 'Key' %}
|
||||
</th>
|
||||
<th scope="col">
|
||||
{% trans 'Value' %}
|
||||
</th>
|
||||
<th scope="col" data-type="date" data-format="YYYY-MM-DD HH:mm">
|
||||
{% trans 'Created on' %}
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for a in object.get_user_properties %}
|
||||
<tr>
|
||||
<td>{{ a.key }}</td>
|
||||
<td>{{ a.value }}</td>
|
||||
<td>{{ a.created }}</td>
|
||||
<td>
|
||||
<div class="btn-group float-end">
|
||||
<button type="button" class="btn btn-sm btn-primary" data-bs-toggle="modal" data-bs-target="#editModal{{ a.id }}">
|
||||
<i class="bi bi-pencil"></i> {% trans 'Edit' %}
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-danger" data-bs-toggle="modal" data-bs-target="#deleteModal{{ a.id }}">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% include 'tabs/lots.html' %}
|
||||
|
||||
<!-- pop up modal for delete confirmation -->
|
||||
{% for a in object.get_user_properties %}
|
||||
<div class="modal fade" id="deleteModal{{ a.id }}" tabindex="-1" aria-labelledby="deleteModalLabel{{ a.id }}" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="deleteModalLabel{{ a.id }}">{% trans "Confirm Deletion" %}</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p><strong>{% trans "Key:" %}</strong> {{ a.key }}</p>
|
||||
<p><strong>{% trans "Value:" %}</strong> {{ a.value }}</p>
|
||||
<p><strong>{% trans "Created on:" %}</strong> {{ a.created }}</p>
|
||||
</div>
|
||||
<div class="modal-footer justify-content-center">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans "Cancel" %}</button>
|
||||
<form method="post" action="{% url 'device:delete_user_property' a.id %}">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="btn btn-danger">{% trans "Delete" %}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% include 'tabs/evidences.html' %}
|
||||
|
||||
<!-- popup modals for edit button -->
|
||||
{% for a in object.get_user_properties %}
|
||||
<div class="modal fade" id="editModal{{ a.id }}" tabindex="-1" aria-labelledby="editModalLabel{{ a.id }}" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="editModalLabel{{ a.id }}">{% trans "Edit User Property" %}</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="editForm{{ a.id }}" method="post" action="{% url 'device:update_user_property' a.id %}">
|
||||
{% csrf_token %}
|
||||
<div class="mb-3">
|
||||
<label for="key" class="form-label">{% trans "Key" %}</label>
|
||||
<input type="text" class="form-control" id="key" name="key" value="{{ a.key }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="value" class="form-label">{% trans "Value" %}</label>
|
||||
<input type="text" class="form-control" id="value" name="value" value="{{ a.value }}">
|
||||
</div>
|
||||
<div class="modal-footer justify-content-center">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans "Cancel" %}</button>
|
||||
<button type="submit" class="btn btn-primary">{% trans "Save changes" %}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<div class="tab-pane fade" id="documents">
|
||||
<div class="btn-group mt-1 mb-3">
|
||||
<a href="{% url 'device:add_document' object.pk %}" class="btn btn-primary">
|
||||
<i class="bi bi-plus"></i>
|
||||
{% trans 'Add new document' %}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<h5 class="card-title">{% trans 'Documents' %}</h5>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
{% trans 'Key' %}
|
||||
</th>
|
||||
<th scope="col">
|
||||
{% trans 'Value' %}
|
||||
</th>
|
||||
<th scope="col" data-type="date" data-format="YYYY-MM-DD HH:mm">
|
||||
{% trans 'Created on' %}
|
||||
</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for a in object.get_user_documents %}
|
||||
<tr>
|
||||
<td>{{ a.key }}</td>
|
||||
<td>{{ a.value }}</td>
|
||||
<td>{{ a.created }}</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="lots">
|
||||
{% for tag in lot_tags %}
|
||||
<h5 class="card-title">{{ tag }}</h5>
|
||||
{% for lot in object.lots %}
|
||||
{% if lot.type == tag %}
|
||||
<div class="row mb-3">
|
||||
<div class="col">
|
||||
<a href="{% url 'dashboard:lot' lot.id %}">{{ lot.name }}</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="components">
|
||||
<h5 class="card-title">{% trans 'Components last evidence' %}</h5>
|
||||
<div class="list-group col-6">
|
||||
{% for c in object.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">
|
||||
{% for k, v in c.items %}
|
||||
{% if k not in 'actions,type' %}
|
||||
{{ k }}: {{ v }}<br />
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="evidences">
|
||||
<h5 class="card-title">{% trans 'List of evidences' %}</h5>
|
||||
<div class="list-group col-6">
|
||||
{% for snap in object.evidences %}
|
||||
<div class="list-group-item">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<small class="text-muted">{{ snap.created }}</small>
|
||||
</div>
|
||||
<p class="mb-1">
|
||||
<a href="{% url 'evidence:details' snap.uuid %}">{{ snap.uuid }}</a>
|
||||
</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- add state to device - popup modal-->
|
||||
{% if state_definitions %}
|
||||
|
|
27
device/templates/tabs/components.html
Normal file
27
device/templates/tabs/components.html
Normal file
|
@ -0,0 +1,27 @@
|
|||
|
||||
{% load i18n %}
|
||||
|
||||
<div class="tab-pane fade" id="components">
|
||||
<h5 class="card-title">{% trans 'Components last evidence' %}
|
||||
</h5>
|
||||
<div class="list-group col-6">
|
||||
{% for c in object.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">
|
||||
{% for k, v in c.items %}
|
||||
{% if k not in 'actions,type' %}
|
||||
{{ k }}: {{ v }}
|
||||
<br />
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
49
device/templates/tabs/documents.html
Normal file
49
device/templates/tabs/documents.html
Normal file
|
@ -0,0 +1,49 @@
|
|||
|
||||
{% load i18n %}
|
||||
<div class="tab-pane fade" id="documents">
|
||||
<div class="btn-group mt-1 mb-3">
|
||||
<a href="{% url 'device:add_document' object.pk %}" class="btn btn-primary">
|
||||
<i class="bi bi-plus">
|
||||
</i>
|
||||
{% trans 'Add new document' %}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<h5 class="card-title">{% trans 'Documents' %}
|
||||
</h5>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
{% trans 'Key' %}
|
||||
</th>
|
||||
<th scope="col">
|
||||
{% trans 'Value' %}
|
||||
</th>
|
||||
<th scope="col" data-type="date" data-format="YYYY-MM-DD HH:mm">
|
||||
{% trans 'Created on' %}
|
||||
</th>
|
||||
<th>
|
||||
</th>
|
||||
<th>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for a in object.get_user_documents %}
|
||||
<tr>
|
||||
<td>{{ a.key }}
|
||||
</td>
|
||||
<td>{{ a.value }}
|
||||
</td>
|
||||
<td>{{ a.created }}
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
19
device/templates/tabs/evidences.html
Normal file
19
device/templates/tabs/evidences.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
|
||||
{% load i18n %}
|
||||
|
||||
<div class="tab-pane fade" id="evidences">
|
||||
<h5 class="card-title">{% trans 'List of evidences' %}</h5>
|
||||
<div class="list-group col-6">
|
||||
{% for snap in object.evidences %}
|
||||
<div class="list-group-item">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<small class="text-muted">{{ snap.created }}</small>
|
||||
</div>
|
||||
<p class="mb-1">
|
||||
<a href="{% url 'evidence:details' snap.uuid %}">{{ snap.uuid }}</a>
|
||||
</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
128
device/templates/tabs/general_details.html
Normal file
128
device/templates/tabs/general_details.html
Normal file
|
@ -0,0 +1,128 @@
|
|||
|
||||
{% load i18n %}
|
||||
|
||||
<!-- Device Details -->
|
||||
<div class="tab-pane fade show active" id="details">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-lg-6">
|
||||
<h5 class="card-title">{% trans 'Details' %}
|
||||
</h5>
|
||||
<hr>
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Phid' %}
|
||||
</div>
|
||||
<div class="col-sm-8">{{ object.id }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if object.is_eraseserver %}
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Is an erase server' %}
|
||||
</div>
|
||||
<div class="col-sm-8">{% trans 'Yes' %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Type' %}
|
||||
</div>
|
||||
<div class="col-sm-8">{{ object.type }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if object.is_websnapshot and object.last_user_evidence %}
|
||||
{% for k, v in object.last_user_evidence.items %}
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{{ k }}
|
||||
</div>
|
||||
<div class="col-sm-8">{{ v|default:'' }}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Manufacturer' %}
|
||||
</div>
|
||||
<div class="col-sm-8">{{ object.manufacturer|default:'' }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Model' %}
|
||||
</div>
|
||||
<div class="col-sm-8">{{ object.model|default:'' }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Serial Number' %}
|
||||
</div>
|
||||
<div class="col-sm-8">{{ object.serial_number|default:'' }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Identifiers' %}
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
{% for chid in object.hids %}
|
||||
<div>{{ chid|default:'' }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Device Current State -->
|
||||
<div class="col-lg-6">
|
||||
<h5 class="card-title">{% trans 'Current State' %}
|
||||
</h5>
|
||||
<hr>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead class="table">
|
||||
<tr>
|
||||
<th scope="col">{% trans 'State' %}
|
||||
</th>
|
||||
<th scope="col">{% trans 'User' %}
|
||||
</th>
|
||||
<th scope="col">{% trans 'Date' %}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if device_states %}
|
||||
<tr class="table-success">
|
||||
<td>{{ device_states.0.state }}
|
||||
</td>
|
||||
<td>{{ device_states.0.user.responsable_person|default:device_states.0.user.username }}
|
||||
</td>
|
||||
<td>{{ device_states.0.date|date:"SHORT_DATETIME_FORMAT" }}
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="3" class="text-center">{% trans 'No state recorded.' %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- TODO: display last note? -->
|
||||
{% if last_note %}
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Note' %}
|
||||
</div>
|
||||
<div class="col-sm-8">{{ object.last_state.note }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
61
device/templates/tabs/log.html
Normal file
61
device/templates/tabs/log.html
Normal file
|
@ -0,0 +1,61 @@
|
|||
{% load i18n %}
|
||||
<!-- Log Tab TODO: currently only displays states, change when log table is implemented-->
|
||||
|
||||
<div class="tab-pane fade" id="log">
|
||||
<h5 class="card-title mb-3">{% trans 'Log' %}</h5>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead class="table">
|
||||
<tr>
|
||||
<th scope="col">{% trans 'Date' %}</th>
|
||||
<th scope="col">{% trans 'User' %}</th>
|
||||
<th scope="col">{% trans 'State' %}</th>
|
||||
<th scope="col">{% trans 'Actions' %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for state_change in device_states %}
|
||||
<tr {% if forloop.first %}class="table-success"{% endif %}>
|
||||
<td>{{ state_change.date|date:"SHORT_DATETIME_FORMAT" }}</td>
|
||||
<td>{{ state_change.user.responsable_person|default:state_change.user.username }}</td>
|
||||
<td><strong>{{ state_change.state }}</strong></td>
|
||||
<td>
|
||||
{% if state_change.date|timesince < '1 hour' %}
|
||||
<a href="#" data-bs-toggle="modal" data-bs-target="#deleteStateModal{{ state_change.id }}" title="{% trans 'Delete State' %}">
|
||||
<i class="bi bi-trash text-danger"></i>
|
||||
</a>
|
||||
|
||||
<!-- Delete Confirmation Modal -->
|
||||
<div class="modal fade" id="deleteStateModal{{ state_change.id }}" tabindex="-1" aria-labelledby="deleteStateModalLabel{{ state_change.id }}" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="deleteStateModalLabel{{ state_change.id }}">{% trans 'Confirm Delete' %}</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{% trans 'Close' %}"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>{% trans 'Are you sure you want to undo this state?' %}</p>
|
||||
<p><strong>{{ state_change.state }}</strong> - {{ state_change.date|date:"SHORT_DATETIME_FORMAT" }}</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans 'Cancel' %}</button>
|
||||
<form method="post" action="{% url 'action:undo_action' state_change.id %}">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="btn btn-danger">{% trans 'Delete' %}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="4" class="text-center">{% trans 'No state changes recorded.' %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
19
device/templates/tabs/lots.html
Normal file
19
device/templates/tabs/lots.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
|
||||
{% load i18n %}
|
||||
|
||||
<div class="tab-pane fade" id="lots">
|
||||
{% for tag in lot_tags %}
|
||||
<h5 class="card-title">{{ tag }}
|
||||
</h5>
|
||||
{% for lot in object.lots %}
|
||||
{% if lot.type == tag %}
|
||||
<div class="row mb-3">
|
||||
<div class="col">
|
||||
<a href="{% url 'dashboard:lot' lot.id %}">{{ lot.name }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</div>
|
132
device/templates/tabs/user_properties.html
Normal file
132
device/templates/tabs/user_properties.html
Normal file
|
@ -0,0 +1,132 @@
|
|||
|
||||
{% load i18n %}
|
||||
|
||||
<div class="tab-pane fade" id="user_properties">
|
||||
<div class="btn-group mt-1 mb-3">
|
||||
<a href="{% url 'device:add_user_property' object.pk %}" class="btn btn-primary">
|
||||
<i class="bi bi-plus">
|
||||
</i>
|
||||
{% trans 'New user property' %}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<h5 class="card-title">{% trans 'User properties' %}
|
||||
</h5>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
{% trans 'Key' %}
|
||||
</th>
|
||||
<th scope="col">
|
||||
{% trans 'Value' %}
|
||||
</th>
|
||||
<th scope="col" data-type="date" data-format="YYYY-MM-DD HH:mm">
|
||||
{% trans 'Created on' %}
|
||||
</th>
|
||||
<th>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for a in object.get_user_properties %}
|
||||
<tr>
|
||||
<td>{{ a.key }}
|
||||
</td>
|
||||
<td>{{ a.value }}
|
||||
</td>
|
||||
<td>{{ a.created }}
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group float-end">
|
||||
<button type="button" class="btn btn-sm btn-primary" data-bs-toggle="modal" data-bs-target="#editModal{{ a.id }}">
|
||||
<i class="bi bi-pencil">
|
||||
</i> {% trans 'Edit' %}
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-danger" data-bs-toggle="modal" data-bs-target="#deleteModal{{ a.id }}">
|
||||
<i class="bi bi-trash">
|
||||
</i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- pop up modal for delete confirmation -->
|
||||
{% for a in object.get_user_properties %}
|
||||
<div class="modal fade" id="deleteModal{{ a.id }}" tabindex="-1" aria-labelledby="deleteModalLabel{{ a.id }}" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="deleteModalLabel{{ a.id }}">{% trans "Confirm Deletion" %}
|
||||
</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>
|
||||
<strong>{% trans "Key:" %}
|
||||
</strong> {{ a.key }}
|
||||
</p>
|
||||
<p>
|
||||
<strong>{% trans "Value:" %}
|
||||
</strong> {{ a.value }}
|
||||
</p>
|
||||
<p>
|
||||
<strong>{% trans "Created on:" %}
|
||||
</strong> {{ a.created }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="modal-footer justify-content-center">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans "Cancel" %}
|
||||
</button>
|
||||
<form method="post" action="{% url 'device:delete_user_property' a.id %}">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="btn btn-danger">{% trans "Delete" %}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<!-- popup modals for edit button -->
|
||||
{% for a in object.get_user_properties %}
|
||||
<div class="modal fade" id="editModal{{ a.id }}" tabindex="-1" aria-labelledby="editModalLabel{{ a.id }}" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="editModalLabel{{ a.id }}">{% trans "Edit User Property" %}
|
||||
</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="editForm{{ a.id }}" method="post" action="{% url 'device:update_user_property' a.id %}">
|
||||
{% csrf_token %}
|
||||
<div class="mb-3">
|
||||
<label for="key" class="form-label">{% trans "Key" %}
|
||||
</label>
|
||||
<input type="text" class="form-control" id="key" name="key" value="{{ a.key }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="value" class="form-label">{% trans "Value" %}
|
||||
</label>
|
||||
<input type="text" class="form-control" id="value" name="value" value="{{ a.value }}">
|
||||
</div>
|
||||
<div class="modal-footer justify-content-center">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans "Cancel" %}
|
||||
</button>
|
||||
<button type="submit" class="btn btn-primary">{% trans "Save changes" %}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
Loading…
Reference in a new issue