devicehub-django/device/templates/details.html

159 lines
5.8 KiB
HTML

{% extends 'base.html' %}
{% load i18n %}
{% block content %}
<div class="row">
<div class="col">
<h3>{{ object.shortid }}</h3>
</div>
<div class="col text-end">
{% if state_definitions %}
<div class="dropdown">
<button class="btn btn-green-admin dropdown-toggle" type="button" id="addStateDropdown" data-bs-toggle="dropdown" aria-expanded="false">
{% trans "Action" %}
</button>
<ul class="dropdown-menu" aria-labelledby="addStateDropdown">
{% for state in state_definitions %}
<li>
<a class="dropdown-item" href="#" data-bs-toggle="modal" data-bs-target="#addStateModal{{ state.id }}">
{{ state.state }}
</a>
</li>
{% endfor %}
</ul>
</div>
{% else %}
<button class="btn btn-green-admin" type="button" disabled>
{% trans "Action" %}
</button>
{% endif %}
</div>
</div>
<div class="row">
<div class="col">
<ul class="nav nav-tabs nav-tabs-bordered">
<li class="nav-item">
<a href="#details" class="nav-link active" data-bs-toggle="tab" data-bs-target="#details">{% trans 'General details' %}</a>
</li>
<li class="nav-item">
<a href="#log" class="nav-link" data-bs-toggle="tab" data-bs-target="#log">{% trans 'Log' %}</a>
</li>
<li class="nav-item">
<a href="#user_properties" class="nav-link" data-bs-toggle="tab" data-bs-target="#user_properties">{% trans 'User properties' %}</a>
</li>
<li class="nav-item">
<a href="#documents" class="nav-link" data-bs-toggle="tab" data-bs-target="#documents">{% trans 'Documents' %}</a>
</li>
<li class="nav-item">
<a href="#lots" class="nav-link" data-bs-toggle="tab" data-bs-target="#lots">{% trans 'Lots' %}</a>
</li>
<li class="nav-item">
<a href="#components" class="nav-link" data-bs-toggle="tab" data-bs-target="#components">{% trans 'Components' %}</a>
</li>
<li class="nav-item">
<a href="#evidences" class="nav-link" data-bs-toggle="tab" data-bs-target="#evidences">{% trans 'Evidences' %}</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'device:device_web' object.id %}" target="_blank">Web</a>
</li>
</ul>
</div>
</div>
<div class="tab-content pt-4">
{% include 'tabs/general_details.html' %}
{% include 'tabs/log.html' %}
{% include 'tabs/user_properties.html' %}
{% include 'tabs/documents.html' %}
{% include 'tabs/lots.html' %}
{% include 'tabs/evidences.html' %}
<!-- add state to device - popup modal-->
{% if state_definitions %}
{% for state in state_definitions %}
<div class="modal fade" id="addStateModal{{ state.id }}" tabindex="-1" aria-labelledby="addStateModalLabel{{ state.id }}" aria-hidden="true">
<div class="modal-dialog">
<form method="post" action="{% url 'action:new_action'%}">
{% csrf_token %}
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addStateModalLabel{{ state.id }}">{% trans "Summary of changes" %}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body m-2">
<div class="mb-3">
<div class="d-flex align-items-center">
<i class="bi bi-arrow-right-circle text-danger me-2"></i>
<span class="text-danger fw-bold me-2">{% trans "From:" %}</span>
<span class="text-danger fw-italic">state_placeholder</span>
</div>
<div class="d-flex align-items-center mt-2">
<i class="bi bi-arrow-right-circle text-success me-2"></i>
<span class="text-success fw-bold me-2">{% trans "To:" %}</span>
<span class="text-success fw-italic">{{ state.state }}</span>
</div>
</div>
<div class="form-check form-switch mt-3 d-flex justify-content-end">
<label class="form-check-label font-monospace" for="addNoteCheckbox{{ state.id }}">
{% trans "Add a note" %}
</label>
<input class="form-check-input ms-2" type="checkbox" id="addNoteCheckbox{{ state.id }}" data-bs-toggle="collapse" data-bs-target="#collapseInput{{ state.id }}" name="add_note">
</div>
<div class="mb-3 mt-2 collapse" id="collapseInput{{ state.id }}">
<textarea type="text" class="form-control" id="stateNote{{ state.id }}" name="note" rows="4" maxlength="200" placeholder="{% trans "Max 200 characters" %}"></textarea>
</div>
<input type="hidden" name="state_id" value="{{ state.id }}">
<input type="hidden" name="snapshot_uuid" value="{{ object.last_uuid }}">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans "Cancel" %}</button>
<button type="submit" class="btn btn-primary">{% trans "Add State" %}</button>
</div>
</div>
</form>
</div>
</div>
{% endfor %}
{% endif %}
{% endblock %}
{% block extrascript %}
<script>
document.addEventListener('DOMContentLoaded', function () {
// Obtener el hash de la URL (ejemplo: #components)
const hash = window.location.hash
// Verificar si hay un hash en la URL
if (hash) {
// Buscar el botón o enlace que corresponde al hash y activarlo
const tabTrigger = document.querySelector(`[data-bs-target="${hash}"]`)
if (tabTrigger) {
// Crear una instancia de tab de Bootstrap para activar el tab
const tab = new bootstrap.Tab(tabTrigger)
tab.show()
}
}
})
</script>
{% endblock %}