2024-10-08 05:26:48 +00:00
{% extends 'base.html' %}
2024-07-05 13:32:07 +00:00
{% load i18n %}
{% block content %}
2024-12-05 21:31:30 +00:00
< div class = "row" >
< div class = "col" >
< h3 > {{ object.shortid }}< / h3 >
< / div >
< div class = "col text-end" >
2024-12-06 00:30:06 +00:00
{% 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" %}
2024-12-05 21:31:30 +00:00
< / button >
2024-12-06 00:30:06 +00:00
{% endif %}
2024-07-05 13:32:07 +00:00
< / div >
2024-12-05 21:31:30 +00:00
< / div >
2024-07-05 13:32:07 +00:00
2024-10-29 07:29:13 +00:00
< div class = "row" >
< div class = "col" >
< ul class = "nav nav-tabs nav-tabs-bordered" >
2024-10-29 07:25:01 +00:00
< li class = "nav-item" >
< a href = "#details" class = "nav-link active" data-bs-toggle = "tab" data-bs-target = "#details" > {% trans 'General details' %}< / a >
2024-10-29 07:29:13 +00:00
< / li >
2024-10-29 07:25:01 +00:00
< li class = "nav-item" >
2024-11-14 15:00:03 +00:00
< a href = "#user_properties" class = "nav-link" data-bs-toggle = "tab" data-bs-target = "#user_properties" > {% trans 'User properties' %}< / a >
2024-10-29 07:29:13 +00:00
< / li >
2024-10-29 07:25:01 +00:00
< li class = "nav-item" >
< a href = "#documents" class = "nav-link" data-bs-toggle = "tab" data-bs-target = "#documents" > {% trans 'Documents' %}< / a >
2024-10-29 07:29:13 +00:00
< / li >
2024-10-29 07:25:01 +00:00
< li class = "nav-item" >
< a href = "#lots" class = "nav-link" data-bs-toggle = "tab" data-bs-target = "#lots" > {% trans 'Lots' %}< / a >
2024-10-29 07:29:13 +00:00
< / li >
2024-10-29 07:25:01 +00:00
< li class = "nav-item" >
< a href = "#components" class = "nav-link" data-bs-toggle = "tab" data-bs-target = "#components" > {% trans 'Components' %}< / a >
2024-10-29 07:29:13 +00:00
< / li >
2024-10-29 07:25:01 +00:00
< li class = "nav-item" >
< a href = "#evidences" class = "nav-link" data-bs-toggle = "tab" data-bs-target = "#evidences" > {% trans 'Evidences' %}< / a >
2024-10-29 07:29:13 +00:00
< / li >
2024-10-29 07:25:01 +00:00
< li class = "nav-item" >
2024-10-30 15:00:23 +00:00
< a class = "nav-link" href = "{% url 'device:device_web' object.id %}" target = "_blank" > Web< / a >
2024-10-29 07:29:13 +00:00
< / li >
< / ul >
2024-07-05 13:32:07 +00:00
< / div >
< / div >
2024-12-06 20:48:06 +00:00
< div class = "tab-content pt-4" >
2024-12-06 21:21:46 +00:00
<!-- Device Details -->
2024-10-08 05:26:48 +00:00
< div class = "tab-pane fade show active" id = "details" >
2024-12-06 20:48:06 +00:00
< div class = "row" >
2024-12-06 21:21:46 +00:00
2024-12-06 20:48:06 +00:00
< 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 >
2024-10-29 07:29:13 +00:00
< / div >
2024-12-06 20:48:06 +00:00
{% if object.is_eraseserver %}
2024-10-29 07:29:13 +00:00
< div class = "row mb-3" >
2024-12-06 20:48:06 +00:00
< div class = "col-sm-4 text-muted fw-bold" > {% trans 'Is an erase server' %}< / div >
< div class = "col-sm-8" > {% trans 'Yes' %}< / div >
2024-10-22 05:24:42 +00:00
< / div >
2024-12-06 20:48:06 +00:00
{% 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 >
2024-10-29 07:29:13 +00:00
< / div >
2024-12-06 20:48:06 +00:00
{% 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 >
2024-10-29 07:29:13 +00:00
< / div >
2024-12-06 20:48:06 +00:00
< 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 >
2024-10-29 07:29:13 +00:00
< / div >
2024-10-08 05:26:48 +00:00
< / div >
2024-12-06 20:48:06 +00:00
<!-- Device Current State -->
< div class = "col-lg-6" >
< h5 class = "card-title" > {% trans 'Current State' %}< / h5 >
< hr >
< div class = "row mb-3" >
< div class = "col-sm-4 text-muted fw-bold" > {% trans 'State' %}< / div >
< div class = "col-sm-8" > {{ device_states.0.state }}< / div >
< / div >
< div class = "row mb-3" >
< div class = "col-sm-4 text-muted fw-bold" > {% trans 'Date' %}< / div >
< div class = "col-sm-8" > {{ device_states.0.date|date:"SHORT_DATETIME_FORMAT" }}< / div >
< / div >
2024-10-29 07:29:13 +00:00
2024-12-06 20:48:06 +00:00
<!-- 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 %}
2024-10-29 07:29:13 +00:00
< / div >
2024-10-08 05:26:48 +00:00
< / div >
2024-07-05 13:32:07 +00:00
< / div >
2024-12-06 20:48:06 +00:00
2024-12-06 21:21:46 +00:00
<!-- End of Details -->
2024-07-05 13:32:07 +00:00
2024-11-14 15:00:03 +00:00
< div class = "tab-pane fade" id = "user_properties" >
2024-10-29 07:29:13 +00:00
< div class = "btn-group mt-1 mb-3" >
2024-11-12 14:47:32 +00:00
< a href = "{% url 'device:add_user_property' object.pk %}" class = "btn btn-primary" >
2024-10-08 05:26:48 +00:00
< i class = "bi bi-plus" > < / i >
2024-11-12 14:47:32 +00:00
{% trans 'New user property' %}
2024-10-08 05:26:48 +00:00
< / a >
< / div >
2024-07-05 13:32:07 +00:00
2024-11-12 14:47:32 +00:00
< h5 class = "card-title" > {% trans 'User properties' %}< / h5 >
2024-10-08 05:26:48 +00:00
< table class = "table table-striped" >
< thead >
< tr >
2024-10-29 07:29:13 +00:00
< 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 >
2024-10-08 05:26:48 +00:00
< th > < / th >
< / tr >
< / thead >
< tbody >
2024-11-14 00:14:23 +00:00
{% for a in object.get_user_properties %}
2024-10-08 05:26:48 +00:00
< tr >
< td > {{ a.key }}< / td >
< td > {{ a.value }}< / td >
< td > {{ a.created }}< / td >
2024-11-15 21:16:45 +00:00
< td >
< div class = "btn-group float-end" >
2024-11-15 22:38:33 +00:00
< 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 >
2024-11-15 21:16:45 +00:00
< 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 >
2024-10-08 05:26:48 +00:00
< / tr >
{% endfor %}
< / tbody >
< / table >
2024-07-05 13:32:07 +00:00
< / div >
2024-12-06 20:48:06 +00:00
<!-- pop up modal for delete confirmation -->
2024-11-15 21:16:45 +00:00
{% 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" >
2024-11-21 13:45:18 +00:00
< div class = "modal-dialog modal-dialog-centered" >
2024-11-15 21:16:45 +00:00
< 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 >
2024-11-21 13:45:18 +00:00
< div class = "modal-footer justify-content-center" >
2024-11-15 21:16:45 +00:00
< 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 %}
2024-11-15 22:38:33 +00:00
<!-- 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" >
2024-11-21 13:45:18 +00:00
< div class = "modal-dialog modal-dialog-centered" >
2024-11-15 22:38:33 +00:00
< 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 >
2024-11-21 13:45:18 +00:00
< 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 >
2024-11-15 22:38:33 +00:00
< / form >
< / div >
< / div >
2024-11-21 13:45:18 +00:00
< / div >
2024-11-15 22:38:33 +00:00
< / div >
{% endfor %}
2024-11-15 21:16:45 +00:00
2024-10-29 07:29:13 +00:00
< div class = "tab-pane fade" id = "documents" >
< div class = "btn-group mt-1 mb-3" >
2024-10-08 05:26:48 +00:00
< a href = "{% url 'device:add_document' object.pk %}" class = "btn btn-primary" >
< i class = "bi bi-plus" > < / i >
2024-10-29 07:29:13 +00:00
{% trans 'Add new document' %}
2024-10-08 05:26:48 +00:00
< / a >
< / div >
2024-07-30 11:37:08 +00:00
2024-10-29 07:29:13 +00:00
< h5 class = "card-title" > {% trans 'Documents' %}< / h5 >
2024-10-08 05:26:48 +00:00
< table class = "table table-striped" >
< thead >
< tr >
2024-10-29 07:29:13 +00:00
< 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 >
2024-10-08 05:26:48 +00:00
< 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 >
2024-07-05 13:32:07 +00:00
< / div >
2024-10-29 07:29:13 +00:00
< 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 >
2024-10-08 05:26:48 +00:00
< div class = "list-group col-6" >
2024-10-22 05:24:42 +00:00
{% for c in object.components %}
2024-10-08 05:26:48 +00:00
< 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" >
2024-10-22 05:24:42 +00:00
{% for k, v in c.items %}
{% if k not in 'actions,type' %}
{{ k }}: {{ v }}< br / >
{% endif %}
{% endfor %}
2024-10-08 05:26:48 +00:00
< / p >
< / div >
{% endfor %}
2024-07-05 13:32:07 +00:00
< / div >
2024-07-18 15:21:22 +00:00
< / div >
2024-10-29 07:29:13 +00:00
< div class = "tab-pane fade" id = "evidences" >
< h5 class = "card-title" > {% trans 'List of evidences' %}< / h5 >
2024-10-08 05:26:48 +00:00
< 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 %}
2024-07-05 13:32:07 +00:00
< / div >
< / div >
< / div >
2024-12-05 21:31:30 +00:00
2024-12-06 00:30:06 +00:00
<!-- add state to device - popup modal -->
{% if state_definitions %}
2024-12-05 21:31:30 +00:00
{% 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" >
2024-12-06 00:30:06 +00:00
< form method = "post" action = "{% url 'action:new_action'%}" >
2024-12-05 21:31:30 +00:00
{% 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 >
2024-12-06 00:30:06 +00:00
< span class = "text-danger fw-italic" > state_placeholder< / span >
2024-12-05 21:31:30 +00:00
< / 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 >
2024-12-06 00:30:06 +00:00
< / div >
< / div >
2024-12-05 21:31:30 +00:00
< 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 }}" >
2024-12-06 20:48:06 +00:00
< input type = "hidden" name = "snapshot_uuid" value = "{{ object.last_uuid }}" >
2024-12-05 21:31:30 +00:00
< / 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 %}
2024-12-06 00:30:06 +00:00
{% endif %}
2024-12-05 21:31:30 +00:00
2024-07-05 13:32:07 +00:00
{% endblock %}
2024-10-22 05:24:42 +00:00
{% 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 %}